@Override
  public void encode(Object object, Type bodyType, RequestTemplate template) {
    if (!(bodyType instanceof Class)) {
      throw new UnsupportedOperationException(
          "JAXB only supports encoding raw types. Found " + bodyType);
    }
    try {
      Marshaller marshaller = jaxbContextFactory.createMarshaller((Class<?>) bodyType);
      StringWriter stringWriter = new StringWriter();
      marshaller.marshal(object, stringWriter);
      template.body(stringWriter.toString());
    } catch (JAXBException e) {
      throw new EncodeException(e.toString(), e);
    }
  }
Encodes requests using JAXB. <br>

<p>Basic example with with Feign.Builder:

<pre>
JAXBContextFactory jaxbFactory = new JAXBContextFactory.Builder()
    .withMarshallerJAXBEncoding("UTF-8")
    .withMarshallerSchemaLocation("http://apihost http://apihost/schema.xsd")
    .build();

api = Feign.builder()
    .encoder(new JAXBEncoder(jaxbFactory))
    .target(MyApi.class, "http://api");
</pre>

<p>The JAXBContextFactory should be reused across requests as it caches the created JAXB
contexts.
jaxb/src/main/java/feign/jaxb/JAXBEncoder.java