我只是对 Mule ESB 3.5 有一点经验,我发现大多数 Mule 示例只使用一个参数创建 SOAP Web 服务。例如,您可以在 SOAP Web 服务安全示例中看到这一点。
http://www.mulesoft.org/documentation/display/current/SOAP+Web+Service+Security+Example
所以我有一个问题,根据上面的例子,在使用 CHOICE 流控制之后,如何将多参数传递给 SOAP 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/client?clientType=usernameToken&name=John 但是,当我将greet方法更改为welcome方法时,我不知道如何向它传递更多参数或必须更改任何内容,因为有效负载仅包含name参数