jax-rs

Getting XML in JAX-RS service

Hello! How can I get XML and/or URL (String) in JAX-RS service? For example in GET method URL @GET @Produces("application/xml; charset=UTF-8") public JaxrsPriceWrapper getPrice(@QueryParam("firstId"), @QueryParam("materialId"),...) { //here I would like to get whole URL } and in POST method XML @POST public JaxrsOrderWrapper in...

Using CDI + WS/RS + JPA to build an app

@Path(value = "/user") @Stateless public class UserService { @Inject private UserManager manager; @Path(value = "/create") @GET @Produces(value = MediaType.TEXT_PLAIN) public String doCreate(@QueryParam(value = "name") String name) { manager.createUser(name); return "OK"; } } here is the u...

Jersey: Inject Spring component into ContainerRequestFilter

I am using Jersey 1.4 ea together with Spring 3.0 and the jersey-spring integration. Integrating Jersey and Spring works fine for resource classes as described here. How ever I want to inject a spring component into a ContainerRequestFilter to do some pre-processing of requests. @Component public class SecurityFilter implements Contai...

how can I get URI of currently dispatched web resource, in JAX-RS?

How can I get a full URI of the resource currently dispatched in JAX-RS? I'm trying to return a URI of newly created object, and need a prefix part of it, with host, port, etc.: // @import-s skipped public class Factory { @POST public final Response create() { Integer id; // new object created and id is set return Respon...

How to set an HTTP error code in JAX-RS

I have a web service using jar-rs. How do I throw a custom http error code to the calling application? Thanks ...

How can I tell Jersey to use my MessageBodyReader instead using JAXB?

Basically, I have some models which all use JAXB. However, I have some highly custom functionality to convert to JSON and back so I want to write my own MessageBodyReader/Writer to do the job for me. Right now, the writing portion is done: if i return one of my models from a REST resource, it goes through my writer. But when I try and a...

Examples and extension in Nuxeo

Hi guys, I'm trying to set up Nuxeo's examples, but I can't get them working. Does someone succeed in compiling and deploying them ? I know it uses JAX-RS, but I'm still trying to set up a project with Eclipse to generate bundles, and I'm quite lost. I would be very happy if someone could give me a compiling project, or a link for a s...

How and who should inject PersistenceContext when running tests through Jersey/Grizzly?

I have this class (mix of JAX-RS/Jersey and JPA/Hibernate): public class Factory { @PersistenceContext(unitName = "abc") EntityManager em; @Path("/{id}") @GET public String read(@PathParam("id") int i) { return em.find(Employee.class, i).getName(); } } This is the unit test: public class FactoryTest extends JerseyTest...

How do I get the URL of a request ?

I am using Jeresy Jax-RS to build a web service. Now I need to get the url of the request with the port # if one exist. So if my service runs on http://www.somelocation.com/web/services I want to capture the www.somelocation.com How can I do this ? ...

Enterprise Aplication with EJB, JSF and JAX-RS

What is the best Maven archetype to use on enterprise application in java using EJB and JAX-RS, considering that in a near future i will have to make a front-end in JSF2 using as the backend EJBs used with the JAX-RS? ...

EJB-like transactions in JAX-RS

I'm adding a RESTful API to an existing application (JBoss 4, EJB 2, adding RESTEasy). The application currently has Session beans with container-managed transactions. To start with, I'm calling remote interfaces on the Enterprise Beans. The EJB usage is being phased out, so new functionality will be added without writing new methods ...

JAX RS Jersey Schema Validation

How to configure schema validation for JAX-RS RESTFul services? We are using XSD to define the models, and JAXB to generate the java models. ...

Custom annotations to set HTTP response headers in a JAX-RS service

I have a JAX-RS web service for which I would like to disable the same-origin policy via the new CORS HTTP headers. (I am fully aware of the security implications.) I'd like to have a custom annotation that lets me set HTTP response headers. For example, @ResponseHeaders({"Access-Control-Allow-Origin: *", "Access-Cont...

Can I wrap all JAX-RS requests with custom pre-dispatch, post-dispatch and error-handler code?

I have a number of classes exposed as JAX-RS request "handlers", using javax.ws.rs.Path annotations. I want to add certain actions before every request and after each request. Also, I need to create a global application-wide exception handler, which will catch everything thrown by these handlers and protocol. Is it possible to achieve t...

JAX-RS and SLSB's

Hey guys, Transforming some SOAP web services in to REST. It's been a painless process although I've encountered a problem in exposing a stateless session bean as a RESTful web service. Basically if the bean implements an interface and also has Jersey annotations it will not deploy with a object is not of declaring class error. Remove ...

Using RESTful services with JAX-RS/CXF in Tomcat

I'm interested in using Apache's JAX-RS implementation (CXF) in a Tomcat environment. The documentation is pretty clear and straight forward about developing a RESTful service with JAX-RS/CXF. However, I'm not sure how to develop a JAX-RS service within the context of a Tomcat environment. Does anyone know of a good tutorial on developi...

problem with JAX-RS and foursquare

I don't know why I can't use the MultivaluedMap here, can someone help. Eclipse is giving me that it can't be resolved into a type import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.util.Map; import javax.net.ssl.SSLContext; import com.sun.jersey.api.client.*; import com.sun.jersey.api.client.config....

XPath to parse JAX-RS result

I don't know how to use XPath so I can parse the result of the XML I got from JAX-RS and put it into an ArrayList or something, here's the code I have so far, it generates a String... but I want to be able to use XPath to parse it, as it's better to parse XML rather than parsing String. private Client client = Client.create(); priva...

Securing Jersey RESTful services with spring-security-core using jaxrs plugin

I'm needing to implement some RESTful webservices for a client in a Grails app and I want to use the jaxrs plugin but I am having a heck of a time finding information on how to implement security that isn't realm based (tomcat-users.xml). I am using the spring-security-core plugin and I'd like to utilize it to authenticate against my we...

Grails with JAX-RS vs UrlMappings for RESTful Services

I started out looking at the JAX-RS plugin for grails and thought that was the way to go mainly because it was based on JSR-311 and I figure following standards is usually the smart thing to do. However, using Grail's UrlMappings it seems I basically achieve the same thing. I figure I'm missing something, however, we aren't doing anyth...