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