Contributions
Re: Changing port for REST Mock Service
Hi, Can I set the host and port values from inside a setup script in my mock service? I need to bring those values into a config file, but I am not sure as to how do I set these variables from script. What I know is that by starting the mock service from the command line I can manually change the port (http://blog.ashwani.co.in/blog/2013-01-10/soapui-mockservicerunner-on-linux-without-x-config/), but what I am interested in is setting host and port from inside a setup script. P.s. I am not sure that it is possible, but if it's not, then could I change the host the way it is done forport? (from the command line)6KViews0likes0CommentsHow to get a parameter value from x-www-form-urlencoded request?
Hi Everyone, I have a mock service with a response to a request with Content-Type application/x-www-form-urlencoded. I.e. a request looks like the following: param1=value1¶m2=value2&guid={someGuid} I need to get the value of my "guid" parameter in the MockResponse script. How can I do that? I've tried the following: 1. def request = mockRequest.getRequestContent(); String uid = request.guid 2. def request = mockRequest.getRequestContent(); String uid = request.get(guid) in which case I get the error messages: Caused by: com.eviware.soapui.impl.wsdl.mock.DispatchException: java.lang.Exception: No such property: guidfor class:String Caused by: com.eviware.soapui.impl.wsdl.mock.DispatchException: java.lang.Exception: No such property: guidfor class:Script4 Of course I can do that with a Java regex, but I think there should be an easier way. Thanks in advance.1.9KViews0likes1CommentRe: Cyrillic alphabet characters in JSON response
Well, since no answers have appeared in this topic, I'd like to give a solution here in case someone else needs it later. You simply need to open the fileSoapUI-5.3.0.vmoptions (or whatever version you are using) with a text editor and add -Dfile.encoding=UTF8 on a new line, and save it. The file can be found at the bin folder of your SoapUI application. For instance, I have mine located atC:\Program Files\SmartBear\SoapUI-5.3.0\bin After this is done, restart your SoapUI and everything should work fine.6.2KViews1like0CommentsRe: Get MockResponse as a String in the Response script
Hi! I'll try to explain further. I have a Mock Service with a bunch of Mock Operations. Here we are considering one particular operation with a few Mock Responses. The decision about which Response is chosen is made in dispatch script for this mock operation. After the response is given to a user I'd like to write a value from this response (id in the above case) to a MockService property. I need to do that because the next mock operation in the cycle chooses which response to give to a user based on this id. So when the first mock operation completes, I want to use the value of a given id and set it to the MockService property. Does it make the things clearer?8 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.5KViews0likes0CommentsGet MockResponse as a String in the Response script
Hi Everyone, Not sure if this question has never been asked before. If so, please provide me with an approproate address. I need to set a MockService property from a MockResponse, so that I can use it in the dispatch script for the next mock operation. For that I am trying to read the response as a string and put a value from that response to the MockService property. How can I get my response as a string in this case? I tried to look here for an answerhttps://www.soapui.org/rest-testing-mocking/mock-service-scripting.html but to no avail. Here is what I've tried: https://www.soapui.org/apidocs/com/eviware/soapui/model/mock/MockResponse.html#getResponseContent() def response = MockResponse.getResponseContent(); String id = response.Flights[0].Id; log.info(id); def mockService = mockRunner.mockService; mockService.setPropertyValue("myId", id); Also, I tried to use json slurper to parse the response as a text as I do in testcase scripts and assertion scripts. Neither of these seem to work, though. I am pretty sure the answer should be quite obvious, but I cannot find it for some reason.8 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.5KViews0likes2CommentsCyrillic alphabet characters in JSON response
Hi Everyone, I am wondering how to get a JSON response with Cyrillic characters in SoapUI. If I set Content-Type "application/json; charset=utf-8" in the request headers that does not work and in the headers of the response I see just "application/json", and hence the cyrillic alphabet isn't recognized. In my mock service I set the response Content-Type to be "application/json; charset=windows-1251" and it works just fine. However, that doesn't work for the requests. Thanks in advance.Solved6.2KViews0likes1CommentRe: Transferring properties from JSON response to Script TestStep
Hello! Yep, this helps, I made my tests work by changing the TestSuite property in a Script test step, everything works fine, thank you! But the main question remains: if I can define my Script test case to be a Target for a PropertyTransfer, how do I transfer some value from the response of previous test step to a variable in the script? Of course I understand that I can do it using script anytime, but this is just for the sake of my curiosity. Here is a screen shot to make things more concrete:8 years agoPlace ReadyAPI QuestionsReadyAPI Questions3.4KViews0likes0CommentsTransferring properties from JSON response to Script TestStep
Hi Everyone, I am pretty new to writing automated tests for APIs using scripts, so my question might have a completely obvious answer (and I assume it does), but I haven't been able to find it on the web. Here is a test case I am writing and what I want to achieve: - I am working with RestAPI and obtain a result from one test step in a form of a JSON response; - From that JSON response I need to transfer some property called "ids" into my testSuite property in order to use it as a parameter in the Endpoint of the following TestStep; (transferring from one JSON response to another JSON request is, of course, straight forward, but in my case that would not work since the property is to be transferred to the Endpoint) - So I decided to make a Script testStep where I want to append that "ids" property to the TestSuite Property I have. Here is the script: def endpoint = testRunner.testCase.testSuite.getPropertyValue(property name); def ids; //this is what I tried to use as a destination to store my "ids" property from a Property Transfer testStep def updated = endpoint.concat("?posts=").concat(ids); testRunner.testCase.testSuite.setPropertyValue(property name, updated); - Between the test step where I am getting my JSON response, and this Script test step I put a Property Transfer test step, where I transfer "ids" from the JSON response by using JSONPath,then I define a destination as my Script test step, but I don't know how to define a location for "ids" to be transferred. So far, I tried ids and def idsbut these do not seem to work. And more importantly, I don't know which Path language to use for this, since JSONPath is obviously not going to work, because my script isn't in JSON format, but it isn't in XML either, so xPath and xQuery don't seem to be a solution, do they? I am using open source version of SoapUI, so these three Path languages are the only choices. But I am pretty sure that there should be a way to transfer a property from JSON to a script since one can define a Script test step as a Target in the Property Transfer test step. Apologise for the poem I've written, but any help would be highly appreciated. Thanks in advance.8 years agoPlace ReadyAPI QuestionsReadyAPI Questions3.5KViews0likes2Comments