XPath - castlemock/castlemock GitHub Wiki

XPath

SOAP and REST projects can be configured to use XPath as a response strategy. The incoming request will match a predefined XPath definition for a mocked response. The mocked response's XPath that matches the incoming request will be chosen as the response.

A default mocked response can be configured in case the incoming request would not match any of the defined XPaths in the mocked responses.

Example

Request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.castlemock.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:Request>
         <web:Name>Karl</web:Name>
         <web:Country>Sweden</web:Country>
      </web:Request>
   </soapenv:Body>
</soapenv:Envelope>

XPath

//Request/Name[text()='Karl']
⚠️ **GitHub.com Fallback** ⚠️