Package feign.soap
Class SOAPEncoder
- java.lang.Object
-
- feign.soap.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 ofSOAPEncoder
.
-
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)
-