title: How to make JAX-WS webservice respond with specific http code
body: <p>Just like the title says.</p>
  
  <pre><code>    @WebService(
          targetNamespace = "http://com.lalaland.TestWs",
          portName = "TestWs",
          serviceName = "TestWs")
  public class TestWs implements TestWsInterface {
  
      @EJB(name="validator")
      private ValidatorLocal validator;
  
      @WebMethod(operationName = "getStuff")
      public List&lt;StuffItem&gt; getStuff(@WebParam(name = "aaa")String aaa, 
                          @WebParam(name = "bbb")int bbb )  {
  
            if ( ! validator.check1(...) ) 
                 return HTTP code 403        &lt;------------ Here
            if ( ! validator.check2(...) )
                 return HTTP code 404        &lt;------------ Here
            if ( ! validator.check3(...) ) 
                 return HTTP code 499        &lt;------------ Here
  
            return good list of Stuff Items
  
      }
  </code></pre>
  
  <p>Is there anyway I can make a method return a specific HTTP code on demand? I know that some of the stuff, like authentication, internal server errors , etc  make the the WS method return 500 and auth errors , but I would like to be able to send these in accordance with by business logic.</p>
  
  <p>Anyone done this before? Been using jax-WS for some time and this was the first time I had this need, tried searching for it and couldn't find an answer anywhere.</p>
  
  <p>Thanks</p>