DZone
Mobile Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Mobile Zone > How to Incorporate a SOAP Service in AppCode

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.

Pavan Kumar user avatar by
Pavan Kumar
·
Jul. 16, 16 · Mobile Zone · Tutorial
Like (3)
Save
Tweet
2.57K Views

Join the DZone community and get the full member experience.

Join For Free

SOAPandAPPCode

"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"/>
</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, 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.

SOAP Web Protocols

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

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Maven Tutorial: Nice and Easy [Video]
  • Top Six Kubernetes Best Practices for Fleet Management
  • After COVID, Developers Really Are the New Kingmakers
  • Java: Why Core-to-Core Latency Matters

Comments

Mobile Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo