How to Incorporate a SOAP Service in AppCode

DZone 's Guide to

How to Incorporate a SOAP Service in AppCode

Looking to incorporate SOAP into AppCode? Look no further. Here are a few ways to leverage SOAP services and methods within AppCode.

· Mobile Zone ·
Free Resource


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

Here's a link for AppCode 'helloworld' example.

Since AppCode is a simple Java application, implementing SOAP services in AappCode is not any different. Into that, we have some additional scripts to build the application and packaging AppCode.

Here's a basic example of the SOAP client.

Steps to Generate Stubs Using Ant

Once you have the .wsdl in place use the below ant script to generate stub in your "appcode-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"/>

<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"/>
<path refid="cxf.classpath"/>

It generates the .class files of the WSDL into your project. Once it is created, you can use its method to get the appropriate data in the AppCode method.

Implementing AppCode With SOAP Service

As said earlier, AppCode is a simple Java application that implements the AppCode interface to your Java class. It has three more methods to override, those are:

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

Set Authentication or Config Details Only Once

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

The setContext method is part of the AppCode interface, and you must override the method in your AppCode class. It takes properties as an argument, which the DBSync engine provides. 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 Logging In

If a SOAP service has any login required, then implement those login implementation in Open() of the AppCode. Since the setContext method is the one that will be called first, 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 AppCode methods. The Open method will be called by the DBSync engine so it gets called before AppCode method is called.

code ,method ,interface ,soap ,java ,application ,engine ,service ,client ,appcode

Published at DZone with permission of Pavan Kumar , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}