我在 Mule 3 中使用 cxf:jaxws-client,我从 Web 服务调用中得到的响应是 ReleasingInputStream 类型。我尝试添加 http-response-to-message-transformer,但这会产生错误 - 有谁知道我如何将响应作为对象而不是 ReleasingInputStream 检索?
非常感谢。
To solve the issue put the <cxf-client>
inside the <outbound-endpoint>
section (NOT BEFORE IT), by modifying the following code
<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" />
which produces a ReleasingInputStream
output to
<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>
that returns the expected object.
我只是遇到了同样的问题。我通过将 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>
jaxws-client 的全部意义在于接收未编组的 Java 对象,因此将 WS 响应作为 String 或 ReleasingInputStream 甚至不应该是一种选择。
要使 <cxf:jaxws-client> 像预期的 WS 客户端那样“工作” - 将 <outbound-endpoint> 的 INSIDE 放入您将获得一个正确的 Java 对象作为有效负载。