amaters
amaters

Reputation: 2316

How to Use Query_Match for Soap UI

I am having trouble using the MockOperation Editor in Soap UI.

I have got this request:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <methodName xmlns="http://tempuri.org/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <dataAreaId>error</dataAreaId>
      <pInvoiceList>
      <dataAreaId>NOTTHESAME</dataAreaId>
        ...
      </pInvoiceList>
    </methodName>
  </s:Body>
</s:Envelope>

I tried almost every XPATH expression but I always get "Missing match in request"

What to fill in the Xpath box?

I tried:

Upvotes: 8

Views: 11656

Answers (4)

Andr&#233;s Cuadros
Andr&#233;s Cuadros

Reputation: 2122

If you don't care about namespaces you can use the following syntax:

XPath1.0

//*[local-name() = 'methodName']/*[local-name() = 'dataAreaId'][1]

XPath2.0

//*:methodName/*:dataAreaId[1]

Upvotes: 5

Jake
Jake

Reputation: 11

There is a good hint: When defining an Assertion for a Testcase (or maybe also in the Mock-Window) there is a button "Declare" above the XPath-Expression-Field. It doesn't really look like a button, until you point with the mouse-pointer at it, so I didn't realize it at first.

Just click on the button an SoapUI (actually I use 5.2.1) will add the declare-statements for you, that you can use.

I found that feature coincidentally, as it is not really visible. Maybe this can help also...

Upvotes: 1

amaters
amaters

Reputation: 2316

I finally managed to get it based on the answer from user1740631

Seems I it had to do with namespaces afterall.

The correct syntax:

declare namespace tem='http://tempuri.org/';
//tem:methodName/tem:dataAreaId[1]

Upvotes: 11

pshekhar
pshekhar

Reputation: 166

Write like this

For First One

//methodName[1]/dataAreaId[1]

For Second one

//methodName[1]/pInvoiceList[1]/dataAreaId[1]

*If you have multiple node with same name in Xml then you should use numbers to locate that particular node.

Upvotes: 4

Related Questions