Package feign.soap

Class SOAPEncoder

  • All Implemented Interfaces:
    feign.codec.Encoder

    public class SOAPEncoder
    extends java.lang.Object
    implements feign.codec.Encoder
    Encodes requests using SOAPMessage and JAXB for the body part.

    Basic example with with Feign.Builder:

     
     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()
         .encoder(new SOAPEncoder(jaxbFactory))
         .target(MyApi.class, "http://api");
         
     ...
    
     try {
        api.getObject(new MyJaxbObjectRequest());
     } catch (SOAPFaultException faultException) {
        log.info(faultException.getFault().getFaultString());
     }
     

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

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  SOAPEncoder.Builder
      Creates instances of SOAPEncoder.
      • Nested classes/interfaces inherited from interface feign.codec.Encoder

        feign.codec.Encoder.Default
    • Field Summary

      • Fields inherited from interface feign.codec.Encoder

        MAP_STRING_WILDCARD
    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void encode​(java.lang.Object object, java.lang.reflect.Type bodyType, feign.RequestTemplate template)  
      • Methods inherited from class java.lang.Object

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

      • SOAPEncoder

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

      • encode

        public void encode​(java.lang.Object object,
                           java.lang.reflect.Type bodyType,
                           feign.RequestTemplate template)
        Specified by:
        encode in interface feign.codec.Encoder