jax-rs

JAX-RS Frameworks

I've been doing some work with the JAX-RS reference implementation (Jersey). I know of at least two other frameworks (Restlet & Apache CXF). My question is: Has anyone did some comparison between those frameworks and if so, which framework do you recommend and why? ...

Unit 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 JUnit, but I'm not sure how that can be achieved. What approach do you use to test your we...

Java REST client without schema

Goal Java client for Yahoo's HotJobs Resumé Search REST API. Background I'm used to writing web-service clients for SOAP APIs, where wsimport generates proxy stubs and you're off and running. But this is a REST API, which is new to me. Details REST API No WADL No formal XML schema (XSD or DTD files). There are example XML request/...

JAX-RS / Jersey how to customize error handling?

I'm learning JAX-RS (aka, JSR-311) using Jersey. I've successfuly created a Root Resource and am playing around with parameters: @Path("/hello") public class HelloWorldResource { @GET @Produces("text/html") public String get( @QueryParam("name") String name, @QueryParam("birthDate") Date birthDate) { // ...

What is the minimal configuration for REST-fully annotated service built on Spring 3 (m3)?

I'm trying to expose a REST-full service (hosted by Tomcat) and can't figure out what is the required configuration for Spring 3 (M3). This is how (example) the service looks like: @Controller @Scope("prototype") public class UsersController { @RequestMapping(value="/users/hello", method=RequestMethod.GET) public String hello()...

What is the best way to write a test case for RESTLET web services?

I have a JAX-RS web service implemented with Restlet library and now I want to test it. In order to do that I'd like to host this service in my test by preinitializing it with mocked services. What is the best way to host such a service and execute the test calls? @Path("/srv") public class MyService { @GET public void action(@Co...

What is the best way to write a test case for JERSEY web services?

I have a JAX-RS web service implemented with Jersey library and now I want to test it. In order to do that I'd like to host this service in my test by preinitializing it with mocked services. What is the best way to host such a service and execute the test calls? @Path("/srv") public class MyService { @GET public void action(@Con...

JAX-RS is perfect for implementing REST. What do you use to call REST services in Java?

Ideally, I am looking for something like JAX-RS (using annotations to describe the services I want to call), but allowing to call REST services implemented using other technologies (not JAX-RS). Any suggestion? ...

Exception handling / resource management in Jersey JAX-RS

I'm trying to manage a contended resource (as in: database session) while programming a RESTful web application in Jersey. Usually I'd write code like this: Session session = getSession(); try { doWork(); session.commit(); } finally { session.rollback(); // doesn't hurt after commit session.release(); // or whatever } Now with...

Problem with JERSEY and JAX-RS

I am new to RESTful Services. I am trying to deploy a simplest REST service using jersey, and JAX-RS, but i am getting this error, HTTP ERROR: 404 NOT_FOUND RequestURI=/hosting/demo/example Powered by Jetty:// Where i think i have done everything right, below is the code i am using for it. POM.XML (only pasting the part related to je...

Compatibility Issue of ASM 3.1 and HIbernate and JAX-RS

Hi, I have found out that "Hibernate cannot be combined with the reference implementation of JAX-RS." on the link http://lists.jboss.org/pipermail/hibernate-issues/2009-May/015628.html So i am unable to combine JAX-RS (jersey) with hibernate, does anybody know a work around for this ? ...

How to reuse Jersey's JSON/JAXB for serialization?

I have a JAX-RS REST service implemented using Jersey. One of the cool features of JAX-RS/Jersey is how easily a POJO can be turned into a REST service, simply by sprinkling a few Java annotations... including a trivially easy mechanism for translating POJOs to JSON - using JAXB annotations. Now, I'd like to be able to take advantage of...

exception propogation from jersey class

Hi, Could some one give me some pointers as to how do i propogate an exception from jersey class to lets say a JSP, along with some examples if possible.. Thanks in advance Adhir ...

jax-ws mtom sample code (service + Client) need.. SIMPLE one

hi All, I looking for a simple , working sample mtom sample code (service + Client) either using jax-ws RI or Axis 2 based. I googled the world only to find snippets and codes that dont simply work ! Want to send PDF attachments to the requesting web service client.. Thanks Sam-ant ...

JAX-RS access control

Hi, Can some one provide me some pointers about access control in JAX-Rs web services. e.g. limiting access on the basis of user credentials, or name or any other criteria. Could not find any useful information in the sun manuals. Thanks in advance, Adhir ...

URL Mapping a Rest Webservice

Hi There, I have to map a REST Webservice URL like "http://server:8080/application/service/customer/v1" to createCustomer method in CreateCustomerBean class.. I have done the following mappings.. *Web.xml* <servlet-mapping> <servlet-name>RestiveServlet</servlet-name> <url-pattern>/service/*</url-pattern> </servlet-m...

Jersey JAXB problem

Hi, I'm trying to use the best practices of rest notes in the following article regarding the connectedness http://www.infoq.com/articles/rest-introduction <order self='customers/1234' > 23 but I can not implement it. if I use the @XmlElement on product object which is an inner object of order class, All of the product f...

How can I implement Session-Per-Request ("Open-Session-In-View") pattern using JAX-RS?

I'm using JDO on AppEngine with Restlet + JAX-RS extensions. In my sub-resource locator class I load the entity in the constructor. Then for the various methods I used the data. If I close the PersistenceManager before returning from the Constructor, collections of one-to-many fields are not initialized and remain null. I read about "d...

Content negotiation ignored when using browser Back button

Here's the situation: I have a web application which response to a request for a list of resources, lets say: /items This is initially requested directly by the web browser by navigating to that path. The browser uses it's standard "Accept" header which includes "text/html" and my application notices this and returns the HTML content...

What is the best way to "fake" DELETE and PUT methods using JAX-RS?

I've just started to use Jersey to create a RESTful API for my site. Its a wonderful change from having to roll my own support for RESTful services in Java. One thing I just can't seem to figure out is how to "fake" a DELETE and PUT method. Jersey supports the annotations @PUT and @DELETE, however many Load-Balancers will not allow th...