skip to Main Content

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'']')

as you can see here:
enter image description here

but this reutn to me an error:
enter image description here

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

2

Answers


  1. I have reproduced in my environment and got expected results as below:

    Design:

    json(xml(triggerBody()))
    

    enter image description here

    Then used outputs('Compose')['SOAP-ENV:Envelope']['SOAP-ENV:Body']['tns:Order'] :

    enter image description here

    Output:

    enter image description here

    CodeView:

    {
        "definition": {
            "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
            "actions": {
                "Compose": {
                    "inputs": "@json(xml(triggerBody()))",
                    "runAfter": {},
                    "type": "Compose"
                },
                "Compose_2": {
                    "inputs": "@outputs('Compose')['SOAP-ENV:Envelope']['SOAP-ENV:Body']['tns:Order']",
                    "runAfter": {
                        "Compose": [
                            "Succeeded"
                        ]
                    },
                    "type": "Compose"
                }
            },
            "contentVersion": "1.0.0.0",
            "outputs": {},
            "parameters": {},
            "triggers": {
                "manual": {
                    "inputs": {
                        "schema": {}
                    },
                    "kind": "Http",
                    "type": "Request"
                }
            }
        },
        "parameters": {}
    }
    

    Edit:

    If you want output in xml:

    xml(outputs('Compose_2'))

    enter image description here

    Output:

    enter image description here

    Codeview:

    {
        "definition": {
            "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
            "actions": {
                "Compose": {
                    "inputs": "@json(xml(triggerBody()))",
                    "runAfter": {},
                    "type": "Compose"
                },
                "Compose_2": {
                    "inputs": "@outputs('Compose')['SOAP-ENV:Envelope']['SOAP-ENV:Body']",
                    "runAfter": {
                        "Compose": [
                            "Succeeded"
                        ]
                    },
                    "type": "Compose"
                },
                "Compose_3": {
                    "inputs": "@xml(outputs('Compose_2'))",
                    "runAfter": {
                        "Compose_2": [
                            "Succeeded"
                        ]
                    },
                    "type": "Compose"
                }
            },
            "contentVersion": "1.0.0.0",
            "outputs": {},
            "parameters": {},
            "triggers": {
                "manual": {
                    "inputs": {
                        "schema": {}
                    },
                    "kind": "Http",
                    "type": "Request"
                }
            }
        },
        "parameters": {}
    }
    
    Login or Signup to reply.
  2. 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

    Flow

    This is the expression in the second step …

    first(xpath(xml(variables('XML')), '//*[local-name()="Order"]'))

    Result

    Result

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search