I have a flow in MULE which receives SOAP messages. I am trying to extract the name of a node in this soap message.
My soap message looks like this:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http://abc/dto/2013/08"
xmlns:ns1="http://abc/message/dto/2013/08"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<ns:RetrieveOrgNumber>
<ns:request>
<ns1:sessionId>SessionId</ns1:sessionId>
<ns1:timeStamp>2001-12-31T12:00:00</ns1:timeStamp>
<ns1:userIdentifier>UserIdentifier</ns1:userIdentifier>
<ns1:language>EN</ns1:language>
<ns1:source>SoapUI</ns1:source>
<!-- 1 or more repetitions: -->
<ns:orgNumber>AE7WJ046</ns:orgNumber>
</ns:request>
</ns:RetrieveOrgNumber>
</soapenv:Body>
</soapenv:Envelope>
I want to be able to retrieve the name of the node RetrieveOrgNumber in an operation. I want to set it as a variable.
I have tried #[xpath(fn:local-name('soapenv:Envelope/soapenv:Body/*[1]'))]
but i get this error:
Execution of the expression xpath(fn:local-name('soapenv:Envelope/soapenv:Body/*[1]')) failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: String
I forgot to add that I did add the namespaces in the message flow xml:
<mulexml:namespace-manager>
<mulexml:namespace prefix="soapenv" uri="http://schemas.xmlsoap.org/soap/envelope/" />
<mulexml:namespace prefix="ns" uri="http://sanlam.co.za/group/party/service/clientmanagement/dto/2013/08" />
<mulexml:namespace prefix="ns1" uri="http://sanlam.co.za/group/common/message/dto/2013/08" />
<mulexml:namespace prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance" />
</mulexml:namespace-manager>
Thank you for the reply Mark.
I tried editing but it is not working. I cannot post a picture of my flow diagram here. I need a reputation of at least 10.
However considering your suggestion I tried Object to XML (StringTobyteArray
did not work) Now for my xpath expression I have:
#[xpath(local-name('soapenv:Envelope/soapenv:Body/*[1]'))]
The error I get is:
Caused by: [Error: unresolvable property or identifier: local]
[Near : {... xpath(local-name('soapenv:Envelope/s ....}]
^
[Line: 1, Column: 7]
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:687)
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanPropertyAO(ReflectiveAccessorOptimizer.java:472)
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:374)
When I tried fn:local-name
I had a namespace error with fn
.