Skip to Content
Programming Visual Basic .NET
book

Programming Visual Basic .NET

by Dave Grundgeiger
December 2001
Beginner
464 pages
13h 51m
English
O'Reilly Media, Inc.
Content preview from Programming Visual Basic .NET

Consuming a Web Service

On the .NET platform, consuming a web service is as easy as creating one. This section contains the steps for creating a web-service client that can call the web service shown in Example 7-1.

Consuming a Web Service in Visual Studio .NET

To use a web service from a Visual Studio .NET project, right-click on the References node in the Solution Explorer window, and select Add Web Reference. This causes the Add Web Reference dialog box to appear.

In the Address field of the Add Web Reference dialog box, enter the URI of a web-service description document, and click the Add Reference button. When adding references to web services hosted by ASP.NET, the web-service description document is obtained by appending ?wsdl to the path of the service itself. For example: http://www.company.com/myWebService.asmx?wsdl or http://localhost/WebServices/Hello-WebService.asmx?wsdl.

Visual Studio .NET reads the web-service description document and builds a corresponding proxy class that knows how to access the described web service. The proxy class is local and exposes the same functionality as the web service. To call the web service from within the project, instantiate the proxy class and call its methods. For example, the following code instantiates the HelloWebService class and calls its SayHello method in response to a button click:

' Assumes that this code is part of a form having a button named ' btnOk_Click, a text box named txtName, and a text box named txtResult. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Visual Basic .NET, Second Edition

Programming Visual Basic .NET, Second Edition

Jesse Liberty

Publisher Resources

ISBN: 0596000936Supplemental ContentCatalog PageErrata