aspose file tools*
The moose likes Web Services and the fly likes restlet web service not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "restlet web service not working" Watch "restlet web service not working" New topic
Author

restlet web service not working

gilbert engle
Greenhorn

Joined: Jun 03, 2009
Posts: 24
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
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://aspose.com/file-tools
 
subject: restlet web service not working