骡子CXF马歇尔回应

时间:2011-06-14 15:15:13

标签: cxf mule

我在Mule 3中使用cxf:jaxws-client,我从Web服务调用获得的响应是​​ReleasingInputStream类型。我尝试添加http-response-to-message-transformer,但是会产生错误 - 是否有人知道如何将响应作为对象检索而不是ReleasingInputStream?

非常感谢。

3 个答案:

答案 0 :(得分:3)

要解决此问题,请将<cxf-client>放入<outbound-endpoint>部分(不是IT之前),修改以下代码

    <cxf:jaxws-client
        clientClass="com.xyz.services.WSServices"
            port="WSServicesSoap"
            wsdlLocation="classpath:wsdl-file.wsdl"
            operation="GimmeDataOperation" />
    <outbound-endpoint exchange-pattern="request-response" address="http://localhost:8083/OutboundService" />

产生ReleasingInputStream输出到

    <outbound-endpoint exchange-pattern="request-response" address="http://localhost:8083/OutboundService" >
        <cxf:jaxws-client
            clientClass="com.xyz.services.WSServices"
            port="WSServicesSoap"
            wsdlLocation="classpath:wsdl-file.wsdl"
            operation="GimmeDataOperation" />
    </outbound-endpoint>

返回预期的对象。

答案 1 :(得分:1)

我刚遇到同样的问题。我通过将ObjectToString转换器添加到出站端点的响应端来解决它,如下所示:

<mule>
   <object-to-string-transformer name="ObjectToString"/>

   <flow>
      ...
      ...
      ...
      <cxf:jaxws-client clientClass="com.my.ClientClass"
                        port="MyPort" 
                        wsdlLocation="classpath:MyWsdl.wsdl"
                        operation="MyOperation" />
      <outbound-endpoint address="http://some.address/path/to/service"
                         exchange-pattern="request-response" 
                         responseTransformer-refs="ObjectToString" />
      ...
      ...
      ...
   </flow>
</mule>

答案 2 :(得分:1)

jaxws-client的重点是接收unmarshaled Java对象,因此将WS响应作为String或ReleasingInputStream来获取甚至不应该是一个选项。

制作&lt; cxf:jaxws-client&gt;人们期望WS客户端工作的“工作” - 将&lt; outbound-endpoint&gt;的INSIDE放入您将获得一个正确的Java对象作为有效负载。