Forum Discussion
mvnarendra
7 years agoOccasional Contributor
Answering my own question.
I have used below code to set query params to REST request.
String targetQueryString = "";
if (mockRequest.getHttpRequest().getQueryString() != null) {
targetQueryString = mockRequest.getHttpRequest().getQueryString();
}
Project project = new WsdlProject();
RestServiceConfig serviceConfig = RestServiceConfig.Factory.newInstance();
RestService service = new RestService((WsdlProject) project, serviceConfig);
RestResourceConfig resourceConfig = RestResourceConfig.Factory.newInstance();
RestResource resource = new RestResource(service, resourceConfig);
RestMethodConfig methodConfig = RestMethodConfig.Factory.newInstance();
RestMethod restMethod = new RestMethod(resource, methodConfig);
RestRequestConfig requestConfig = RestRequestConfig.Factory.newInstance();
RestRequest restRequest = new RestRequest(restMethod, requestConfig, false);
if (targetQueryString.length() > 0) {
for (String param : targetQueryString.split("&")) {
restMethod.setPropertyValue(param.split("=")[0], param.split("=")[1]);
}
}
Related Content
- 2 years ago
- 4 years ago
- 5 years ago
- 7 years ago
Recent Discussions
- 15 years ago