Server code,
Client code,
To obtain a general map of parameter names and values for query and path parameters, use the following code:
@Path("/hello")
public class HelloResource {
@GET
public Response helloGet(@javax.ws.rs.CookieParam("username") String username) {
return Response.ok("[GET] Hello "+username+" from JAX-RS on WebSphere Application server")
.cookie(new NewCookie("key","value"))
.build();
}
}
Client code,
String lsUrl = "http://localhost:9080/RSServer/HelloApp/hello";
RestClient client = new RestClient();
Resource resource = client.resource(lsUrl);
ClientResponse result = resource.contentType(MediaType.TEXT_PLAIN).cookie(new Cookie("username", "John")).get();
System.out.println(result.getEntity(String.class));
To obtain a general map of parameter names and values for query and path parameters, use the following code:
@GET
public String get(@Context UriInfo ui) {
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
MultivaluedMap<String, String> pathParams = ui.getPathParameters();
}
No comments:
Post a Comment