4

我对 Mule 很陌生,所以这可能是一个愚蠢的问题。我想从 Mule 调用远程axis2 SOAP 服务,为此我将使用SOAP 组件。我正在努力解决的是 PAYLOAD 人口的正确模式。这是一个非常简单的有效载荷示例

  <oper:CreateTask xmlns:oper="http://api.abc.com/workflow/operationtypes">
     <workType>
        <Name>Reminder Task</Name>
     </workType>
     <activitySubject>
        <GenericSubject>Richard Fanning</GenericSubject>
     </activitySubject>
     <description>This is a Mule generated Reminder Task</description>
  </oper:CreateTask>

当前正在通过 set-payload 转换器填充有效负载,并且 XML 嵌入在流中,如下所示

<flow name="createWorkflowTask" doc:name="createWorkflowTask">
    <set-payload value="&lt;oper:CreateTask xmlns:oper=&quot;http://api.abc.com/workflow/operationtypes&quot;&gt;&lt;workType&gt;&lt;Name&gt;Reminder Task&lt;/Name&gt;&lt;/workType&gt;&lt;activitySubject&gt;&lt;GenericSubject&gt;Richard Fanning&lt;/GenericSubject&gt;&lt;/activitySubject&gt;&lt;description&gt;This is a Mule generated Reminder Task&lt;/description&gt;&lt;/oper:CreateTask&gt;" doc:name="Set Payload"/>
    <cxf:proxy-client doc:name="SOAP" enableMuleSoapHeaders="true" payload="body"/>
    <http:outbound-endpoint exchange-pattern="one-way" method="POST" address="http://localhost:6081/workflow/services/ActivityServices" doc:name="HTTP"/>
</flow>

我的问题是设置此有效负载的最合适方法是什么。我的想法是

  1. 如果 PAYLOAD 更大,最好将此 XML 保存在 Mule 项目的文件中并按照问题中的概述进行阅读
  2. 我不想为请求生成客户端存根类,但也许我应该使用 CXF 来定义服务类。这将提供什么优势?

是否有其他首选的有效载荷填充方法。在我的用例中,这个(子)流将从路由器调用,因此我不会传递任何会改变消息的相关信息。

旁白:也许对于工作类型名称“提醒任务”,我应该提取到 mule-app.properties 并使用 XSLT 填充最终请求?

谢谢

富有的

4

1 回答 1

2

In order to set payload in a flow, you can use either of the following ways.

  1. Write a component(Java bean) which has the XML request as String and then make that string as return from the component. This component should be the first message processor in your flow.

  2. Write a component(Java bean) which read the XML request from a file into a String and then make that String as return from the component. This component should be the first message processor in your flow.

  3. Use a Inbound-Endpoint ( file or JMS) as the entry point of your flow. These inbound can read from the path specified. This way your input can be dynamic. And you can execute the flow multiple times fo different requests without the need to start the Mule server everytime.

More on Mule File and JMS endpoints in the following links.

Mule JMS Transport Reference

Mule File Endpoint

Next for your XSLT population of the worktype name, Mule XSLT Transformer from the XML module can be used. More on this in the following link Mule XSLT Transformer

Hope this helps.

于 2013-08-20T17:26:39.673 回答