A more important part of Microsoft .NET strategy is WebService, using WebService we can create a real valid distributed application. Here, we do some instructions for WebService. Suppose A is the client, B is the WebService server, and the user sends SOAP requests to the server via HTTP protocol, and WebService returns data in the client XML format. Now let's take a look at the process of creating a WebService: the server's WebService is necessary. In the middle of SOAP, XML we don't have to care, on the client, how is it more important to get an object from WebService? The answer is to use the Proxy object. The client is responsible for communicating with WebService by the proxy object (Proxy). So use WebService in the client, which is completely and uses a local object. We now explain with a simple example. Open vs.net, new project (ASP.NET Web Service), type http: // localhost / webserver in your location, where WebServer is the name of the project. After determining the emergence of a Service1.asmx.cx, double-click, the code window, using System appears; using System.Collections; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Web; using System.Web. Summary Description of Services; Namespace WebServer {///
/// summary> Protected Override Void Dispose (Bool Disposing) {IF (Disposing && Components! = NULL) {Components.dispose ();} #ndregion // Web Services example /// HelloWorld () Sample Service Returns Hello World // To generate, cancel the following list, then save and generate items / / To test this web service, press F5 // [WebMethod] // Public String HelloWorld () // {// Return "Hello World"; //}}} Add [WebSpace = "http: // localhost / webserver /")] This is because SOAP is based on HTTP protocol The client cannot know that WebService is on that server. In practical applications, this WebService is placed on http://www.orfly.com, then Namespace is changed to http://www.orfly.com/webserver. Let's add a method to this WebService. // [WebMethod] // public string helloworld () // {// return "hello world"; //} Microsoft helped us write one, then add a method. Method name is show. [WebMethod] public string show (String Yourname) {return "http://www.orfly.com" "Welcome" YourName;} Now, you can run, press F5, click Show, enter Your name, then click INVOTE to see it. XML Version = "1.0" encoding = "UTF-8"?>