Announcement Announcement Module
Collapse
No announcement yet.
Exceptions in unmarshalling requests Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    had one thought: implement MessageEndpoint, copy the guts out of AbstractMarshallingPayloadEndpoint and modify the invoke method.
    Is this the only way?
    Alan

    Comment


    • #3
      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?

      Comment


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

        Comment


        • #5
          EndpointExceptionResolvers worked beautifully!

          Thanks
          Alan

          Comment

          Working...
          X