我只是对Mule ESB 3.5有一点经验,我发现大多数Mule示例只创建了带有一个参数的SOAPWeb服务。例如,您可以在SOAPWebServiceSecurity示例中看到这一点。
http://www.mulesoft.org/documentation/display/current/SOAP+Web+服务+安全+示例
所以我有一个问题,针对上面的例子,在使用CHOICE流控制之后,如何将多参数传递给SOAP web服务的方法。
有人建议我使用对象数组来传递多参数,但我仍然一无所知。
感谢大卫。我只是试试你的建议。但我认为我应该更新我的问题,让它变得清楚。
首先,我创建了web服务
@WebService
public interface Greeter
{
public String greet(String name);
public String welcome( String name1,String name2);
}
然后我有一个web服务配置的控制流程
<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>
使用该地址来调用greet方法是可以的,它只有一个参数。localhost:63080/客户端?clientType=用户名令牌&name=约翰但是,当我将welcome方法更改为welcomeayload只包含name参数
从远程web服务WSDL生成JAX-WS客户端类,并在cxf:jaxws-client
配置元素中使用它们。
在您的情况下,您需要在每个when
中使用set-payload
,以便创建cxf:jaxws-client
所需的请求对象。
假设您需要为samlToken
情况创建一个org.saml.SamlToken
对象,您可以执行以下操作:
<set-payload value="#[st=new org.saml.SamlToken();st.field1=message.inboundProperties.field1; ... ; st]" />
就在CCD_ 8之前的CCD_。
PS。您可以使用#[message.inboundProperties.clientType]
而不是#[message.inboundProperties['http.query.params']['clientType']]