niangsou
11 years agoNew Contributor
Sopui groovy script not executed when deployed in tomcat
hi all,
im actually using soap ui pro release 5.1.0 to develop a Rest web service with mock service;
i create a POST method with several requests and the mock responses corresponding to each request in one ressource (/api/1/mobile/users).
as im using one ressource for all responses, i tried to do script groovy, in order to get right response for each request;
the script is well executed, when i run the mock service locally in the soap ui tool; but when i deploy my project in tomcat server, i notice that all requests have an unique response( default response);
i dont know why this difference and how to solve it; furthermore when i use an old soapui project (xml project) that had a groovy script in the tomcat server, i notice, its well performed.
exemple of my request: POST http://localhost:8080/account/api/1/mob ... 0gmail.com
here the code of my scirpt (quite simple) :
import com.eviware.soapui.impl.rest.mock.RestMockRequest
import com.eviware.soapui.SoapUI
//import com.eviware.soapui.model.iface.MessageExchange
// check for PUT
SoapUI.log.info ("before post :"+ mockRequest)
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.
im actually using soap ui pro release 5.1.0 to develop a Rest web service with mock service;
i create a POST method with several requests and the mock responses corresponding to each request in one ressource (/api/1/mobile/users).
as im using one ressource for all responses, i tried to do script groovy, in order to get right response for each request;
the script is well executed, when i run the mock service locally in the soap ui tool; but when i deploy my project in tomcat server, i notice that all requests have an unique response( default response);
i dont know why this difference and how to solve it; furthermore when i use an old soapui project (xml project) that had a groovy script in the tomcat server, i notice, its well performed.
exemple of my request: POST http://localhost:8080/account/api/1/mob ... 0gmail.com
here the code of my scirpt (quite simple) :
import com.eviware.soapui.impl.rest.mock.RestMockRequest
import com.eviware.soapui.SoapUI
//import com.eviware.soapui.model.iface.MessageExchange
// check for PUT
SoapUI.log.info ("before post :"+ mockRequest)
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.