sentence
stringlengths 1
1.38k
| label
stringclasses 3
values |
---|---|
I could write a simple web service framework in a third of the time it takes me to understand the RESTlet architecture.
|
p
|
Could you describe precisely what caused you troubles in our Restlet tutorials?
|
o
|
We are interested in fixing/improving what needs to.
|
o
|
Did you check the screencasts?
|
o
|
URL_http://www.restlet.org/documentation/1.1/screencast/ [ URL_http://www.restlet.org/documentation/1.1/screencast/ ] Otherwise, there is a Restlet tutorial in the O'Reilly book that we wrote in their Chapter 12.
|
o
|
If you still have troubles, please contact our mailing list: URL_http://www.restlet.org/community/lists [ URL_http://www.restlet.org/community/lists ] Best regards,Jrme Louvel Restlet ~ Founder and Lead developer ~ URL_http://www.restlet.org [ URL_http://www.restlet.org ] Noelios Technologies ~ Co-founder ~ URL_http://www.noelios.com [ URL_http://www.noelios.com ] .
|
p
|
Please see my new edits in my question - cheers.
|
p
|
It sounds like you could use a solid understanding of the fundamentals of REST, and for that I _highly_ recommend URL_http://rads.stackoverflow.com/amzn/click/0596529260 [RESTful-Web-Services] by Leonard Richardson and Sam Ruby.
|
p
|
I provides a great introduction to REST: what it is and how to implement a (practical) RESTful web service.
|
p
|
Most of the example code in the book is actually Ruby, but it's easy enough to understand even if you're not a Ruby expert.
|
p
|
But one thing that should help you specifically is that one of the later chapters of the book contains overviews of several RESTful frameworks, including Restlet.
|
o
|
It doesn't really get into any code (it's a 50,000-foot flyover) but I think it'll give you just what you need at this stage.
|
o
|
Funnily enough I have just ordered RESTful Web Services on Amazon before I read your post.
|
p
|
Thanks for your valuable comments too.
|
o
|
The Restlet framework is composed of four main parts.
|
o
|
o
|
|
Restlet API** First, there is the "Restlet API", a neutral API supporting the concepts of REST and facilitating the handling of calls for both client-side and server- side applications.
|
o
|
This API is backed by the Restlet Engine and both are now shipped in a single JAR ("_org.restlet.jar_").
|
o
|
This separation between the API and the implementation is similar to the one between the Servlet API and Web containers like Jetty or Tomcat, or between the JDBC API and concrete JDBC drivers.
|
o
|
o
|
|
Retrieving the content of a Web page** As we mentioned in the introduction paper, the Restlet framework is at the same time a client and a server framework.
|
o
|
For example, Restlet can easily work with remote resources using its HTTP client connector.
|
o
|
A connector in REST is a software element that enables the communication between components, typically by implementing one side of a network protocol.
|
o
|
Restlet provides several implementations of client connectors based on existing open-source projects.
|
o
|
The connectors section lists all available client and server connectors and explain how to use and configure them.
|
o
|
Here we will get the representation of an existing resource and output it in the JVM console: CODESNIPPET_JAVA1 .
|
o
|
Note that the example above uses a simplified way to issue calls via the _ClientResource_ class.
|
o
|
If you need multi-threading or more control it is still possible to manipulate use the _Client_ connector class or the _Request_ objects directly.
|
o
|
The example below how to set some preferences in your client call, like a referrer URI.
|
o
|
It could also be the languages and media types you prefer to receive as a response: CODESNIPPET_JAVA2 .
|
p
|
o
|
|
Listening to Web browsers** Now, we want to see how the Restlet framework can listen to client requests and reply to them.
|
o
|
We will use the internal Restlet HTTP server connector (even though it is possible to switch to others such as the one based on Mortbay's Jetty) and return a simple string representation "hello, world" as plain text.
|
p
|
Note that the _Part03_ class extends the base _ServerResource_ class provided by Restlet: CODESNIPPET_JAVA3 .
|
o
|
If you run this code and launch your server, you can open a Web browser and hit the .
|
o
|
Actually, any URI will work, try also.
|
o
|
Note that if you test your server from a different machine, you need to replace "localhost" by either the IP address of your server or its domain name if it has one defined.
|
o
|
So far, we have mostly showed you the highest level of abstraction in the Restlet API, with the ClientResource and ServerResource classes.
|
o
|
But as we move forward, you will discover that those two classes are supported by a rich API, letting you manipulate all the REST artifacts.
|
o
|
o
|
|
Overview of a REST architecture** Let's step back a little and consider typical web architectures from a REST point of view.
|
n
|
In the diagram below, ports represent the connector that enables the communication between components which are represented by the larger boxes.
|
o
|
Not specifically Java-related, but I thought these InfoQ articles were quite good:
URL_http://www.infoq.com/articles/rest-introduction [A-Brief-Introduction-to-REST]
URL_http://www.infoq.com/articles/tilkov-rest-doubts [Addressing-Doubts-about-REST]
URL_http://www.infoq.com/articles/rest-anti-patterns [REST-Anti-Patterns] .
|
p
|
you point to an error inside the web.xml, but I've just checked in both Restlet 1.0 and 1.1 documentation, and I don't see this kind of error.I would like to mention that you can find at the end of the page a zip that contains a complete war file and the list of source files in case you want to run in "standalone" mode.Did you try the standalone mode?
|
o
|
As explained in the tuto, you only need 2 jars in the classpath, and the source files.
|
o
|
We would like also to point that the "firstSteps" tutorial is not a tutorial on REST but on the programmation with Restlet.
|
o
|
You can also have a look at the "firstResource" tutorial ( URL_http://www.restlet.org/documentation/1.1/firstResource [ URL_http://www.restlet.org/documentation/1.1/firstResource ] ) which describes how to develop a simple resource and which introduces some concepts of the REST architecture style.
|
p
|
It should help you.
|
o
|
Here is a well written tutorial on REST.. URL_http://rest.elkstein.org/2008/02 /what-is-rest.html [ URL_http://rest.elkstein.org/2008/02/what-is-rest.html ] .
|
p
|
Whilst this may theoretically answer the question, [it would be preferable]( URL_http://meta.stackoverflow.com/q/8259 ) to include the essential parts of the answer here, and provide the link for reference.
|
p
|
In addition, the qualified named suggested in the tutorial is indeed "firstStepsServlet.FirstStepsApplication" and not "com.firstStepsServlet.FirstStepsApplication".
|
o
|
Therefore, the suggested param value in web.xml is correct.
|
p
|
Could you confirm that this fixes your issue?
|
o
|
Also, did you have Servlet deployment knowledge before reading the tutorial?
|
o
|
If not, that would explain the pain.
|
n
|
In this case, the standalone mode is probably a better fit.
|
p
|
See my new edits in my post.
|
o
|
We fixed the typo.
|
o
|
Note that in addition to the firstSteps and firstResource pages supposed to get you started quickly, there is a more detailled Tutorial that will walk you through the various concepts of REST and Restlet: URL_http://www.restlet.org/documentation/1.1/tutorial .
|
p
|
eSoftHead company has just released a URL_http://blog.esofthead.com/develop- restful-application-with-resteasy/ [short-tutorial] of developing Restful application by using RESTeasy.
|
o
|
Rest clients for Java?
|
o
|
With JSR 311 and it's implementations we have a powerful standard for exposing Java objects via Rest.
|
p
|
However on the client side there seems to be something missing that is comparable to Apache Axis for SOAP - something that hides the web service and marshals the data transparently back to Java objects.
|
o
|
How do you create Java RESTful clients?
|
o
|
Using HTTPConnection and manual parsing of the result?
|
o
|
Or specialized clients for e.g.
|
p
|
Jersey or Apache CXR?
|
o
|
check this out: URL_http://igorpolevoy.blogspot.com/2011/01/java-rest-with - ease.html thanks igor.
|
o
|
This is an old question (2008) so there are many more options now than there were then:
CXF** has three different URL_http://cxf.apache.org/docs/jax-rs-client-api.html [REST-Client-options]
(mentioned above).
|
o
|
also has its own called URL_http://blog.springsource.com/2009/03/27/rest-in-spring-3-resttemplate/ [RestTemplate]
HTTP Client** build your own.
|
o
|
<strike>** URL_https://github.com/sonatype/async-http-client [Async-http-client]
by Sonatype</strike>.
|
o
|
URL_https://github.com/AsyncHttpClient/async-http-client [Ning-Async-http-client] .
|
o
|
The new kid on the block which provides NIO support (although truthfully I don't think this really improves performance for clients like it does servers).
|
p
|
[UniREST]( URL_http://unirest.io /#java) is also pretty good nowadays.
|
p
|
As I mentioned in URL_http://stackoverflow.com/questions/165720/how-to-debug- restful-services#166269 [this-thread] I tend to use URL_http://jersey.java.net/ [Jersey] which implements JAX-RS and comes with a nice REST client.
|
p
|
The nice thing is if you implement your RESTful resources using JAX-RS then the Jersey client can reuse the entity providers such as for JAXB/XML/JSON/Atom and so forth - so you can reuse the same objects on the server side as you use on the client side unit test.
|
p
|
For example URL_http://svn.apache.org/viewvc/activemq/camel/trunk/components /camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java?r evision=700513&view=markup [here-is-a-unit-test-case] from the URL_http://activemq.apache.org/camel/ [Apache-Camel-project] which looks up XML payloads from a RESTful resource (using the JAXB object Endpoints).
|
o
|
The resource(uri) method is defined in URL_http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/sr c/test/java/org/apache/camel/rest/resources/TestSupport.java?revision=700513&v iew=markup [this-base-class] which just uses the Jersey client API.
|
o
|
e.g.
|
o
|
CODESNIPPET_JAVA1 .
|
o
|
BTW I hope that future version of JAX-RS add a nice client side API along the lines of the one in Jersey .
|
p
|
Is there a method where we can mention REST service server list in ClientResource, in case the server is down try the next server?
|
o
|
Just an update, but to address James' 'BTW' comment, the new version of JAX-RS 2.0 will have a client-side API: URL_http://www.infoq.com/presentations/Java-REST .
|
o
|
The link with text "here is a unit test case" is broken.
|
n
|
You can use the standard Java SE APIs: CODESNIPPET_JAVA1 .
|
p
|
Or you can use the REST client APIs provided by JAX-RS implementations such as Jersey.
|
o
|
These APIs are easier to use, but require additional jars on your class path.
|
p
|
CODESNIPPET_JAVA2 .
|
o
|
For more information see:
URL_http://bdoughan.blogspot.com/2010/08/creating-restful-web-service-part-55.html [ URL_http://bdoughan.blogspot.com/2010/08/creating-restful-web-service-part-55.html ] .
|
o
|
You can also check URL_http://www.restlet.org [Restlet] which has full client- side capabilities, more REST oriented that lower-level libraries such as HttpURLConnection or Apache HTTP Client (which we can leverage as connectors).
|
o
|
Best regards,Jerome Louvel .
|
p
|
You could try URL_https://github.com/harikrishnan83/rapa/wiki/ [Rapa] .
|
o
|
Let us know your feedback about the same.And feel free to log issues or expected features.
|
p
|
Rapa has a really nice interface and few dependencies.
|
p
|
A good alternative to RestSharp in the .NET world.
|
p
|
If you only wish to invoke a REST service and parse the response you can try out URL_http://code.google.com/p/rest-assured/ [REST-Assured] : CODESNIPPET_JAVA1 .
|
o
|
I use Apache HTTPClient to handle all the HTTP side of things.
|
o
|
I write XML SAX parsers for the XML content that parses the XML into your object model.
|
o
|
I believe that Axis2 also exposes XML -> Model methods (Axis 1 hid this part, annoyingly).
|
n
|
XML generators are trivially simple.
|
p
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.