public class SOAPEncoder extends Object implements Encoder
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.
Modifier and Type | Class and Description |
---|---|
static class |
SOAPEncoder.Builder
Creates instances of
SOAPEncoder . |
Encoder.Default
MAP_STRING_WILDCARD
Constructor and Description |
---|
SOAPEncoder(JAXBContextFactory jaxbContextFactory) |
Modifier and Type | Method and Description |
---|---|
void |
encode(Object object,
Type bodyType,
RequestTemplate template) |
public SOAPEncoder(JAXBContextFactory jaxbContextFactory)
public void encode(Object object, Type bodyType, RequestTemplate template)
Copyright © 2012–2021 OpenFeign. All rights reserved.