且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在wcf和android中创建web服务

更新时间:2022-03-22 08:42:15

你需要了解Web服务的概念,WCF只是一个可用于创建Web服务的技术。



Web服务只是一个应用程序,它充当服务器,可以被连接的设备使用,传递一些数据,执行任何功能。服务器。 WCF是此过程中使用的技术。使用WCF,您可以在任何应用程序(甚至是控制台应用程序)中托管Web服务,并通过任何应用程序甚至网站访问服务,并在服务器上执行一组命令(在我们的示例中;请参阅最后一段,控制台应用程序)。 Android应用程序只是一个客户端,它将使用该服务传递一些数据,执行一个函数等。



但是会有一个你需要了解的几件事,





  • 您的网络服务将托管在计算机上,并带有Uri指定客户端与之通信。
  • 将数据保存在MySQL数据库中的代码将是Web服务功能的一部分,而不是Android应用程序。
  • 创建一个模块,它将连接到MySQL并将数据保存到它。
  • 您将从Android应用程序向您的Web服务发送数据以保存数据。
  • 然后向Android应用程序发送回复。
You need to understand the concepts of a Web Service, WCF is just a technology that can be used to create a web service.

A Web Service is a just an application that acts as a server that can be used by the devices connected, to pass on some data, to execute any function on the server. WCF is the technology used in this process. Using WCF you can host the web service in any application, even a Console application and access the service through any application even websites and execute a set of commands on the server (in our case; see the last paragraph, a Console application). Android application would just be a client, that would be using the service to pass on a few data, to execute a function or so on.

But there would be a few things you need to understand,


  • Your web service would be hosted on a computer, with a Uri specified for the clients to communicate with it at.
  • The code to save the data in the MySQL database would be a part of the Web Service function, not the Android application.
  • Create a module, that would connect to MySQL and would save the data to it.
  • You will send the data from the Android application to your web service to save the data.
  • Send a response to the Android application then.