uCosminexus Application Server, Web Service Development Guide

[Contents][Glossary][Index][Back][Next]

36.5.1 Processing of the handleMessage method

This subsection describes the processing when the handleMessage method returns true, returns false, and throws an exception.

Organization of this subsection
(1) When the method returns true
(2) When the method returns false
(3) When the method throws the ProtocolException or a sub-class
(4) When the method throws other runtime exceptions

(1) When the method returns true

When the handleMessage method returns true, the JAX-WS engine processes the handler in the same direction as the currently running direction. If there are no more handlers, the messages are distributed.

The following figure shows the flow of request processing:

Figure 36-4 Processing when the handleMessage method returns true (request)

[Figure]

The following figure shows the flow of response processing:

Figure 36-5 Processing when the handleMessage method returns true (response)

[Figure]

(2) When the method returns false

When the handleMessage method that is processing the request message returns false, the JAX-WS engine reverses the direction of the message and handler processing, and invokes the handleMessage method of the previous handler. If there are no more handlers, the messages are distributed.

The following figure shows the flow when handler 2 returns false during request processing:

Figure 36-6 Processing when the handleMessage method returns false (request)

[Figure]

The JAX-WS engine does not change the message set in the message context. Therefore, the request messages are distributed to the Web Service client as is. In the Web Service client where the intended response messages were not distributed, the javax.xml.ws.WebServiceException is thrown.

When the handleMessage method that processes the response message returns false, the direction of the message does not change. However, all the subsequent handlers are omitted and the messages are distributed.

The following figure shows the flow when handler 2 returns false during response processing:

Figure 36-7 Processing when the handleMessage method returns false (response)

[Figure]

(3) When the method throws the ProtocolException or a sub-class

When the handleMessage method that processes the request message throws the ProtocolException or a sub-class, the JAX-WS engine reverses the direction of the message and handler processing, and invokes the handleFault method of the previous handler. If there are no more handlers, the messages are distributed.

The following figure shows the flow when handler 2 throws the ProtocolException during request processing:

Figure 36-8 Processing when handleMessage throws the ProtocolException (request)

[Figure]

The JAX-WS engine generates and propagates the fault message. The following table lists and describes the generated messages that differ depending on SOAP versions:

Table 36-2 Faultmessages generated by the JAXWS engine (ProtocolException throw/ request)

Version Fault message
SOAP 1.1 specification In the Web Service client faultcode is QName soapenv:Client
In the Web Service faultcode is QName soapenv:Server
SOAP 1.2 specification In the Web Service client soapenv12:Code is QName soapenv12:Sender
In the Web Service soapenv12:Code is QName soapenv12:Receiver

When the handleMessage method that is processing the response message throws the ProtocolException or a sub-class, the direction of the message does not change. However, all the subsequent handlers are omitted and the exception is thrown as is.

The following figure shows the flow when handler 2 throws the ProtocolException during response processing:

Figure 36-9 Processing when handleMessage throws the ProtocolException (response)

[Figure]

In the Web Service, the JAX-WS engine converts the exception into a SOAP fault and sends the fault. For details about the fault message conversion, see 10.4.1(2) Runtime exception binding.

(4) When the method throws other runtime exceptions

When the handleMessage method that is processing the request message throws other runtime exceptions, the JAX-WS engine reverses the direction of the message and handler processing. The JAX-WS engine also omits all the subsequent handlers and throws the exception as is.

The following figure shows the flow when handler 2 throws the RuntimeException during request processing:

Figure 36-10 Processing when handleMessage throws RuntimeException (request)

[Figure]

In the Web Service, the JAX-WS engine converts the exception into a SOAP fault and sends the fault. For details about the fault message conversion, see the subsection 10.4.1(2) Runtime exception binding.

In the Web Service client, the JAX-WS engine wraps the exception with javax.xml.ws.WebServiceException and throws WebServiceException.

When the handleMessage method that is processing the response message throws a runtime exception, the direction of the message does not change. However, all the subsequent handlers are omitted and the messages are distributed.

The following figure shows the flow when handler 2 throws the RuntimeException during response processing:

Figure 36-11 Processing when handleMessage throws RuntimeException (response)

[Figure]

In the Web Service, the JAX-WS engine converts the exception into a SOAP fault and sends the fault. For details about the fault message conversion, see the subsection 10.4.1(2) Runtime exception binding.

In the Web Service client, the JAX-WS engine wraps the exception with javax.xml.ws.WebServiceException and throws WebServiceException.