Saturday 24 March 2012

Accessing Restful Services from Java Command Line Application`




In this small note, let us see the simple java command line programs to access RESTful Service.REST stands for Representational State Transfer(that is representation of resources is exchanged between client and server).I would be using( accessing :-) ) the Twitter WebService(Messaging API) and the Webservice URI for the same is


http://twitter.com/statuses/public_timeline.xml (for payload in xml format)
http://twitter.com/statuses/public_timeline.json(for payload in json format).



I've tried accessing the service in two simple ways


1.using java.net package
2.using jakarta Commons HttpClient.


1.Using java.net package






2.Using HttpClient : This method of accessing is also simple as first one,but is little sophisticated with the return status code check and granularity.
needed binaries
1.jakarta commons Httpclient 
2.jakarta commons codec
3.jakarta commons logging.






Cheers and Thanks for reading :-) :-)

No comments:

Post a Comment