Mule 3.4+: Best practice for setting payload for static SOAP request

I'm new to Mule, so that might be a dumb question. I would like to name the axis2 remote SOA service from Mule, and for this I will use the SOAP component. What I'm struggling with is the right model for the 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 populated using the set-payload transformer, and XML is embedded in the stream, as shown 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 the most appropriate way to configure this payload. My thoughts would be

  • if there was more PAYLOAD, it would be better to save this XML in a file in the Mule project and read it as described in this question
  • I would prefer not to create client cache classes for the request, but maybe I should use CXF to determine the class of service. What are the benefits of this?

Are there other preferred payload population methods. In my use case, this (optional) thread will be called from the router, so I will not transmit any relevant information that could change the message.

Beyond this: Perhaps for the job type name "Reminder Task" I should extract in mule-app.properties and use XSLT to populate in the final query?

thanks

Rich

+4
source share
1 answer

To set the payload in a stream, you can use any of the following methods.

  • Write a component (Java bean) that has an XML query as a String, and then returns that string as a return from the component. This component should be the first message handler in your thread.

  • Write a component (Java bean) that reads an XML request from a file into a String and then returns this string as a component from the component. This component should be the first message handler in your thread.

  • Use an inbound-endpoint (file or JMS) as the entry point of your stream. This input can be read from the specified path. Thus, your input can be dynamic. And you can execute the thread several times for different requests without having to start the Mule server every time.

Read more about Mule File and JMS in the following links.

Mule JMS Transport Reference

Mule file endpoint

You can then use the Mule XSLT Transformer from the XML module for your XSLT population of the job type name. More on this in the next Mule XSLT Transformer link.

Hope this helps.

+2
source

Source: https://habr.com/ru/post/1497961/


All Articles