I have mocked server created with MockServer. It have to answer for requests with parameter with specified value. I have simple SOAP message sent as text/xml:
<soapenv:Envelope xmlns:soapenv="http://ift.tt/sVJIaE">
<soapenv:Header/>
<soapenv:Body>
<x>y</x>
</soapenv:Body>
</soapenv:Envelope>
On mocked server side I want to check if parameter x is equal to y. So I am testing it with online xpath parser http://ift.tt/1i4Ssa3 and it works. My XPATH expression is:
/soapenv:Envelope/soapenv:Body/x='y'
So I want to set rule on MockServer based on this XPATH and it doesn't work. Log says that body doesn't match.
My MockServer code:
MockServerClient mock = new MockServerClient("localhost", 12121);
mock.reset();
mock.when(
request()
.withBody(StringBody.xpath("/soapenv:Envelope/soapenv:Body/x='y'").getValue())
)
.respond(
response()
.withStatusCode(200)
);
Request is logged to file on mockerver side and all those backslahes and new line symbols are printed and I am wondering if it's not something wrong with that, but probably it is not the case and it's only added when logging to file:
<soapenv:Envelope xmlns:soapenv=\"http://ift.tt/sVJIaE\">\n
<soapenv:Header>
<wsse:Security xmlns:wsse=\"http://ift.tt/LRW8Ij\" xmlns:wsu=\"http://ift.tt/Hm2joJ\">
<wsse:UsernameToken wsu:Id=\"UsernameToken-12\">
<wsse:Username>a</wsse:Username>
<wsse:Password Type=\"http://ift.tt/1aTA7XU\">a</wsse:Password>
<wsse:Nonce EncodingType=\"http://ift.tt/14yUvuM\">n0ktTNd2fplBouQcI7cc/Q==</wsse:Nonce>
<wsu:Created>2015-02-17T08:38:55.834Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>\n
<soapenv:Body>\n
<parameters>sda</parameters>\n
</soapenv:Body>\n
</soapenv:Envelope>
No comments:
Post a Comment