cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
talldutchguy
New Member

help with Xpath and Soap message

Hi,

 

I am trying to parse several details from a SOAP message.

I have looked at many post and i think i need to use xpath.

However, each time i get an error, so i must be formatting my xpath statements incorrect:

 

InvalidTemplate. Unable to process template language expressions in action 'Compose_2' inputs at line '1' and column '2032': 'The template language function 'xpath' parameters are invalid: the 'xpath' parameter must be a supported, well formed XPath expression. Please see https://aka.ms/logicexpressions#xpath for usage details.
 
 
this is the flow:
it is an HTML POST request that revives a SOAP message back.
flow1.PNG
 
 
the result of the HTTP is the following: 
 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ipgapi:IPGApiActionResponse xmlns:ipgapi="http://ipg-online.com/ipgapi/schemas/ipgapi" xmlns:a1="http://ipg-online.com/ipgapi/schemas/a1" xmlns:v1="http://ipg-online.com/ipgapi/schemas/v1">
<ipgapi:successfully>true</ipgapi:successfully>
<ipgapi:OrderId>A-60e00f5b-SomeID</ipgapi:OrderId>
<ipgapi:TransactionId>84521877SomeTransact</ipgapi:TransactionId>
<ipgapi:Url>https://test.p-online.com/connect/processing?store=SomeStore</ipgapi:Url>
</ipgapi:IPGApiActionResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
for example i am trying to parse the TransactionID and / or the URL.
I have tried several versions, but i keep getting invalid XPATH
 
xpath(xml(body('Http')), 'string(/SOAP-ENV:Envelope/SOAP-ENV:Body/ipgapi:IPGApiActionResponse/ipgapi:TransactionId)')
xpath(xml(body('Http')), 'string(/*[name()=\"SOAP-ENV:Envelope\"]/*[name()=\"SOAP-ENV:Body\"]\"]/*[name()=\"ipgapi:IPGApiActionResponse\"]\"]/*[name()=\"ipgapi:TransactionId\"])')
testing this in a xpath tester i do get the correct results
 
any insights would be appreciated - thank you in advance 
 
 
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
yashag2255
Dual Super User II
Dual Super User II

Hi @talldutchguy 

 

 

The issue might be because of the Namespaces in your XML. Can you try out below expression in the Compose action:
 
xpath(xml(body('Http')), '//*[local-name()="Envelope"]/*[local-name()="Body"]/*[local-name()="IPGApiActionResponse"]/*[local-name()="TransactionId"]/text()')
 
Hope this Helps!
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

4 REPLIES 4
yashag2255
Dual Super User II
Dual Super User II

Hi @talldutchguy 

 

 

The issue might be because of the Namespaces in your XML. Can you try out below expression in the Compose action:
 
xpath(xml(body('Http')), '//*[local-name()="Envelope"]/*[local-name()="Body"]/*[local-name()="IPGApiActionResponse"]/*[local-name()="TransactionId"]/text()')
 
Hope this Helps!
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Thank you so much! it works, this in the final result

 

 

xpath(xml(body('Http')), '//*[local-name()="Envelope"]/*[local-name()="Body"]/*[local-name()="IPGApiActionResponse"]/*[local-name()="TransactionId"]/text()')

@yashag2255 - I am trying to accomplish something similar, and I've used your suggestion, but I must be missing something, I can't seem to make it work, the output of the compose step is blank.   Here is a sample of the XML that gets returned from in the API response that is going into the Compose step....I need to be able to use the data under <RESOURCES><AIRCRAFT>.

I've tried this so far...but the compose output is just BLANK.

 

 

xpath(xml(body('Operations_-_Aircraft_Info')), '//*[local-name()="Envelope"]/*[local-name()="Body"]/*[local-name()="etaWebServicesResponse"]/*[local-name()="RESOURCES"]/text()')

 

 

Sample API XML response data.  

 

 

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <SOAP-ENV:Body>
        <ns1:etaWebServicesResponse xmlns:ns1="http://ws.talonsystems.com/Talonws.wsdl" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
            <return xsi:type="xsd:string">
                <RESOURCES>
                    <AIRCRAFT>
                        <AIRCRAFT_ID>XX</AIRCRAFT_ID>
                        <AIRCRAFT>XXXXXX</AIRCRAFT>
                        <SITE_ID/>
                        <SITE/>
                        <DESCRIPTION>XXXXXX</DESCRIPTION>
                        <RESOURCE_TYPE>XXXXX</RESOURCE_TYPE>
                        <COLOR>XXXXXX</COLOR>
                        <AIRCRAFT_CLASS>XXXXX</AIRCRAFT_CLASS>
                        .....
                        .....
                   </AIRCRAFT>
                </RESOURCES>
            </return>
        </ns1:etaWebServicesResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

 

 

Automata
Regular Visitor

Hi folks, 

I have been struggling with a similar situation.

I have following SOAP response body to parse using xpath in my flow. This response is received by in flow after calling the custom connector to read data from a legacy NAV. I need the value in the XML tag.

<Soap:Envelope xmlns:Soap="http://schemas.xmlsoap.org/soap/envelope/"><Soap:Body><GetRecIdFromKey_Result xmlns="urn:microsoft-dynamics-schemas/page/crm_contact_stg_ws"><GetRecIdFromKey_Result>CRM Contact Stg: 4801</GetRecIdFromKey_Result></GetRecIdFromKey_Result></Soap:Body></Soap:Envelope>

 

I have tried a number of xpath expressions to get the value from this tag, but I have hit the wall. I really wonder if somebody shares similar experience as I just do. I used online xpath tool as here https://www.freeformatter.com/xpath-tester.html, but many expressions that work here, do not give any results when used as xpath expression in flow. Have you observed the same ? as a standard, any xpath expression (irrespective of which tool it is used in), should give same result ? Or correct me if i am wrongly assuming this.

 

Anyway, can somebody get me the value of the innermost tag <GetRecIdFromKey_Result>  ?

 

Thanks

Automation continued ...

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (3,127)