user3190499
user3190499

Reputation: 61

Mule ESB: How to use xpath expression on session variable?

I have a requirement to extract some information form session variables. The session variables Type is String and contains XML. i tried XPATH expression like -

xpath('//tns:CreateUpdateRQ/tns:RequestInfo/sns:requestSourceID',sessionVars.originalMessage)

however I get exception stating "Could not find transformer NULL Payload to Document". I tried MEL like - #[sessionVars.originalMessage.CreateUpdateRQ.RequestInfo.requestID]. But it's not working either.

How can I extract information from session variable of Type string holding XML.

P.S. I can set the payload to sesion variable & use xpath but it's not suitable for my case because I need to extract the information from session variable 7 pass it as argument to datamapper.

Appreciate you help on this.

Upvotes: 0

Views: 460

Answers (1)

Julio Cejas
Julio Cejas

Reputation: 573

To facilitate reading the xml file, I recommend transforming String (Object) to xml, for example:

<xml:object-to-xml-transformer /> 

then

<logger level="WARN" message="#[xpath://soapenv:Envelope/soapenv:Body//...]" />

In short, make sure the payload is XML type, you can by setting it

<set-property propertyName="Content-Type" value="text/xml" />

Upvotes: 0

Related Questions