rest client request with same param and multiple values - rest

I'm using Jersey 1.x rest client.
I need to do a GET request passing a param multiple times.
Using
com.sun.jersey.api.client.WebResource.queryParams(MultivaluedMap<String, String> params)
I can achieve what I want. But.
the generated url is something like
http://blablabla?foo=value1&foo=value2&foo=value3
is there a way to tell jersey I want to set the parameters in this way?
http://blablabla?foo[0]=value1&foo[1]=value2&foo[2]=value3

Related

pollerName() cannot accept a param like " ${id}"

I want to fetch information by call an API with an unique param doc,pollerName. But I don't know why the pollerName() didn't accept param like "${id}",I was trying pollerName(Random.nextInt(999)),but the Random result always the same, so is there any other solutions?
.foreach("${idList}","id"){
polling.pollerName("${id}").exec(some exec)
}
looking at the implementation of pollerName (in gatling 3.1), it takes a String and not an Expression[String] which would enable the use of values from the gatling session.
So I don't think gatling supports what you want

How to call REST service by setting Matrix Params using Camel-Http4 component?

I have a problem trying to use Camel-http4 component. What I want to do is to set from my camel route the Matrix Params that the REST service needs to work properly. Is there any way to do that?
Thank you,
Roxana
Using traditional query parameters, the Camel URI looks as follows:
from("direct:start")
.to("http4://oldhost?order=123&detail=short");
Thus, using matrix parameters should work as well:
from("direct:start")
.to("http4://oldhost;order=123;detail=short");
Edit:
Use Exchange.HTTP_URI for dynamically setting the properties or use recipientList such as:
from("direct:start")
.recipientList(simple("http4://oldhost;order=${header.123Header};detail={{value.from.cfg}}"));

WSO2 Getting POST PUT DELETE REST parameters

Is there a way to get the parameters set in a post-delete-put REST request? in a proxy or programmatically developing a mediator (i mean in the MessageContext object passed to the mediate method)?
I know that parameters are appended to the url in a GET request e they appear by
getProperty("REST_URL_POSTFIX");
What about the other CRUD commands?
To get programatically, you can retrive those details from Axis2 messagecontext.
HttpServletRequest obj = (HttpServletRequest)
msgContext.getProperty("transport.http.servletRequest");
System.out.println("Method :" + obj.getMethod());
Here is a detail post

Integrate AngularJS App with SoftwareAG webMethods Integration Server

I have been trying to set up a sample AngularJS app with webMethods Integration Server on the backend. Using $resource, I can easily pull normal JSON files and manipulate the data within the file. However, the goal is that I want to create services in webMethods Designer and call them from AngularJS using $resource to display the data in my app. The problem is that from AngularJS I cannot extract the data I need from the service that I'm creating in Designer. In Designer I can use (in WMPublic) documentToJSONString, and output something like:
jsonString {"id":"1", "name":"Dan", "quantity":"3"}
But I cannot extract the data because this is not a pure JSON string. Does anyone know how to (1) extract the JSON string output data using AnularJS or (2) output a JSON document from Designer? I am calling a REST service; something to the effect of
http://localhost:2222/rest/Get/getOrderData
from my services.js file in AngularJS.
Here is my services.js file:
/* Services */
var orderServices = angular.module('orderServices', ['ngResource']);
orderServices.factory('Order', ['$resource',
function($resource){
return $resource('http://localhost:2222/rest/REST/getOrderData', {}, {
query: {method:'GET', isArray:true}
});
}]);
Then, in my app, I want to use an ng-repeat to call things like {{order.id}}, {{order.name}} etc. Is anyone good with webMethods and Angular or done this before?
To force the response that you want, I would have used the service
pub.flow:setResponse mapping the jsonString to it's string parameter and probably hardcoded (eww!) the contentType parameter to 'application/json'
You may also need to use the service pub.flow:setResponseCode to set the response code.
They would be the last services in getOrderData
I would have invoked it using the below (where namespace is the folder structure in designer)
http://localhost:2222/invoke/namespace:getOrderData
The above applies to Integration Server V8 and it looks like you're using V9 since some of the services that you mention didn't exist in V8. This would also apply to a normal flow service, not a specific REST one (assuming they exist in V9).

http delete with REST

I am currently using Jersey Framework (JAX-RS implementation) for building RESTful Web Services. The Resource classes in the project have implemented the standard HTTP operations - GET,POST & DELETE. I am trying to figure out how to send request parameters from client to these methods.
For GET it would be in the query string(extract using #QueryParam) and POST would be name/value pair list (extract using #FormParam) sent in with the request body. I tested them using HTTPClient and worked fine. For DELETE operation, I am not finding any conclusive answers on the parameter type/format. Does DELETE operation receive parameters in the query string(extract using #QueryParam) or in the body(extract using #FormParam)?
In most DELETE examples on the web, I observe the use of #PathParam annotation for parameter extraction(this would be from the query string again).
Is this the correct way of passing parameters to the DELETE method? I just want to be careful here so that I am not violating any REST principles.
Yes, its up to you, but as I get REST ideology, DELETE URL should delete something that is returned by a GET URL request. For example, if
GET http://server/app/item/45678
returns item with id 45678,
DELETE http://server/app/item/45678
should delete it.
Thus, I think it is better to use PathParam than QueryParam, when QueryParam can be used to control some aspects of work.
DELETE http://server/app/item/45678?wipeData=true
The DELETE method should use the URL to identify the resource to delete. This means you can use either path parameters or query parameters.
Beyond that, there is no right and wrong way to construct an URL as far as REST is concerned.
You can use like this
URL is http://yourapp/person/personid
#DELETE
#Path("/person/{id}")
#Produces(MediaType.APPLICATION_JSON)
public Response deletePerson(#PathParam("id") String id){
Result result = new Result();
try{
persenService.deletePerson(id);
result.setResponce("success");
}
catch (Exception e){
result.setResponce("fail");
e.printStackTrace();
}
return Response.status(200).entity(result).build();
}
#QueryParam would be the correct way. #PathParam is only for things before any url parameters (stuff after the '?'). And #FormParam is only for submitted web forms that have the form content type.