How to get response based on the request body matching using wiremock and JSON


How to get response based on the request body matching using wiremock and JSON



How to verify if my Soap request consists of an particular element in header and body using JSON and standalone WireMock.



I should get response1 if my request contain <a:Id>1876</a:Id> in the header else i should get response2


<a:Id>1876</a:Id>



similarly i need to check in body also.



Below is my request XML


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:a="http://abc.example.com/a"
xmlns:b="http://abc.example.com/b"
xmlns:c="http://abc.example.com/c"
<soapenv:Header>
<a:abcHeaders>
<a:Id>1876</a:Id>
<a:Xid>12</a:Xid>
</a:abcHeaders>
</soapenv:Header>
<soapenv:Body>
<b:abcOpern>
<b:xyz>
<c:pqr>12</c:pqr>
</b:xyz>
</b:abcOpern>
</soapenv:Body>
</soapenv:Envelope>




1 Answer
1



In WireMock.Net you can use XPath matching. For some details see here.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

how to run turtle graphics in Colaboratory

Export result set on Dbeaver to CSV