I have a situation where the XML received has a combination of namespace elements and elements without namespace. The XPATH being tried does not work with Extract variables even though it works elsewhere: ie https://www.freeformatter.com/xpath-tester.html etc.
I am looking for content of <Payload> element ie valueofpayloadelement in below example.
Either of the XPATHs works in https://www.freeformatter.com/xpath-tester.html but does not work with extract variables in APIGEE.
/*[contains(local-name(),'Envelope')]/*[contains(local-name(),'Body')]/*[contains(local-name(),'COREEnvelopeRealTimeRequest')]/Payload/text()
OR
/s:Envelope/s:Body/COREEnvelopeRealTimeRequest/Payload/text()
XML as below:
-----------------------------------------------------------------------------------------------------------------------------
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"> <s:Header> <a:Action s:mustUnderstand="1">http://www.caqh.org/SOAP/WSDL/ICORETransactions/RealTimeTransaction</a:Action> <a:MessageID>urn:uuid:testid</a:MessageID> <a:ReplyTo> <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> </a:ReplyTo> <a:To s:mustUnderstand="1">https://abcd-dev.apigee.net/mocktest</a:To> </s:Header> <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <COREEnvelopeRealTimeRequest xmlns="http://www.caqh.org/SOAP/WSDL/CORERule4.0.0.xsd"> <PayloadType>X12_278_Request_005010X217E1_2</PayloadType> <ProcessingMode>RealTime</ProcessingMode> <PayloadID>randomid</PayloadID> <TimeStamp>5/1/2018</TimeStamp> <SenderID>HospitalA</SenderID> <ReceiverID>GATEWAY</ReceiverID> <CORERuleVersion>4.0.0</CORERuleVersion> <Payload>valueofpayloadelement</Payload> <SiteId>abcd</SiteId> <PassWord>defg</PassWord> </COREEnvelopeRealTimeRequest> </s:Body> </s:Envelope>
-----------------------------------------------------------------------------------------------------------------------------
Spent much time but no solution yet. Any help is appreciated. Thanks in advance
Solved! Go to Solution.
I am guessing this is because COREEnvelopeRealTimeRequest and Payload exist within the default namespace. So, the XPath parser may not be evaluating correctly. I don't know of a way to tell the XPath parser of the default Namespace.
Look at
<COREEnvelopeRealTimeRequest xmlns="http://www.caqh.org/SOAP/WSDL/CORERule4.0.0.xsd">
can you change it to
<COREEnvelopeRealTimeRequest xmlns:tns="http://www.caqh.org/SOAP/WSDL/CORERule4.0.0.xsd">
Then,
/s:Envelope/s:Body/tns:COREEnvelopeRealTimeRequest/tns:Payload/text()
3. Enhance all child nodes to be prefixed with tns
Since your XPath Expression uses Namespace Prefixes, did you try updating the namespace map (prefix and url) in the Extract Variable Policy and then evaluate the Xpath expression?
<Namespaces> <Namespace prefix="s">"http://www.w3.org/2003/05/soap-envelope</Namespace> <Namespace prefix="a">http://www.w3.org/2005/08/addressing</Namespace> </Namespaces>
Thanks for the reply:
<Namespaces>
<Namespace prefix="s">http://www.w3.org/2003/05/soap-envelope</Namespace>
<Namespace prefix="a">http://www.w3.org/2005/08/addressing</Namespace>
</Namespaces>
The above had been added. Note this works
/s:Envelope/s:Header/a:MessageID/text()
This does NOT:
/s:Envelope/s:Body/COREEnvelopeRealTimeRequest/Payload/text()
i am looking for content inside payload tag:
Any help is appreciated
<Namespaces>
http://www.w3.org/2003/05/soap-envelope>
http://www.w3.org/2005/08/addressing>
</Namespaces>
The above had been added.
Note this works
/s:Envelope/s:Header/a:MessageID/text()
This does NOT:
/s:Envelope/s:Body/COREEnvelopeRealTimeRequest/Payload/text()
I am looking for content inside payload tag:
Any help is appreciated
I am guessing this is because COREEnvelopeRealTimeRequest and Payload exist within the default namespace. So, the XPath parser may not be evaluating correctly. I don't know of a way to tell the XPath parser of the default Namespace.
Look at
<COREEnvelopeRealTimeRequest xmlns="http://www.caqh.org/SOAP/WSDL/CORERule4.0.0.xsd">
can you change it to
<COREEnvelopeRealTimeRequest xmlns:tns="http://www.caqh.org/SOAP/WSDL/CORERule4.0.0.xsd">
Then,
/s:Envelope/s:Body/tns:COREEnvelopeRealTimeRequest/tns:Payload/text()
3. Enhance all child nodes to be prefixed with tns
Actually I was able get it working by the time you replied: using the same way mentioned.Not sure why I need to add the NS when it works everywhere without it.
/s:Envelope/s:Body/a:COREEnvelopeRealTimeRequest/a:Payload/text()
Thanks a lot for the reply. Apprciate it.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |