전 Wiremocks로 사례를 만들고 응답 모의를 생성하고 있습니다.Xpath 유효성 검사 wiremock matchesXPath expressions
는 I 이런 XML 요청 가지고
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xw="http://example.com">
<soapenv:Header/>
<soapenv:Body>
<xw:gen>
<xw:input>
<xw:element1>0100</xw:element1>
<xw:element2>741</xw:element2>
<xw:element3>JAVA</xw:element3>
<xw:element4>123</xw:element4>
</xw:input>
<xw:global>
<xw:obj1>
<xw:attr1>john</xw:attr1>
<xw:attr2>doe</xw:attr2>
</xw:obj1>
</xw:global>
</xw:gen>
</soapenv:Body>
</soapenv:Envelope>
는 I에서만 유효 할 그런 XW : 입/XW :에서 element1 = 0100, XW : 입/XW :이 element2 = 741 및 I 그 xw : 글로벌 노드가 필요합니다. xw : global의 유일한 조건은입니다. 이 노드는 <xw:global></xw:global>
일 수 있습니다.
이것은 JSON 내 모의입니다 :
{
"request" : {
"url" : "/myweb/myrequest.asmx",
"headers": {
"SOAPAction": {
"equalTo": "\"http://example.com/gen\""
}
},
"bodyPatterns" : [ {
"matchesXPath": "//xw:input[xw:element1=\"0100\" and xw:element2=\"741\" ]",
"xPathNamespaces" : {
"xw" : "http://example.com"
}
}]
},
"response" : {
"status" : 200,
"headers": {
"Content-Type": "text/xml;charset=UTF-8"
},
"body" : "<Abody>"
}
}
질문은 : 글로벌 비어 있지 않거나 null이되지 않습니다 : 내가 노드 XW는 것을 확인할 수있는 방법?
나는이 matchesXPath과 노력하지만 난 운이 없었 :"matchesXPath": "//xw:input[xw:element1=\"0100\" and xw:element2=\"741\" ] and count(//xw:global) > 0"
합니다.
감사합니다.
스텁 정의에 네임 스페이스를 지정 했습니까? 그렇지 않으면 XPath 표현식에서 사용할 수 없습니다. – Tom
예. 네임 스페이스를 지정했습니다. 감사. – dani77