Client client = ClientBuilder.newClient(); WebTarget target = client.target("http://localhost:8080").path("/method"); Response response = target.request(MediaType.APPLICATION_XML) .post(Entity.entity(entityInstance, MediaType.APPLICATION_XML)); System.out.println(response.getStatus()); System.out.println(response.readEntity(String.class));
<dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> <version>2.4.1</version> </dependency>