spring-ws icon indicating copy to clipboard operation
spring-ws copied to clipboard

Automatically unmarshal soap faults with WebServiceTemplate [SWS-531]

Open gregturn opened this issue 16 years ago • 4 comments

Kenny MacLeod opened SWS-531 and commented

If I call WebServiceTemplate.marshalSendAndReceive, and the server throws a fault, you currently have to catch the WebServiceClientException, extract the fault detail, and then manually unmarshal the fault elements.

It would be great if this was done for you. We're using marshalSendAndReceive, and so we already know we have a marshaller available.


Affects: 1.5.7

Attachments:

6 votes, 3 watchers

gregturn avatar Jun 18 '09 03:06 gregturn

Kenny MacLeod commented

I should have mentioned that these soap faults have been generated by a Spring-WS server, using JAXB-generated Fault POJOs. The server has marshalled these POJOs into the SOAP fault, and the client now needs to unmarshal them.

gregturn avatar Jun 18 '09 03:06 gregturn

Kenny MacLeod commented

See attached FaultUnmarshallingWebServiceTemplate.java as an illustration of what I'm talking about. The new functionality of this subclass could be rolled into WebServiceTemplate itself.

One thing I'm unsure of is maintaining backwards compatibility with existing users of WebServiceTemplate. I suspect the best option is to have a boolean property of WebServiceTemplate (defaulting to false) which instructs it whether or not to attempt to unmarshal the fault detail.

gregturn avatar Jun 22 '09 00:06 gregturn

Lukasz Antoniak commented

I agree with Mr MacLeod. However my solution would be to override hasFault WebServiceTemplate's method, so that it recognizes soap fault message. Then a user defined FaultMessageResolver could handle fault object. Of course Spring-WS could provide an AbstractFaultMessageResolver that already unmarshals soap fault.

gregturn avatar Oct 10 '10 06:10 gregturn

Was this ever solved?

mcahornsirup avatar Apr 13 '21 08:04 mcahornsirup