I am trying add some response headers to some of my webservice calls. I wrote my webservice using CXF 2.1.2 and JAX-RS. I need to return an object and I also want to add some headers to the Response. Without returning a javax.ws.rs.core.Response object, how do I add a header to the response and still return my javabean?
...
I'm writing a RESTful Web Service with RESTeasy. This is an implementation of JAX-RS. You annotate a class or method with a single @Path annotation. Regular expressions are used to get path parameters. For instance
@Path("/foo{varname:.*}/bar")
matches all patterns starting with "/foo", ending with "/bar" and having anything in be...
Which REST API do you prefer - Jersey or Restlet? This would encompass both the client and server API-s.
We really need to just pick one and kick the tires around but I was curious what the community thinks.
Restlet seems simpler and better documented to me. I've had a hard time even finding decent documentation about the Jersey clie...
I ran into the following issue when setting up a JAXRS test service in a unit test.
This is the code (taken from an AbstractJUnit4SpringContextTests-derived test class):
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setServiceBeans(applicationContext.getBean("searchXY"));
sf.setAddress("http://localhost:9000/"...
Consider the following simple RESTEasy (JAX-RS) service:
@Path("/example-service")
public interface ExampleService {
@Path("/ping")
@GET
public String ping(String message);
}
I want to define JAXRS specifics on the interface rather than the class so I can use the nice client framework, ie:
ExampleService client = ProxyF...
Giver a resource class that has a method witch returns a Viewable (or generaly any jsp page). Is there a way to use the c:import or jsp:include taglib to include a Viewable response from a jaxrs anotatted class? For example given the class
@Path("/some/path")
public class SomeJaxrsResource {
@GET
public Viewable get() {
return n...
I am working on a REST based API, and having some trouble figuring out what the canonical way is to represent parent / child relationships. (I am writing beans in CXF and using JAX-RS and JAXB. I started from the basic example provided by CXF)
My problem is let's say you have a Foo and a Bar. There is a 1-N relationship with Foo and ...
I'm playing around with jax-rs , deploying on tomcat (handling via com.sun.ws.rest.spi.container.servlet.ServletContainer). It's basically
@Path("/hello")
@Produces({"text/plain"})
public class Hellohandler{
@GET
public String hello() {
return "Hello World";
}
}
Is there any way I can get hold of the ServletContext w...
I have a JAX-RS web service (using jersey) that accepts a JAXB object as the request entity. When we get an error, we want to log the original xml string that was sent to us. Currently, I am just re-marshalling the JAXB object, but since we have several java enums in those classes, enum values that are not spelled correctly in the origin...
RESTEasy (a JAX-RS implementation) has a nice client framework, eg:
ServiceApi client = ProxyFactory.create(ServiceApi.class, baseUri);
How do you provide HTTP authentication credentials to this client?
...
Hi!
I'm using JAX-RS to create restful webservices in Java. I am getting to much overhead in the produced JSON.
Data class:
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Test {
private Map<String,String> data;
Test() {}
public Test(Map<String,String> data) {
this.data = data;
}
publ...
I am successfully marshaling a POJO into JSON using JAX-RS and JAXB annotations.
The problem is that when I am trying to use the same for un-marshalling my request it doesn’t work. As far as I can see in the documentation JAX-RS can automatically marshal and unmarshal application/json strings back to java classes.
Do I need to create m...
I'm wondering whether to use matrix or query parameters in my URLs. I found an older discussion to that topic not satisfying.
Examples
URL with query params: http://some.where/thing?paramA=1&paramB=6542
URL with matrix params: http://some.where/thing;paramA=1;paramB=6542
At first sight matrix params seem to have only advantages:...
Yes, I know, the old question of the best web framework ... but let me explain.
I'm looking for Java Servlet based web framework that allowes RESTful interaktion and is also suitable to build web GUIs.
What I want:
REST support with http content negotiation and nice URL mapping
data conversion from request params to domain object (an...
If a method of a JAX-RS application would return a domain object, the representation (say JSON) would contain all attributes of this object - right? But what if this object would contain "private" data, that shouldn't be exposed to the web?
And what is about the other direction from outside in: how could be prevented that private fields...
Hi! I have a method definition as such:
@POST
@Path("save")
@Consumes("application/json")
public void save(Map<ClientVO, Map<AssessmentVO, String>> data){
System.out.println("THIS IS THE DATA: " + data);
}
When I try to unmarshall on the server, I get the following exception
Exception in thread "main"
org.jboss.resteasy....
What minimum version of the Servlet API is required to run JAX-RS 1.1 (for example Jersey 1.1)?
...
The JAX-RS 1.1 specification says on page 6:
If no Application subclass is present
the added servlet MUST be named:
javax.ws.rs.core.Application
What is the added servlet? Could it be an arbitrary servlet?
If an Application subclass is present
and there is already a servlet defined
that has a servlet initialization
pa...
Hi guys,
We're using Jersey 1.0.3 to implement a REST client. This client needs to post an XML envelope containing UTF-8 characters. When debugging, we can clearly see that the entity that is being sent is correct. However, the request that is being sent changes the entity and garbles non-ASCII characters. We've dug into the Jersey sour...
The CXF documentation mentions caching as Advanced HTTP:
CXF JAXRS provides support for a number of advanced HTTP features by handling If-Match, If-Modified-Since and ETags headers. JAXRS Request context object can be used to check the preconditions. Vary, CacheControl, Cookies and Set-Cookies are also supported.
I'm really interes...