简体   繁体   English

从Android设备调用.Net Web服务

[英]Calling .Net web service from Android Device

I am using Android Studio and Visual Studio (.NET MVC) to develop an application where an android device may store/retrieve/process (login /registration forms etc) data by calling methods in a .NET application. 我正在使用Android Studio和Visual Studio(.NET MVC)开发一个应用程序,其中android设备可以通过调用.NET应用程序中的方法来存储/检索/处理(登录/注册表格等)数据。

I want to know the best way to achieve this. 我想知道实现此目标的最佳方法。
Should I create a .NET Web service on my .NET side? 是否应该在.NET端创建.NET Web服务? (WCF) (WCF)

This is my first time creating a web service layer so I would really appreciate it if someone could provide me an article on how to achieve this. 这是我第一次创建Web服务层,因此如果有人可以向我提供有关如何实现此目的的文章,我将不胜感激。 I found a nice one below: 我在下面找到了一个不错的:

http://hintdesk.com/how-to-call-asp-net-web-api-service-from-android/ http://hintdesk.com/how-to-call-asp-net-web-api-service-from-android/

Thanks guys, just checking if I'm on the right track using web services for my application. 谢谢大家,只需检查我是否对应用程序使用Web服务就可以了。

If you want to use .NET, then I would go with Wcf/Web api, depends on what you need. 如果您想使用.NET,那么我将使用Wcf / Web api,具体取决于您的需求。

The basics of building an HTTP service using ASP.NET Web API 使用ASP.NET Web API构建HTTP服务的基础

Configure your Service to be restful, and pass the data using JSON so it would be easy to consume using libraries such as Retrofit or Volley. 将您的服务配置为静态,并使用JSON传递数据,以便使用Retrofit或Volley之类的库很容易使用。 You can then use a library like Gson to parse the response. 然后,您可以使用Gson之类的库来解析响应。

Another upside is that if you later want to consume the data from other platforms (iPhone or web/mobile web) it would be very easy. 另一个好处是,如果您以后想使用其他平台(iPhone或Web /移动Web)上的数据,这将非常容易。

使用KSOAP的链接有一个非常简单的示例LINK

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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