Create a Client Application

In this section, you'll create a Visual Basic 6 client application to consume the Mortgage Payment Calculator Web Service. Start a new Visual Basic 6 application and create a new Standard EXE project. Name the project MortgageCalculatorClient, and rename the default form frmMain. Build the user interface as shown in Figure 22.1.

Figure 22.1: VB6 Mortgage-Payment CalculatorClient application interface

Note You must download and install the Microsoft SOAP Toolkit before you can create or run this project in the development environment.

Note If you simply want to see the project run and don't have Visual Studio 6, you can install the Visual Basic runtime, the redistributable files for the SOAP Toolkit, and the

MortageCalculatorClient.exe executable file from www.sybex.com.

The background panels on the frmMain form in this example are PictureBox controls with their BorderStyle property set to None. The PictureBoxes resize to fill the width of the form when the form loads.

Private Sub Form Load() Unload frmInit pnl1.Move 0, 0, Me.Width pnl2.Move 0, pnl1.Top + pnl1.Height, Me.Width End Sub

Select the Project ® References menu item and add the references required for the SOAP Toolkit: the Microsoft SOAP Message Object Generator and the Microsoft SOAP Type Library. After adding the references, you can access the objects and methods in the Toolkit components.

When the user clicks the Get Payment button, the project must validate the user-entered values, contact the server, and retrieve the results, just as the browser and Windows Forms clients did in the last chapter. The SOAP Toolkit handles generating the SOAP request and parsing the SOAP response. All you need to do is create a SOAP client proxy object.

Dim wsClient As MSSOAPLib.SoapClient Set wsClient = New soapClient

The preceding lines create the client, but it isn't "attached" to a specific Web Service instance. To do that, you must initialize the SoapClient object, as discussed in the next section.

Was this article helpful?

0 0

Post a comment