Bringing an SOAP API under Management in Mule

This is a simple usecase where you want to expose an SOAP endpoint in Mule and make sure it is under management of the MuleSoft AnyPoint Platform.

The normal workflow is to create a RAML specification in the design center and fine-tuned the specification through the mocking service. After you are satisfied with the specification you can go to the management center and in the API Manage section you can add your newly created application.

With a SOAP/WSDL application the workflow is slightly different.

The Mule best practice is to make use of a Proxy configuration and expose the endpoint as a REST application. But there are situations where you simply need a SOAP/WSDL endpoint.

The first step is to create your wsdl outside of the Design center. You can create the WSDL with anypoint studio or some other IDE.

Let’s say we have our helloworld wsdl below and we want this application to be known in the API Manager.  (Example is supplied by tutorialspoint.com)

<definitions name = "HelloService"
   targetNamespace = "http://www.examples.com/wsdl/HelloService.wsdl"
   xmlns = "http://schemas.xmlsoap.org/wsdl/"
   xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:tns = "http://www.examples.com/wsdl/HelloService.wsdl"
   xmlns:xsd = "http://www.w3.org/2001/XMLSchema">

   <message name = "SayHelloRequest">
      <part name = "firstName" type = "xsd:string"/>
   </message>

   <message name = "SayHelloResponse">
      <part name = "greeting" type = "xsd:string"/>
   </message>

   <portType name = "Hello_PortType">
      <operation name = "sayHello">
         <input message = "tns:SayHelloRequest"/>
         <output message = "tns:SayHelloResponse"/>
      </operation>
   </portType>

   <binding name = "Hello_Binding" type = "tns:Hello_PortType">
      <soap:binding style = "rpc"
         transport = "http://schemas.xmlsoap.org/soap/http"/>
      <operation name = "sayHello">
         <soap:operation soapAction = "sayHello"/>
         <input>
            <soap:body
               encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
               namespace = "urn:examples:helloservice"
               use = "encoded"/>
         </input>

         <output>
            <soap:body
               encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
               namespace = "urn:examples:helloservice"
               use = "encoded"/>
         </output>
      </operation>
   </binding>

   <service name = "Hello_Service">
      <documentation>WSDL File for HelloService</documentation>
      <port binding = "tns:Hello_Binding" name = "Hello_Port">
         <soap:address
            location = "http://www.examples.com/SayHello/" />
      </port>
   </service>
</definitions>

First we go to the Anypoint Exchange and create a new asset.

Assets

Here we select our helloworld WSDL and create our new asset.

Creating asset

The API is now published in the Exchange and the next step is to add the API to the API Manager.

API Manager

Click Manage API and select your newly created API from the Exchange.

Manage API

Select your newly created API and don’t forget to check the box if this is an Mule 4 application.

Add API From Exchange

And that’s it now you can finish the application and deploy the application to the Anypoint platform using the autodiscovery feature.  Mule autodiscovery

Now your application is under management of the Anypoint platform.

Leave a Reply

Your email address will not be published. Required fields are marked *

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