samedi 10 mars 2018

SoapUI Assertions - either XPath or Contains Assertion would be fine

Sample response below. I want to check the existence of a specific error code (860) in the response below. Technically, to avoid picking the error up accidentally in a reference number, I need to be checking it is in the bit labelled < code >860< /code > (inserted spaces so it would show).

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns2:activatePortResponse xmlns:ns2="http://transferobjects.abc.abc.org">
         <return som="6001365" state="Approved">
            <errors>
               <error>
                  <code>860</code>
                  <description>The Port cannot be activated outside the ready for service dateTime window (grace period taken into account).</description>
                  <mnemonic>RFS_WINDOW</mnemonic>
               </error>
               <name>som</name>
            </errors>
            <success>false</success>
         </return>
      </ns2:activatePortResponse>
   </soap:Body>
</soap:Envelope>

I was trying to build a set of calls with expected error results to check the the error responses are returned as they should. Going through all the usual garbage messages that meant nothing to me, I just kept tweaking.

Turned out I could use a Contains method and just paste in more, rather than just 860 or even < code >860< /code > I just had to paste in a bigger chunk like this:

       <error>
          <code>860</code>
          <description>The Port cannot be activated outside the ready for service dateTime window (grace period taken into account).</description>
          <mnemonic>RFS_WINDOW</mnemonic>
       </error>

So I have a solution, but if anyone wants to show me how to do it with XPath, in a less hamfisted way, that would be cool.

Aucun commentaire:

Enregistrer un commentaire