Forum Discussion

VTest's avatar
VTest
Occasional Contributor
12 years ago

Not able to Parse response xml

Hi ,
I have two test steps, one for database connnection , the second one is rest request.

i am unable to get the response from the groovy script , if the request is one step above the groovy script,
the order of the test steps
1) SOAP REST REQUEST
2)JDBC CONNECTION STEP
3)Groovy Script.

In groovy script if i run requests 1,2 i am able to parse only request 2 , i am not able to parse the request 1 response , for some reason i get namespace not defined error.
if i remove my database connection request step(2), then i am able to parse the response 1(request 1) without any errors.

Could some one help , to receive the request from the two test requests as xml and parse both of them, the piece of code i used is

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
testRunner.runTestStepByName("Teststep1")
def Holder1 = groovyUtils.getXmlHolder("ResponseAsXml")

testRunner.runTestStepByName("Teststep2")
def Holder2 = groovyUtils.getXmlHolder("ResponseAsXml")

Everything i am trying to do in onetestcase but different test steps.

5 Replies

  • nmrao's avatar
    nmrao
    Icon for Champion Level 1 rankChampion Level 1
    Would you please clarify?
    1. Though test case has 3 steps, are you running only groovy script?
    2. Post the error you are seeing
    3. If required do you consider having separate groovy script after each request step?
  • VTest's avatar
    VTest
    Occasional Contributor
    Thank you Rao for responding,
    the error log shows
    " java.lang.RuntimeException: net.sf.saxon.trans.XPathException: XPath syntax error at char 14 in {//ns1:userList/ns1:user}: Prefix ns1 has not been declared error at line: 13"

    And the test i want to perform is , finding the userlist from the SOAP Request and copying the all usernames to a array/list
    then getting the actual users list from the data base to another list and comparing them in a single groovy script.

    Thank you
  • nmrao's avatar
    nmrao
    Icon for Champion Level 1 rankChampion Level 1
    Looks the questions are not seen at details from earlier reply, may be you are in hurry for the solution.
    Because not sure why you have the following statement in groovy if teststep1 is executed first.
    testRunner.runTestStepByName("Teststep1")

    Please see the link
    http://www.soapui.org/Scripting-Propert ... rate-nodes

    Notes: Both below are from above link only.
    1. In the groovy script, you can specify to read the response of particular step
    for eg: if the step1 name is Request1, similarly you may handle for other steps
    def holder = groovyUtils.getXmlHolder( "Request1#Response" )
    2. Namespaces can be defined as below, if you have more keep adding.
    example
    holder.namespaces["ns"] = "http://acme.com/mynamspace"
  • VTest's avatar
    VTest
    Occasional Contributor
    Thanks Rao,
    yes i was in hurry , but i found the solution, all i was missing is request name in the getXmlHolder.Now i am able to it is working Thank you