0

我有一个 ./mappings/*.json 文件中描述的存根。

"request": {
        "method": "POST",
        "url": "/some/thing",
        "bodyPatterns" : [ {
                "matchesXPath" : {
                    "expression": "//nodeA/text()",
                    "contains": "999"
                }
            } ]
    }

Wiremock (ver.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,但到目前为止还没有运气

4

1 回答 1

1

我发现问题出在curl我使用的那个上。它格式不正确,因为我在 XML 声明中使用了相同的双引号。现在我从文件中加载请求正文,一切正常 curl -H "Content-Type: application/xml" -d "@path_to_request_file" -X POST http://localhost:8888/some/thing

于 2020-03-12T08:05:11.820 回答