Tuesday, October 15, 2013

Mule - piggybacking SOAP calls in flows

I needed to handle session Cookie between connection calls and later data calls all in SOAP. I did this by using the same global HTTP connector with cookie enabled and using it on all the endpoints.

The connection call was in the first flow which then called the next ... that solves the Session handling without any coding, but i got mimetype/transformer exception on the 'return' / response path.

Errors like:
Could not find a transformer to transform "SimpleDataType{type=org.apache.cxf.staxutils.DepthXMLStreamReader, mimeType='text/xml'}" to "SimpleDataType{type=java.io.InputStream, mimeType='*/*'}".

The easy solution turned out to be saving the first SOAP response, calling the data flows with their own SOAP, and after the flow call, restoring the SOAP response.

...
<set-variable variableName="connectionUpPayload" value="#[message.payload]" doc:name="save response"/>
<flow-ref name="GetAllProperties" doc:name="GetAllProperties"/>
<set-payload value="#[flowVars['connectionUpPayload']]" doc:name="Set Payload"/>

...