niangsou
11 years agoNew Contributor
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 ... l.lycos.fr
request2: POST http://localhost:8080/api/1/mobile/user ... 0gmail.com
request3: POST http://localhost:8080/api/1/mobile/user ... 0gmail.com
request4: POST http://localhost:8080/api/1/mobile/user ... 0gmail.com
request5: POST http://localhost:8080/api/1/mobile/user ... 0gmail.com
here's the script groovy managing the different responses:
/////////////////////////////////////////////////////////////////
import com.eviware.soapui.impl.rest.mock.RestMockRequest
import com.eviware.soapui.SoapUI
//import com.eviware.soapui.model.iface.MessageExchange
def methods=mockRequest.getMethod()
def method=methods.getMethodsAsStringArray()
SoapUI.log.info ("method :"+ method[1])
if( method[1] == "POST" )
{
def content=mockRequest.getRequest().toString()
SoapUI.log.info ("content request: "+content)
if( content.contains("John2") )
{
SoapUI.log.info("get response 1 ")
return "Response 1"
}
else if(content.contains("JohnDoe"))
{
SoapUI.log.info("get response 2 ")
return "Response 2"
}
else if(content.contains("Faudeur1"))
{
SoapUI.log.info("get response 3 ")
return "Response 3"
}
else if(content.contains("MissingFields"))
{
SoapUI.log.info("get response 4 ")
return "Response 4"
}
else if(content.contains("emailExist"))
{
SoapUI.log.info("get response 5 ")
return "Response 5"
}
}
thanks for your help
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 ... l.lycos.fr
request2: POST http://localhost:8080/api/1/mobile/user ... 0gmail.com
request3: POST http://localhost:8080/api/1/mobile/user ... 0gmail.com
request4: POST http://localhost:8080/api/1/mobile/user ... 0gmail.com
request5: POST http://localhost:8080/api/1/mobile/user ... 0gmail.com
here's the script groovy managing the different responses:
/////////////////////////////////////////////////////////////////
import com.eviware.soapui.impl.rest.mock.RestMockRequest
import com.eviware.soapui.SoapUI
//import com.eviware.soapui.model.iface.MessageExchange
def methods=mockRequest.getMethod()
def method=methods.getMethodsAsStringArray()
SoapUI.log.info ("method :"+ method[1])
if( method[1] == "POST" )
{
def content=mockRequest.getRequest().toString()
SoapUI.log.info ("content request: "+content)
if( content.contains("John2") )
{
SoapUI.log.info("get response 1 ")
return "Response 1"
}
else if(content.contains("JohnDoe"))
{
SoapUI.log.info("get response 2 ")
return "Response 2"
}
else if(content.contains("Faudeur1"))
{
SoapUI.log.info("get response 3 ")
return "Response 3"
}
else if(content.contains("MissingFields"))
{
SoapUI.log.info("get response 4 ")
return "Response 4"
}
else if(content.contains("emailExist"))
{
SoapUI.log.info("get response 5 ")
return "Response 5"
}
}
thanks for your help