How to use XPATH functions in Mule



I have an input SOAP XML as follows :-



<soapenv:Envelope xmlns:soapenv="http://ift.tt/sVJIaE" xmlns:v1="http://ift.tt/1kFt6Sx">
<soapenv:Header>
</soapenv:Header>
<soapenv:Body>
<v1:retrieveDataRequest>
<v1:Id>662</v1:Id>
</v1:retrieveDataRequest>
</soapenv:Body>
</soapenv:Envelope>


Now my question is simple ...


How can I use XPATH functions like count(),name(),substring() etc in Mule


I want to use XPATH on this SOAP request like the following :-



<logger message="#[xpath('count(//v1:retrieveDataRequest/v1:Id)')]" level="INFO" doc:name="Logger"/>


But It is throwing following exception :-



java.lang.RuntimeException: org.mule.api.MuleRuntimeException: Failed to evaluate XPath expression: "count(//v1:retrieveDataRequest/v1:Id)"
at org.mule.module.xml.el.XPathFunction.call(XPathFunction.java:70)


Please note :- I have already used Mule namespace-manager as following :-



<mulexml:namespace-manager includeConfigNamespaces="true">
<mulexml:namespace prefix="soapenv" uri="http://ift.tt/sVJIaE"/>
<mulexml:namespace prefix="v1" uri="http://ift.tt/1kFt6Sx"/>
</mulexml:namespace-manager>


and I am getting results for the following :- <logger message="#[xpath('//v1:retrieveDataRequest/v1:Id').text]" level="INFO" doc:name="Logger"/>


Please help


No comments:

Post a Comment