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
Post a Comment