【发布时间】:2013-11-05 15:28:15
【问题描述】:
我只是对 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 方法时,我不知道如何将更多参数传递给它或必须更改任何内容,因为 payload只包含 name 参数
【问题讨论】:
-
首先创建您的 WSDL,然后从中生成 JAX-WS 基础架构,您将拥有一个能够处理复杂对象的 Web 服务。
-
谢谢大卫,但我想你在这里误解了我。在该示例中,通过选择流控制后,我将调用一个已经构建的 Web 服务方法,但该方法只有一个参数,当我更改为另一个有 2 个参数的方法时,我不知道如何传递参数给它。或者你可以更详细地指导我你的方法。再次感谢!
-
我不明白:你想调用一个已经存在的网络服务吗?
标签: web-services soap cxf mule url-parameters