Web services Mule ESB-如何在浏览器中将多参数传递给soap web服务
我只是对Mule ESB 3.5有一点经验,我发现大多数Mule示例只使用一个参数创建SOAP Web服务。例如,您可以在SOAP Web服务安全示例中看到这一点 所以我有一个问题,通过上面的例子,在使用选择流控制之后,如何将多个参数传递给SOAP web服务的方法 有人建议我使用对象数组来传递多个参数,但我仍然没有任何线索 多亏了大卫。我只是试试你的建议。但我想我应该更新我的问题,让它更清楚 首先,我创建了web服务Web services Mule ESB-如何在浏览器中将多参数传递给soap web服务,web-services,soap,cxf,mule,url-parameters,Web Services,Soap,Cxf,Mule,Url Parameters,我只是对Mule ESB 3.5有一点经验,我发现大多数Mule示例只使用一个参数创建SOAP Web服务。例如,您可以在SOAP Web服务安全示例中看到这一点 所以我有一个问题,通过上面的例子,在使用选择流控制之后,如何将多个参数传递给SOAP web服务的方法 有人建议我使用对象数组来传递多个参数,但我仍然没有任何线索 多亏了大卫。我只是试试你的建议。但我想我应该更新我的问题,让它更清楚 首先,我创建了web服务 @WebService public interface Greeter
@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>
接下来是使用jax-ws-client调用web服务方法的子流程
可以使用该地址调用greet方法,它只有一个参数。
localhost:63080/client?clientType=usernameToken&name=John
但是,当我将greet方法更改为welcome方法时,我不知道如何向其传递更多参数,或者必须更改任何内容,因为有效负载只包含名称参数从远程web服务WSDL生成JAX-WS客户端类,并在
cxf:jaxws客户端
配置元素中使用它们
在您的情况下,您需要在时在每个内设置有效负载,以便创建cxf:jaxws客户端所需的请求对象
假设您需要为SamlToken
案例创建org.saml.SamlToken
对象,您将执行以下操作:
<set-payload value="#[st=new org.saml.SamlToken();st.field1=message.inboundProperties.field1; ... ; st]" />
在流参考
之前的时
另外,您可以使用#[message.inboundProperties.clientType]
而不是#[message.inboundProperties['http.query.params']['clientType']]
首先创建您的WSDL,然后从中生成JAX-WS基础结构,您将拥有一个能够处理复杂对象的web服务。谢谢David,不过我想你在这里误解了我。在那个例子中,在传递选择流控制之后,我将调用已经构建的web服务的一个方法,但该方法只有一个参数,因此当我切换到另一个有2个参数的方法时,我不知道如何向它传递参数。或者你能更详细地告诉我你的方法吗。再次感谢!我不明白:你想调用一个已经存在的web服务吗?再次感谢你,David。我尝试了你的建议,但我只是更新了我的答案。你能再帮我一次吗?很好,我已经相应地复习了我的答案。所以,如果我使用这个地址,我如何将param1和param2作为参数传递给service welcome(String,String)。若我将服务更改为welcome(NameObject),我可以使用负载作为NameObject容器,这样服务就可以很好地运行。但我不想将所有服务更改为单参数服务。在这种情况下,请求对象是一个值数组,即[String,String]
。不确定“单参数服务”有什么问题?这不是文档/文字服务的全部理念吗?是否遵循WSDL优先的方法来创建这些服务?是的,这就是问题所在,David。如何传递一个值数组?在我的例子中,我需要纯粹从URL执行web服务(用于性能测试)并获得输出