Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
2.6k views
by The go-to Tester (360 points)
retagged by

I am working on API testing using soapui and capturing response data of Soap request, I used below code but it return null.

Response Body:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <ConversionRateResponse xmlns="http://www.webserviceX.NET/">
         <ConversionRateResult>-1</ConversionRateResult>
      </ConversionRateResponse>
   </soap:Body>
</soap:Envelope>

Groovy Scripts:

import com.eviware.soapui.support.XmlHolder

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)

def ResponseMessage = testRunner.testCase.testSteps["ConversionRate"].testRequest.response.contentAsString
def response = new XmlHolder(ResponseMessage)

def byteResponse = response.getNodeValue("//ConversionRateResult")

log.info byteResponse
 

Where "ConversionRate" test steps name.

Please suggest me on same what I am missing here.

1 Answer

0 like 0 dislike
by The go-to Tester (181 points)
selected by
 
Best answer

This is because your response data has namespace. You will need to use your script as given below.

response.namespaces["ns"] = "http://www.webservicex.net/"
 

and then

response.getNodeValue('//ns:ConversionRateResult')


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...