I have to invoke a restful Web-Service from client side java class.
I need to pass HashMap, Strings and it must return me a list of beans.
I am using jersey restful web service
My REST service is like this:
@put
public List<MilestoneDetailsBean> getMPPReader(
@QueryParam("username") String username,
@QueryParam("projid") String projid,
@QueryParam("mppfile") File file,
@QueryParam("dbtemplate") Map<String,Integer> dbtemplate)
could some one help me with how could I:
- assign values to these query parameters in my client side java code
- what type of produces and consumes parameter I should put for my Web-Service
1) depends on how you create the query.
QueryParamsare those parts of an URL behind the?:?key=value&key2=value2So what you could do is to just append the keys and values to the request URL. Remember to encode the values.
Like:
http://mydomain/service?username=hage&projid=hello+world&mppfile=myfile.txtMap is not usable for this. See here
2) Dont’t know.
Producesdefinitely depends on how you want to return the data (as xml, json, etc) andConsumesdepends on what data you want to send to the serverGenerally, for the client there exists a Jersey client API. Didn’t use it yet, but you might look at it.