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

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.


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


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

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
54
&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" version="EE-3.6.0"
 
    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;