Contact Us 1-800-596-4880

Web Service Consumer Reference

The component formerly known as the SOAP Connector is now known as the CXF Component. It should not be confused with the Web Service Consumer.

Elements and Attributes

Studio Palette XML Element Use

Web Service Consumer

ws:consumer

Use to consume a SOAP Web service from within a Mule application.

Element Attribute Value Attribute Req’d Attribute Description

ws:consumer

doc:name

unique name for message processor

x

Defines unique identifier for Web Service Consumer element. (Studio requirement)

config-ref

name of global Web service consumer

x

Identifies the name of the global Web service consumer connector consumer-config the ws:consumer references for connection and security details.

operation

operation to perform during Web service call

x

Identifies the operation to perform during the Web service call; default values extracted from WSDL.

<ws:consumer config-ref="OrderWS" operation="login" doc:name="Login"/>

Global Element

Studio Visual Editor XML Element Use

Global Web Service Consumer

ws:consumer-config

Use to identify the WSDL of the Web service, and to define any security settings required for consuming the Web service.

Element Attribute Value Attribute Req’d Attribute Description

ws:consumer-config

name

unique name

x

Defines unique identifier for global element that can be referenced by message processors.

doc:name

display name

x

Defines display name for Web Service Consumer global element. (Studio requirement)

wsdlLocation

filepath and filename OR URL

x

Identifies the location of the WSDL of the Web Service which you are consuming.

service

name of Web service

x

Identifies the Web service itself by name.

port

name or port number

x

Identifies the port through which you connect to Web service.

serviceAddress

URL

x

Identifies the URL of the Web service.

connector-ref

connector name

References another global connector from which the ws:consumer-config element borrows configuration details. If specified, then the Web Service Consumer created to connect to the Web service uses the referenced connector. The protocol specified in the serviceAddress must be supported by this connector.

Studio XML Child Element Use

Security tab of Global Web Service Consumer

ws:security

Use to apply security settings to the Web service consumer, according to the requirements of the Web service itself.

Studio XML Child Element Use

Security tab of Global Web Service Consumer

ws:wss-username-token

Use to apply username token settings to the Web service consumer.

Child Element Attribute Value Attribute Req’d Attribute Description

ws:wss-username-token

username

username

x

Defines the username to access Web service; added to header of request sent to Web service.

password

password

x

Defines the password to access Web service; added to header of request sent to Web service.

passwordType

DIGEST or TEXT

x

Identifies the type of password.

addCreated

true or false

Specifies whether or not to add a "Created" header to the Web service request.

addNonce

true or false

Specifies whether or not to add a "Nonce" header to the Web service request.

Child Element Attribute Value Attribute Req’d Attribute Description

ws:wss-timestamp

expires

x

Defines the number of seconds, from the point of creation, for which the request remains valid to the Web service.

...
    <ws:consumer-config name="OrderWS" wsdlLocation="enterprise.wsdl.xml" service="OrderService" port="Soap" serviceAddress="https://login.orderservice.com/services/Soap/c/22.0" doc:name="Web Service Consumer">
        <ws:security>
            <ws:wss-username-token username="test" password="test" passwordType="DIGEST" addCreated="true" addNonce="true"/>
            <ws:wss-timestamp expires="30000"/>
        </ws:security>
    </ws:consumer-config>
...

Complete Code Example

STUDIO Visual Editor

final+flow

XML Editor

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


<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" 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:spring="http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd

http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd

http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.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/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd

http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">

    <ws:consumer-config name="Web_Service_Consumer" wsdlLocation="tshirt.wsdl.xml" service="TshirtService" port="TshirtServicePort" serviceAddress="http://tshirt-service.qa2.cloudhub.io/tshirt-service" doc:name="Web Service Consumer"/>

    <data-mapper:config name="xml_listinventoryresponse__to_json" transformationGraphPath="xml_listinventoryresponse__to_json.grf" doc:name="xml_listinventoryresponse__to_json"/>

    <data-mapper:config name="json_to_xml_ordertshirt_" transformationGraphPath="json_to_xml_ordertshirt_.grf" doc:name="json_to_xml_ordertshirt_"/>

    <data-mapper:config name="xml_ordertshirtresponse__to_json" transformationGraphPath="xml_ordertshirtresponse__to_json.grf" doc:name="xml_ordertshirtresponse__to_json"/>

    <data-mapper:config name="string_to_xml_authenticationheader_" transformationGraphPath="string_to_xml_authenticationheader_.grf" doc:name="string_to_xml_authenticationheader_"/>

    <flow name="orderTshirt" doc:name="orderTshirt">
        <http:inbound-endpoint host="localhost" port="8081" path="orders">
            <http:response-builder statusCode="200"/>
        </http:inbound-endpoint>
        <data-mapper:transform config-ref="json_to_xml_ordertshirt_" doc:name="JSON To Xml&lt;OrderTshirt&gt;"/>
        <set-variable variableName="apiKey" value="#['abc12345']" doc:name="Set API Key"/>
        <data-mapper:transform config-ref="string_to_xml_authenticationheader_" input-ref="#[flowVars[&quot;apiKey&quot;]]" target="#[message.outboundProperties[&quot;soap.header&quot;]]" doc:name="String To Xml&lt;AuthenticationHeader&gt;"/>
        <ws:consumer config-ref="Web_Service_Consumer" operation="OrderTshirt" doc:name="Order Tshirt"/>
        <data-mapper:transform config-ref="xml_ordertshirtresponse__to_json" doc:name="Xml&lt;OrderTshirtResponse&gt; To JSON" returnClass="java.lang.String"/>
    </flow>

    <flow name="listInventory" doc:name="listInventory">
        <http:inbound-endpoint host="localhost" port="8081" path="inventory">
            <http:response-builder statusCode="200"/>
        </http:inbound-endpoint>
        <ws:consumer config-ref="Web_Service_Consumer" operation="ListInventory" doc:name="List Inventory"/>
        <data-mapper:transform config-ref="xml_listinventoryresponse__to_json" returnClass="java.lang.String" doc:name="Xml&lt;ListInventoryResponse&gt; To JSON"/>
    </flow>

</mule>