8000 feign/jaxb at 7.x · dragonforce2010/feign · GitHub < 8000 meta name="turbo-body-classes" content="logged-out env-production page-responsive">
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

JAXB Codec

This module adds support for encoding and decoding XML via JAXB.

Add JAXBEncoder and/or JAXBDecoder to your Feign.Builder like so:

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

Response response = Feign.builder()
                         .encoder(new JAXBEncoder(jaxbFactory))
                         .decoder(new JAXBDecoder(jaxbFactory))
                         .target(Response.class, "https://apihost");

Alternatively, you can add the encoder and decoder to your Dagger object graph using the provided JAXBModule like so:

JAXBContextFactory jaxbFactory = new JAXBContextFactory.Builder().build();

Response response = Feign.create(Response.class, "https://apihost", new JAXBModule(jaxbFactory));
0