• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

restlet web service not working

 
gilbert engle
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic