wood burning stoves 2.0*
The moose likes Web Services and the fly likes Help with REST web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Help with REST web service" Watch "Help with REST web service" New topic
Author

Help with REST web service

Charan Kumar Br
Greenhorn

Joined: Oct 24, 2011
Posts: 10
Hello members,

I am developing an android app! Thought of using REST webservice with PHP to connect with remote database. I am a newbee to this. anybody with some example code on connecting login table with REST & PHP would help me a lot...

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
A RESTful web service does not care where the requests come from so the fact that Android is involved is not important.

The real question is, what on the server that can talk to a database is under your control??

Bill
Charan Kumar Br
Greenhorn

Joined: Oct 24, 2011
Posts: 10
That's so nice Brodgen.

can you give me some examples on REST to connect to a remote database...?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
As mentioned else where in another question you asked, DBs are not accessible via HTTP. You'll need to route the call through an HTTP server. One possibility would be a servlet container like Tomcat that runs the RESTful service using a library such as Jersey.
Charan Kumar Br
Greenhorn

Joined: Oct 24, 2011
Posts: 10
@Tim Moores thanks a lot..

Any other possibilities of accessing the DB's through HTTP server?? please mention so that i can select the best and easy one for me!!
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
What's best for you depends on lots of circumstances about which we know nothing. Maybe start by telling us why you think the approach I mentioned might not be a good one in your situation.
Charan Kumar Br
Greenhorn

Joined: Oct 24, 2011
Posts: 10
I have no clue about library Jersey. I have time to complete project. Let me finish with the easiest things.

Would you tell me how to call a webservice from android...?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Calling a RESTful WS from Android is pretty easy, as it has the capable Apache Commons HttpClient library built in. There are lots of example on how to use it around on the web; there's nothing Android-specific about it.
Charan Kumar Br
Greenhorn

Joined: Oct 24, 2011
Posts: 10
yes understood. Thanks a lot people. I also studied some books and got help from frnd.
How to consume webservices in java?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
Charan Kumar Br wrote: How to consume webservices in java?


That depends on the web service, doesn't it?

SOAP web services typically publish a WSDL which can be used to create a client.

RESTful web services typically publish a text description and example client code.

Bill
Charan Kumar Br
Greenhorn

Joined: Oct 24, 2011
Posts: 10
fine. how to consume RESTful webservices on java??? If any example code, please send me..
Amit Bathla
Ranch Hand

Joined: Feb 11, 2005
Posts: 51
Charan, I would suggest, you please read the basics about web serivces before consuming/building it.


Amit
University of Florida
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Charan Kumar Br wrote:how to consume RESTful webservices on java??? If any example code, please send me..

Did you read my previous reply? What further questions do you have?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
There are many web service tutorials, including for RESTful web services, here: http://netbeans.org/kb/trails/web.html
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Charan Kumar Br
Greenhorn

Joined: Oct 24, 2011
Posts: 10
Thank you Ivan!!
 
 
subject: Help with REST web service