web services - Java Rest webservice with bad queryparam -


i have below web service method,

@get @produces({ "application/xml", "application/json" }) @path("/service/salesorder/{identifier}/{ordertype}") public response readorder(@pathparam("identifier") string identifier,                           @pathparam("ordertype") string ordertype);  

if user calls below correct url, want service work fine, if 1 calls bad url (extra query param), not defined in method, want throw error, how can catch bad urls?

correct url : http://myapp.com/service/salesorder/123/shoppingorder

bad url : http://myapp.com/service/salesorder/123/shoppingorder&badparam

addionial should inject @context method parameter:

public response readorder(@pathparam("identifier") string identifier,                           @pathparam("ordertype") string ordertype,                           @context httpservletrequest req);  

and check servlet api httpservletrequest#getparameternames() if query parameter given.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -