user447607
user447607

Reputation: 5469

In a Spring WS, how can I handle SaajSoapEnvelopeException and get a copy of the SOAP after an exception?

That is "After and only After" an Exception since I've been told to get it up front is a performance hit we don't want because that would be for each and every call rather than just for an Exception. Makes sense of course but I sure don't see how it can be done AFTER an Exception.

Use case goes like this: Some guys, perhaps bad guys, send us some bad SOAP and the dispatcher chucks out a SaajSoapEnvelopeException. How do I handle this gracefully?

So far what I have is an extension of MessageDispatcherServlet with an override of the doService() method. The web.xml file has been updated to show this Dispatcher for Spring's config. Within this override, surround the call to the super method with a try/catch and you catch the Exception but the problem here is that the stream for the HttpServletRequest is already closed, so you can't get the SOAP from here, AFIK.

Another problem is that I can't get a marshaller to wire in here. I have Java faults generated from our WSDL I would like to use but I think there is a problem with wiring marshallers in a non-endpoint class. Perhaps something about the namespace? I probably need to read up on how these work.

Bottum line: Is it possible to get the SOAP after an Exception or is it possible to predict that there will be an Exception so that I can grab it up front? Also, how can I get a fault marshaller into this Dispatcher or will I have to BS up a text version of the fault?

I'm fairly new to Web Services and what I know so far is mostly CXF. So far, I'm not much impressed with Spring WS. They have a long ways to go yet, IMHO. The fact that I can't get my WSDL from the service due to a known bug having to do with XSD references in WSDL not getting properly renamed to match the bean, is particularly annoying.

Upvotes: 0

Views: 298

Answers (1)

evandongen
evandongen

Reputation: 2065

Have you tried a EndpointExceptionResolver? For instance, I have used one to catch and translate authentication exceptions.

You'll probably need an EndpointInterceptor as well to wrap the exception resolver.

Upvotes: 0

Related Questions