ServiceV Pro: Default response unexpectedly replacing the scripted one
First thing first: I'm new to the ServiceV product, just got it few days ago. I'm creating a virt api where the following path is being used: /api/aicm/v1/subject/{subject_nr}/mandate/{creditor_id} where subject_nr and creditor_id represent the required TEMPLATE parameters. Beside the main success scenario (GET: -> HTTP 200 OK), where both arguments are made available in the URI, I'm trying to handle the following alternative scenarios in my virt api: a) GET: {subject_nr} is empty -> HTTP 400 Bad Request b) GET: {creditor_id} is empty -> HTTP 400 Bad Request c) GET: both {subject_nr} and {creditor_id} are empty -> HTTP 400 Bad Request The test paths associated with the four scenarios (1 main + 3 alts) are: 1. HTTP 200: /urds/wrd/api/aicm/v1/subject/0303200001/mandate/AB51TST405365330000 2. HTTP 400: /urds/wrd/api/aicm/v1/subject//mandate/AB51TST405365330000 3. HTTP 400: /urds/wrd/api/aicm/v1/subject/0303200001/mandate/ 4. HTTP 400: /urds/wrd/api/aicm/v1/subject//mandate/ I use the "Dispatch Strategy: Script" with default response returning HTTP 404 Not Found, and the following validation script to check the path arguments and return the appropriate response: assert log log.info("Executing dispatch script...") assert requestContext def props = requestContext.getProperties() assert props log.info("Request arguments: ${props}") def subNr = props["subject_nr"] def credId = props["creditor_id"] if (subNr.empty || credId.empty) { // return HTTP 400 return "GET 400 Bad Request" } log.info("subject_nr: ${subNr}") log.info("creditor_id: ${credId}") def isSubNrMatching = subNr ==~ /^\d{10}$/ log.info("subject_nr RegEx match is: ${isSubNrMatching}") def isCredIdMatching = credId ==~ /^(ab|AB)(\d{2})([a-zA-Z]{3})(\d{8})(0{4})$/ log.info("creditor_id RegEx match is: ${isCredIdMatching}") def areReqArgsValidated = isSubNrMatching && isCredIdMatching if (!areReqArgsValidated) { // return HTTP 400 return "GET 400 Bad Request" } log.info("Request arguments validated: ${areReqArgsValidated}") // return HTTP 200 return "GET 200 OK" Now, the problem is: Main success scenario and alternative scenario a) work just fine (meaning: in both cases I get the expected response dispatched by the script). With the remaining scenarios b) and c), a response with HTTP status code 404 is dispatched instead of the scripted one (400). This response is apparently not the default 404 response I created andselected in the "Default Response" drop-down list (which features a JSON payload in the body), for its body is empty. Additionally, no log output shows up in the script (or error) log tab, showing clearly thatthe dispatch strategy script is not executed. Any clue about why is this happening? Am I missing something fundamental, due to my lack of product knowledge?Solved6.4KViews0likes16CommentsHow to retrieve a value from the request header?
Hi All, I have a service sending below request headers to my virt. I want to store the value of theoauth_callback present under Authorization header, highlighted in red and store this in a property and then use it in a subsequent response. { 'Connection': 'keep-alive', 'Accept': '*/*', 'Content-Length': '0', 'Accept-Encoding': 'gzip, deflate', 'Authorization': 'OAuth oauth_nonce="123123123123123", oauth_timestamp="12312312123", oauth_version="1.0", oauth_signature_method="HMAC-SHA1", oauth_consumer_key="XXXXXXXXXXX", oauth_callback="http%3A%2F%2Flocalhost%3YYYYYYYYY", oauth_signature="AAAAAAAAAAAA"' } How can i store this value? Using below, i am able to store the value of authorization header, however, i can'tfind a way to get theoauth_callback value. def acceptEncodingHeaderList = mockRequest.getRequestHeaders().get("Authorization") Thank You.2.9KViews0likes1CommentServiceV all responses are zipped GZIP, how to send simple content of string?
Hello, no idea why, but each response created by Groovy is put in to GZip. My client is unable to read this kind of responses. Is there any way, how to disable this zipping? My code in response is: context.mockResponse.setResponseContent("some text here - calculated by script") In ServiceV transaction log response view I can see the RAW response in readable form with this text. But in Headers is "Content-Encoding: gzip". When I catch this respnse by WireShark.. I can see, that body content is compressed.. So is correct, because my server expect this GZIP. But I want to simulate situation, when instead of compressed data I am sending simple RAW data. This is the test of configuration. So my server send request to MOCK with Encoding: gzip and I need to send non compressed response to him. Now is compressed. Please tell me, how to turn OFF this feature of ServiceV. Thank you in advance for your advice.Solved2KViews0likes1CommentServiceV Mock Response Query Match with multiple parameters
Hi, I'm looking to create a query match under the dispatch strategy to send themock responses in ServiceV PRO. Here i would my query match parameter to check multiple values rather than just one. What would be the delimiter or the syntax of OR condition? If query matches > 'a' OR 'b' OR 'c'; Send Response X If query matches > 'c' OR 'd' OR 'e'; Send ResponseY1.6KViews0likes1CommentServiceV routing
Hello Community! I have a similar case as this one:https://community.smartbear.com/t5/ReadyAPI-Feature-Requests/ServiceV-selective-routing/idi-p/106004 Initially I was asked to route the request to a virtual/real service depending on a query string value. I was able to get that done with no problem. Routing option and dispatcher made it to work as expected but now that it's set up like that I have another request. Dev Team wants me to send the request over real service and if response return a code such as 404, 500, 504 then re-route to virtual service instead. I just want to confirm if there will be a tool limitation or if is something feasible to create. To be honest I'm not even sure if Smartbear would be able to capture the reponse from the real service to eventually place the values into a dispatcher scripts. I don't want to say NO! without giving a try. Feel free to give your opinion!1.4KViews0likes1CommentSSL and SoapUI Request from my Application
I am a web developer and I have a project to do for Xerox (Cyprus). I have access to the Xerox API. The API allows for 'Mock' simulations (not requiring an actual photo copy machine). For this all of the Xerox samples use SoapUI. I am not very familiar with Soap and I have no experience with SoapUI. I can get the API calls to work using the SoapUI (I am using ReadyAPI) interface but I am facing CORS issues when I call the API from my .NET project. via javascript AJAX calls. My project uses SSL https but SoapUI uses a http connection. So, when I try to connect, I get the CORS error. I have spent several days trying to configure ReadyAPI to accept a https request from my project but with no luck. The SSL request, however, does work in the ReadyAPI application. When I run it from my app, I get the "Failed to load resource: net::ERR_CERT_AUTHORITY_INVALID" error. Perhaps I am not completely understanding how this SSL certificate works? Anyway, if you could help me solve my CORS issue, I would happily pay for your service and expertise.706Views0likes0Comments