Skip to main content
Omnitracs Knowledge Base

J2EE Using Axis2

A QSP customer has graciously shared their guidelines instructions for integrating with the Services Portal through J2EE using Axis2.

Here's a recipe for using Axis 2 1.1.1 w/ Qualcomm:

1. Download and install Axis2 from The current release version (as of 3/21) is 1.1.1. One can easily become confused as Axis1 is still available and supported for production use.

2. Download the WSDL from and save it to a file (c:\omnitracs.wsdl or wherever)

3. Generate client stubs. In windows, execute this command:

C:\axis2-1.1.1\bin\wsdl2java.bat -uri c:\qualcomm.wsdl -p com.yourcompany.client -d adb -s -o c:\youroutputdir\client

Here is some sample code for invoking the web service:

public static String callOV(String url, String proxyHost, String proxyPort,

   String userName, String password, String transId, String subId)

   throws Exception {

  OTSWebSvcsServiceStub stub = new OTSWebSvcsServiceStub(url);


  if (proxyHost != null && proxyHost.length() > 0) {

   Options options = stub._getServiceClient().getOptions();


   HttpTransportProperties.ProxyProperties proxyProperties = new HttpTransportProperties.ProxyProperties();


   proxyProperties.setProxyPort(new Integer(proxyPort).intValue());

   options.setProperty(HTTPConstants.PROXY, proxyProperties);




  OMFactory factory = OMAbstractFactory.getOMFactory();

  OMNamespace wsseNS = factory





  OMNamespace envNS = factory.createOMNamespace(



  OMElement securityElement = factory.createOMElement("Security", wsseNS);

  OMAttribute soapThing = factory.createOMAttribute("mustUnderstand",

    envNS, "1");


  OMElement untElem = factory.createOMElement("UsernameToken", wsseNS);

  OMElement unameElem = factory.createOMElement("Username", wsseNS);

  OMElement pwElem = factory.createOMElement("Password", wsseNS);


  OMText unameTxt = factory.createOMText(unameElem, userName);

  OMText pwTxt = factory.createOMText(pwElem, password);











  Dequeue dequeue = new OTSWebSvcsServiceStub.Dequeue();


  dequeue.setSubscriberId(new Integer(subId));

  dequeue.setTransactionId(new Integer(transId));


  DequeueResponse resp = stub.dequeue(dequeue);


  TransactionBlock tb = resp.getDequeueReturn();


  DataHandler handler = tb.getTransactions();


  ByteArrayInputStream bais = (ByteArrayInputStream) handler.getContent();

  ByteArrayOutputStream baos = new ByteArrayOutputStream();


  int b;

  while ((b = >= 0) {




  return new String(baos.toByteArray());


This code results in a string containing an xml document.

Note that this is not the proper way to use Axis2 with WS-Security. In theory, one should use rampart 1.1 (the Apache WS-Security package), but I had no success in getting this to work. See for details.

  • Was this article helpful?