如何将文件作为SOAP请求传递给Mule SOAP客户端以使用服务

时间:2014-06-28 10:21:16

标签: web-services soap cxf mule mule-studio

我有一个公开网络服务的流程: -

<flow name="ServiceFlow" doc:name="ServiceFlow">

<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP"/>

<cxf:jaxws-service  serviceClass="com.test.services.schema.maindata.v1.MainData"  doc:name="SOAP"/>

<component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl" doc:name="JavaMain_ServiceImpl"/>

</flow>

此Web服务有一个操作 insertDataOperation ,它接受来自SOAP请求的所有输入并将其插入数据库中... 我的SOAP请求如下: -

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://services.test.com/schema/MainData/V1">
   <soapenv:Header/>
   <soapenv:Body>
      <v1:insertDataRequest>
         <v1:Id>311</v1:Id>
         <v1:Name>ttttt</v1:Name>
         <v1:Age>56</v1:Age>
         <v1:Designation>eeeee</v1:Designation>
      </v1:insertDataRequest>
   </soapenv:Body>
</soapenv:Envelope>

现在我有另一个使用此Web服务的Web服务客户端流程,流程为: -

<flow name="ClientFlow" doc:name="ClientFlow">
 <file:inbound-endpoint responseTimeout="10000" connector-ref="File_Global" doc:name="File"  path="E:\backup\test">
            <file:filename-regex-filter pattern="SoapRequestInsert.xml" caseSensitive="false"/>
    </file:inbound-endpoint>
    <file:file-to-string-transformer encoding="UTF-8" mimeType="text/xml" doc:name="File to String"/>
<cxf:jaxws-client doc:name="SOAP" serviceClass="com.test.services.schema.maindata.v1.MainData" operation="insertDataOperation" port="MainDataPort" />
        <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP"/>
</flow>

现在我在这里尝试使用文件入站端点并在文件 SoapRequestInsert.xml 中传递SOAP请求来使用Web服务..但问题是我没有得到任何错误,但数据没有插入数据库..我检查了日志..我发现它进入webservice实现类的插入方法,但它没有得到输入值...请帮助...我参考了以下内容: - Consuming a JAX-WS in a Mule ESB flow

但它无法正常工作..我该怎么做才能让它成功消费并插入数据库?请帮忙

2 个答案:

答案 0 :(得分:3)

因为您发布的文件包含整个SOAP信封,您可以按原样HTTP POST:

<flow name="ClientFlow" doc:name="ClientFlow"> <file:inbound-endpoint responseTimeout="10000" connector-ref="File_Global" doc:name="File" path="E:\backup\test"> <file:filename-regex-filter pattern="SoapRequestInsert.xml" caseSensitive="false"/> </file:inbound-endpoint> <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP"/> </flow>

请注意,您可能需要在http:outbound-endpoint

之前添加SOAP操作标头
<set-property name="SOAPAction"
     value="http://services.test.com/schema/MainData/V1/insertDataOperation" />

答案 1 :(得分:1)

最终的工作解决方案是David建议流程并在出站端点之前设置SOAPAction: -

<set-property name="SOAPAction"
     value="http://services.test.com/schema/MainData/V1/insertDataOperation" />