public class SOAPDecoder extends Object implements Decoder
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()); }
SOAPErrorDecoder
,
SOAPFaultException
Modifier and Type | Class and Description |
---|---|
static class |
SOAPDecoder.Builder |
Decoder.Default
Constructor and Description |
---|
SOAPDecoder(JAXBContextFactory jaxbContextFactory) |
public SOAPDecoder(JAXBContextFactory jaxbContextFactory)
public Object decode(Response response, Type type) throws IOException
decode
in interface Decoder
IOException
Copyright © 2012–2019 OpenFeign. All rights reserved.