jersey-client

Jersey version issue: MessageBodyReader not found for media type=application/xml

▼魔方 西西 提交于 2019-11-30 11:33:14
While writing a simple Jersey client that was consuming XML data, I came across this exception "MessageBodyReader not found for media type=application/xml". All of my settings, including the jersey-client as maven dependencies was just fine. The version that I was using was 2.17. Once I degraded the version to 2.15 it started working fine. Can anyone explain what dependencies that needs to be included for version 2.17 to work. Maven Dependency (works on 2.15 and lower) <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> <version>${jersey.version}<

PATCH request using Jersey Client

孤人 提交于 2019-11-30 04:51:47
I want to execute a PATCH request supported by our server for testing using Jersey client. My code is as below, but I get com.sun.jersey.api.client.ClientHandlerException: java.net.ProtocolException: HTTP method PATCH doesn't support output exception. Can someone let me know whats wrong with the code below? String complete_url = "http://localhost:8080/api/request"; String request = "[{\"op\":\"add\", \"path\":\"/name\", \"value\":\"Hello\"}]"; DefaultClientConfig config = new DefaultClientConfig(); config.getProperties().put(URLConnectionClientHandler.PROPERTY_HTTP_URL_CONNECTION_SET_METHOD

jersey - StreamingOutput as Response entity

对着背影说爱祢 提交于 2019-11-30 00:11:46
I had implemented streaming output in my Jersey Resource class. @GET @Path("xxxxx") @Produces(BulkConstants.TEXT_XML_MEDIA_TYPE}) public Response getFile() { FeedReturnStreamingOutput sout = new FeedReturnStreamingOutput(); response = Response.ok(sout).build(); return response; } class FeedReturnStreamingOutput implements StreamingOutput { public FeedReturnStreamingOutput() @Override public void write(OutputStream outputStream) { //write into Output Stream } } The problem is eventhough a response is sent back from the resource before FeedReturnStreamingOutput is called Jersey client waits

How do Jersey-client and Apache HTTP Client compare?

馋奶兔 提交于 2019-11-29 19:31:51
First of all, I'm not trying to start a flame-war here. I know Jersey sufficiently well, but have hardly used httpclient. What are the key differences between jersey-client and Apache's httpclient? In what areas is one better than the other? Is there a good comparison chart somewhere? Which one performs better with larger files (say 2048 MB)? Many thanks for your comments! These two things probably should not be compared directly. Jersey is a REST-client, featuring full JAX-RS implementation, neat fluent API and a powerfull filter stack. Apache Http Client is a HTTP-client, perfect in managing

Exception in thread “main” java.lang.NoClassDefFoundError: Could not initialize class com.sun.jersey.core.header.MediaTypes

偶尔善良 提交于 2019-11-29 19:12:05
问题 I'm trying to run a jersey client and facing this issue. WS Class: import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @Path("/hello") public class HelloWorldService { @GET @Path("/vip") @Produces(MediaType.APPLICATION_JSON) public Response getMsg(@QueryParam("msg") String msg) { String output = "Jersey say : " + msg; return Response.status(200).entity(output).build();

REST JAX-RS javax.ws.rs.ProcessingException:

对着背影说爱祢 提交于 2019-11-29 18:23:33
问题 I am getting below exception whenever my REST client code makes a call to the REST service using below code: Code: public void putWatcher(Watcher watcher) { System.out.println("In REST Client putWatcher.***********"); target = target.path(RESOURCE_WATCHERS).path(watcher.getWatcheruri()); System.out.println(target.getUri()); Invocation.Builder builder = target.request(); builder.put(Entity.json(watcher)); // Response response = target.request().put(Entity.json(watcher)); System.out.println(

Jersey version issue: MessageBodyReader not found for media type=application/xml

寵の児 提交于 2019-11-29 17:14:43
问题 While writing a simple Jersey client that was consuming XML data, I came across this exception "MessageBodyReader not found for media type=application/xml". All of my settings, including the jersey-client as maven dependencies was just fine. The version that I was using was 2.17. Once I degraded the version to 2.15 it started working fine. Can anyone explain what dependencies that needs to be included for version 2.17 to work. Maven Dependency (works on 2.15 and lower) <dependency> <groupId

Why does Jersey swallow my “Content-Encoding” header

徘徊边缘 提交于 2019-11-29 14:22:13
Why does the following example swallow my HTTP-Header for "Content-Encoding" in the request. I am writing an application where I need to decode a custom encoding format. However, I can never get hold of the "Content-Encoding" header from the request. Neither in the actual resource nor in an ReaderInterceptor. In the response, this encoding header is not swallowed. This behavior can be easily observed in the following (runnable) example: public class Demo extends JerseyTest { @Override protected Application configure() { enable(TestProperties.DUMP_ENTITY); enable(TestProperties.LOG_TRAFFIC);

Unable to Mock Glassfish Jersey Client response object

落爺英雄遲暮 提交于 2019-11-29 13:46:53
I am having problems with creating a mock Response object to use with my unit tests. I am using org.glassfish.jersey.core.jersey-client version 2.3.1 to implement my RESTful client and mockito version 1.9.5 to help me with mock objects. Here is my test's code: @Test public void testGetAll() throws IOException { // Given String expectedResource = "expectedResource" final Response expectedRes = Response.ok(expectedResource, MediaType.APPLICATION_JSON).build(); String receivedResource; BDDMockito.given(this.client.getSimpleClient().getAllWithResponse()).willReturn(expectedRes); // When

How to extract ObjectMapper from JAX-RS Client?

耗尽温柔 提交于 2019-11-29 09:35:19
I am using Jersey JAX-RS client (version 2.0). I know it is using a Jackson ObjectMapper to generate and parse JSON. I want to use that same object to generate JSON for some java classes so that I can write them to a log. I know I can create a new instance of ObjectMapper but I prefer to request Jersey Client to give me a reference to the one it is using. How can I do this? Jersey 2.0 is aware of Jackson because it includes a JacksonFeature class that is used to configure the Jackson feature in the first place. necromancer I solved this by adding the following static members: private static