我有两个xml请求如下,只是想获得响应。如果请求主体包含节点A,B,C且不包含D,则为Response1。如果A,B,C,D全部包含在请求中,则为Response2。
有人可以帮我这个。
此外,如果有人可以帮助我根据请求匹配使用身体模式获得好文章或者身体模式可用的不同选项,这将是有帮助的。
提前致谢!!
我尝试过包含和优先级,但这没有帮助。
REQ1:
<TestService>
<A> test </A>
<B> testB</B>
<C> testC </C>
<XYZ> test </XYZ>
</TestService>
REQ2:
<TestService>
<A> test </A>
<B> testB</B>
<C> testC </C>
<XYZQ> test test</XYZQ>
<D> testD</D>
</TestService>
在WireMock中,它可能最终会有两个规则,每个规则一个:
标签何时存在的规则:
{
"request": {
"method": "ANY",
"url": "/xmltag",
"bodyPatterns" : [ {
"matchesXPath" : "/TestService[count(//D) = 1]"
} ]
},
"response": {
"status": 200,
"body": "<root><tag>D</tag></root>"
}
}
当没有D标签时另一个:
{
"request": {
"method": "ANY",
"url": "/xmltag",
"bodyPatterns" : [ {
"matchesXPath" : "/TestService[count(//D) = 0]"
} ]
},
"response": {
"status": 200,
"body": "<root><tag>No D found</tag></root>"
}
}