8

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:

  • //dataAreaId/text()
  • //dataAreaId/
  • //dataAreaId
  • /dataAreaId/text()
  • /dataAreaId
  • /methodName/dataAreaId/text()
  • /methodName/dataAreaId/
  • /methodName/dataAreaId
amaters
  • 2,266
  • 2
  • 24
  • 44

4 Answers4

11

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]
amaters
  • 2,266
  • 2
  • 24
  • 44
  • Yep, that was it. Pretty annoying that their website doesn't give this hint. My XML result didn't contain namespace prefixes, but it still required that I create a virtual namespace as you suggested above. – djangofan Dec 17 '13 at 00:46
5

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]
Andrés Cuadros
  • 1,962
  • 1
  • 21
  • 22
4

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.

pshekhar
  • 166
  • 1
  • 7
  • Tried this. Still without result. Can it be because of missing namespaces or am i suggesting something really stupid here? – amaters Oct 31 '12 at 07:25
1

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...

Jake
  • 11
  • 1