Package feign.soap

Class SOAPDecoder

  • All Implemented Interfaces:
    feign.codec.Decoder

    public class SOAPDecoder
    extends java.lang.Object
    implements feign.codec.Decoder
    Decodes SOAP responses using SOAPMessage and JAXB for the body part.

    The JAXBContextFactory should be reused across requests as it caches the created JAXB contexts.

    A SOAP Fault can be returned with a 200 HTTP code. Hence, faults could be handled with no error on the HTTP layer. In this case, you'll certainly have to catch SOAPFaultException to get fault from your API client service. In the other case (Faults are returned with 4xx or 5xx HTTP error code), you may use SOAPErrorDecoder in your API configuration.

    
     public interface MyApi {
    
        @RequestLine("POST /getObject")
        @Headers({
          "SOAPAction: getObject",
          "Content-Type: text/xml"
        })
        MyJaxbObjectResponse getObject(MyJaxbObjectRequest request);
    
     }
    
     ...
    
     JAXBContextFactory jaxbFactory = new JAXBContextFactory.Builder()
         .withMarshallerJAXBEncoding("UTF-8")
         .withMarshallerSchemaLocation("http://apihost http://apihost/schema.xsd")
         .build();
    
     api = Feign.builder()
         .decoder(new SOAPDecoder(jaxbFactory))
         .target(MyApi.class, "http://api");
    
     ...
    
     try {
        api.getObject(new MyJaxbObjectRequest());
     } catch (SOAPFaultException faultException) {
        log.info(faultException.getFault().getFaultString());
     }
     

    See Also:
    SOAPErrorDecoder, SOAPFaultException
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  SOAPDecoder.Builder  
      • Nested classes/interfaces inherited from interface feign.codec.Decoder

        feign.codec.Decoder.Default
    • Constructor Summary

      Constructors 
      Constructor Description
      SOAPDecoder​(feign.jaxb.JAXBContextFactory jaxbContextFactory)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object decode​(feign.Response response, java.lang.reflect.Type type)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SOAPDecoder

        public SOAPDecoder​(feign.jaxb.JAXBContextFactory jaxbContextFactory)
    • Method Detail

      • decode

        public java.lang.Object decode​(feign.Response response,
                                       java.lang.reflect.Type type)
                                throws java.io.IOException
        Specified by:
        decode in interface feign.codec.Decoder
        Throws:
        java.io.IOException