我在./mappings/*.json文件中描述了一个存根。
"request": {
"method": "POST",
"url": "/some/thing",
"bodyPatterns" : [ {
"matchesXPath" : {
"expression": "//nodeA/text()",
"contains": "999"
}
} ]
}Wiremock (版本2.26.2)以独立模式启动。当我像这样调用服务时:
curl -d "<request><nodeA>999</nodeA></request>" -X POST http://localhost:8888/some/thing不出所料,我从存根得到了响应。问题是请求必须与XML声明标签一起发送,例如
curl -d "<?xml version="1.0" encoding="UTF-8"?><request><nodeA>999</nodeA></request>" -X POST http://localhost:8888/some/thing在这种情况下,请求不匹配。我试图在有关smth的文档中找到smth,但到目前为止还没有成功。
发布于 2020-03-12 16:05:12
我发现问题出在我使用的curl上。它的格式不正确,因为我在XML声明中使用了相同的双引号。现在我从文件中加载请求正文,一切都很正常,curl -H "Content-Type: application/xml" -d "@path_to_request_file" -X POST http://localhost:8888/some/thing
https://stackoverflow.com/questions/60563426
复制相似问题