How to Incorporate a SOAP Service in ApiCode

“ApiCode” is a framework which allows developers to plugin custom JAVA code. It can effectively integrate with any external system by implementing the necessary “ApiCode” interface exposed for integration with DBSync platform.

Link for ApiCode ‘helloworld‘ example.

Since ApiCode is a simple java application, implementing SOAP services in ApiCode is not any different. It is as same as how you implement SOAP service in your Java applications. Into that we have some additional scripts to build the application and packaging ApiCode.

SOAP client basic example

Steps to generate stubs using ant

Once you have the .wsdl in place use the below ant script to generate stub in your “appicode-deploy.xml”.

<property name="cxf.home" location ="/usr/myapps/cxf-2.5.1"/>


<path id="cxf.classpath">
<fileset dir="${cxf.home}/lib">
<include name="*.jar"/>
</fileset>
</path>
 
<target name="cxfWSDLToJava">
<java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true">
<arg value="-client"/>
<arg value="-d"/>
<arg value="src"/>
<arg value="MyWSDL.wsdl"/>
<classpath>
<path refid="cxf.classpath"/>
</classpath>
</java>
</target>

It generates the .class files of the wsdl into your project. Once it is created and use its method to get the appropriate data in the ApiCode method.

Implementing ApiCode with SOAP service

As said earlier, ApiCode is a simple java application and to make it simple only by implementing the ApiCode interface to your java class. It has three more methods to override, those are

  1. Open()
  2. SetContext()
  3. close()

Set Authentication or configuration details only once
If a SOAP service has authentication, then for every request it is required to send those details. To do so it is not required to have it in all ApiCode methods. Instead if we use setContext(Properties argProperties) method in ApiCode to set the value of those and use it in all the methods.

setContext method is part for ApiCode interface and you must override the method in your ApiCode class. It takes properties as an argument which will be provided by DBSync engine. This property object is created based on the input you provide in the Connectors page. The properties are

  1. Classpath
  2. Username
  3. Password
  4. Baseurl

Using Open method for login

If a SOAP service has any login required, then implement those login implementation in Open() of the ApiCode. Since setContext method is the one which will be called first, so all required inputs will be available to that object. Implement the SOAP service call to do the login in the Open method so it will be called only once across all the ApiCode methods. Open method will be called by the DBSync engine so it gets called before ApiCode method is being called.

For more information:

Extend the Integration Platform

Building ApiCode Program On DBSync

Leave a Reply

One Step Away...

Get access to All our Demo and Tutorial videos, Case studies, White Papers and Webinar recordings - 50+ hours of content