简体   繁体   English

Azure 逻辑应用程序问题 SOAP XML 的液体转换

[英]Azure Logic Apps Problem with Liquid Transformation of SOAP XML

I'm using Azure Logic Apps to integrate with a legacy SOAP API.我正在使用 Azure 逻辑应用程序与旧版 SOAP API 集成。 I would like to translate the XML (particularly the responses) in to something easier to use such as json.我想将 XML(尤其是响应)翻译成更易于使用的东西,例如 json。

Normally I use a Custom Connector within Logic Apps to connect to new APIs.通常我在逻辑应用程序中使用自定义连接器来连接到新的 API。 I've tried to create a Custom Connector for this SOAP, but the WSDL contains recursive references which apparently aren't allowed.我尝试为此 SOAP 创建一个自定义连接器,但 WSDL 包含显然不允许的递归引用。 I was able to create managed API with our APIM container, but still could not produce anything that would allow me to create the custom connector.我能够使用我们的 APIM 容器创建托管 API,但仍然无法生成任何允许我创建自定义连接器的东西。 So, I moved on to dealing with the transactions individually.所以,我继续单独处理交易。 A Liquid transformation map from XML to json seems ideal, but so far I haven't got it to work, namely because I can't figure out the naming convention to access certain XML elements (those that happen to have the same id as their parent). A Liquid transformation map from XML to json seems ideal, but so far I haven't got it to work, namely because I can't figure out the naming convention to access certain XML elements (those that happen to have the same id as their父母)。 For now I am using the json(xml()) function as a work around, but it seems less ideal than a Liquid map.现在我正在使用 json(xml()) function 作为解决方法,但它似乎不如 Liquid map 理想。

As you can see the AgreementId is easily accessible via the normal naming conventions, but I can't seem to access any of the child elements of the 2nd RequestReportResponse node.如您所见,可以通过正常的命名约定轻松访问 AgreementId,但我似乎无法访问第二个 RequestReportResponse 节点的任何子元素。

This is the XML I'm trying to transform:这是我正在尝试转换的 XML:

<SOAP-ENV:Envelope>
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <RequestReportResponse>
         <MessageHeader>
            <AgreementId>urn:agreementId:</AgreementId>
         </MessageHeader>        
      <RequestReportResponse>
            <Extension>csv</Extension>
            <FileByteArray>xyzFileBytes</FileByteArray>
            <FileName>xyzFileName</FileName>
            <StatusCode>200</StatusCode>
            <StatusDescription>SUCCESS</StatusDescription>
         </RequestReportResponse>
      </RequestReportResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Here is the Liquid map I'm using:这是我正在使用的液体 map:

{
  "AgreementId": "  {{content.Envelope.Body.RequestReportResponse.MessageHeader.AgreementId}}",
  "FileByteArray": "{{content.Envelope.Body.RequestReportResponse.RequestReportResponse.FileByteArray}}",
  "FileName": "{{content.Envelope.Body.RequestReportResponse.RequestReportResponse.FileName}}",
  "StatusCode": "{{content.Envelope.Body.RequestReportResponse.RequestReportResponse.StatusCode}}",
  "StatusDescription": "{{content.Envelope.Body.RequestReportResponse.RequestReportResponse.StatusDescription}}"
}

Expected result:预期结果:

{
  "AgreementId": "urn:agreementId:",
  "FileByteArray": "xyzFileBytes",
  "FileName": "xyzFileName",
  "StatusCode": "200",
  "StatusDescription": "SUCCESS"
}

Actual result:实际结果:

{
  "AgreementId": "urn:agreementId:",
  "FileByteArray": "",
  "FileName": "",
  "StatusCode": "",
  "StatusDescription": ""
}

It seems liquid doesn't have good support for the nested same tag name, we can use xslt instead to operate the xml and then transform to json which we want.好像液体对嵌套的同名标签没有很好的支持,我们可以用 xslt 代替 xml 转换成我们想要的 json。 But it's better for us to improve the format of xml resource to escape nested same tag name.但是我们最好改进 xml 资源的格式以逃避嵌套的相同标签名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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