I have a question regarding Mule ESB and how to manipulate the response to an incoming SOAP request.
The use-case scenario is this:
incoming SOAP request --> take request and send to async flow for processing --> return the message ID for the Mule transaction back to the caller in the SOAP response --> (async processing of the original request continues)
In this scenario the resut of the SOAP request processing is not relevant to the caller.
<flow name="asyncTestFlow1" doc:name="asyncTestFlow1">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8088" doc:name="HTTP" />
<logger message="F1: messageID:#[message:id]" level="INFO" />
<async doc:name="Async">
<flow-ref name="asyncTestFlow2" doc:name="Flow Reference" />
</async>
<!-- ### need to modify the request, add the message ID and send back to the client ### -->
</flow>
<flow name="asyncTestFlow2">
<cxf:proxy-service payload="body" soapVersion="1.2" doc:name="SOAP" />
<logger message="after cxf:proxy-service -> #[groovy:payload.getClass()]" level="INFO" />
<cxf:proxy-client payload="body" enableMuleSoapHeaders="true" soapVersion="1.2" doc:name="SOAP" />
<http:outbound-endpoint exchange-pattern="request-response"
address="http://example.net/KnowYourClient/KYCService"
doc:name="HTTP" />
<logger message="SOAP response: #[payload:java.lang.String]" level="INFO" />
</flow>
Around line 9, I added a comment where I would like to modify the payload of the request / response. I am thinking that I need a custom message transformer but I do not know where to start. I can get the input as either ContentLengthInputStream (default incoming) or as DepthXMLStreamReader (after calling cxf:proxy-service). I think in the XML format it would be easier to manipulate..
Can someone please point me in the right direction on how to get started in manipulating that XML content?
thank you, Markus
--update--working example now
I think I got it working now.. the key was the initial object to bye array transformer which allows to consume the incoming message in the private flow.
<flow name="asyncTestFlow1" doc:name="asyncTestFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" doc:name="HTTP" />
<object-to-byte-array-transformer />
<logger message="F1: messageID:#[message:id]" level="INFO" doc:name="Logger" />
<async doc:name="Async">
<flow-ref name="asyncTestFlow2" doc:name="Flow Reference" />
</async>
<custom-transformer class="org.mule.examples.hello.SoapResponseTransformer" doc:name="Java" />
</flow>
<flow name="asyncTestFlow2" doc:name="asyncTestFlow2">
<cxf:proxy-service payload="body" soapVersion="1.2" doc:name="SOAP"/>
<cxf:proxy-client payload="body" enableMuleSoapHeaders="true" soapVersion="1.2" doc:name="SOAP"/>
<http:outbound-endpoint exchange-pattern="request-response"
address="http://.../Service"
doc:name="HTTP" />
<logger message="SOAP response: #[payload:java.lang.String]" level="INFO" doc:name="Logger" />
</flow>