I want to connect android application with sql server with web service - android

i want to build an android application and i need to save and retrieve data from sql server database
so i need to do that with web service
i dont have knowledge in web services and how they are done
so can you help me what is the best way to do the web service and connect my android client with sql database

That's a pretty broad question, but here are the basics. A web service is a program or app that runs on a web server, usually exposed to the internet, or within a company's LAN on their intranet. Web Services can be built using ASP.NET or JAVA or PHP. I've used ASP.NET, specifically Web API 2.0, and Entity Framework. Entity Framework makes it very easy to connect your Web Service to your SQL Server database. With Web API and Entity Framework, you can create your web service and connect it to your database with basic Read/Add/Update/Delete capability in 1-2 hours.
Once you write your web service, you need to publish it on a Web Server as a Web App. I typically publish to an IIS Web Server (also Microsoft). For that you need a Website Hosted account with a Microsoft based server. Microsoft can host your Web Service using the Azure Cloud service. You can check out some tutorials for building your Web Service using the technologies mentioned and deploying to the Web using Azure. You can get a free Azure account to start with. Then, if you need to use it for a long time, you might need to pay for hosting fees.
This is probably the easiest and best way for you to get started, particularly if you are new to web services.
Good Luck!
Here is a tutorial using the technologies I've mentioned, except for Azure. But you should be able to find a tutorial for publishing a web service to Azure separately.
https://www.c-sharpcorner.com/article/asp-net-web-api-crud-logics-using-entity-framework-without-writing-single-code/

Related

ASP.NET Backend for Native Mobile Application

I'm looking for a little top/level guidance. I don't expect a solution to the problems at hand. My goal is to create a native mobile application (not web) for iOS and Android. I want the content to be served from an in-house Microsoft Server, not a cloud based service like Azure. The mobile clients need to be able to login and make authorized read and write requests to the server. I figure I will return data as plain text and/or JSON. I'm debating using SQL Server or a NoSQL solution. I am also considering using something like ElasticSearch if I can't get speedy text searching working. The Microsoft topic has been somewhat confusing because I have never developed a Microsoft Web Application and most of the resources seem to assume a web based application or Azure hosting. So I was hoping for a little assurance I'm on the right track and hoping for a point in the direction to some resources that will help me on my way.
Microsoft Server. Not sure if I should be looking into ASP.NET MVC or ASP.NET WEB API, or something else entirely. If I use these frameworks, I can perform other async tasks on the machine right? For example, making additional calls to other web services to process requests.
Login: SSL for all connections. User sends username/password and system authentication. Server sends back token. With every request, client sends back token and server verifies token before processing request. Is this valid as long on a HTTPS connection? Just store the tokens in the server database and verify?
This application is not going to generate profit so an MBAAS is not really an option. It also is expected to handle roughly 2000 users and may need to scale to 10,000. Traffic would likely be concentrated as well. I know this is super broad, I just want a little direction to resources and big picture regarding Microsoft in this context.
If you're building an app that will communicate with a server, you probably want a Windows Service (SOAP) or a Web Service (REST) that it can communicate with.
You don't need ASP.NET MVC or WebAPI unless you're planning on creating a website (ASP.NET MVC) and communicating from said website using HTTP requests from the client side (WebAPI).
A Microsoft server hosting a Windows Service or Web Service should be fine. Yes, you can perform other requests from the server, even if you're hosting websites, a web service or Windows service on the same machine. Each HTTP request is a separate request that will be processed independently of one another.
Yes, you can secure the communications of between your web service and application quite easily using HTTPS/SSL. I'm not sure about just sending an identifier back and forth and that's it, this probably wouldn't be that secure. Maybe you can employ oAuth or a method that already exists. I believe that if you're creating you're own security system that you're probably doing it wrong - Leave it to people that specialise in those things.

Android application connecting to a public server database

I'm creating an application in Android, and I also have a virtual server in Amazon Web Services, because I'm trying to connect to a database hosted in there from my Android application; I'd like to know how could I connect to the AWS database (Microsoft SQL Server), I understand that the servers in AWS are visible publicly, but I'm lost here, Could you provide me some guidance on this? thanks!
Your best bet is to create a web service layer between your Android app and your back-end database. That way, your Android app talks to the web service via the HTTP protocol, and the web service (running on a web server with access to your SQL Server) talks to the database. This is the most common method for achieving the database connectivity you need.
You create your web services using whichever web technology you are most comfortable with; .NET, PHP, ColdFusion, or whatever. So-called RESTful web services are a nice way to do this. You can read about building RESTful web services with .NET here. Hope it helps. Good luck with your app.

Service to connect to SQL Server with Android

I'm creating my first android app. My app works in the following way:
User log into the app.
The login details is on an online server which is SQL Server 2008 R2
The server will return data to the app and the data the data will be stored on the app's database.
The problem I am facing is how should i connect to Sql server database. I researched on this topic and found out that I need to use some service. Can someone suggest as to what service should i use? A normal .NET web service, WCF service or Java Service.
I also need to know how to consume this service in my app.
Softwares I have with me:
Visual Studio 2008
SQL Server 2008 R2.
Android Development Kit & Eclipse
SQLite
Please help me.
I highly recommend the Asp.Net Web API for this:
"ASP.NET includes ASP.NET Web API for creating rich REST-ful Web Services that return JSON, XML, or any kind of content the web supports! ASP.NET Web APIs can provide data services to mobile apps like Windows Phones, iPhones, Android and more. ASP.NET Web APIs can be used in any ASP.NET Web Application, including ASP.NET MVC, Web Forms, or Web Pages – it's all One ASP.NET."
http://www.asp.net/web-api
Just to get you the general overview here;
You do not connect your (Android) app directly to the remote SQL database/server. Android, nor any other mobile platform, provides a steady and reliable interface for doing so.
Secondly, what you want to make indeed is a (REST) web-service.
As long as your needs are simple (passing along a bit of simple data between your app and your database) this means nothing more then having some web language take up some GET or POST variables and putting them in the database for you. And the same the other way around.
You can do this in any (web)language. The choice for language might be most influenced by the server you want to run in on, and what languages it already supports.

Web service for android social networking app?

I am developing social networking app on android.Rough idea of my app is that when user launches an app it will get all users of this app in near by location.So for storage purpose of users data I want to use web server. I don't have an idea what is best way to start with.Should i use Amazon web services ? (S3,Ec2) I was surfing internet got these buzz words.
Please guide me what is best approach for database storage ? Should i write my own server api ? or What ?
These are some general things you will have to do:
Buy some server space where you can host your server (this is the amazon ec2, etc). If you need a fancy domain name, buy that too, and map it to IP address of the server that you brought (optional).
Setup a db of some kind on this server to store your data (msql)
Write wrapper web services (php, jsp, etc) which will expose apis to access your data remotely. For security reasons, you should also have some authentication using some token passing mechanism.
Access the data on your server remotely using the APIs you created in the web service.
I personally favor using a MySQL database with PHP to interface between the app and the backend! Your app can send requests to PHP and then your PHP webservice would write/read to the database and then return JSON to your app.
I would say this is a very subjective question though as there as so many ways that you can write a web service.

What should I use as a server to meet the following requirements?

I am trying to develop a system that involves a:
server with a database that will handle the system's logic and manipulate data
an android app that will interact with that server (pull and push data into the server)
a website that will do the same as the android app, but from a website with slightly different data.
What I thought of is to use SQLite with Apache Tomcat installed on the server and deploy a Grails war file on it. That will take care of the 'website' side of the system. But what about the android app? Can it communicate with Tomcat as well?
Tomcat will suit your needs. I would look at hosting options though. Are you hosting your own server, or do you have a hosting provider? Do you have experience hosting a tomcat server etc. Do you have experience with java web applications, or other web frameworks? All of the above, and probably more should lead you to your decision on what type of framework/language to use on the server. This in turn will lead you to your options for hosting, and web-container to use.
Once that is determined all major web frameworks will allow you to publish web-services Rest, Soap, etc. that can be consumed by an android application.
Also, if you are planning on providing a web interface and service at the server level, my guess is you are going to be storing a fair amount of data, I would look into a more robust and scalable database such as mysql or postgres. This post contains some insights into this.
If you have an API that is web accessible, an Android can access it.
Android shouldn't have any problems communicating with Tomcat.
Look at http://grails.org/doc/latest/guide/13.%20Web%20Services.html for more information.
A RESTful web service is most likely what you'll need. Android can consume SOAP web services but it requires more work for less overall functionality.

Categories

Resources