Forum Discussion

toks122's avatar
toks122
New Contributor
13 years ago

Urgent Help

Manual Test
-----------
i am using the free version of soapUI

I copied xml(By creating REST test request) for a request and sent it to a service which i got the below response back:
Response Message looks like this:

<Messages xmlns:fo="http://www.w3.org/1999/XSL/Format">
<Message>
<Type>randomdata</Type>
<SubType>Unknown</SubType>
<Qualifier>randomdata</Qualifier>
<Text>randomdata</Text>
<ID1>randomdata</ID1>
</Message>
<Message>
<Type>randomdata</Type>
<SubType>Unknown</SubType>
<Qualifier>randomdata capsules</Qualifier>
<Text>Breast randomdata</Text>
<ID1>randomdata</ID1>
</Message>

The only assertion i was able to do was to count the number of <Method> node returned in the response i.e. count(//Method)

Now, i am trying to use Groovy script to run a request and assert the response i got back but i am having issues and i am not sure where to start from.

i dont have any previous knowlegde on Groovy. i am just going by what i saw online. below are the code i wrote:

import com.eviware.soapui.support.XmlHolder

def holder = new XmlHolder(messageExchange.responseContentAsXml);
def node = holder.getNodeValue("//Message[1]");
log.info(node);

How can i do more assertion on the response please? e.g. check the text within the nodes of 50(more sometimes depending on the response) possible <Method> node returned in the response?

Also, what further check can i do on the response.

Looking forward to you guys helping me out

2 Replies

  • leskop's avatar
    leskop
    Occasional Contributor
    you are missing namespace in xpath

    try something like


    import com.eviware.soapui.support.XmlHolder

    def holder = new XmlHolder(messageExchange.responseContentAsXml);
    def node = holder.getNodeValue("//*[local-name() = 'Messages ']//*[local-name() = 'Message'][1]//*[local-name() = 'Type']/text()");
    log.info(node);

  • toks122's avatar
    toks122
    New Contributor
    Thanks for your reply. running the code you suggested threw up No such property:messageExchange for class.

    i have good experience in java, i.e. when you import in java you have a corresponding jar file to it. with Groovy i still dont understand/know what class to import.

    Also, if anyone has a useful link or material on how to use Groovy in SoapUI, i will really appreciate it as it will mean that a newbie like me can read more before asking questions on the board.