【问题标题】:Mule 3.2 flow and cxf:jaxws-serviceMule 3.2 流程和 cxf:jaxws-service
【发布时间】:2012-07-01 17:40:25
【问题描述】:

我对 mule 比较陌生,并试图定义一个 mule 流,该流通过基于肥皂的 Web 服务获取请求 XML。 XML 基于复杂的模式,我使用 WSDL2Java 生成了类

cxf:jaxws-service收到请求后执行submitOrder(SubmitOrderRequest参数)方法。执行此方法后,我想将请求 XML 转换为稍微不同的格式。然后需要将此 XML 转发到另一个 Web 服务。问题是来自 ServiceImpl 的 mule 消息包含 SubmitOrderResponse 而我仍然想处理 SubmitOrderRequest。

<flow name="testService">
    <http:inbound-endpoint address="http://localhost:62005/test"
        exchange-pattern="request-response">
        <cxf:jaxws-service serviceClass="com.test.ServicePortType" />
    </http:inbound-endpoint>
    <component class="com.test.ServiceImpl" />
    <!--  transformer ref="MVIRequestTransformer" / -->
    <!--  xm:object-to-xml-transformer / -->
    <!-- logger message="XML payload is #[payload]" level="INFO" / -->
    <!-- SEND TRASNFORMED MESSAGE TO ANOTHER SERVICE -->
</flow>


@WebService(endpointInterface = "com.pennmutual.services.mvi.MVIServicePort")
public class ServiceImpl implements ServicePortType {
    ...
    @Override
    public SubmitOrderResponse submitOrder(SubmitOrderRequest parameters) {
    ...
    }
...
}

我的选择是什么。我能想到以下几点—— 1. 将请求对象放在上下文中的某个位置,稍后将其检索以进行处理。 2.将submitOrder的返回类型改为Object,返回SubmitOrderRequest而不是SubmitOrderResponse。

请建议处理这种情况的最佳方法。我正在使用 mule 3.2。

【问题讨论】:

    标签: mule


    【解决方案1】:

    我认为有两种优雅的方法可以做到这一点(不包括涉及更改 web 服务接口的方法)

    将请求存储到会话变量中,然后将其恢复。 以下是您的流程的样子:

    <flow name="testService">
    <http:inbound-endpoint address="http://localhost:62005/test" exchange-pattern="request-response">
    <cxf:jaxws-service serviceClass="com.test.ServicePortType" />
    </http:inbound-endpoint>
    <message-properties-transformer scope="session">
    <add-message-property value="payload" key="originalPayload" />
    </message-properties-transformer>
    <component class="com.test.ServiceImpl" />
    </flow>
    

    在组件周围使用丰富器将返回的值存储到变量中,这样它就不会成为流的负载。下面举例说明如何实现这一点

    <flow name="Echo" doc:name="Echo">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="6090" path="echo" encoding="UTF-8" />
    <cxf:jaxws-service serviceClass="org.mule.example.echo.Echo" />
    <enricher target="#[variable:echo]">
    <component class="org.mule.example.echo.Echo" />
    </enricher>
    <logger level="ERROR" message="#[variable:echo]"/>
    </flow>
    

    您可以找到更多关于丰富器的信息here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-06
      相关资源
      最近更新 更多