Forum Discussion

niangsou's avatar
New Contributor
10 years ago

Rest: soap ui groovy script not running on tomcat server

Hi everybody,
i have a problem about executing groovy script of my rest mock service project on tomcat server and i hope if you can help me to solve it, please.

actually im using soap ui pro 5.1.0 to create a complete REST web services with the mock service;
indeed, after ressources creation (/api/1/mobile/users), i create a method POST that contains several requests and i generate the corresponding REST responses under (/api/1/mobile/users) ressource; then to have the corresponding response for each request, i develop a groovy script that check the request content and send the right response; the script is well performed locally in the soap ui tool, but when i deploy the project on tomcat server, and try to send request with the client, i notice that the default response is sent for all requests instead of targetted response; it seems that the script is not performed, and no log info is received.
here's the requests sent:
request1: POST http://localhost:8080/api/1/mobile/user ...
request2: POST http://localhost:8080/api/1/mobile/user ...
request3: POST http://localhost:8080/api/1/mobile/user ...
request4: POST http://localhost:8080/api/1/mobile/user ...

request5: POST http://localhost:8080/api/1/mobile/user ...

here's the script groovy managing the different responses:
import com.eviware.soapui.SoapUI
//import com.eviware.soapui.model.iface.MessageExchange

def methods=mockRequest.getMethod()
def method=methods.getMethodsAsStringArray() ("method :"+ method[1])
if( method[1] == "POST" )

def content=mockRequest.getRequest().toString() ("content request: "+content)
if( content.contains("John2") )
{"get response 1 ")
return "Response 1"

else if(content.contains("JohnDoe"))
{"get response 2 ")
return "Response 2"
else if(content.contains("Faudeur1"))
{"get response 3 ")
return "Response 3"
else if(content.contains("MissingFields"))
{"get response 4 ")
return "Response 4"
else if(content.contains("emailExist"))
{"get response 5 ")
return "Response 5"

thanks for your help

2 Replies

  • Hey,


     I am facing same issue. Kindly let me know if you have figured out a solution for this?




    • nmrao's avatar
      Champion Level 3
      May be you want to provide more details regarding your issue?