best practices for restful webservice - android

Tried to search for this online and didn't get very far, so I'm asking here. What are some of the best practices people have come across for building a website with a restful service? Is it good to combine them both into one or keep them as two separate applications?

Although it depends on a lot of things what's the best to do, what I probably would do is, I'll have a set of "backend" functionality what are doing the "business" things, and the web app will call these functions "directly", and they will be exported as web service calls too. In Java there are lots of handy framework making this very easy - like Spring + Jackson - and I'm sure this is the case in other languages too.

Related

Android application interacting with a server

Ok so, I know the question is pretty much google-able and I did google it and found out a few answers ,so I am not asking this question knowing completly nothing.
So, I have an application (Cannot specify much about what it does or is or so...) and I need to get some data from a database.
As far as I know, the Volley is the best way to go ,but I am still looking for more details.
Could anyone tell me which is the best way to go?
NOTE: I am NOT looking for code,I am looking for methods.A name would sufice ,as I can do the digging myself.Eventually links to documentations would be awesome, but again, I can find documentations.I just need to know which is the fastest way and the most optimized.
Based on your comment, it looks like there are two different aspects to your application:
Sending out the HTTP requests from your client- i.e. your android app
Processing and sending the response to these requests on the server side, by setting up a web service
Looks like you have part 1 figured out. Note that, volley is a library, similar to android HTTP library, but optimized for faster networking.
For part 2, unless you're planning to use embedded database like sqlite, you'd need to learn about writing web services to provide database access.
Spring Data JPA is one of the many ways to do it.
I hear Parse is great too, but not free.

Architecture for a Website which will have a Mobile app.

I am planning on creating a DB driven site/ Application which needs to also have a mobile version e.g iPhone App or an Android App.
What are the things I should consider before building the site.
E.g DB so that it is accesible by the apps too.
Should I build Web services ?
Just want to start off right so I dont need to modify things once the site is live.
This is a general architecture question on how the design of the site needs to be so that it can be accessed by the various app SDK's.
Well I am not sure what language/framework you have in mind.
Personally I'd recommend using .NET with MVC.
Furthermore I would use webservices, but I would definitely make them in WCF vs the older asmx. What is WCF
You can use WCF to create different entry points into your services. EG one for the website, one for mobile devices.
For the database my tendency is to use MSSQL [you can use the free one if you are going to be using under 10 GB]. However you are in no way constrained. Use MySQL if you want, or hey, maybe you don't need an RDBMS, in which case try MongoDB!
The main thing to consider though is that it really depends on your needs and what you are delivering. You are getting my preference not The Right Thing in all cases.

Middleware design for mobile application

I am developing application for iPhone and android. In code i need to access the data from database(oracle) .
I am planning to use REST web services to return JSON data to devices. I dont know much about developing web servies(all i did is 'consumption' part).
Now the question came to my mind, i can still manage to return the JSON data from java servlets.
IS there any advantage of using web services. I know for sure I am missing something but want to know what is it.
Now the question came to my mind, i can still manage to return the JSON data from java servlets.
Yes, you can return JSON from java servlets. There are plenty of libraries out there for taking what ever data you've retrieved from you database and serializing it into JSON.
IS there any advantage of using web services. I know for sure I am missing something but want to know what is it.
This is a super general question, but yes. I think the best answer is that (among other things) it gives you an API that arbitrary clients can plug into. So you can expand to new platforms trivial. That's the main benefit as far I see it.

Android application consuming WCF/RESTful service

I have a WCF RESTful application I wrote based off of WcfRestContrib and hosting in iis7.5, which passes a pdf as a byte[]. I'm trying to figure out how, and what the best way would be, to consume this service in an Android application. I believe I took care of all the Java/WCF interop issues because the service is used by an outside company that uses java. But I don't see to many examples out there. I've read that I'm going to have to make a method that passes JSON instead XML, but otherwise I believe it should be usable for an Android app. I'm not seeing too many examples of Android apps that consume RESTful services, is this not the preferred method for Android?
I seen a couple articles (http://romenlaw.blogspot.com/2008/08/consuming-web-services-from-android.html) but most seem kind of old, though they still may be useful. I'm just curious how any experts out there would suggest I handle such a project, I can create another kind of service if need be. I just want to be able to load pdf's from a service based on some parameters. Security is a concern, but not mandatory at this stage. Service currently uses basic auth and is on a https.
Any thoughts? Suggestions?
While also adressing your security concernt, you could use an HttpsURLConnection and then use getInputStream() from that to put it in a bytearray using read().

How to use webservices in android?

I want to know about how to call webservices in android I had done a lot of search from Internet and have read several tutorials but was not able to understand much and manipulate, can anyone suggest any Tutorial, or provide any Pdf file or any book related to web services so that I can understand it.
Thanks in advance
The first reading I would suggest is this one - this is the W3School tutorial. Don't forget to read the related chapters included in this tutorial - Soap, Wsdl, etc - as this tutorial taken as a standalone would not be so valuable. This tutorial is not specifically related to Android but will give you all the information needed to understand the use and constraints of this kind of architecture, and then structure your project.
Under Android, you will face the specific contraint of mobile phones and tablets: the network can be down, and is often down: in the tube, in a basement, in any area that have a bad network coverage. So you will have to take care of this, either by caching data or allowing the application to work in degraded mode when no network is available. These are just examples as I don't know your context.
After that, Android is developed in Java, with a specific API that comes on top of the regular java.* packages. These are just tools to implement the client side. On server side, depending of whether you control these services, you may also have some implementation to do. If so, this can be Java, PHP, .Net, anything: one of the purpose of the web services architecture is to stay independant of the remote implementation to only care the exchange protocol. But reading your question, I think the two first points are more important (or have an higher priority let's say) than the implementation as they are prerequisites. (EDIT: Anyway, a useful discussion about that can be found here on StackOverflow.)
Android Doesn't have it's own tool then you should use your own or use some Thing Like KSOAP2.
You Can Use This.
http://www.c-sharpcorner.com/UploadFile/88b6e5/how-to-call-web-service-in-android-using-soap

Categories

Resources