Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-925

WebServiceTemplate doesn't correctly handle fault for a non-500 http status response


    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 2.2.0.RELEASE, 2.2.1, 2.3.0, 3.0.0.RC1, 2.2.2
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
    • Environment:
      Java 7


      WebServiceTemplate doesn't correctly handle faults on a non-500 http status response. If you look at the handleFault method in WebServiceTemplate on line 740 - the method returns false if the connection does not have a fault (500 http status). In our scenario, the response comes back as a 200 but inside the soap message there is a fault. Lines 743-746 never get executed, which would have caught the fault in the soap message and would have made the handleFault method return true, which then kicks in the appropriate faultMessageResolver from the doSendAndReceive method (lines 613-621). Because of this the if statement on line 613 returns true and the responseExtractor tries to extract the data but gets Unmarshalling exceptions. Instead in this situation hasFault should return true and therefore the else block (lines 619-621) should kick in.

      I've had to create a workaround by extending WebServiceTemplate like this:

      public class FixedWebServiceTemplate extends WebServiceTemplate {
      public FixedWebServiceTemplate(WebServiceMessageSender messageSender, WebServiceMessageFactory messageFactory, ClientInterceptor interceptor) {

      setInterceptors(new ClientInterceptor[]

      { new CustomClientInterceptor(), interceptor }

      setFaultMessageResolver(new SoapFaultMessageResolver());

      protected boolean hasFault(WebServiceConnection connection, WebServiceMessage response) throws IOException

      { boolean hasFault = super.hasFault(connection, response); // Underlying logic is flawed in my opinion - it doesn't handle the case where the response is a 200 but the // response payload contains a soap fault return (!hasFault && (response instanceof FaultAwareWebServiceMessage)) ? ((FaultAwareWebServiceMessage) response).hasFault() : hasFault; }





            • Assignee:
              edeandrea Eric Deandrea
            • Votes:
              0 Vote for this issue
              4 Start watching this issue


              • Created: