如何根据使用wiremock和JSON的请求正文匹配获得响应

问题描述 投票:0回答:1

如何使用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个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.