在mule中使用具有多个输入参数的Web服务

时间:2014-04-01 12:32:40

标签: web-services mule mule-studio

我是初学者,我有一个骡子流,我想调用SOAP web服务操作,它有4个输入参数 “public double calculateInterest(double principal,double year,double rate,int appid)”。

我尝试使用文件或http端点,其中我在使用set payload时最终使用String数组或对象数组。 抛出的异常是

无法强制转换为java.lang.Double。无法通过端点路由事件:org.mule.module.cxf.CxfOutboundMessageProcessor。消息有效内容的类型为:String []

有人可以建议最好的方法。

2 个答案:

答案 0 :(得分:0)

这里是一个简单的web服务的例子: -

<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="CE-3.3.0" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
    <flow name="getCalculationFlow1" doc:name="getCalculationFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="getCalculation" doc:name="HTTP"/>
        <cxf:jaxws-service serviceClass="com.services.getcalculation.v1.GetCalculation" doc:name="SOAP"/>
        <component class="com.services.schema.getcalculation.v1.GetCalculationImpl" doc:name="Java"/>
    </flow>
</mule>

其中 com.services.getcalculation.v1.GetCalculation 是使用 WSDL 文件中的 Apache CXF 生成的Web服务类,并且 com.services.schema.getcalculation.v1.GetCalculationImpl 是webservice的实现类...希望这个帮助

答案 1 :(得分:0)

您可以配置文件或http入站,编写java组件(删除cxf组件),从有效负载中提取参数,以所需类型强制转换,并从组件中调用Web服务方法。