Azure Logic应用程序XPath未返回值 [英] Azure Logic Apps xpath not returning value
本文介绍了Azure Logic应用程序XPath未返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个调用SOAPAPI的逻辑应用程序。我正在尝试从XML响应中提取节点的值,但似乎无法获得值输出,以便在进一步的操作中使用。
这是XML响应的节略版本:
<?xml version="1.0" encoding="utf-8"?>
<Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Body>
<DoLoginResponse xmlns="http://apiserver.wireless.com/0905/">
<DoLoginResult>
<OperationStatus>true</OperationStatus>
<StatusMessage />
<SecurityProfile>
<User>
<UserID>6e37c720-b40e-4a4b-8e7a-b0c431ac8749</UserID>
</User>
<Session>
<SessionId>888c9c94-f33b-4766-97c0-8f8031bda104</SessionId>
</Session>
</SecurityProfile>
<Authenticated>true</Authenticated>
</DoLoginResult>
</DoLoginResponse>
</Body>
</Envelope>
在Logic Apps Designer中,我要提取经过身份验证的和SessionID节点。例如,我尝试使用XPath函数获取经过身份验证的节点值:
xpath(outputs('xml'),'/Envelope/Body/DoLoginResponse/DoLoginResult/Authenticated')
运行后,输出为[]
作为使用XML的新手,我们非常感谢您的帮助。
推荐答案
文档元素的名称不是Envelope
,而是http://schemas.xmlsoap.org/soap/envelope/:Envelope
,如果您能够在Logic Apps中传递NamespaceManager,那么它将能够使用简写soap:Envelope
,而您不能。是的,XPath就是这样的迂腐。命名空间在XPath中很重要。
为了稍微简单一些,您可以使用语法/*[local-name() = 'Envelope']
,它忽略了元素的名称空间。或者,假设您希望在结构已知的SOAP消息内部进行查询,可以将其进一步缩写为/*
,因为您知道文档元素将始终为soap:Envelope
。
逻辑应用程序不擅长处理XML,如果可以选择,我会使用函数或几乎任何其他工具。
这篇关于Azure Logic应用程序XPath未返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文