繁体   English   中英

如何使用Wiremock和JSON根据请求主体匹配获取响应

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

如何使用JSON和独立的WireMock验证我的Soap请求是否包含标头和正文中的特定元素。

如果我的请求的标头中包含<a:Id>1876</a:Id> ,我应该得到response1,否则我应该得到response2

同样,我也需要检查身体。

以下是我的请求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>

在WireMock.Net中,您可以使用XPath匹配。 有关详细信息,请参见此处

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM