>
> -------- Original Message --------
> Subject: Service error handling
> Date: Fri, 24 Feb 2006 12:00:41 +0100
> From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
> Reply-To: dev_at_jax-ws.dev.java.net
> To: dev_at_jax-ws.dev.java.net
>
>
>
> Hi,
>
> I'm looking for implementation of Http transport on server side and
> specifically class com.sun.xml.ws.transport.http.HttpAdapter and its
> inner class HttpToolkit.
>
> I have one question, how good is solution to send error code using
> http status.
> ........................
> try {
> packet =
> head.process(packet,con.getWebServiceContextDelegate(),this);
> } catch(Exception e) {
> e.printStackTrace();
> if (!closed) {
> writeInternalServerError(con);
> }
> return;
> }
> .........................
> I found if essentially service implementation method throws exception
> - then it is caught and fail message is created and sent back, but if
> some other error occurs on server not in service implementation
> method, then just http status sets as error.
> Is it correct way? Don't we need to send fail message in any case?
If you see WSEndpointImpl code, process() catches almost all the
implementation errors in the Pipeline and converts to SOAP Fault
messages. If there is an error between process() and sending it on the
HTTP response stream, it is just returned as InternalServerError. We
don't want to put too much burden on the transport to convert exception
to correct message based on the binding. This way, writing transports
will be easy. Ideally, we shouldn't expect errors in the JAXWS runtime
!! Let us know what you think.
public PipeHead createPipeHead() {
public Packet process(Packet request,
WebServiceContextDelegate wscd, TransportBackChannel tbc) {
...
Packet response;
try {
response = pipe.process(request);
} catch (RuntimeException re) {
// Catch all runtime exceptions so that transport
doesn't
// have to worry about converting to wire message
// TODO XML/HTTP binding
re.printStackTrace();
Message faultMsg =
SOAPFaultBuilder.createSOAPFaultMessage(
soapVersion, null, re);
response = new Packet(faultMsg);
}
return response;
}
};
}
Thanks,
Jitu
Thanks.
WBR,
Alexey.