O'Reilly logo

Programming Visual Basic .NET, Second Edition by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the Proxy

Before you can create a client application to interact with the calculator web service, you must first create a proxy class. Once again, you can do this by hand, but that would be hard work. The folks at Microsoft have provided a tool called wsdl that generates the source code for the proxy based on the information in the WSDL file.

To create the proxy, enter wsdl at the Visual Studio .NET command-line prompt followed by the path to the WSDL contract and the /l:vb flag:

wsdl <url> /l:vb

For example, you might enter:

wsdl http://localhost/VBWSCalc/Service1.asmx?wsdl /l:vb

The flag /l:vb tells wsdl to produce a Visual Basic .NET file.

The result is the creation of a Visual Basic .NET client file named Service1.vb, an excerpt of which appears in Example 16-3. You must add the namespace WSCalc because you’ll need it when you build your client (the tool does not insert it for you).

Example 16-3. Sample client code to access the calculator web service

'------------------------------------------------------------------------- ' <autogenerated> ' This code was generated by a tool. ' Runtime Version: 1.0.3705.288 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. ' </autogenerated> '------------------------------------------------------------------------ Option Strict Off Option Explicit On Imports System Imports System.ComponentModel Imports System.Diagnostics Imports System.Web.Services Imports System.Web.Services.Protocols ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required