Contact Us 1-800-596-4880

Web Service Consumer Reference

Use the Web Service Consumer reference guide as you design a Mule application to consume a SOAP service. Learn about the elements and attributes necessary for your use case.

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.

Web Service Consumer 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"/>

Web Service Consumer Global Element and Attributes

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.

mtomEnabled

true/false

Whether or not MTOM (attachment support) is enabled

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>
...
Child Element Attribute Value Attribute Req’d Attribute Description

ws:wss-sign

tlsContext-ref

x

References a TLS context where to obtain a Key Store used to add a soap header with a signature to outgoing messages.

The sign security policy adds a signature to the header of the SOAP request. The signature is generated using the private key of the client. Therefore, a reference to a TLS Context must be provided, and this context must contain the definition of a key-store. The private key of this key-store is used to generate the signature.

<tls:context name="tlsContext">
   <tls:key-store path="path" keyPassword="pass" password="pass" alias="keyalias" />
</tls:context>

<ws:consumer-config serviceAddress="http://localhost/test" wsdlLocation="Test.wsdl"
                    service="TestService" port="TestPort" name="wsConfig">
        <ws:security>
            <ws:wss-sign tlsContext-ref="tlsContext" />
        </ws:security>
</ws:consumer-config>
Child Element Attribute Value Attribute Req’d Attribute Description

ws:wss-verify-signature

tlsContext-ref

x

References a TLS context where to check a Trust Store to certify the signatures on incoming messages.

The verify-signature security policy allows the client to validate a signature that was added by the server to the SOAP response. In order to perform this validation, a reference to a TLS Context must be provided, and this context must contain a trust-store. The trust-store must contain the certificate of the server that is signing the response.

<tls:context name="tlsContext">
   <tls:trust-store path="trustStore" password="pass" />
</tls:context>

<ws:consumer-config serviceAddress="http://localhost/test" wsdlLocation="Test.wsdl"
                    service="TestService" port="TestPort" name="wsConfig">
        <ws:security>
            <ws:wss-verify-signature tlsContext-ref="tlsContext" />
        </ws:security>
</ws:consumer-config>
Child Element Attribute Value Attribute Req’d Attribute Description

ws:wss-encrypt

tlsContext-ref

x

References a TLS context where to obtain a Trust Store to use in the encryption of outgoing messages. This encryption occurs at SOAP level, not at HTTP level

alias

x

Alias of the key to use inside the trust-store

The encrypt security policy allows the client to encrypt the SOAP body of the request. The body is encrypted using the public key of the server, so a TLS Context with a trust-store must be provided. As the trust-store may contain many entries for trusted servers, the alias of the key to use must be also specified as an attribute:

<tls:context name="tlsContext">
   <tls:trust-store path="trustStore" password="pass" />
</tls:context>

<ws:consumer-config serviceAddress="http://localhost/test" wsdlLocation="Test.wsdl"
                    service="TestService" port="TestPort" name="wsConfig">
        <ws:security>
            <ws:wss-encrypt tlsContext-ref="tlsContext" alias="keyalias" />
        </ws:security>
</ws:consumer-config>
Take into account that this encryption occurs at SOAP level. If you wish to encrypt your messages at HTTP level, then you must do that through having your WSC reference a different http-request-config element from the default, which in turn must reference a TLS element.
Child Element Attribute Value Attribute Req’d Attribute Description

ws:wss-decrypt

tlsContext-ref

x

References a TLS context where to obtain a Key Store to use for decrypting incoming messages. This decryption occurs at SOAP level, not at HTTP level.

The decrypt security strategy allows the client to decrypt a SOAP response that is encrypted by the server. A reference to a TLS Context with a key-store must be provided. The private key in the keystore will be used to decrypt the response.

<tls:context name="tlsContext">
   <tls:key-store path="path" keyPassword="pass" password="pass" alias="keyalias" />
</tls:context>

<ws:consumer-config serviceAddress="http://localhost/test" wsdlLocation="Test.wsdl"
                    service="TestService" port="TestPort" name="wsConfig">
        <ws:security>
            <ws:wss-decrypt tlsContext-ref="tlsContext" />
        </ws:security>
</ws:consumer-config>
Take into account that this decryption occurs at SOAP level. If you wish to decrypt messages at HTTP level, then you must do that through having your WSC reference a different http-request-config element from the default, which in turn must reference a TLS element.

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_"/>

    <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>


    <flow name="orderTshirt" doc:name="orderTshirt">
        <http:listener config-ref="HTTP_Listener_Configuration" path="orders" doc:name="HTTP">
            <http:response-builder statusCode="200"/>
        </http:listener>
        <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:listener config-ref="HTTP_Listener_Configuration" path="inventory" doc:name="HTTP">
            <http:response-builder statusCode="200"/>
        </http:listener>
        <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>
View on GitHub