wso2 esb xpath问题
-
21-12-2019 - |
题
我想使用以下XPath
/用户/用户/ userid
这不起作用,因为ESB在我的XML周围添加了一个SOAP信封和身体,所以要使用的正确XPath是什么,或者如何删除SOAP信封和身体?
XML是:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<Users xmlns="http://ws.wso2.org/dataservice">
<User>
<UserID>a</UserID>
<Username>a</Username>
<Email>a</Email>
<Password>a</Password>
</User>
<User>
<UserID>a</UserID>
<Username>a</Username>
<Email>a</Email>
<Password>a</Password>
</User>
<User>
<UserID>a</UserID>
<Username>a</Username>
<Email>a</Email>
<Password>a</Password>
</User>
</Users>
</soapenv:Body>
</soapenv:Envelope>
.
编辑:
当我尝试将其登录到我的迭代调解员
之外时,工作//*[local-name() = 'Users']/*[local-name() = 'User']/*[local-name() = 'UserID']
.
但是当我尝试在迭代调解员内登录它时,它没有返回?
解决方案
使用以下
获取此工作<property xmlns:int="http://ws.wso2.org/dataservice" name="uri.var.ID" expression="$body/int:User/int:UserID/text()" scope="default" type="STRING"/>
. 其他提示
访问您的元素,您应该通过信封和身体。 以下是具有开关介质的示例:
<switch xmlns:ns="http://org.apache.synapse/xsd"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:int="http://ws.wso2.org/dataservice"
source="boolean(/soap:Envelope/soap:Body/int:Users/int:User/int:UserID/text() = 'string_to_compare'">
<case regex="true">
....
</case>
<default/>
</switch>
.
更新 纠正XPath表达式
试试:
<property name="yourParamName" expression="$body/Users/User/UserID" scope="default" type="STRING"/>
.
您可以在预定义的突触xpath变量 here 。
不隶属于 StackOverflow