Results 1 to 5 of 5

Thread: Exceptions in unmarshalling requests

  1. #1
    Join Date
    Dec 2005
    Posts
    935

    Default Exceptions in unmarshalling requests

    I have endpoints which handle various messages with different rootQNames. I have extended in each case the AbstractMarshallingPayloadEndpoint and send back a corresponding response message in the invokeInternal() method - all works well when the messages are unmarshalled correctly.

    However, I still need to send a response message back to the client even if an unmarshalling exception is thrown, and the response message must be specific the request, for example, if a <Foo ...> message comes in, the client is expecting a <FooResponse ... > message to come back regardless of any errors. Thus if a request message is well-formed, but an extraneous or mispelled attribute is included and a unmarshalling exception is thrown, I still need to the code in the invokeInternal method to be called to send a response, but currently the org.springframework.oxm.jibx.JibxUnmarshallingFail ureException I am getting prevents invokeInternal from being called.

    I thought about using onUnmarshalRequest, but this gets called after the message has attempted to be unmarshalled. The exception is already thrown at this point, according to the code in the invoke method of AbstractMarshallingPayloadEndpoint:
    Code:
        public final void invoke(MessageContext messageContext) throws Exception {
            WebServiceMessage request = messageContext.getRequest();
            Object requestObject = unmarshalRequest(request);
            if (onUnmarshalRequest(messageContext, requestObject)) {
                Object responseObject = invokeInternal(requestObject);
                if (responseObject != null) {
                    WebServiceMessage response = messageContext.getResponse();
                    marshalResponse(responseObject, response);
                    onMarshalResponse(messageContext, requestObject, responseObject);
                }
            }
        }
    How can I solve this problem?
    Thanks
    Alan

  2. #2
    Join Date
    Dec 2005
    Posts
    935

    Default

    had one thought: implement MessageEndpoint, copy the guts out of AbstractMarshallingPayloadEndpoint and modify the invoke method.
    Is this the only way?
    Alan

  3. #3

    Default

    You could also implement an EndpointExceptionResolver (or subclass one of the provided implementations). The resolveException method gives you access to the message context (hence the request and the response objects), the endpoint and the cause exception.
    Thus, your exception-handling logic will be reusable and you won't have to copy AbstractMarshallingPayloadEndpoint.
    Would that work for you?
    Tareq Abedrabbo

    My Twitter
    My Blog

  4. #4
    Join Date
    Dec 2005
    Posts
    935

    Default

    I wasn't aware of this feature - will try it (when I get into the office tomorrow)
    Thanks
    Alan

  5. #5
    Join Date
    Dec 2005
    Posts
    935

    Default

    EndpointExceptionResolvers worked beautifully!

    Thanks
    Alan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •