我在wiremock中创建存根。如果我在xml中有xmlns,那么它就不匹配,但是如果没有它,它就可以工作。
请求
curl -d '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><a xmlns="http://www.example.com/namespaces/ad"><b>1</b><c>2</c><d>9407339517</d></a>' -i -H "Content-Type: text/xml" -X POST "http://localhost:8080/test"
存根Json
{
"request": {
"method": "POST",
"url": "/test",
"headers" : {
"Content-Type" : {
"equalTo" : "text/xml"
}
},
"bodyPatterns" : [ {
"matchesXPath" : "/stuff:a[b='1'][c='2']",
"xPathNamespaces" : {
"stuff" : "http://www.example.com/namespaces/ad"
}
} ]
},
"response": {
"body": "Hello world!",
"status": 200
}
}
除了上面提到的方法,我也尝试了使用local-name()。
https://stackoverflow.com/questions/56779242
复制相似问题