Contributions
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 help1.9KViews0likes2CommentsSopui 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.868Views0likes0Comments