Web Services Clients

From iDempiere en

A web service client can establish a connection with adempiere, using SOAP as the communication protocol.

This page list and describes the existing Web Services Client Implementations for iDempiere.


iDempiere Java Webservice Client

Ingeint Logo.jpg


Description

It allows the programmer to abstract the generation of XML requests, making development easier. This implementation can be used in Java SE or Android, do not use third party libraries.

Example

 public LoginRequest getLogin() {
   LoginRequest login = new LoginRequest();
   login.setUser("SuperUser");
   login.setPass("System");
   login.setClientID(11);
   login.setRoleID(102);
   login.setOrgID(0);
   return login;
 }
 public String getUrlBase() {
   return "https://localhost:8443";
 }
 public WebServiceConnection getConnection() {
   WebServiceConnection connection = new WebServiceConnection();
   connection.setAttempts(3);
   connection.setTimeout(2000);
   connection.setAttemptsTimeout(2000);
   connection.setUrl(getUrlBase());
   connection.setAppName("Java Test WS Client");
   return connection;
 }
 QueryDataRequest ws = new QueryDataRequest();
 ws.setWebServiceType("QueryBPartner");
 ws.setLogin(getLogin());
 ws.setLimit(3);
 ws.setOffset(3);
 
 DataRow data = new DataRow();
 data.addField("Name", "%Store%");
 ws.setDataRow(data);
 
 WebServiceConnection connection = getConnection();
 
 try {
   WindowTabDataResponse response = connection.sendRequest(ws);
   if (response.getStatus() == WebServiceResponseStatus.Error) {
     System.out.println(response.getErrorMessage());
   } else {
     System.out.println("Total rows: " + response.getTotalRows());
     System.out.println("Num rows: " + response.getNumRows());
     System.out.println("Start row: " + response.getStartRow());
     System.out.println();
 
     for (int i = 0; i < response.getDataSet().getRowsCount(); i++) {
       System.out.println("Row: " + (i + 1));
       for (int j = 0; j < response.getDataSet().getRow(i).getFieldsCount(); j++) {
         Field field = response.getDataSet().getRow(i).getFields().get(j);
         System.out.println("Column: " + field.getColumn() + " = " + field.getValue());
       }
       System.out.println();
     }
   }
 } catch (Exception e) {
     e.printStackTrace();
 }

Output:

 Total rows: 5
 Num rows: 2
 Start row: 3
 
 Row: 1
 Column: C_BPartner_ID = 50008
 Column: Name = Store South
 
 Row: 2
 Column: C_BPartner_ID = 50009
 Column: Name = Store West
 
 --------------------------
 Web Service: QueryBPartnerTest
 Attempts: 1
 Time: 1163
 --------------------------

Screenshot Android Example:

Screenshot AndroidClient.png Screenshot AndroidClient2.png

iDempiere .NET Webservice Client

Ingeint Logo.jpg


Description

It allows the programmer to abstract the generation of XML requests, making development easier. This implementation can be used in .NET 3.5, 4.5 or .NET CF .3.5, do not use third party libraries.

Example

 public LoginRequest GetLogin() {
   LoginRequest login = new LoginRequest();
   login.User = "SuperUser";
   login.Pass = "System";
   login.ClientID = 11;
   login.RoleID = 102;
   login.OrgID = 0;
   return login;
 }
 public string GetUrlBase() {
   return "https://localhost:8443";
 }
 public WebServiceClient GetClient() {
   WebServiceClient client = new WebServiceClient();
   client.Attempts = 3;
   client.Timeout = 2000;
   client.AttemptsTimeout = 2000;
   client.Url = GetUrlBase();
   client.UserAgentProduct = "C# Test WS Client";
   return client;
 }
 QueryDataRequest ws = new QueryDataRequest();
 ws.WebServiceType = "QueryBPartner";
 ws.Login = GetLogin();
 ws.Offset = 1;
 ws.Limit = 2;
 
 DataRow data = new DataRow();
 data.AddField("Name", "%Store%");
 ws.DataRow = data;
 
 WebServiceClient client = GetClient();
 
 try {
   WindowTabDataResponse response = client.SendRequest(ws);  
   if (response.Status == WebServiceResponseStatus.Error) {
     Console.WriteLine(response.ErrorMessage);
   } else {
     Console.WriteLine("Total rows: " + response.TotalRows);
     Console.WriteLine("Num rows: " + response.NumRows);
     Console.WriteLine("Start rows: " + response.StartRow);
     Console.WriteLine();
       for (int i = 0; i < response.DataSet.GetRowsCount(); i++) {
         Console.WriteLine("Row: " + (i + 1));
         for (int j = 0; j < response.DataSet.GetRow(i).GetFieldsCount(); j++) {
           Field field = response.DataSet.GetRow(i).GetFields()[j];
           Console.WriteLine("Column: " + field.Column + " = " + field.Value);
         }
         Console.WriteLine();
       }
   }
 } catch (Exception e) {
   Console.WriteLine(e);
 }

Output:

 Total rows: 5
 Num rows: 2
 Start rows: 1
 
 Row: 1
 Column: C_BPartner_ID = 50004
 Column: Name = Store Central
 
 Row: 2
 Column: C_BPartner_ID = 50007
 Column: Name = Store North
 
 --------------------------
 Web Service: QueryBPartnerTest
 Attempts: 1
 Time: 5358
 --------------------------

Screenshot Windows Mobile 6.5 Example:

Screenshot WindowsCE.jpg Screenshot WindowsCE2.jpg

See also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.