Multipart WSDL With Mule ESB

DZone 's Guide to

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.

· Integration Zone ·
Free Resource

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">         


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.


    @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. 

cxf, integration, jax-ws, jaxb, mule 3.9, mule esb, mulesoft, soap web services, tutorial, wsdl

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}