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
2
  • Do you want the node, all nodes by that name, or just the text in the node? Also, XPath ending with '/' isn't valid.
    – JWiley
    Oct 30, 2012 at 15:54
  • I want the text of the first one
    – amaters
    Oct 31, 2012 at 7:21

4 Answers 4

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]
1
  • 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, 2013 at 0: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]
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.

1
  • Tried this. Still without result. Can it be because of missing namespaces or am i suggesting something really stupid here?
    – amaters
    Oct 31, 2012 at 7: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...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.