7 min read

 

ADempiere 3.6 Cookbook

ADempiere 3.6 CookbookOver 100 recipes for extending and customizing ADempiere beyond its standard capabilities       

Introduction

ADempiere has various modules and processes to provide the ERP, SCM, and CRM capability to the user. However, as ADempiere is still evolving, so are our business processes in the constant quest for efficiency and effectiveness. With this in perspective, there may be instances where an enterprise would have multiple applications, including ADempiere, sitting side-by-side and providing some specialized services to the user or complementing ADempiere’s functionality. This, in most of the instances, calls for an integration of different systems. Moreover, if the enterprise uses ADempiere as its centralized system, then all other applications may have to integrate themselves with ADempiere so that they can read the common data and make their data available in it. For example, a shopping cart application needs product information. To achieve this, ADempiere provides the Web services interface. There are four types of Web service interfaces provided:

  • UI oriented Web services: Provides APIs based on ADempiere’s Window, Tab, and Field constructs
  • Model oriented Web services: This provides APIs based on ADempiere’s data model
  • eCommerce Integration Web services: Provides integration of external eCommerce packages, such as Online Store or POS
  • Openbravo POS integration Web services: Custom APIs provided for integration with Openbravo

Out of the listed types, model-oriented Web services will be the focus of this article. UI Web services are special services and unless you understand the ADempiere’s Application Framework, it would be very difficult for any third party integrator to understand them and use them. Besides, the security layer has not been implemented yet in it, so it is not recommended for production use. Openbravo services are still at the alpha stage.

Model oriented services are built on top of ADempiere’s data model and provides the following generic APIs to execute any ADempiere Web service:

  • createData: For creating one record on a table
  • readData: To return values from one record on a table
  • queryData: To query records on a table
  • getList: To get data from a list (reference list or reference table)
  • updateData: To modify one record on a table
  • deleteData: To delete one record from a table
  • runProcess: To run a process or raise a process that starts a document workflow
  • setDocAction: To trigger a change in document action, that is, complete a material receipt

In this article, we will look into the model oriented Web services and understand what it takes to consume them. Since these are generic APIs, it requires us to configure the security and our specific Web services detail in ADempiere, which will be the first thing/process we will cover to ensure our installation is built and configured for Web services.

For all the Web services execution, we will be using the soapUI (http://www.eviware.com) client. So, kindly install it on your system and keep it ready before we start. soapUI is a Web services testing tool.

Also, the APIs require various details to be specified (for example, login details, warehouse, language, and so on). With reference to the WSDL of the model-oriented Web services, keep the following detail handy, as it will be useful during the execution of the Web services.

Building Web services support

Support for Web services is not in-built into ADempiere and is also not part of the trunk (main branch) in the SVN repository. The Web services support was sponsored and the seed code was provided by 3E and the complete code resides, at the time of writing this article, in the branches3E_WebServices folder of the ADempiere SVN repository. This recipe takes us through the steps required to build and deploy the Web services so that they can be used in conjunction with our ADempiere application.

Getting ready

To execute the steps mentioned in this recipe, we need to ensure that we have got the working and deployable version of the adempiere_360 project in Eclipse.

How to do it…

  1. Check out the https://adempiere.svn.sourceforge.net/svnroot/ adempiere/branches/3E_WebServices SVN URL in branches.
  2. Launch Eclipse.
  3. Import the newly checked out 3E_WebServices project in Eclipse.
  4. Right-click on the project and go to Properties. This will pop-up the Properties window.
  5. Click on Java Build Path. You will see the build-related details on the right-hand side.
  6. Click on the Projects tab and remove all the existing entries from the Required projects on the build path list.
  7. Add the adempiere_360 project to the Required projects on the build path and click on the OKbutton.
  8. Edit the build.xml file and make the following changes:
    • Set the Adempiere.dir property value to ${basedir}/../../tags/ adempiere360lts/lib to point it to our adempiere_360 project folder
    • Add the following to the war target before the WAR file is being created (war element):










    
    
  9. Right-click on build.xml Run As | Ant Build| to build and create the WAR file. On a successful build, it will create the ADInterface-1.0.war file in the 3E_WebServicesdist folder. You will have to refresh your project to see this in Eclipse.
  10. Copy the ADInterface-1.0.war file to the server adempiere360ltsdeploy folder.
  11. Go to Eclipse and go to Server view.
  12. Start the JBoss server instance where we had deployed the adempiere_360 project.
  13. Access the http://127.0.0.1:9080/ADInterface-1.0/services/ ADService?wsdl URL in the browser. This will download the UI Web services WSDL file and display it, which means the Web services have been deployed successfully.
  14. Access the http://127.0.0.1:9080/ADInterface-1.0/services/ ModelADService?wsdl URL in the browser. This will download the Model Web services WSDL file and display it, which means the Web services have been deployed.
  15. Open the URLs mentioned in step 13 and 14 in the soapUI client.
  16. Run the getVersion Web service from the UI Web services list. Upon success, you shall get the version number returned from the service, for example, 0.7.0. With this, we have verified that the installation is working fine.

Configuring Web services

Now that we can build, deploy, and test the sample login service to verify the deployment, we can configure our ADempiere instance so that we can start configuring our new Web services and run them. Here we will see what we must do in order to configure our ADempiere instance for Web services support.

Getting ready

Make sure that you have followed the steps mentioned in the Building Web services support recipe to build and deploy the Web services.

How to do it…

  1. Log in to the adempiere360 database using the adempiere/adempiere credential.
  2. Import the following SQL files from the 3E_WebServicesmigration folder:
    • WS001_WebServices.sql: This creates the tables and windows to define the Web service security, as shown in ADempiere Web Services Security
    • WS002_WebServicesDefinition.sql: This creates the definition of the currently supported Web services and methods
    • WS003_WebServicesConfigGardenWorldSample.sql: This creates the role, user, and two sample tests for testing Web services with GardenWorld
    • WS004_WebServicesFixDict.sql: This is for fixing a dictionary problem from the WS001_WebServices.sql script
  3. Launch ADempiere from the adempiere_360 project and log in as SuperUser/ System with the System Administrator role.
  4. Go to the Window, Tab, and the Field window and lookup the records by entering %Web Service as the name on the Lookup Record window. You shall see the following entries:
    • Web Service Definition
    • Web Service Security

  5. Verify the Access of both the windows. Note that GardenUser has access to the Web services. We’ll use it for all our Web services-related activities.

  6. Go to the Table and Column window and lookup the records by entering %Web service as the Name on the Lookup Record window. You shall see the Web services-related tables. Verify that the Data Access Level is set to Client+Organization for all the table entries. Based on this setting, the data access security will be applied.

  7. Log out and log in as GardenUser/GardenUser with the GardenWorld User role.
  8. Lookup for Web service and make sure you have the following menus existing in your Menu tree:
    • Web Service Security
    • Web Services

With this, we have verified the Web services configuration needed to configure and consume new Web services, which we will see in the subsequent recipes.


Subscribe to the weekly Packt Hub newsletter

* indicates required

LEAVE A REPLY

Please enter your comment!
Please enter your name here