Web Services - Microsoft Visual Studio .NET Example

This example is written in Visual Basic.NET and consists of the code for a button click handler on a form. The class hb-ac13281.GETADDRESSService was created by adding a Web Reference to the WSDL file (http://hb-ac13281:8080/NorthgateWebServices/GETADDRESS?wsdl) using the Add Web Reference... command on the Project menu.

Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
    Dim ga As hb-ac13281.GETADDRESSService
    Dim companyName, addressLine, telephone, zip, id As String
    companyName = ""
    addressLine = ""
    telephone = ""
    zip = ""
    id = TextBox1.Text
    Try
        ga = New hb-ac13281.GETADDRESSService
        ga.GETADDRESS(id, companyName, addressLine, telephone, zip)
    Catch ex As Exception
        Debug.WriteLine(ex.Message)
    End Try
    Label2.Text = companyName & vbCrLf & addressLine & vbCrLf _
        & zip & vbCrLf & telephone
End Sub

The code declares and initialises variables in which values will be passed to and returned by the GetAddress web service method (the id variable is set to a company ID that the user has entered into the TextBox1 control). The method is then called and the results displayed in the Label2 control. Code is included to handle any errors.