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