Questions tagged [jax-rs]

JAX-RS: Java API for RESTful Web Services. It is an API that provides support in creating web services according to the REST architectural style.

JAX-RS: API for RESTful Web Services is an API that provides support in creating web services according to the architectural style. JAX-RS uses annotations, introduced in Java SE 5, to simplify the development and deployment of web service clients and endpoints. From version 1.1 on, JAX-RS is an official part of Java EE.

The home for the JAX-RS JSRs is on Java.net.

JAX-RS is implemented by the following frameworks:

Resources:

7676 questions
99
votes
5 answers

What is the difference between JAX-RS and JAX-WS?

After reading a few articles about JAX-RS and JAX-WS, I had a few questions that I want to confirm? Can JAX-RS do Asynchronous Request like JAX-WS? Can JAX-RS access a web service that is not running on the Java platform, and vice versa? What does…
pmark019
  • 1,199
  • 5
  • 15
  • 24
97
votes
7 answers

Read response body in JAX-RS client from a post request

Having some sort of proxy between a mobile app and a web-service, we are puzzled by the response when issuing a post request. We receive response with status 200: OK. But we can not find/extract the JSON response body. Client client =…
user2657714
  • 1,134
  • 1
  • 8
  • 7
95
votes
3 answers

How can I grab all query parameters in Jersey JaxRS?

I am building a generic web service and need to grab all the query parameters into one string for later parsing. How can I do this?
Tom
  • 953
  • 1
  • 7
  • 5
92
votes
1 answer

What exactly is the ResourceConfig class in Jersey 2?

I have seen a lot of Jersey tutorials that starts with something like @ApplicationPath("services") public class JerseyApplication extends ResourceConfig { public JerseyApplication() { packages("com.abc.jersey.services"); } } without…
Chin
  • 19,717
  • 37
  • 107
  • 164
88
votes
2 answers

Why use JAX-RS / Jersey?

Sorry, this questions sounds silly, but after developing some of my RESTful services using Jersey, I asked myself the question -- If REST is just an architecture, and not a protocol like SOAP, why do we need a specification like JAX-RS? I actually…
WinOrWin
  • 2,107
  • 3
  • 19
  • 25
87
votes
4 answers

Required @QueryParam in JAX-RS (and what to do in their absence)

I deploy a web-services component to JBoss Application Server 7 using the RESTEasy JAX-RS implementation. Is there an annotation available to declare required, mandatory @QueryParam parameters in JAX-RS ? And, if not, what is the 'standard' way to…
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
86
votes
10 answers

Testing a JAX-RS Web Service?

I'm currently looking for ways to create automated tests for a JAX-RS (Java API for RESTful Web Services) based web service. I basically need a way to send it certain inputs and verify that I get the expected responses. I'd prefer to do this via…
Einar
  • 3,279
  • 2
  • 26
  • 28
83
votes
6 answers

How to set up JAX-RS Application using annotations only (no web.xml)?

Is it possible to set up a JAX-RS application using annotations only? (using Servlet 3.0 and JAX-RS Jersey 1.1.0) I tried and had no luck. Using some web.xml seems required. Configuration A (working, but has web.xml configuration) web.xml ... …
Eran Medan
  • 44,555
  • 61
  • 184
  • 276
82
votes
6 answers

How to handle CORS using JAX-RS with Jersey

I'm developing a java script client application, in server-side I need to handle CORS, all the services I had written in JAX-RS with JERSEY. My code: @CrossOriginResourceSharing(allowAllOrigins =…
user2773716
  • 865
  • 1
  • 7
  • 5
80
votes
14 answers

MessageBodyWriter not found for media type=application/json

I am facing issues while consuming JAX-RS services as JSON. Below I have added my code. This is my service class: //Sets the path to base URL + /hello @Path("/hello")…
Fahad Mullaji
  • 1,332
  • 5
  • 15
  • 30
78
votes
10 answers

How to enable Cross domain requests on JAX-RS web services?

I developed a set of restful web services. I couldn't call any of these methods from remote clients due to the error No 'Access-Control-Allow-Origin' header is present on the requested resource. The services work perfectly on localhost. Is there…
Naili
  • 1,564
  • 3
  • 20
  • 27
77
votes
3 answers

How to POST a JSON object to a JAX-RS service

I am using the Jersey implementation of JAX-RS. I would like to POST a JSON object to this service but I am getting an error code 415 Unsupported Media Type. What am I missing? Here's my…
Naresh
  • 23,937
  • 33
  • 132
  • 204
77
votes
9 answers

JAX-RS Post multiple objects

I have a method; @POST @Path("test") @Consumes(MediaType.APPLICATION_JSON) public void test(ObjectOne objectOne, ObjectTwo objectTwo) Now I know I can post a single object in json format, just putting it into the body. But is it possible to do…
Thizzer
  • 16,153
  • 28
  • 98
  • 139
76
votes
6 answers

File upload along with other object in Jersey restful web service

I want to create an employee information in the system by uploading an image along with employee data. I am able to do it with different rest calls using jersey. But I want to achieve in one rest call. I provide below the structure. Please help me…
Sambit
  • 7,625
  • 7
  • 34
  • 65
76
votes
6 answers

How to have a @PATCH annotation for JAX-RS?

JAX-RS has annotations for HTTP verbs such as GET (@GET) and POST (@POST) but there is no @PATCH annotation. How can I have an annotation for the PATCH HTTP verb? Something like the following: @PATCH public Response someCode() { // Code to…
VishalDevgire
  • 4,232
  • 10
  • 33
  • 59