简体   繁体   中英

Map file in the Integration for the LogicApp in Azure

Have the following XML as a result of the HTTP GET function from the B2B supplier.

<Invoices xmlns="http://gateway.com/schemas/Invoices" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://gateway..com/schemas/Invoices Invoices.xsd">
   <DocumentInfo>
      <DocType>INVOICES</DocType>
      <DocVersion>2.0</DocVersion>
   </DocumentInfo>
   <Header>
      <StartDate>2018-12-01T00:00:00+01:00</StartDate>
      <EndDate>2019-01-03T00:00:00+01:00</EndDate>
   </Header>
   <Documents>
      <Invoice InvoiceId="RP82807" InvoiceDate="2019-01-02T00:00:00+01:00" DocumentType="IN" RefDocId="FT34532" RefDocType="ORDER" SystemId="10" HasPDFImage="0" />
      <Invoice InvoiceId="T609881" InvoiceDate="2018-12-31T00:00:00+01:00" DocumentType="IN" RefDocId="FT39339" RefDocType="ORDER" SystemId="0" HasPDFImage="0" />
   </Documents>
</Invoices>

Based on this article I've created the liquid map file to get the list of InvoiceIds:

{
"Invoice": "{{content.Documents.Invoice}}"
}

When using it in the LogicApp in the XML->Json converter, got the following result:

{
    "Invoice": ""
} 

I have also tried this as a liquid file:

{
"Invoice": "{{content.Invoices.Documents}}"
} 

and this:

{
"Invoice": "{{content.Invoices.Documents.Invoice}}"
}

with the same result. Can you give me a tip what I do wrong?

I tried to transfer part of your xml file to json with this map:

{
"DocType":"{{content.DocumentInfo.DocType}}",
"Invoice":"{{content.Documents.Invoice}}"
}

And get the output:

{
"DocType": "INVOICES",
"Invoice": ""
}

So this means I can get the DocType but can't get Invoice properties, so I think maybe the Liquid map doesn't support the XML format. Maybe you could change it to like this:

<Invoice>
<InvoiceId>T609881</InvoiceId>
  <InvoiceDate>2018-12-31T00:00:00+01:00</InvoiceDate>
  <DocumentType>IN</DocumentType>
  <RefDocId>FT39339</RefDocId>
</Invoice>

This will work, or you could go to Liquid reference to check is there any methods to match the properties.

在此处输入图片说明

Note:what you want for now,binding to Xml Attributes is not currently supported.You could refer to this answer .

If you still have other questions, please let me know.

UPDATE:You still could do it with logic app. For example I used a FTP connector to get xml file content then create a json with "json(xml(body('Get_file_content')))" expression. 在此处输入图片说明

And this is the result. 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM