Expose SOAP Web Service using APIkit SOAP in Mule ESB

In addition to using the CXF Component to expose a SOAP Web Service, we can also use the APIkit SOAP together with a WSDL file to do this in the Mule ESB. How is it in details? Let’s find out in this tutorial.

First, I will also create a Mule Maven project as an example:

Expose SOAP Web Service using APIkit SOAP in Mule ESB

The WSDL file defined for the SOAP Web Service we use in this example is as simple as:

This WSDL defines a SOAP Web Service that allows a user to pass a string, the implementation will depend on us.

I will put this file into the /src/main/wsdl directory of the project.

In fact, the /src/main/wsdl directory is available when we create a new Mule Maven project but by default, it is not included as the source folder of the project so you do not see it. Normally, if our project is an Eclipse based project, you can right-click on the project, select Build Path and then select Configure Build Path … Then in the Source tab, click Add Folder … and check wsdl directory:

Expose SOAP Web Service using APIkit SOAP in Mule ESB

to include this directory as the source folder of the project.

But here our project is Mule Maven project so if you do the same, when building with Maven, it will be lost. To configure this folder as the source folder of the project with Maven, just open the pom.xml file of Maven, look for the build-helper-maven-plugin plugin declaration, and then add the resource declaration for the wsdl directory as follows. :

then you will see the wsdl directory included as the source folder of the project.

Expose SOAP Web Service using APIkit SOAP in Mule ESB

Please put our wsdl file into this folder.

Expose SOAP Web Service using APIkit SOAP in Mule ESB

OK, now let’s go to the main topic of this tutorial.

To use the APIkit SOAP in Mule ESB, first, we need to declare its dependencies. There are 3 dependencies we need to declare for the APIkit SOAP:

Currently, I cannot find the Maven repository that contains these three dependencies on the network, so there is only one way that we will go to the plugins folder of Anypoint Studio and look for the org.mule.tooling.soapkit.contribution_1.1.4/lib directory

Expose SOAP Web Service using APIkit SOAP in Mule ESB

to get these files, then install them into the Local Maven repository. You can see the guideline for installing dependencies into the Local Maven repository here.

OK, after adding the dependencies, right-click on the hello.wsdl file in the example project and select Mule, then select Generate Flows from WSDL.

Expose SOAP Web Service using APIkit SOAP in Mule ESB

At this point, a window will appear:

Expose SOAP Web Service using APIkit SOAP in Mule ESB

allow us to choose the Mule Configuration file to generate Mule Flows.

You can leave the defaults and click the OK button.

You will see that Mule Flows is generated as follows:

Expose SOAP Web Service using APIkit SOAP in Mule ESB

As you can see, Anypoint Studio has generated Mule Flows using the APIkit SOAP with an api-main Mule flow will receive requests from the client, each SOAP Web Service operation will be generated as a Mule Flow. Our task is to implement the Mule flow for each operation. By default, the flow mule for each operation has only one endpoint Set Payload. The content of this Set Payload endpoint depends on the operation of the SOAP Web Service, which will have different content. In this example, the content of the Set Payload endpoint is as follows:

You can remove this Set Payload enpoint to implement this flow in your own way but must conform to the definition of your WSDL file. Here, I will delete this Set Payload endpoint and add a Transform Message Component to build the SOAP response message back to the client as follows:

Expose SOAP Web Service using APIkit SOAP in Mule ESB

You will now see the endpoint of the HTTP Listener Connector being corrupted. The cause is that after generating from the WSDL file, the Global Configuration of this connector has not been created. Please configure it, can see the guideline here.

Here, I configured the Global Configuration for the HTTP Listener Connector as follows:

Expose SOAP Web Service using APIkit SOAP in Mule ESB

Change the configuration of the HTTP Listener Connector to the correct definition of the WSDL file:

Expose SOAP Web Service using APIkit SOAP in Mule ESB

Here we have completed a simple example using the SOAP API to expose the SOAP Web Service, but to get our application running, you need to take more step to bring the SOAP API library into our application when running it with Mule Runtime. If you do not do this, you will get an error regarding the SOAP API’s mule-apikit-soap.xsd. With this last step, you need to open the pom.xml file and find the mule-app-maven-plugin plugin to include the SOAP API libraries as follows:

OK, that’s all, let run our application now.

Results when running with SOAPUI:

Expose SOAP Web Service using APIkit SOAP in Mule ESB


Expose SOAP Web Service using APIkit SOAP in Mule ESB
Đánh giá bài viết
Chia sẽ bài viết này ...Share on Facebook
7Share on Google+
0Tweet about this on Twitter
Share on LinkedIn

6 thoughts on “Expose SOAP Web Service using APIkit SOAP in Mule ESB

  1. POC1:

    (Create Salesforce developer account; Any point account)

    Implement a SOAP API with two resources. One is to get account detail from salesforce by account id & another one is to delete.
    Implement a REST API which should act as a wrapper / pass through service for SOAP.
    Should accept account id in path parameter
    Use appropriate HTTP method for resources
    Should return JSON response
    i. Account detail for get operation

    ii. and delete confirmation message for delete operation.

    Implement proper exception handling

    Please let me know how to implement a soap web service as per the above requirement?

    1. Khanh Nguyen

      You should use Salesforce connector for calling and manipulating with Salesforce. Let define REST API with APIkit Router and implement the calling to SF for each resource. You should research more about SF to understand about it.

      Best regards,

  2. HI Khanh Nguyen, i was trying to create a Mule project to expose a soap service as above and while deploying the project i’m getting an error as below. I’m using Mule 3.9.0 Run-time.

    org.mule.module.launcher.DeploymentException: Failed to deploy artifact [helloservicesoapkit]
    at org.mule.module.launcher.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:85) ~[mule-module-launcher-3.9.1.jar:3.9.1]
    at org.mule.module.launcher.DefaultArchiveDeployer.deployArtifact(DefaultArchiveDeployer.java:547) ~[mule-module-launcher-3.9.1.jar:3.9.1]
    at org.mule.module.launcher.DefaultArchiveDeployer.deployArtifact(DefaultArchiveDeployer.java:325) ~[mule-module-launcher-3.9.1.jar:3.9.1]
    at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:185) ~[mule-module-launcher-3.9.1.jar:3.9.1]
    at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:274) ~[mule-module-launcher-3.9.1.jar:3.9.1]
    at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:80) ~[mule-module-launcher-3.9.1.jar:3.9.1]
    at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:577) ~[mule-module-launcher-3.9.1.jar:3.9.1]
    at org.mule.module.launcher.DeploymentDirectoryWatcher.deployPackedApps(DeploymentDirectoryWatcher.java:283) ~[mule-module-launcher-3.9.1.jar:3.9.1]
    at org.mule.module.launcher.DeploymentDirectoryWatcher.start(DeploymentDirectoryWatcher.java:155) ~[mule-module-launcher-3.9.1.jar:3.9.1]
    at org.mule.module.launcher.MuleDeploymentService.start(MuleDeploymentService.java:135) ~[mule-module-launcher-3.9.1.jar:3.9.1]
    at org.mule.module.launcher.MuleContainer.start(MuleContainer.java:172) ~[mule-module-launcher-3.9.1.jar:3.9.1]
    at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:15) ~[tooling-support-3.9.1.jar:?]
    Caused by: java.lang.NoClassDefFoundError: org/mule/module/soapkit/metadata/api/FaultMetaDataResolver

    here is my wsdl file

    WSDL File for HelloService

    and my implementation is as below

    Please help me to resolve this issue

Add Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.