web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / help with Xpath and So...
Power Automate
Answered

help with Xpath and Soap message

(0) ShareShare
ReportReport
Posted on by 6

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 
 
 
 
 
Categories:
  • Verified answer
    yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    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!
  • talldutchguy Profile Picture
    6 on at

    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()')
  • wstock Profile Picture
    57 on at

    @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>

     

     

     

  • rise to distinction Profile Picture
    12 on at

    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 ...

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 377

#2
11manish Profile Picture

11manish 302 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 130

Last 30 days Overall leaderboard