0
votes

I just have a little experience with Mule ESB 3.5, and I found that most of Mule examples only create SOAP Web Service with one parameter. For example, you can see that in SOAP Web Service Security example.

http://www.mulesoft.org/documentation/display/current/SOAP+Web+Service+Security+Example

So I have one question, acroding to above example, after using CHOICE flow control, how to pass multi parameter to method of SOAP web service.

Some suggests for me is to use object array to pass multi parameter, but I still have no clue at all.

Thanks to David. I just try your suggestion. But I think I should update my question to make it clearly.

Firstly, I create web service

@WebService
public interface Greeter
{
    public String greet(String name);
    public String welcome( String name1,String name2);

}

Then I have a control flow for web service configuration

<flow name="UnsecureServiceFlow" doc:name="UnsecureServiceFlow">
    <http:inbound-endpoint address="http://localhost:63081/services/unsecure" exchange-pattern="request-response" doc:name="HTTP Inbound Endpoint"/>
    <cxf:jaxws-service serviceClass="com.mulesoft.mule.example.security.Greeter" doc:name="Unsecure service"/>
    <component class="com.mulesoft.mule.example.security.GreeterService" doc:name="Greeter Service" />
</flow>

Next is the sub flow using jax-ws client to call the method of web service
 <flow name="SecurityClients" doc:name="SecurityClients">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="63080" path="client" doc:name="HTTP Inbound Endpoint"/>
        <set-payload value="#[message.inboundProperties['http.query.params']['name']]" doc:name="Set payload with 'name' query param"/>
        <set-variable variableName="clientType" value="#[message.inboundProperties['http.query.params']['clientType']]" doc:name="Set clientType"/>
        <choice doc:name="Choice">
            <when expression="#[clientType == 'unsecure']">
                    <flow-ref name="unsecure" doc:name="Invoke unsecure sub-flow"/>
            </when>
            <when expression="#[clientType == 'usernameToken']">
                    <flow-ref name="usernameToken" doc:name="Invoke usernameToken sub-flow"/>
            </when>
            <when expression="#[clientType == 'usernameTokenSigned']">
                    <flow-ref name="usernameTokenSigned" doc:name="Invoke usernameToken Signed sub-flow"/>
            </when>
            <when expression="#[clientType == 'usernameTokenEncrypted']">
                    <flow-ref name="usernameTokenEncrypted" doc:name="Invoke usernameToken Encrypted sub-flow"/>
            </when>
            <when expression="#[clientType == 'samlToken']">
                    <flow-ref name="samlToken" doc:name="Invoke samlToken sub-flow"/>
            </when>
            <when expression="#[clientType == 'samlTokenSigned']">
                    <flow-ref name="samlTokenSigned" doc:name="Invoke samlToken Signed sub-flow"/>
            </when>
            <otherwise>
                    <set-payload value="Client type is not supported" doc:name="Client type is not supported"/>
            </otherwise>
        </choice>
        <set-property propertyName="Content-Type" value="text/plain" doc:name="Set response Content-Type"/>
        <catch-exception-strategy doc:name="Catch Exception Strategy">
            <set-payload value="There has been an Error processing the request" doc:name="Set Payload"/>
            <set-property propertyName="Content-Type" value="text/plain" doc:name="Set response Content-Type"/>
        </catch-exception-strategy>
    </flow>
    <sub-flow name="unsecure" doc:name="unsecure">
        <cxf:jaxws-client operation="greet" serviceClass="com.mulesoft.mule.example.security.Greeter" doc:name="Unsecure SOAP client" doc:description="Unsecure SOAP client"/>
        <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="63081" path="services/unsecure" doc:name="Invoke unsecure Web Service"/>
    </sub-flow>

It's ok to use that address to invoke greet method, it only has one parameter. localhost:63080/client?clientType=usernameToken&name=John However when I change greet method to welcome method, I do not know how to pass more parameter to it or have to change anything , because payload only contains name parameter

1
Create your WSDL first then generate the JAX-WS infrastructure from it and you'll have a web service that is capable of dealing with complex objects.David Dossot
Thank David, however I think you misunderstood me here. In that example, after pass choice flow control, I will invoke one method of web service which was already built, but that method only have one parameter, whereby when I change to another method which has 2 parameters, I don't know how to pass parameters to it. Or may be could you instruct me your method with more detail. Thanks again!Thien Dinh
I don't get it: you want to invoke an already existing web service?David Dossot

1 Answers

1
votes

Generate the JAX-WS client classes from the remote web service WSDL and use them in a cxf:jaxws-client configuration element.

In your case, you need to set-payload inside each when in order to create the request object that is needed by cxf:jaxws-client.

Suppose that you need to create a org.saml.SamlToken object for the samlToken case, you would do:

<set-payload value="#[st=new org.saml.SamlToken();st.field1=message.inboundProperties.field1; ... ; st]" />

in the when right before flow-ref.

PS. You can use #[message.inboundProperties.clientType] instead of #[message.inboundProperties['http.query.params']['clientType']]