The example in this article describes the method by which ASP.net calls the WebService service. Share to everyone for your reference, specific as follows:
Webservice:webservice is an application logic unit that can be accessed by a program in a platform-independent manner through a standard web protocol.
(1) Application logic unit: Web services include some application logic units or code. These code can complete the computation task, may complete the database inquiry, may complete any work which the computer program can complete.
(2) accessible by program: Most Web sites are currently accessed by human browsers, and Web services can be accessed by computer programs.
(3) Standard we protocol: all protocols to Web services are based on a set of standard Web protocols such as HTTP, XML, SOAP, WSDl, UDDI, etc.
(4) Platform independence: Web services can be implemented on any platform. Because the standard protocol is not dedicated to a single vendor, it is supported by most major vendors.
Soap(Simple Object access Protocol) protocol: A lightweight protocol for exchanging XML encoded information, a SOAP protocol that is a combination of HTTP and XML protocols.
The WSDL(Web service Description language,web Service Description Language) is the standard for describing Web services using XML documents, and is the interface definition language for Web services.
Ii. creating asp.net Web Services
Setting up a Web service is exposing some information or logic to other computers and customers, and, further, creating one or more methods from a class that supports SOAP communication.
Steps to create a Web service: (VS2008)
First, create a new Web site. Select the file--------> New---------> Web site, open the New Web Site dialog box, and select the ASP.net Web service template. When determined, the creation succeeds.
When created, Service.asmx is generated and the code-behind file Servece.cs is located in the App_Code file. Web Service files all use the extension. asmx.
Found in VS2010, creating a Web service is to create a new Web site first, add a new item in the selection, and then select a Web service.
Iii. use of asp.net Web services
(1) Adding Web references
1, create a new site, right-click the site root, select the Add Web Reference item.
2, in the Add Web Reference dialog box, select or fill in the URL of the Web service in the URL list box. (. asmx file path) and then in the Add Web Reference text box, fill in the Add Web reference name that you want to use in your application.
3, click the "Add Reference" button, which is located in the App_WebReferences directory, where the WSDL file for the Web service has been added. In the <appSettings> block of the application's Web.config file, the following configuration is added to set the actual Web reference.
(2) The client invokes the Web service
After you add a Web reference service, you can invoke the Web service on the client.
1. In the new Web site, add a page default.aspx, add a TextBox control, a button control, and a label control to the page
2. The Click event code for the Add button "Invoke Serice service" is as follows.
Using Simpleweb;
protected void Button1_Click (Object Sender,eventargs e)
{
//Materialized service object
Service ms=new service ();
Invokes the Helloword method of the service object Ms
//passes TextBox.Text as a parameter to the Helloword method
label1.text=ms. HelloWorld (TextBox1.Text);
}
(3) Browse the Web default.aspx, enter a name in the browser, and then click the button to invoke the HelloWorld method of the Web service services and display the results on the label.
Summary: The whole process of applying Web services is to add Web Services----------> Add Web References----------------> client calls
More interested readers of asp.net related content can view the site topics: "asp.net string operation tips Summary", "ASP.net Operation XML Skills summary", "asp.net file Operation skills Summary", "ASP.net Ajax Skills Summary topics" and " Summary of ASP.net caching operation techniques.
I hope this article will help you to ASP.net program design.