DZone
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
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Multipart WSDL With Mule ESB

Multipart WSDL With Mule ESB

Let's take a look at a tutorial that explains SOAP binding for an operation that has two parts with a SOAP header part and a SOAP body.

venu a user avatar by
venu a
·
Aug. 30, 18 · Tutorial
Like (3)
Save
Tweet
Share
10.79K Views

Join the DZone community and get the full member experience.

Join For Free

Before getting into an article, let’s have a quick introduction about web services with multi-part WSDL.

We can say a WSDL as multipart WSDL when:

1. SOAP binding for an operation bound to A SOAP body and non-binary attachments.

2. SOAP binding for an operation that has two parts with a SOAP header part and a SOAP body. The below screenshot from WSDL will help you in identifying the multi-part WSDL.Image title

In this article, we are going to discuss scenario number 2.

Currently, most of the banking, healthcare, insurance, and aviation sector players maintain their core enterprise integration systems with SOAP-based services for various reasons.

When you are migrating from a legacy WBS-based system into Mule, you will surely end up consuming WS with multi-part WSDL’s.

SOAP-based Webservice’s can be consumed in Mule using a Webservice consumer or CXF component with a JAX-WS client operation. As a web service consumer doesn’t support multi-part implementation, we will go with the CXF component.

Components used:

  1. CXF as JAX-WS client

  2. SOAP Router

  3. XML to JAXBObject transformer

  4. WSDL2 Java tool by CXF can be found here. 

Whenever you try consuming services with multi-part messages, the web service consumer shows a warning as “Warning: Operation Messages With More Than 1 Part Are Not Supported.”

When you drag and drop the DW component, it senses either SOAP Body or other parts, which makes it difficult for developers to perform transformations.

Step 1

Generate JAXB Objects corresponding to the given service WSDL.

Before generating JAXB objects, we need to make the below change to WSDL.

Find the PortType for your interface and place the below binding statement in your WSDL.

<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">         
<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>

</jaxws:bindings>

Drag and drop CXF componant, select operation as Jax-WS Client as shown in the below screenshot.

Image title

To generate JAXB objects, click on Generate from WSDL as highlighted in the above screenshot. Enter the WSDL location and Java package name in the "Generate from WSDL" pop-up:

Image title

Step 2

Identify the below classes from the generated Java files:

1. The interface represents Webservice (tip: search with “@WebService”).

2. Request header and body Java Objects (tip: Identify from Interface class Operation).

3. Webservice Client class (tip: search with “@WebServiceClient”).

Step 3

Prepare request for Jax-WS client.

As our message payload contains data formats like XML, we need to convert XML to the equivalent, JAXB object, using XML to JAXB Object Transformer.

Header JAXB object creation:

Image title

Body JAXB Object creation:

Image title

Step 4

Consume Webservice:

Assign the Payload with the required variables for the given Operation. As getDetails operation as two parameters, out payload will be an array of two JAXB objects.

@WebMethod

    @WebResult(name = "getDetailsResponse", targetNamespace = "http://soapMain.capg.com", partName = "parameters")

    public GetDetailsResponse getDetails(

        @WebParam(partName = "getDetails", name = "getDetails", targetNamespace = "http://soapMain.capg.com")

        GetDetails getDetails,

        @WebParam(partName = "InputHeader", name = "getDetailsHeader", targetNamespace = "http://soapMain.capg.com", header = true)

        GetDetailsHeader inputHeader

    );

Request Payload:

requestPayload = new object[2]();

requestPayload[0] = payload;

requestPayload[1] = flowVars.flwJaxBHeader;

payload = requestPayload;

Add a combination of CXF as JAX-WS client and HTTP requester for consuming the Webservice.

Image title

Thanks for reading this article, and let me know your thoughts and/or suggestions in the comments section. 

Enterprise service bus

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • The 12 Biggest Android App Development Trends in 2023
  • Utilize OpenAI API to Extract Information From PDF Files
  • 2023 Software Testing Trends: A Look Ahead at the Industry's Future
  • Why Open Source Is Much More Than Just a Free Tier

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • 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: