Access to add and change pages is restricted. See: https://cwiki.apache.org/confluence/display/OFBIZ/Wiki+access

1. About OFBiz and Liferay

Apache OFBiz is an Enterprise automation software which includes

  • Open Source ERP
  • Open Source CRM
  • Open Source E-Business / E-Commerce
  • Open Source SCM
  • Open Source MRP
  • Open Source CMMS/EAM, and so on.

Liferay Portal is an enterprise web platform for building business solutions that deliver immediate results and long-term value. Liferay Portal ships with broad product capabilities to provide immediate return on investment:

  • Content & Document Management with Microsoft Office integration
  • Web Publishing and Shared Workspaces
  • Enterprise Collaboration
  • Social Networking and Mashups
  • Enterprise Portals and Identity Management

2. Need for integrating OFBiz and Liferay

As both the products are having a strong growth in their respective areas. Following are the situations which suggest to think of integrating both the solutions

Situation 1: When Customer placing an order

  1. Customer or end user landed to liferay portal page .
  2. Now he is redirected to OFBiz page to buy some products .
  3. He placed the order and he is returned back to Liferay portal
  4. Next day he want to check the status of the order. So do we redirect him again to OFBiz order history page ?
  5. This time we are calling ofbiz order service and display the order status to the customer

Situation 2: When OFBiz admin wants to view the order list

  1. After login into Liferay portal as an administrator. He wants to view orders placed by customers and approve it
  2. For this , do we redirect the administrator to OFBiz admin order page to view and approve the orders ?
  3. So this time, we can call ofbiz order list service from the portal and it will be displayed to the admin in the portal page itself.

Situation 3 : When OFBiz admin wants to view person details

  1. This time the OFBiz admin wants to see the Particular person and the contact details from Portal page
  2. So we can now call OFBiz party service and display the details to the admin

Situation 4 : When OFBiz admin wants to get product details

1. In this situation the admin wants to view the products ordered by the customer

2. For this, we can call OFBiz product services to display the product details on the portal page

Situation 5 : When OFBiz admin wants to add few products from Portal to OFBiz category

1 . This is the admin situation where a particular product needs to be added and so it can be available in OFBiz site for purchase

2. For this situation we can call OFBiz add product to category service on the portal page itself.

The above are many situations like this and i mentioned very few cases.

3. About OFBiz web services

In OFBiz every service can potentialy be invoked as webservice by doing minor modifications to it. You can navigate to service engine application of OFBiz admin to view the services available and other details of the services.

Navigate *http://your_host_name/webtools/control/ServiceList*

There you can find thousands of services in OFBiz.

Navigate and find the appropriate service which you want to export as web service. When you find the particular service say for example “getOrderStatus” , click on it to get the details of the service.

Check Exportable option . If its false make it to true by navigating to the Services.xml file of the particular application. In our case it is /application/order/servicedef/Services.xml . Restart OFBiz

Now you can view the wsdl file of the servicee by navigating to the service engine tools application again and now click on the service name and you can see “Export wsdl” next to the service name . Click on it will display the wsdl definition.

Also you need to get the SOAP link as it is given as end point to the java client to call the web service from outside application.

So the link is usualy available under:

http://your_hostname/webtools/control/SOAPService

4. System Requirement for integration

  1. Liferay product suite
  2. OFBiz
  3. Axis or Axis2 library
  4. Netbeans IDE

5. Creating portlet in liferay

  Install Netbean Liferay plugin to create pages with portlet support in Netbeans. You may need to add the following jar files in the project to make the webservice work

1. Jax-rpc.jar

2. axis.jar

3. commons-discovery.jar

After adding the above jar files create new package under Project_name/source packages/ and add a java file under it . This java file is first invoked from the jsp page given below.

Under Project_name/web pages/WEB-INF/jsp/ create 2 jsp pages. One for getting input from user and one for displaying the result to the user.

Now create the service java file and add the webservice content to it.

public String ServiceCall (String OrderId) {
	String output=null;
	String endpoint,inputParam, username, password;
	inputParam= OrderId;
	try{
		endpoint = "http://hostname:8080/webtools/control/SOAPService";
		username="admin";
		password="ofbiz";
		Call call = (Call) new Service().createCall();
		call.setTargetEndpointAddress(new URL (endpoint));
		call.setOperationName(new javax.xml.namespace.QName("getOrderStatus"));
		call.addParameter ("orderId", org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
		call.addParameter("login.username", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
		call.addParameter("login.password", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
		call.setReturnType(org.apache.axis.Constants.SOAP_STRING);
		Object response = call.invoke(new Object[]{inputParam,username,password});
		output = (String) response;
		try{
			System.out.println(output);
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}catch(Exception e){
		e.printStackTrace();
	}
	return output;
}

Now its time to deploy the portlet in portal server and check it in browser. This can be done in 2 ways. Either you can run directly from netbeans or you can pack a war file and deploy the same in standalone liferay portal.

In this way you can create as many portlets you want by calling various services of OFBiz.

6. Troubleshooting the integration

From the above code the parameters such as endpoint, input parameter and output paremeter needs to be taken care of to input the correct value according to the type of service you are invoking

For exmaple In the above code the getOrderStatus is the method which takes 3 arguements.

orderId , login.username, login.password.

Error :

content is not allowed in Prolog

The above error occurs in following cases and it can be resolved by correcting the following

Missing export=”true” in service.xml file of ofbiz service.

Permission Auth=”false” in service.xml file of ofbiz service.

Incorrect input or output parameter

Incorrect order of input arguments passed to it

Error :

Bad type (class type -> class type) example Bad type (class java.lang.string -> java.lang.map)

this type of error occurs due to incorrect input type or return type specified . Change the type according to the implemented service type and try again.

  • No labels