Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

restlet web service not working

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic