Skip to Content
Author's profile photo AK K

Consuming ODATA service in Agentry (SMP 2.3) – Part 1

This blog will list steps that required to be configured in order to consume OData service in agentry client by using Java.

I am targeting Agentry Client 6.1.0/WPF 6.1.3 & Agentry Server 6.1.0 for development.

1.  Create and configure an object to hold data that is returned/exposed by web service as shown below.Object1.png

2. Create a collection to fetch data for the objects that we created in step 1.

3. Create a fetch for this collection as shown below.


(Note : I have configured this fetch as non-main fetch since its invoked by user and need to capture

username and password for consuming OData service and that are being passed as fetch parameters

to back-end)

4. Since user is required to enter username and password (passed as fetch parameters)

    I have configured a Fetch screen as shown below.


5.  Now create an action that will be executed on button click to initiate this fetch.

     Add a transmit step and configure it to initiate this Fetch.

6. Configure a server exchange step for this fetch as usual procedure.(as shown below)

    This step is created by using Java System Connection.


7. This step will refer to our java class that is extended from class.Which calls a Stephandler to

handle that request and will directly call a web-service as shown in the code snaps below.

Also create a pojo class (here having properties to hold data exposed by web-service. This pojo class is extended from class as usual.

Code for Steplet:

import com.syclo.agentry.AgentryException;

import com.syclo.agentry.BusinessLogicException;

import com.syclo.agentry.FetchSession;


public class FlightCarrOdataSteplet extends Steplet{

       public FlightCarrOdataSteplet(FetchSession session)

                     throws AgentryException, BusinessLogicException {




       public boolean execute() throws AgentryException {



                     FlightCarrOdataStephandler handler = new FlightCarrOdataStephandler(this._user);

                     this._returnData = createSAPObjectArray(new Flight(), handler.getFlightCarriers());


              catch(Throwable e)





              return true;




Code for Step Handler :






import java.util.ArrayList;

import javax.xml.bind.DatatypeConverter;

import com.syclo.agentry.AgentryException;




public class FlightCarrOdataStephandler extends StepHandler{

            User u = null;

            public FlightCarrOdataStephandler(User u)



                     this.u = u;



             public ArrayList<? extends SAPObject> getFlightCarriers() throws AgentryException


          ArrayList<SAPObject> recs = new ArrayList();



                     //Specify your service URL here

                             String uri = /FlightSet?$format=json;

                     URL url = new URL(uri);

                     HttpURLConnection conn = (HttpURLConnection) url.openConnection();


                     conn.setRequestProperty(“Accept”, “application/json”);


                     String encode = this.u.getString(“fetch.Username”) + “:” + this.u.getString(“fetch.Password”);

                     String auth = “Basic “ + DatatypeConverter.printBase64Binary(encode.getBytes());


                     BufferedReader inputReader = new BufferedReader(new InputStreamReader(conn.getInputStream()));


                     StringBuilder sb = new StringBuilder();

                     String inline = “”;


                                       while ((inline = inputReader.readLine()) != null) {



                     org.json.JSONObject obj = new org.json.JSONObject(sb.toString());

                     org.json.JSONArray arr1 = obj.getJSONObject(“d”).getJSONArray(“results”);

                                       for(int i=0;i<arr1.length();i++)


                           Flight fl = new Flight();









                           catch(Throwable e)


                                    this.u.rethrowException(e, false);


              return recs;



8. Now sync your Agentry client and consume this web service as shown below./wp-content/uploads/2015/03/client1_664179.png

9.  This will ask user to enter credentials for consuming targeted web service.

     We have designed a fetch screen to capture Username ans password as shown below.

     This username and password will be passed as fetch parameters to backend.


If all steps are configured correctly then it will consume targeted web service and will show result as below./wp-content/uploads/2015/03/client3_664190.png

(Note: This blog do not mention steps to create OData web service, but lists Agentry Steps to consume OData service.

Agentry “System connection” is assumed to be of type Java connection and user has done all

required configs in JavaBE.ini)

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Just to point out if you use SMP 3 SP05 or later, there is a OData system connection so you don't need to use the Java Code to connect to the backend.

      Author's profile photo AK K
      AK K
      Blog Post Author

      Thanks Stephen for that update,

      Actually i am supporting an application which is WorkManager 6.0 on SMP 2.3 where i got to implement this scenario.I thought it would be help-full to those who are still working with SMP 2.3.

      Also i am going to suggest another approach that we are following right now.That's why it says Part-1.

      Thanks once again.