Java Spring Web Service Client Error Handling

I wrote a web service client (using Java Spring and JAXB Marshaller) that works with the UPS web service. When I submit a valid request, everything works well. When I send an invalid request (weigh> 150 pounds), the UPS web service responds with a SOAP error. The client application simply fails with

org.springframework.oxm.UnmarshallingFailureException: JAXB unmarshalling 
exception; nested exception is javax.xml.bind.UnmarshalException: 
unexpected element (uri:"http://schemas.xmlsoap.org/soap/envelope/", local:"Fault").

Obviously, my program is not able to decrypt the SOAP error returned by the web service. I wrote a custom FaultMessageResolver, but it is not called. Here is the code:

public class UpsRateClient extends WebServiceGatewaySupport {
    public UpsRateClient(WebServiceMessageFactory messageFactory) {
        super(messageFactory);
        getWebServiceTemplate().setFaultMessageResolver(new UpsFaultMessageResolver());
    }

    public RateResponse getRate(RateRequest rateRequest) {
        return (RateResponse) getWebServiceTemplate().marshalSendAndReceive(rateRequest, new UpsRequestWSMC());
    }
    private class UpsFaultMessageResolver implements FaultMessageResolver {
        public void resolveFault(WebServiceMessage message) throws IOException{
            System.out.println("Inside UpsFaultMessageResolver");   
        }
    }
}

Thank you for your time!

+5
source share
2 answers

. , - SOAP-, () HTTP 200OK 500 Internal Server error, .
, -, SOAP ( ):
SOAP RFC

SOAP SOAP HTTP HTTP 500 " " SOAP- , SOAP Fault (. 4.4), SOAP.

-, . , , Spring -WS.
Jax-Ws, Dispatcher, xml /demarhal.
Spring -Ws, , -,

+4

( SOAP HTTP 200OK), CheckConnectionForFault false. ..

+4

All Articles