Announcement Announcement Module
Collapse
No announcement yet.
Spring Web Service Client Fault Handling Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Web Service Client Fault Handling

    Hey All,

    I have written a web service client (using Java Spring and JAXB Marshaller) that works with the UPS web service. When I send a valid request everything works well. When I send an invalid request (weight > 150 lbs) then the UPS web service responds with a SOAP Fault. The client application just fails with a UnmarshallingFailureException

    Code:
    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 isn't able to decipher the SOAP fault returned by the web service. I wrote a custom FaultMessageResolver, but it doesn't get invoked. Here's the code:

    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");   
            }
        }
    }
    Thanks,
    joe

  • #2
    I got exactly the same issue after 5 years !!! Anyone got any idea how to resolve the issue?

    Comment


    • #3
      There is need to see that Fault message (XML) and full StackTrace

      Comment

      Working...
      X