cancel
Showing results for 
Search instead for 
Did you mean: 

How do I retreive a value from a Request when creating a Mock Service?

Highlighted
Contributor

How do I retreive a value from a Request when creating a Mock Service?

Here is my request xml:


<E:Envelope xmlns:E="http://schemas.xmlsoap.org/soap/envelope/" xmlns:A="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.w3.org/2001/XMLSchema" E:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <E:Body>
      <m:callADouble xmlns:m="http://www.abc.com/xyz/simpleservice" s:type="y:double">2.54</m:callADouble>
  </E:Body>
</E:Envelope>



How do I access callADouble? I would like to construct a response that doubles the value in the callADouble request.

I have tried


def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder(mockRequest.requestContent)
def a = holder.getNodeValue("//m:callADouble") as double



But I get the following error:


 
  <soapenv:Fault>     
      <faultcode>Server</faultcode>     
      <faultstring>java.lang.Exception: net.sf.saxon.trans.XPathException: XPath syntax error at char 15 in {//m:callADouble}:    Prefix m has not been declared</faultstring>   
  </soapenv:Fault>
1 REPLY 1
Highlighted
Contributor

Re: How do I retreive a value from a Request when creating a Mock Service?

I believe my issue was an xpath issue?


def a = holder.getNodeValue("//*[namespace-uri()='http://www.abc.com/xyz/simpleservice' and local-name()='callADouble'][1]") as double


seems to work.
New Here?
Join us and watch the welcome video:
Announcements