How to set HTTP response code in a JAX-WS SOAP webservice implemented as an EJB ?
In an old SunAS 9.1 + JAX-WS 2.1.6 + Sun JRE 1.6.0_18 (*1), I have an HTTP SOAP web-service implemented as an EJB endpoint. There is no output message, only the HTTP response headers.
When an exception occurs on the server side (and the message content is not properly processed), it returns an HTTP 202 (Accepted) status code to the WS client.
I am trying to handle the fault, and set an HTTP 500 error status code, so that the WS client will attempt to redeliver again later, but I am unable to do so.
I have tried several variations of code like:
messageContext.put(MessageContext.HTTP_RESPONSE_CODE, new Integer(500));
//throw new javax.xml.ws.http.HTTPException(500);
inside message handler's handleFault() and close() methods (and in the endpoint EJB), but to no success. (The SOAP WS client always gets an HTTP 202 status code).
Does anyone know of a working example of similar code ?
*1 - I know that this software is very old, but I get the same dificulty on a GlassFish 3.1.1 + JAX-WS RI 2.2.4
PS: In JAX-WS changelog (Changes from JAX-WS RI 2.1.4 to JAX-WS RI 2.1.5) it says "Allowing HTTP response code to be set via MessageContext property", so someone out there must know how to make it work. :-)