Why webservices in .net




















Scalable e. Programmable encapsulates a task. Based on XML open, text-based standard. Self-describing metadata for access and use. Discoverable search and locate in registries - ability of applications and developers to search for and locate desired Web services through registries. This is based on UDDI.

Web Service History Microsoft coined the term "Web services" in June , when the company introduced Web services as a key component of its. Net initiative, a broad new vision for embracing the Internet in the development, engineering and use of software. As others began to investigate Web services, it became clear that the technology could revolutionize be the next stage in distributed computing. Web services encom a set of related standards that can enable any two computers to communicate and exchange data via a network, such as the Internet.

Developers use XML tags to describe individual pieces of data, forming XML documents, which are text-based and can be processed on any platform. Almost every type of business can benefit from Web services such as expediting software development, integrating applications and databases, and automating transactions with suppliers, partners, and clients.

So, any application that understands XML-regardless of the application's programming language or platform has the ability to format XML in a variety of ways well-formed or valid. SOAP - Provides a communication mechanism between services and applications. WSDL - Offers a uniform method of describing web services to other programs. Web services advantages Use open, text-based standards, which enable components written in various languages and for different platforms to communicate.

Promote a modular approach to programming, so multiple organizations can communicate with the same Web service. Comparatively easy and inexpensive to implement, because they employ an existing infrastructure and because most applications can be repackaged as Web services.

Implemented incrementally, rather than all at once which lessens the cost and reduces the organizational disruption from an abrupt switch in technologies. Write a web service by using Visual C. Original product version: Visual C. Write an. Select Click to switch to code view in the designer environment. Note Not every method needs to have the WebMethod attribute.

Is this page helpful? Yes No. Any additional feedback? Skip Submit. After these steps, an empty website project will be opened. Now add a Web Service file to the website project. The Add New Item window contains three panes, these are left side pane, middle pane, and right side pane. From the middle pane of the Add New Item window, select the Web Service file and under the name textbox enter the name for the Web Service file and then press the Add button of the Add New Item window.

The name of the Web Service file should be any valid name. The extension of the Web Service file is.

When the Web Service file is added to the website project then two files are automatically added to the website project. The extension of one of the file is. Suppose the name of the Web Service file is WebServiceCalculation then two files are automatically added to the website project.

The name of the first file is WebServiceCalculation. Following is the default code of the WebServiceCalculation. We can change the code of this method according to our task or functionality and we can also create more Web Service methods according to the number of tasks or functions.

For example, if we want to create a Web Service for calculation purposes to add and subtract two integer values then we will create two Web Service methods, one method to perform addition and another method to perform subtraction. To create a Web Service that performs addition and subtraction of two integer values, the above code of the WebServiceCalculation.

Now the Web Service Server application is ready to use. When the above Web Service application is run, the. To use a Web Service, a client application is created and it is reference with the Web Service application using the Add Web reference to the website.

NET Web Application. Now, go to the Solution Explorer, right click on the project name and press the Add option then select Service Reference. Now, from the Add Service Reference window, press the Advanced button. Now, copy the URL of the. ASMX is displayed in the browser of the Add Web Reference window then in the Web reference name text box, a default name is displayed for the Web Service that is usually the name of the localhost. We can give any name to the Web reference name.

Change the Web reference name from the localhost to any other name, suppose ReferenceWebService, and then press the Add Reference button.

The Add Reference button creates a Proxy at the client side. The Web reference name is used as a directive in the client application and it must be included in the client application. We can also use a fully qualified name of the Web Service application main class. The Web Service reference automatically added to the Web Application under the Web references folder. Now add a new Web Form to the Web application and give a meaningful name to it.

Now create three textboxes controls and two command button controls on the ConsumeWebServiceForm. The first two textboxes control will read two integer values from the user and the third textbox control is used to display the result of the Web Service method.

The first button control is used to send values of the first two textbox control to the AddTwoValues Web Service method and the second button control is used to send the values of the first two textbox controls to the SubtractTwoValues Web Service method.

When the Web reference name is included in the ASP. The default web service code behind file looks like the following:. Step 6 : Change the code behind file to add the two dimensional array of strings for stock symbol, name and price and two web methods for getting the stock information.

Step 7 : Running the web service application gives a web service test page, which allows testing the service methods.

Step 9 : For testing the GetName method, provide one of the stock symbols, which are hard coded, it returns the name of the stock. For using the web service, create a web site under the same solution. This could be done by right clicking on the Solution name in the Solution Explorer. The web page calling the web service should have a label control to display the returned results and two button controls one for post back and another for calling the service.

A proxy is a stand-in for the web service codes.



0コメント

  • 1000 / 1000