【问题标题】:How to get response based on the request body matching using wiremock and JSON如何使用wiremock和JSON根据请求正文匹配获取响应
【发布时间】:2018-05-18 05:23:38
【问题描述】:

如何使用 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>

【问题讨论】:

    标签: json soap mocking wiremock


    【解决方案1】:

    在 WireMock.Net 中,您可以使用 XPath 匹配。更多详情请见here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-21
      • 2018-10-06
      • 1970-01-01
      • 2017-06-26
      • 1970-01-01
      相关资源
      最近更新 更多