4

I'm pretty new to Mule so this may be a silly question. I'd like to call a remote axis2 SOAP service from Mule and for this I will use the SOAP component. What I am struggling with is the correct pattern for PAYLOAD population. Here is a very simple payload example

  <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>

The payload is currently being populated via the set-payload transformer and the XML is embedded in the flow as seen below

<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>

My question is what the most appropriate way of setting this payload. My thoughts would be

  1. if the PAYLOAD were larger would it be better to maintain this XML in a file in the Mule project and read it as outlined in this question
  2. I'd prefer not to generate client stub classes for the Request but perhaps I should use CXF to define the service class. What advantages would this provide?

Are there other preferred methods of payload population. In my use case this (sub)flow would be called from a router so I'd not be passing any relevant information that would alter the message.

Aside: Perhaps for the worktype name "Reminder Task" I should extract to mule-app.properties and use XSLT to populate in final request?

Thanks

Rich

Community
  • 1
  • 1

1 Answers1

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.

Jorge Córdoba
  • 51,063
  • 11
  • 80
  • 130
user1760178
  • 6,277
  • 5
  • 27
  • 57