Welcome to KLART Technologies.
In this post let’s see how to consume SOAP webservice in MuleSoft Mule 4 version using webservice Consumer Connector.
Let’s take an SOAP API WSDL publicly available in internet to practice this Example. We found this WSDL for calculator service but you can use any other WSDL available with you.
If you want to go through our video tutorial on the topic with detailed explanation navigate to our youtube channel and subscribe for more Updated video tutorials.
Take a WSDL. We have found one calculator WSDL available in Internet, But you can take any other WSDL available for you and can consume that.
Calculator WSDL
http://www.dneonline.com/calculator.asmx?wsdl

- Let’s Analyze the WSDL and search for <Wsdl:Operation> tag to find out how many operations are there in this SOAP service.
- Let’s observe that this SOAP service has 4 calculator operations as “add,subtract,multiply and divide“. Let’s Try to consume Add operation in our mule flow.
MuleSoft Flow Implementation
- First step is to create new Project in Anypoint Studio and Name it as SOAPServiceDemo.

- Once it opens up drag and drop Http Listener and configure it as http://localhost:8089/soaptest.

- Now lets add one simple logger for our debug purpose and search for webservice consumer connector from the palette.

- Now click on Green + Icon to configure web service consumer global connector configuration.
- In the wsdl location field copy and paste the wsdl URL which we have seen in our first step.It will automatically populate the Service Field.

- Now select the Port field values as CalculatorSoap and address Field will populate automatically.

- Once the metadata is calculated now you can observe the list of operations of this WSDL have under Operation Field.

- As per our Requirement select ADD operation from the list.
- Now drag and drop Transform Message component before the web service consumer Component to send SOAP Request to the Calculator service Add Operation.
- Once you click on the Transform Message Properties it will show you the number of input parameters required to send as input request to this SOAP Service. In this example we can observe intA and intB are the required input fields to which we need to send values.

- By Default Dataweave output type is application/java but we need to send soap request in application/xml format right?
- To do that we dont write anything manually, just click on each attribute intA and intB. It will automatically transform the dataweave snippet as shown.

- impressive!! That’s the beauty of Mulesoft right.
- Now we need to map the values instead of null values. To do that we are going to send dynamic values to these two input parameters from postman body payload while testing it.
- Hence, we need to map the two values here like payload.first and payload.second

- Perfect!! Now drag and drop another dataweave after Webservice Consumer connector to capture the response of this web service and write code like to capture payload as application/json as shown.

- We need to do one more last change to make this Http listener to accept POST requests in order to send body for this SOAP request.
- To to that go to http listener and advanced tab Write methods as POST.

- Great!! We completed the implementation of our service. Let’s save our code and deploy it to make it ready for testing.
Testing your service:
Please Subscribe to KLART Technologies – YouTube and go through the testing part.
