简体   繁体   中英

android app webservice pull data from ms sql server 2008

I'm trying to figure out the best way to have my android app pull data from my ms sql server 2008 database. I understand that there's two parts to this that the android app (written in java) has to call the web service (written in .net) and then that will call the database and pull the data, but all the examples I've found are rather piecemeal. They seem to only show the app side and not the webservice side or just the webservice side and not the other way around. I need one where I can see both sides and see how they work together. Does anyone have any good examples?

Some examples I've seen use a ksoap design that doesn't seem the best because it doesn't look like it's really supported that well. http://ksoap2.sourceforge.net/

Another one I've seen is a Jersey based design http://jersey.java.net/ , which looks like it would be easier but I have no idea how to interface it with a .net web service.

With MS SQL Server, I assume you will be using ASP.NET? If so, check out WCF Web HTTP Programming model (http://msdn.microsoft.com/en-us/netframework/cc950529.aspx). It's basically Microsoft's implementation of REST in WCF.

For an example, let's say I want to retrieve a user info from the SQL database. To do this, I can issue a normal HTTP GET request:

GET http://server/service/userinfo/id/5

The above will request user info that has primary id of 5, the WCF layer will then translate this into an appropriate SQL query and return it in a JSON string:

{ name : "john doe", email : "john@doe.com", phone : "111-111-1111" }

Your app basically parse this JSON string and convert it into POJO.

I think this RESTful method is much easier to implement than the traditional SOAP method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM