Web Service Consumer Connector in Mule 4

Web service consumer in mule 4



Web Service Consumer is used to consuming SOAP web service in Mule.

flow of Web Service Consumer in Mule:


WSDL file you can get from here:  http://mu.learn.mulesoft.com/delta?wsdl

for consuming soap web service we need to give WSDL file path in web service consumer.

WSDL file is stored in src/main/resources


Web service consumer configuration:


Connector configuration:


Transform message configuration:


URL: http://localhost:8085/web?code=pune
Method: GET


XML project code:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:wsc="http://www.mulesoft.org/schema/mule/wsc"
     xmlns:http="http://www.mulesoft.org/schema/mule/http"
     xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/wsc http://www.mulesoft.org/schema/mule/wsc/current/mule-wsc.xsd">
     <wsc:config name="Web_Service_Consumer_Config" doc:name="Web Service Consumer Config" doc:id="f63d6809-4952-4571-a4ff-aa8da598973d" >
          <wsc:connection wsdlLocation="soap.wsdl" service="TicketServiceService" port="TicketServicePort" address="http://mu.learn.mulesoft.com/delta" />
     </wsc:config>
     <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="8f86ba62-35e2-4861-b5e3-11e57c0aca7d" >
          <http:listener-connection host="0.0.0.0" port="8085" />
     </http:listener-config>
     <flow name="test_webserviceconsumerFlow" doc:id="ea35e9f8-694f-4b1b-91d8-ad76a918659f" >
          <http:listener doc:name="Listener" doc:id="68fa6fed-9b7a-4115-ab18-d1becf2cf39f" config-ref="HTTP_Listener_config" path="/web"/>
          <ee:transform doc:name="Transform Message" doc:id="d618ff14-5ba3-4b56-a832-79bc2a796003" >
              <ee:message >
                   <ee:set-payload ><![CDATA[%dw 2.0
output application/xml
ns ns0 http://soap.training.mulesoft.com/
---
{
     ns0#listAllFlights: attributes.queryParams.id
}]]></ee:set-payload>
              </ee:message>
          </ee:transform>
          <wsc:consume operation="listAllFlights" doc:name="Consume" doc:id="a3d33234-e13c-4ad4-8fc8-e75c1786105b" config-ref="Web_Service_Consumer_Config"/>
     </flow>
</mule>