Package feign.soap
Class SOAPDecoder
- java.lang.Object
-
- feign.soap.SOAPDecoder
-
- All Implemented Interfaces:
feign.codec.Decoder
public class SOAPDecoder extends 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
SOAPFaultExceptionto get fault from your API client service. In the other case (Faults are returned with 4xx or 5xx HTTP error code), you may useSOAPErrorDecoderin 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 classSOAPDecoder.Builder
-
Constructor Summary
Constructors Constructor Description SOAPDecoder(feign.jaxb.JAXBContextFactory jaxbContextFactory)
-
-
-
Method Detail
-
decode
public Object decode(feign.Response response, Type type) throws IOException
- Specified by:
decodein interfacefeign.codec.Decoder- Throws:
IOException
-
-