Skip to content

Instantly share code, notes, and snippets.

@KomanRudden
Created July 15, 2015 07:42
Show Gist options
  • Save KomanRudden/eaa5df24c96b7c1b345f to your computer and use it in GitHub Desktop.
Save KomanRudden/eaa5df24c96b7c1b345f to your computer and use it in GitHub Desktop.
Apache CXF JAX-RS Client
List<JacksonJsonProvider> providers = new ArrayList<>();
JacksonJsonProvider provider = new JacksonJsonProvider();
provider.addUntouchable(Response.class);
providers.add(provider);
WebClient client = WebClient.create("http://<hostname>/path/to/service", providers);
client.type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON);
client.post(myCustomDTO);
//MyCustomDTO will be an object (basic POJO) that can be JSON'd as required
<--Maven Dependencies-->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.0.0-milestone1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.5.4</version>
</dependency>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment