There is often a need for exchange of data between different systems, and Web service technology enables different applications running on different machines to exchange data or integrate with each other without the use of additional, specialized third-party software or hardware. Applications that are implemented according to the Web Service specification can exchange data with each other, regardless of the language, platform, or internal protocol they are using. Web service is a self-describing, self-contained, available network module that can perform specific business functions. Web service is also easy to deploy because they are based on some common industry standards and some of the technologies that are available, such as subset XML, HTTP, in standard generic markup language. Web service reduces the cost of application interfaces. WEB Service provides a common mechanism for integration of business processes across the enterprise and even across multiple organizations. "Baidu Encyclopedia"
Here is a simple example of an ASP. NET WebService:
1: First add the Web service (that is, the ASMX file) to the project.
2: Add the following asmx file by default code as follows.
3: Customize a Test interface method (Description = "Test service is OK") for descriptive information about the method after deployment.
[WebMethodAttribute (Description = "Test Service is pass")] public string test () {return GetResult (tru E, "Connection succeeded", "", "Test", ""); public string GetResult (bool status, string description, String UserData, String MethodName, String xmlpars) {StringBuilder sb = new StringBuilder (); Sb. Append ("<?xml version=\" 1.0\ "encoding=\" gb2312\ "?>"); Sb. Append ("<DataBody>"); Sb. Append ("<DATA>"); Sb. Append ("<ReturnInfo>"); Sb. Append ("<Status>" + Status. ToString () + "</Status>"); Sb. Append ("<description><![ cdata["+ description +"]]></description> "); Sb. Append ("</ReturnInfo>"); if (status && UserData! = "") {sb. Append ("<UserArea>" + UserData + "</UserArea>"); } sb. Append ("</DATA>"); Sb. Append ("</DataBody>"); Save interface Call log//string ClientIP = Context.Request.ServerVariables.GetValues ("remote_addr") [0]; Db_xxtwebservicelog.insertlog (ClientIP, MethodName, System.Text.Encoding.Default.GetBytes (Xmlpars), System.Text.Encoding.Default.GetBytes (sb.) ToString ()), status? "1": "0", description); Return SB. ToString (); }
3: Compile the project and deploy to IIS, create a new application pool, add the application.
4: Access to the service in the browser
5: You can call the test method in the browser to test whether the service is
6: Specific how to call, different languages have different forms. As for how to use XML to transmit data in WebService, see Webservice,asmx file a way to pass parameters, validate, and get the return value in XML format using XML format data
A simple example of ASP. NET WebService