Suppose we have a webservice request we don’t even want to dignify with a response:
@WebMethod(operationName = "doSomethingForNicePeopleOnly")
public String doSomethingForNicePeopleOnly(@WebParam(name="username") String user) {
if (userIsNice(user)) {
return "something nice";
} else {
// I'd prefer not to return anything at all, not even a 404...
}
}
What is the best technique for not responding to a given Java webservice request?
Why return nothing at all? That just forces your connection to stay open until it times out, wasting both your server’s time and the user’s.
I don’t know how easy this is to do in Java web services, but can you return 202 (“Accepted” but processing not complete, and may be rejected silently later) or 204 (“No response”) maybe?