See matching posts in thread - get parameters via x-ww...
Hi Team, I am trying to virtualize "application/x-www-form-urlencoded" REST service using request and response pair and my request data is beneficiary.given:exact=Matt&beneficiary.family:exact=Clayhews&beneficiary.birthdate=1976-08-11&service-start-date=2020-01-01&service-end-date=2020-12-31 if i add only REST data protocol, the request data arguments are not visible.
2 attachments
See matching posts in thread - virtualize application/x-...
Thanks for the update. i will create virtual service as per your suggestion.
(see VS-Develop-DPH.JPG) code for Scriptable Data Protocol DPH: %beanshell% // You can use %beanshell%, %groovy% or %javascript% or some other installed JSR-223 scripting language // This example is for beanshell import com.itko.util.ParameterList; import com.itko.util.Parameter; import java.lang.Object; import java.net.URLDecoder; ParameterList args = lisa vse request.getArguments(); ParameterList metadata = lisa vse request.getMetaData(); // Looking up parameters if (metadata.containsKey("Content-Type")) ( //int metSize = metadata.size(); String theContentType = metadata.getParameterValue("Content-Type"); if (theContentType.contains("application/x-www-form-urlencoded")) ( // Manipulate request body text String theBody = lisa vse request.getBodyText(); String[] pairs = theBody.split(" for (String pair : pairs) ( int idx = pair.indexOf("="); args.addParameter(new Parameter(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8"))); ) lisa vse request.setArguments(args); // end if (theContentType=="application/x-www-form-urlencoded") ) )
See matching library entry files - RE: virtualize application/x-...
Hi Karl, With the help of your inputs, I could see the request data arguments after creating virtual service in workstation. Ideally, for POST call, we need to have below details recorded raw request: beneficiary.given:exact=Jane&beneficiary.family:exact=DOE&beneficiary.birthdate=1966-08-10 HTTP...
This is how DevTest would see it if you did a recording because : "For application/x-www-form-urlencoded, the body of the HTTP message sent to the server is essentially one giant query string -- name/value pairs are separated by the ampersand (&), and names are separated from values by the equals symbol (=). " Also don't forget to add "HTTP/1.1" at the end of the first line in a RR Pair Request
See matching posts in thread - how to virtualise application/x...