Ask a Question

Need Mock Service to return element from request

wraith77
New Contributor

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 3
wraith77
New Contributor

Re: Need Mock Service to return element from request

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! 🙂
wraith77
New Contributor

Re: Need Mock Service to return element from request

Nevermind. I figured it out.

Re: Need Mock Service to return element from request

Hello,

Glad you figured it out!

Regards,
Dain
eviware.com

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: