Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

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.


         
      
1
<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.


         
      
1
2
3
4
5
6
7
8
...
    <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.


         
      
1
2
3
4
5
6
7
8
9
10
<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.


         
      
1
2
3
4
5
6
7
8
9
10
<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:


         
      
1
2
3
4
5
6
7
8
9
10
<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.


         
      
1
2
3
4
5
6
7
8
9
10
<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

final+flow


    
            
         
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
&lt;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"&gt;
 
    &lt;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"/&gt;
 
    &lt;data-mapper:config name="xml_listinventoryresponse__to_json" transformationGraphPath="xml_listinventoryresponse__to_json.grf" doc:name="xml_listinventoryresponse__to_json"/&gt;
 
    &lt;data-mapper:config name="json_to_xml_ordertshirt_" transformationGraphPath="json_to_xml_ordertshirt_.grf" doc:name="json_to_xml_ordertshirt_"/&gt;
 
    &lt;data-mapper:config name="xml_ordertshirtresponse__to_json" transformationGraphPath="xml_ordertshirtresponse__to_json.grf" doc:name="xml_ordertshirtresponse__to_json"/&gt;
 
    &lt;data-mapper:config name="string_to_xml_authenticationheader_" transformationGraphPath="string_to_xml_authenticationheader_.grf" doc:name="string_to_xml_authenticationheader_"/&gt;
 
    &lt;http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/&gt;
 
 
    &lt;flow name="orderTshirt" doc:name="orderTshirt"&gt;
        &lt;http:listener config-ref="HTTP_Listener_Configuration" path="orders" doc:name="HTTP"&gt;
            &lt;http:response-builder statusCode="200"/&gt;
        &lt;/http:listener&gt;
        &lt;data-mapper:transform config-ref="json_to_xml_ordertshirt_" doc:name="JSON To Xml&amp;lt;OrderTshirt&amp;gt;"/&gt;
        &lt;set-variable variableName="apiKey" value="#['abc12345']" doc:name="Set API Key"/&gt;
        &lt;data-mapper:transform config-ref="string_to_xml_authenticationheader_" input-ref="#[flowVars[&amp;quot;apiKey&amp;quot;]]" target="#[message.outboundProperties[&amp;quot;soap.header&amp;quot;]]" doc:name="String To Xml&amp;lt;AuthenticationHeader&amp;gt;"/&gt;
        &lt;ws:consumer config-ref="Web_Service_Consumer" operation="OrderTshirt" doc:name="Order Tshirt"/&gt;
        &lt;data-mapper:transform config-ref="xml_ordertshirtresponse__to_json" doc:name="Xml&amp;lt;OrderTshirtResponse&amp;gt; To JSON" returnClass="java.lang.String"/&gt;
    &lt;/flow&gt;
 
    &lt;flow name="listInventory" doc:name="listInventory"&gt;
        &lt;http:listener config-ref="HTTP_Listener_Configuration" path="inventory" doc:name="HTTP"&gt;
            &lt;http:response-builder statusCode="200"/&gt;
        &lt;/http:listener&gt;
        &lt;ws:consumer config-ref="Web_Service_Consumer" operation="ListInventory" doc:name="List Inventory"/&gt;
        &lt;data-mapper:transform config-ref="xml_listinventoryresponse__to_json" returnClass="java.lang.String" doc:name="Xml&amp;lt;ListInventoryResponse&amp;gt; To JSON"/&gt;
    &lt;/flow&gt;
 
&lt;/mule&gt;