Using web services - android

This question is maybe easy or unnecessary for you but I'm stuck here.
I'm trying to make application which store your spending money information. I finished the interface of the app, but the sql part isn't done because i wanna use that sql from internet. As i know, i should use web services ( maybe there is another way ). It should do like add 5 dollar to marketing, add 20 dollar to fuel categories.
Is the best way using web service?
How am i going to create and use my own db? ( i mean do i create db
on sql server and upload it to host, or creating db with codes on
android studio ? )
I've looked a lot of web services tutorials, but all of them is very confusing. I need tutorial with very basic explanation. Which tutorial or example do you suggest me?

You should host a SQL database and create a RESTfull HTTP web service to perform your desired functions. Make sure you develop the web service using JSON, since this can be easily parsed and used within Android. This tutorial should get you started, if you know php. You can of course create the API in the language of your preference.
From your android application you can then send HTTP requests to your webservice and parse the JSON response to use it in your API.
Your question is a bit broad, so I hope I provided means to get started. If you have any more specific questions about the above design, feel free to ask them.

Related

How to connect android to python web services and MySQL database

I'm new to Android and to web services in general.
This is what i gotta do: My company has a back end website(for the client to monitor the sales) that's used to manage/monitor sales on some stores and it connects to a MySQL db to store data about sales and users(usernames and passwords).
What I want to do is to get data from that database and to add (sync operations) new rows, all of this from my android app.
I googled this many times and it came up with some similar projects but using another languages.
I would like to see some code samples if possible and some how-to theory, what theory should I follow when developing this, how and what ways of communicating between android and python web services and from the web services to the MySQL database.
Thank you in advance.
You will need a working API, that allows you to communicate to the web service from the android application. I would read into how to write an API and how to build a RESTful service using JSON as a way of communicating between server and android app. There are alternatives to JSON, but JSON is better suited for Android than perhaps AJAX and soap is being used less and less. (Can ajax call be done in Android? It can but has limitations)
(I could only post two full hyper links as i don't have enough reputation yet to do so, you may have to remove the spaces)
API:
http://sharismlab.com/blog/2012/07/21/how-to-write-an-api-for-your-web-app/
REST:
www .restapitutorial. com/lessons/whatisrest.html/
JSON:
htt p:// www.r evillweb.co m/article s/why-use-j son/
You may want to check out restjee. It allows you to define and implement RESTful data access APIs without having to write any server side code. Works with just about any database.

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.

App Reading From SQL Server Web Service

I am in the process of creating an Android application which I want to use to execute a web service on my SQL server which in turn runs a stored procedure.
Having never completed a project like this before, I would like to know what the best way to go about this is?
I.e.
Displaying the SQL results
Reading from the web service
Adding password protection
I've developed apps before, but never SQL - related.
From doing some research I noted the need for a web service and created one, it's the process of running my app to read from it which I would like guidance with. Even a link to a helpful tutorial would be great. Thanks.
EDIT
To be more specific on the display.
Currently the stored procedure is displayed through crystal reports, however I have no need for 'drill - downs' or any functionality other than to actually view.
Something similar without the functionality would be fine.
I would recommend KSOAP with a SOAP webservice for proof of concept/tech demo http://seesharpgears.blogspot.com/2010/11/basic-ksoap-android-tutorial.html
or use the built-in JSON parser with a restful/json webservice
How to call a json webservice through android
Perhaps this link can help you, it has a useful video on the subject and detailed information.
Another link Comsuming WCF Services With Android
And also maybe this could help: Android Web Service MyWeather

Android App Login MS SQL

I am trying to make an android app that requires a user to login against a MS SQL Database.
Having read around the most popular way seems to be to use JSON to do this however I'm not sure how secure this would be (especially if there is no SSL being used).
My question is what are the alternatives available and if JSON is the best/easiest way to achieve this how can I make it more secure? Is this also how big companies (such as dropbox etc) do this?
When I first started Android programming I was told that making a direct connection to the database is considered bad practice, and that an interface (JSP, PHP, .NET) should always be used. I don't know if this is a security thing or not but it would probably be the best for you.
If possible, create a .NET (or whatever server-side language you are comfortable with; .NET would probably be the easiest if you're working with a MS SQL server) page and talk to it over HTTPS (there's your security) and pass it the login info using POST. You could use JSON but name value parameters would accomplish the same thing. Have your page connect to the DB and test the information you pass it against whatever is in it. Then pass back a value that says whether it is correct or not in the response.
EDIT:
This looks like a decent guide to getting HTTPS set up on Android (just browsed through it quickly so I can't vouch for it 100%).
JSON is just the form you pass data in.
Noone stops you from using SSL for the connection. Or encrypting the JSON data in your own way.

How have to be a Webservice for use it with Android?? (limitations, paramters, return... etc)

i have a android APP that needs a remote Database, to do INSERT's and SELECT's.
I will use a webservice to comunicate with the remote database, the webservice will be installed in the server side, with the remote database, and webservice will do the SELECTS and the INSERTS and will return me XML data. But i dont know anything about webservices, then a friend will do it.
But my friend need's to known if there is any limitations making webservices for Android. I search on google for days but all i am finding is very complex and i can't find the answer to these three questions:
Webservice needs to be created with a special way?
Webservice remote functions can have parameters? (i need to give to the webservice parameters to do the select's or the inserts of data)
Webservice can return results in XML normally or needs a special way to do it?
Also, if i have to know something more, please tell me
thanks
Regarding HTTP networking Android can basically do what plain Java can do. There are a few limitations:
XML parsing/generating is pain. AFAIK, there is no automatic XML-object mapping library (JAXB) for Android. For this reason it's best to go with REST/JSON. Jackson does ok on Android.
Yes they can.
Any XML is ok, but look at 1.
My suggestion: go with Restlet - they have clients for all Java platforms (servlet, android, gwt, j2se).

Categories

Resources