restlet

Restlet - serving up static content

Using Restlet I needed to serve some simple static content in the same context as my web service. I've configured the component with a Directory, but in testing, I've found it will only serve 'index.html', everything else results in a 404. router.attach("/", new Directory(context, new Reference(baseRef, "./content")); So... http://ser...

Remoting from a Swing app to GWT server

To put it simple, I've written a JSE Swing app that needs to talk to a GWT server I've written earlier. I absolutely love the way GWT does remoting between it's javascript and server sides and wish I could utilize this mechanism. Has anyone managed to use GWT-RPC this way? Should I just go Restlet instead? ...

REST web service accepting a POST using Restlet - Best Practice

I have my resource and they typical overridden method to handle POST requests. public void acceptRepresentation(Representation rep) { if (MediaType.APPLICATION_XML.equals(rep.getMediaType())) { //Do stuff here } else { //complain! } } What I want to know is the best practice to handle my packet of XML. I see a lo...

Using parameters in a Restlet Client Request

I have: Request request = new Request(Method.GET, "https://www.awebsite.com/login"); Client client = new Client(Protocol.HTTPS); Response response = client.handle(request); ... response.getEntity().write(System.out); But I don't know how to set the login parameters... I want code that does the escaping etc can switch between get/po...

How to use a ThrottlingFilter for Jetty in Restlet

I would like to configure a webservice so that once the accept queue is full the service returns 503. Currently, these requests seem to just time out. I did set paramters like maxThreads and acceptQueuesize (as described here: http://www.restlet.org/documentation/1.1/ext/com/noelios/restlet/ext/jetty/JettyServerHelper). But the servic...

Delivering json content to different browser types using restlet

We have developed a RESTful webservice using the restlet framework. The service is called by ajax requests using Prototype and/or Scriptaculous (I'm not familiar with those libraries, so excuse if any of these mentioned are not accurate). Everything seems to work for most of the popular browsers, i.e. Opera, Firefox, Safari all work fin...

Using HTTP OPTIONS to retrieve information about REST resources

This problem relates to the Restlet framework and Java When a client wants to discover the resources available on a server - they must send an HTTP request with OPTIONS as the request type. This is fine I guess for non human readable clients - i.e. in code rather than a browser. The problem I see here is - browsers (human readable) ...

How To Read Context Parameters From a Restlet?

When using Restlets, how can I read configuration parameters passed in through web.xml? With servlets, context-param can be used. How do I read context parameters from within a Restlet? ...

Sending binary data with the Restlet client

I'm trying to send a byte[] (using PUT) with Restlet but I can't find any info on how to do it. My code looks like this: Request request = new Request(Method.PUT, url); request.setEntity( WHAT DO I PUT HERE?, MediaType.APPLICATION_OCTET_STREAM); I had expected to find something along the lines of ByteArrayRepresentation, just like the...

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...

How does Restlet handle the HTTP Accept header?

The Restlet framework is supposed to handle automatic content negotiation; however, it doesn't seem to do it properly. When a client sends and HTTP GET request with the Accept header with a value, Restlet doesn't automatically negotiates the content. Does anyone know how the Accept header is treated? ...

RESTlet: How to process multipart/form-data requests?

How do you catch incoming @Post variables when it is a multipart/form-data request? For a regular Post request I would do: @Post public void postExample(Representation entity) throws Exception{ Form form = new Form(entity); System.out.println(form.getFirstValue("something")); } But because it is a multipart/form-data request th...

Unmarshalling XML using JAXB in restlet's acceptRepresentation method.

I've created an XML schema by annotating an existing Java domain model class, now when I try to use JAXB to unmarshall the representation received within my restlet webservice I'm getting a host of errors no matter what I seem to try. I'm new to both restlets and JAXB so pointing me in the direction of a decent example of using both woul...

Implementing a custom Python authentication handler

The answer to a previous question showed that Nexus implement a custom authentication helper called "NxBASIC". How do I begin to implement a handler in python? Update: Implementing the handler per Alex's suggestion looks to be the right approach, but fails trying to extract the scheme and realm from the authreq. The returned value f...

Restlet image processing

I need to pass the image from restlet client to server. I am passing the image bytes in the request but the image is getting distorted. ...

Configure Restlet to Return JSPs on Google App Engine?

I have a developed a Restlet application. I would like to return a JSP file on a URL request through Restlet. How can I achieve this without using a redirect? i.e. Let's say I have the file "contact.jsp" on mydomain.com and I want people to be able to access contact.jsp at http://mydomain.com/contact Thus, in Restlet, I would have: r...

How does the timeout work in Restlet's client class?

Here's some code: Client client = new Client(Protocol.HTTP); client.setConnectTimeout(1); //milliseconds Response response = client.post(url, paramRepresentation); System.out.println("timed out"); What I would expect to happen is that it prints "timed out" before the resource has time to process. Instead, nothing happens with the tim...

In Restlet, how can I get the Router instance from a ServerResource?

How can I get access to the Application's Router instance from my ServerResource class? Is it even possible? Thanks in advance. ...

Implementing RESTful web service

Hello, I have a requirement to create RESTful web service. I have narrowed down on 'Restlet' for the web service implementation. Can someone tell me the clear pro's and con's of using Restlet and if there are any better alternatives. thanks in advance ...

Restlet implementing post with json receive and response

First, what i wanted to know is what i am doing is the right way to do it. I have a scenario where i have will receive a json request and i have to update the database with that, once the db is updated i have to respond back with the json acknowledgment. What i have done so far is create the class extending application as follows: ...