I have a Logic app (LA) that have an http trigger. To the LA, I send a SOAP request similar to this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"></SOAP-ENV:Header>
<SOAP-ENV:Body>
<tns:Order xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="http://test.com">
<name>AAAA</name>
<id>1234</id>
<OrderType>new</OrderType>
</tns:Order>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I want to create another action in the LA that extract the Envelope body to me. i.e. I want to only get this:
<tns:Order xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="http://test.com">
<name>AAAA</name>
<id>1234</id>
<OrderType>new</OrderType>
</tns:Order>
I tried to have a compose action with the following function:
xpath(triggerBody(), '/*[local-name()=''Envelope'']/*[local-name()=''Body'']/*[local-name=''Order'']')
but this reutn to me an error:
Any idea for how to solve this problem? I have tried to remove all the namespaces and it seems that it works but not when having namespaecs
Your issue with the null
is a bit perplexing and hard for me to decipher and fix because receiving that error tells me you're not quite reading the incoming request properly (or something) but, if I load your XML into a variable and then extract the contents of tns:Order
, I can get it to work and this approach doesn't require you to traverse down the hierarchy using a fully qualified approach.
Flow
This is the expression in the second step ...
first(xpath(xml(variables('XML')), '//*[local-name()="Order"]'))
Result