在Mule出站端点上使用扩充器,以便不丢失消息属性上下文

时间:2014-02-27 20:26:44

标签: mule

当我使用Mule中的soap组件调用soap web服务时。消息属性上下文丢失。我理解可以使用Mule richher组件但不确定使用方法。您将在下面找到我的测试骡代码

<spring:beans>
 <spring:bean id="myWebServiceImpl" class="com.xxx.xxx.service.MyWebServiceImpl">
 </spring:bean>

</spring:beans>
<custom-transformer class="com.xxx.xxx.service.TestTransformer" name="Java" doc:name="Java"/>
<flow name="testwebserviceFlow1" doc:name="testwebserviceFlow1">
    <file:inbound-endpoint path="c:\landing" responseTimeout="10000" doc:name="File"/>
    <object-to-string-transformer doc:name="Object to String"/>

    <http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:28081/MyWebService" responseTimeout="100000" doc:name="HTTP" >
        <cxf:jaxws-client operation="helloWorld" serviceClass="com.xxx.xxx.service.MyWebService" enableMuleSoapHeaders="true" doc:name="SOAP"/>
    </http:outbound-endpoint>
    <transformer ref="Java" doc:name="Transformer Reference"/>
    <logger level="INFO" doc:name="Logger"/>
</flow>

<flow name="MyWebServiceFlow" doc:name="MyWebServiceFlow">
    <http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:28081/MyWebService?wsdl" doc:name="HTTP" responseTimeout="100000">
        <cxf:jaxws-service serviceClass="com.xxx.xxx.service.MyWebService" doc:name="SOAP"/>
    </http:inbound-endpoint>
    <component doc:name="MyWebService">
        <spring-object bean="myWebServiceImpl"/>
    </component>
</flow>

1 个答案:

答案 0 :(得分:1)

是的,您可以使用richher来保留原始邮件,并将Web服务的返回值放入变量中。它的工作原理如下:

<enricher source="#[payload]" target="#[variable:myVal]">
    <http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:28081/MyWebService" responseTimeout="100000" doc:name="HTTP" >
        <cxf:jaxws-client operation="helloWorld" serviceClass="com.xxx.xxx.service.MyWebService" enableMuleSoapHeaders="true" doc:name="SOAP"/>
    </http:outbound-endpoint>
</enricher>

然后您可以稍后访问变量:

<logger message="#[variable:myVal]" level="INFO"/>

如果您只想调用Web服务并忽略任何返回值,您也可以通过将http outbound放在<async></async>标记而不是richher中来异步执行此操作。