A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Web Services
Author
restlet web service not working
gilbert engle
Greenhorn
Joined: Jun 03, 2009
Posts: 24
posted
Oct 04, 2012 05:57:15
0
public class MyTestClientResource {
public static void main(String[] args) throws Exception {
ClientResource clientResource = new ClientResource(
"http://localhost:8182/rest/test");
MyTestResource testResource = clientResource.wrap(MyTestResource.class);
// Retrieve the JSON value
Customer result = testResource.retrieve();
System.out.println("CUSTOMER " + result);
if (result != null) {
System.out.println(result);
}
}
}
public interface MyTestResource {
@Get
public Customer retrieve();
@Put
public void store(Customer customer);
@Post
public void stop() throws Exception;
@Delete
public void remove() throws Exception;
}
public class TestServerResource extends ServerResource implements MyTestResource {
private static volatile Customer myCustomer = Customer.createSample();
private static Server server = null;
public static void main(String[] args) throws Exception {
server = new Server(Protocol.HTTP, 8182, TestServerResource.class);
server.start();
}
public Customer retrieve() {
System.out.println("GET request received");
System.out.println("CUSTOMER( " + myCustomer + ")");
return myCustomer;
}
public void store(Customer customer) {
System.out.println("PUT request received");
myCustomer = customer;
}
public void stop() throws Exception {
System.out.println("POST request received");
server.stop();
}
public void remove() throws Exception {
System.out.println("DELETE request received");
myCustomer = null;
}
}
runnning MyTestClientResource results in
CUSTOMER = null
I carefully copied all of the source code from the example but it just doesn't work. Any ideas? Thank you very much
source code example
http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/328-restlet/285-restlet.html
gilbert engle
Greenhorn
Joined: Jun 03, 2009
Posts: 24
posted
Oct 04, 2012 15:55:57
0
OK, trying to get this stuff to work on your own is crazy. The pieces and parts that are presented in the user's guide are incomplete. I finally located some working source files.
http://wiki.restlet.org/docs_2.0/304-restlet/version/default/part/AttachmentData/data/serializationFullSource.zip
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: restlet web service not working
Similar Threads
urgent help--SOS-------dynamic class loading in RMI
JAX-WS and REST, anyone?
RESTFul web service
Restlets not responding even though request shows in console
problem with stateful service
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter