Forum Discussion

wraith77's avatar
wraith77
New Contributor
15 years ago

Need Mock Service to return element from request

Hello everyone. I'm new to the board, bu have used SOAPUI for a couple years. I have a question that I hope you can help me with.

I have a Mock Service that needs to respond to a request with one of the elements in the request.

Contained in  the request is an element called . The request ID is just a string of dynamically generated digits. I need SOAPUI to read the string that's inside the tag, and include that string in the response.

So for example :

Request



12345



Response



12345



The request is not static or necessarily predictable which is why I need SOAPUI to actually capture it from the request.

Any ideas?

3 Replies

  • wraith77's avatar
    wraith77
    New Contributor
    I've put together this Groovy Script for the Mock Response.

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context)
    def holder = groovyUtils.getXmlHolder(mockRequest.requestContent)
    def id = String.valueOf(holder.getNodeValue("//ns:RequestID"))
    context.setProperty("requestid", id)


    My assumption is that if my script is correct, the property ${requestid} should be replaced with the value that's in the RequestID node of the request. However, in the response, the RequestID value is empty. I'm obviously doing something wrong. Help! :-)