jazzyekim
jazzyekim

Reputation: 101

Request body matching with XML declaration in Wiremock-standalone

I have a stub described in the ./mappings/*.json file.

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

Wiremock (ver.2.26.2) is started in standalone mode. When I call the service like this:

curl -d "<request><nodeA>999</nodeA></request>" -X POST http://localhost:8888/some/thing

I am getting the response from stub as expected. The problem is that the request has to be sent with XML declaration tag , e.g.

curl -d "<?xml version="1.0" encoding="UTF-8"?><request><nodeA>999</nodeA></request>" -X POST http://localhost:8888/some/thing

and in this case the request isn't matched. I tried to find smth in the documentation regarding it, but so far no luck

Upvotes: 0

Views: 1270

Answers (1)

jazzyekim
jazzyekim

Reputation: 101

I found out that the problem was with curl that I used. It was malformed since I used same double quotes in XML declaration. Now I load the request body from file and everything works just fine curl -H "Content-Type: application/xml" -d "@path_to_request_file" -X POST http://localhost:8888/some/thing

Upvotes: 1

Related Questions