WSO2 ESB XPath 문제
-
21-12-2019 - |
문제
다음 XPath
을 사용하고 싶습니다./ 사용자 / 사용자 / 사용자 ID
ESB가 내 XML 주위에 SOAP 봉투와 본문을 추가하기 때문에 이것은 작동하지 않습니다. 또는 사용하는 올바른 XPath는 무엇입니까? 아니면 어떻게 비누 봉투와 본문을 제거 할 수 있습니까?
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']
.
그러나 Iterater 중재자 안에 로그를 기록하려고하면 아무것도 반환합니까?
해결책
다음을 사용 하여이 작업을 수행했습니다
<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>
.
UPD. 수정 된 XPath 표현식
시도 :
<property name="yourParamName" expression="$body/Users/User/UserID" scope="default" type="STRING"/>
.
미리 정의 된 Synapse XPath 변수 여기 여기를 읽을 수 있습니다.
제휴하지 않습니다 StackOverflow