Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Warning about "WS-I Basic Profile compliant" WDSLs


Alert
titleOFBiz does not generate "WS-I Basic Profile compliant" WDSLs
typeSuccess

OFBiz does not generate "WS-I Basic Profile compliant" WDSLs. If using Apache CXF at the consumer endpoint is an option for you have a look at

Jira
serverASF JIRA
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyOFBIZ-4245


This page documents how to export a service using SOAP. This is relevant only to release r892712+since revision 892712

Note: I have been able to make successful calls using client code generated from the WSDL in java, but not from C# nor flex 3/actionscript 3 so far (see https://issues.apache.org/jira/browse/OFBIZ-3385)

...

UPDATE: since r896347, I am now able to use jax-ws (in Netbeans) to generate the client code to connect to ofbiz. See https://issues.apache.org/jira/browse/OFBIZ-3385 for example code.

Step 1: export service

In the service definition, set the flag export="true", for example the findPartiesById service:

Code Block
<service name="findPartiesById" engine="java" auth="true"
 location="org.ofbiz.party.party.PartyServices" invoke="findPartyById" export="true">
 <description>Find the partyId corresponding to a reference and a reference type</description>
 <attribute type="String" mode="IN" name="idToFind" optional="false"/>
 <attribute type="String" mode="IN" name="partyIdentificationTypeId" optional="true"/>
 <attribute type="String" mode="IN" name="searchPartyFirst" optional="true"/>
 <attribute type="String" mode="IN" name="searchAllId" optional="true"/>
 <attribute type="org.ofbiz.entity.GenericValue" mode="OUT" name="party" optional="true"/>
 <attribute type="List" mode="OUT" name="partiesFound" optional="true"/>
</service>

Step 2: view the WSDL

To see all the exported services: http://demo-trunk.ofbiz.apache.org/webtools/control/SOAPService?wsdlImage Removed
To see SOAP services https://demo-trunk.ofbiz.apache.org/webtools/control/ServiceList?constraint=engine_name@soapImage Removed (credentials: flexadmin/ofbiz)
To view the WSDL for the findPartiesById service: http://demo-trunk.ofbiz.apache.org/webtools/control/SOAPService/findPartiesById?wsdlImage Removed

I would recommend studying the WSDL for the service, as it documents the AXIOM model you need to later create.

Step 3: Create eclipse project

1) Create an eclipse java project.
2) Download axis2, e.g. http://mirrors.dedipower.com/ftp.apache.org/ws/axis2/1_5_1/axis2-1.5.1-bin.zip
3) Unzip axis2
4) In your new eclipse project, set build path to include all the jar files in the axis distribution lib directory. (you don't need all the jars, but this is a quick howto)

Step 4: Create your axis client

Code Block
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;

public class Main {

   private static OMFactory fac;
   private static OMNamespace omNs;

   static {
      fac = OMAbstractFactory.getOMFactory();
      omNs = fac.createOMNamespace("http://ofbiz.apache.org/service/", "ns1");
   }

   public static void main(String[] args) throws AxisFault {

      ServiceClient sc = new ServiceClient();
      Options opts = new Options();
      opts.setTo(new EndpointReference(
         "http://demo-trunk.ofbiz.apache.org//webtools/control/SOAPService"));
      opts.setAction("findPartiesById");
      sc.setOptions(opts);
      OMElement res = sc.sendReceive(createPayLoad());
      System.out.println(res);
   }

   private static OMElement createPayLoad() {

      OMElement findPartiesById = fac.createOMElement("findPartiesById", omNs);
      OMElement mapMap = fac.createOMElement("map-Map", omNs);

      findPartiesById.addChild(mapMap);

      mapMap.addChild(createMapEntry("idToFind", "admin"));
      mapMap.addChild(createMapEntry("login.username", "admin"));
      mapMap.addChild(createMapEntry("login.password", "ofbiz"));

      return findPartiesById;
   }

   private static OMElement createMapEntry(String key, String val) {

      OMElement mapEntry = fac.createOMElement("map-Entry", omNs);

      // create the key
      OMElement mapKey = fac.createOMElement("map-Key", omNs);
      OMElement keyElement = fac.createOMElement("std-String", omNs);
      OMAttribute keyAttribute = fac.createOMAttribute("value", null, key);

      mapKey.addChild(keyElement);
      keyElement.addAttribute(keyAttribute);

      // create the value
      OMElement mapValue = fac.createOMElement("map-Value", omNs);
      OMElement valElement = fac.createOMElement("std-String", omNs);
      OMAttribute valAttribute = fac.createOMAttribute("value", null, val);

      mapValue.addChild(valElement);
      valElement.addAttribute(valAttribute);

      // attach to map-Entry
      mapEntry.addChild(mapKey);
      mapEntry.addChild(mapValue);

      return mapEntry;
   }
}

...