what is a web service in android? - android

Can any one tell what exactly meant by web service in anddroid. Every where am able to find how to call webvservice using different protocols. but am not understanding what exactly a web service.

Web Services are similar to web pages in the sense that you access them over the web using HTTP. The difference is that you are typically getting raw data back instead of a presentation page. For example you might get a row of records back like addresses. So the transport layer is HTTP. The data for Android is typically going to be encoded in JSON, or XML. And you can access the service using HttpClient or URLConnection. Often you can test a web service in a browser to see what you are getting back and you will usually see JSON or XML formatted data. For JSON you use a library like simple_json to extract into java object. XML is usually processed using a SAX Parser. They are really quite easy to use.

A Web Service, in Android, is just like any other computer, a request for information over HTTP.
"Web Services can convert your application into a Web-application" (from w3schools.com) means that your can use Web Services to provide a richer and more up-to-date experience. For example if your application is a text editor it could check a web services for updates rather than force the user to check a website for updates. Another example is writing your own client to Facebook which would use several Web Service calls and depend on Facebook for content to present to the user.

A web service is a standard used for exchanging information between
applications or systems of heterogeneous type. Software applications
written in various programming languages and running on various
platforms can use web services to exchange information over Internet
using http protocol. This inter-operability can be achieved between
Java and Dot net applications, or PHP and Java applications.
For example, an android application can interact with java or .net application using web services.

Related

How does android retrieve data from a website?

I'm new to android, I'm trying to build an android app that is a front for a web portal. For example, Airbnb. They have a website, but they also have an android app that, using it's own layout, will show listings from their website.
There are many websites that teach how to or even directly convert your website to android apps. However, this will result in an app that loads too slowly and is unresponsive due to CPU usage.
Could anyone share any tutorial/guide to learn how to do this myself?
Million thanks.
To actually load data from a web server you're gonna need and API which usually delivers the proper date using JSON or XML format so that you can properly parse and display that data. Building this API is in it self a complete course on its own.
But connecting to and requesting data from the API is usually done using some networking libraries. These are some of the better know libraries for this purpose.
OkHttp: A complete library with a set of tools for handling network connections and HTTP requests.
RetroFit:Type-safe HTTP client for Android and Java by Square, Inc. which is built on top of OkHttp.
Async-Http-Client:
The Async Http Client library's purpose is to allow Java applications
to easily execute HTTP requests and asynchronously process the HTTP
responses. The library also supports the WebSocket Protocol. The Async
HTTP Client library is simple to use.
There tons of other good libraries.
its called webservices
Through android you get data in form of json from a web server and then return in custom view as you want.
Follow this link hope it will help
Step by Step Method to Access Webservice from Android
you would have to write an API/Web service or use if already exits to fetch data from web server. Basically the concept is that, the website itself must be pulling data from some database, so write an API which would fetch the data from same API and return JSON data and consume the API from your android app.
If you know PHP refere to this for the help :http://www.codeproject.com/Articles/267023/Send-and-receive-json-between-android-and-php
You can write WebService, in programming it generally refers to a web page(ex. Airbnb), that can be called from your android application which can pass in data to it, or receive data from it.
WebService is basically like a 'method' or 'function' in a normal programming language; except you're calling it over the internet.
The first thing is you have to create a Web Service. The Web Service will be your "bridge" to consume the data from other Website like airbnb or others and return the data to your android through json format for example.
You can create a Web Service using many languages like C#, Java, PHP, etc. I would like to recommend you to use the language that you know the most.
You can try to google this
Cheers

Creating Web Service for Android Application

I've been reading some info about Web Services for Android using SOAP or REST but I've never created a web service so I have many questions about this.
I'm developing an Android App where the users answer some questions and for each user an XML file is generated and saved in the device.
Here are my queries:
What I would like to do is to send these XML files from the devices to the Web Service and also sometimes to retrieve all the files to any
device.
Do I need to convert these files into Byte or just send the XML?
Are these actions possible with the Web Service or will you use Java Sockets? In case you prefer the Web Service, what would you use:
REST, SOAP.
I would appreciate some links to tutorials and piece of advise.
Use SQL Server to manage the data on your desktop and create a web-service in .NET on Visual Studio.
Then connect to the web-service in your application and set/get data from the DB, using web-services. You can use either XML or JSON to transfer your data between the phone and the server.
There is no need for the use of Java Socket API for this.
Links which might be useful :
How to make a web-service in .NET (does not include the implementation in Android) : http://srikanthtechnologies.com/blog/dotnet/wsdaljava.aspx
How to connect your service with Android :
http://seesharpgears.blogspot.in/2010/11/basic-ksoap-android-tutorial.html
http://www.codeproject.com/Articles/304302/Calling-Asp-Net-Webservice-ASMX-From-an-Android-Ap
http://adrianandroid.blogspot.in/2012/05/access-c-net-web-service-in.html
Note: I have never worked on RESTful services. My work has always been on SOAP and hence it remains my preference.
Your final choice of how, exactly, to architect your app, is going to be based on all sorts of things that you haven't included in your questions: your experience, the experience of the other developers in the project, so on and so on.
I will say this, however. REST is deep in the heart of Android. If you decide to go with REST and, possibly, JSON instead of XML (there is, almost certainly, no reason to use byte arrays), you will find that Android's architecture supports you. SOAP and such and you are on your own.

asp.net Web Api and mobile aplications

I just want to make a TV guide for Android and later some other Mobile Platform. I want to use an RSS updates to update my application. In this specific scenario I want to use http://tvprofil.net/ 's RSS resource. I thought that I could just call site's RSS XML from my Android app, parse it, show, and thats the end of the story.
But, my cousine told me that the best way to do things is through Asp.net Web Api Service. Something to deal with REST. So, If I have to change resource, to like some iptv provider's RSS I would just change the Service and not have to deal anything with my mobile application. Other advantage, he said, is if I want to build Windows Phone application or iOS aplication that works the same way, I would have that same service to do job for me and just create UI and basic things for those apps.
The problem is that I have no idea how Asp.net web Api is used.
Can anyone give me some usefull link, or even better, write an example of this thig. I just want the RSS from http://tvprofil.net/ to go through Asp.Net Web Api Service and that I can call service and get it as XML or ... even Json... or to get anything at all to my app.
The whole thing is pretty confusing to me
If a RSS feed has enough data for your application to function then you do not need ASP.NET Web Api. The only role ASP.NET Web Api could play in this scenario is if it acted as an intermediate. E.g. your client application contacts your server application (ASP.NET Web Api) which in turn pulls the data from the actual external data source (tvprofil.net RSS).
For completeness sake, a list of pro's and con's:
Advantages of using an intermediate server
Reliability. You can cache the data of the external data source and serve that data even while the external data source is offline. Also, by caching the data you can lighten the load on the external data source to a bare minimum.
Transformability. Your intermediate server can translate the data of an external data source to another format that is more suitable for your client application. This is useful when you have many external data sources that each serve data in another format. Your intermediate server acts as a layer of abstraction for your client application.
Disadvantages of using an intermediate server
More effort. It will take more effort to develop and host an intermediate server.
Reliability. You must ensure your intermediate server is online and connected to the internet 24/7

Android web app

What are the best ways to connect site and show it's data on an android application ? Also does I have to create anything on server where the site is for using JSON ? I am new to programming web android application's, though I searched a lot I didn't find anything which would explain me straight to the point.
You're on the solid ground starting out using JSON as the interchange between the two.
Alot of popular mobile apps like Twitter and Foursquare have restful APIs set up to interact with their mobile clients by exchanging HTTP requests that contain data formatted as JSON. Most of the communication between the two can be accomplished with HTTP requests using the standard GET and POST methods.
A good place to start would be setting up some server endpoints that output this data and then setting up your android app to request and parse this data just like a browser would. You just need to set the appropriate mimetypes on your server end (application/json).
Most modern server-side languages have implemented modules/functions that can take their native data structures and approximate them in serialized JSON (PHP's json_encode(), python's json.dumps() etc) These can be used to output data from within the app or database to your mobile client where it can be interpreted and used in the Java environment there.
To pass back JSON you need to set the mime type (http://stackoverflow.com/questions/477816/the-right-json-content-type), which is application/json.
If you are passing back JSON or XML then the client just needs to make the appropriate http call, most likely GET, perhaps POST, to actually retrieve the information.
You can use something like this as a starting point:
http://lukencode.com/2010/04/27/calling-web-services-in-android-using-httpclient/

Needs workflow ideas for Android app

I'm planning on writing an android app that can view and update data on a local network Oracle DB.
I have already written a python script which checks the oracle db every couple of minutes and writes out XML files which I then plan to parse through my android app to display the data.
As I mentioned though this will only work if the android device is part of the same network (either connected locally or through a vpn), and the XML will be stored on a Unix server.
The question is how to access that Unix server with the android app? Can I use FTP via an android app, or should I be looking to change the python script to send the XML to an easily retrievable location?
EDIT To clarify what you mean, you have a web service running on something like tomcat, the client sends a request to get the data from the oracle db (can also use some form of authentication), the web service responds and sends the data in a format (XML, JSON etc.), the client then sends a request back to the web service to change some data on the oracle db, and in turn it does the clients bidding?
Normally you would create a web service to provide data to mobile clients. There are several reasons for this:
Web services are accessed via HTTP/HTTPS which is a standard protocol and is guaranteed to work on all networks. Corporate wifi networks are especially notorious for locking down protocols except for web and email.
Web services compared to static XML files have an advantage of creating response on the fly. Which means that data will be current.
Web services can take some input parameters and create response based on this parameters.
Authentication: it is a common approach to implement username/passord authentication in the web service, especially if you serve some private data.
Update:
REST is a very popular type of web service. Look at some implementations in Python: Recommendations of Python REST (web services) framework?
This book helped me a lot: http://oreilly.com/catalog/9780596529260
REST is a way of designing your web service. Folks much more intelligent than you and me have divined that all of the work needed for something to work on the net can be handled through a combination of HTTP status codes, HTTP verbs like POST, GET, DELETE, PUT etc. and a clear hierarchy of resources (nouns). It sounds very limiting but it's quite beautiful when it all works together.
Have a look at the Facebook Open Graph API (developers.facebook.com) to get an idea of what a proper REST service looks like.

Categories

Resources