jax-rs

How do you return multipart content from a JAX-RS web service?

I'd like to avoid embedding HTML in XML returned from my JAX-RS web service, but still be able to return both XML and HTML in the response to a single GET. Is there a way to do this? Is it a bad idea? Right now I am doing 2 separate GET's for different resources one XML one HTML - however since both resources are always retrieved toget...

Is JAX-RS suitable as a MVC framework?

JAX-RS has some MVC support, but I wonder if JAX-RS is really a good choice to build web application for human use. If a user enters wrong or incomplete information in a form, it should be displayed again like with Grails or Wicket. Is there a comfortable way to do this with JAX-RS? As far as I know the URI mapping doesn't work correct...

Parameters not added in Uri

Hi, i want to build an Uri for an Webservice. I use the UriBuilder and want to add the parameters to the URI. The paramameters are saved in an MultivaluedMap. @GET @PathParam("/{callUrl}/{parameters}") public static String buildGetUri(@PathParam("callUrl") String callUrl, @PathParam("parameters"...

How can I customize serialization of a list of JAXB objects to JSON?

I'm using Jersey to create a REST web service for a server component. The JAXB-annotated object I want to serialize in a list looks like this: @XmlRootElement(name = "distribution") @XmlType(name = "tDistribution", propOrder = { "id", "name" }) public class XMLDistribution { private String id; private String name; // no...

JAX-RS Element name for return type Collection

I have a situation where the method signature of JAX-RS service looks like... public Collection<CustomerData> getCustomers() { ... } The xml generated has the root tag like customerDatas as below <customerDatas><customer>.....</customer></customerDatas> I am using JAXB annotations and root element name for CustomerData is custom...

Question about Request and Session with CXF, JAX-RS webservice

I have a webservice set up using CXF, JAX-RS and Spring. I have the following method: @GET @Path("/getPayload") @Produces("application/XML") public Response makePayload(){ Payload payload = new Payload(); payload.setUsersOnline(new Long(200)); return Response.ok().entity(payload).build(); } How can I get access to the Htt...

JAX-RS @PathParam How to pass a String with slashes, hyphens & equals too

I am new to JAX-RS and I am trying to use Jersey to build a simple RESTful Webservice. I have 2 questions. Please clarify these: I am trying to have my simple webservice like this URL http://localhost:8080/SampleJersey/rest/inchi/InChIName The InChIName is a string like this InChI=1S/C9H8O4/c1-6(10)13-8-5-3-2-4-7(8)9(11)12/h2- 5H,1H...

Web Services in Unix. What should be the directory structure

I earlier got to create a simple RESTful webservice on my localhost using Eclipse IDE, Tomcat, and JAX-RS libraries. I am now trying to move the same on to a different unix server which has Tomcat installed. I am not knowing how to get started as in what is equivalent to creating a "Dynamic Web Project" that I do in Eclipse. Do I need t...

What are HTTP Response Entity Tags?

Specifically in JAX-RS (I'm not sure that is relevant) there are methods that allow you to add EntityTags to the response. What exactly are entity tags and what practical ways are they used? ...

JBoss RESTEasy - show ALL path mappings

Is there any way to dump out a list of mapped paths in RESTEasy? I've searched the documentation and came up empty. ...

JAXB marshalling superclass

I am writing a Resteasy server application and am having trouble getting my superclasses to marshal. I have code something like this: @XmlAccessorType(XmlAccessType.NONE) @XmlRootElement(name = "person") class Person { protected String name; @XmlElement(name = "name") public String getName() { return name; } public void setNam...

unable to find a MessageBodyReader

Hi guys, I have this interface: @Path("inbox") public interface InboxQueryResourceTest { @POST @Path("{membershipExternalId}/query") @Consumes(MediaType.APPLICATION_XML) @Produces("multipart/mixed") public MultipartOutput query(@PathParam("membershipExternalId") final String membershipExternalId, ...

How to pass a very long string/file into RESTWebservice JAX-RS Jersey

Hello All, I wrote a RESTful webservice using JAX-RS API, that returns an XML string. I am trying to write another RESTful webservice that takes in this XML string, does parsing of it using DOM and extract particular things I want. The XML string happens to be very long so I do not want to pass it as a @QueryParam or @PathParam. Say I...

Looking for an example of a web application which provides and uses a JAX-RS web service for "all" logic.

I am looking for a good example of an open source web application that provides and uses a JAX-RS web service for all business logic calls. That is an application that doesn't only provide a RESTful interface for some parts of the system but also uses the same interface within the application. ...

Using implementation specific classes with standard JAX-RS

I want to use classes from a specific JAX-RS implementation together with the classes defined by Java EE, which are available on an application server. More specifically I want to use Viewable from Jersey but want to use the default Java EE deployment without wrapper servlet. Is it possible? How? Is it a good idea? Or would it be better...

Custom Response + HTTP status?

Hi, I have a rest interface for my project. For one class i have a POST method where you can post an xml and i RETURN a custom response like: <customResponse>Invalid email</customResponse> if the email from the xml which was posted, was incorrect + other custom messages i have defined for different situations. For all of these the HTT...

Unable to set cookie in response header (newcookie doesn't show in external browser) : Jersey jax-rs in eclipse galilio

I am trying to set a session cookie from server side : import javax.ws.rs.core.NewCookie; import javax.ws.rs.core.Response; public class Login { @POST @Produces("application/json") @Consumes("application/json") public Response login (String RequestPacket){ NewCookie cookie=null; CacheControl cc=new CacheControl(); cookie = Lo...

How do I do a multipart/form file upload with jax-rs?

(specifically RESTeasy) It would be nice (for a single file) to have a method signature like: public void upload(@FormParam("name") ..., @FormParam("file") file: InputStream) ... doable? or am I dreaming? doesn't seem to be that simple. ...

How to create a JAX-RS service where the sub-resource @Path doesn't have a leading slash

I've created a JAX-RS service (MyService) that has a number of sub resources, each of which is a subclass of MySubResource. The sub resource class being chosen is picked based on the parameters given in the MyService path, for example: @Path("/") @Provides({"text/html", "text/xml"}) public class MyResource { @Path("people/{id}") publ...

JAX-RS and JAXB_ENCODING

I am using the RestEasy library to do JAX-RS web services. I am not instantiating a JAXBContext in my service methods. Is there a way to make JAX-RS include the "<?xml version...?>" header string in the XML it returns? Here is a sample service method from my code: @GET @Path("/patients/{patient_id}/diagnoses/portal_edits") @Produces({ M...