The aim of the following tutorial is to give you a basic information about Web Service
To execute the example in this tutorial you need visual studio 2005 or 2008 :
This is an express edition of visual studio 2008 VS2008
In this tutorial we will create a form that gets information from a web service about the euro2008 (Europe football cup) .
Firstly select a vb.net project and design a form like this:

Application Interface

Application Interface


In this form we will show a list of all stadiums, teams of euro2008 football cup.
Select a stadium and click the button Click, the application gets the city and capacity of the stadium selected in the stadium combobox from the webservice.
Now let’s select the reference to the web service, right click to the service references, add a service reference.

Service References

Service References

Secondly we will add the link of web service to our project: http://euro2008.dataaccess.eu/footballpoolwebservice.wso?WSDL , and click “go to” then wait until VB find to webservice, now specifiy a name for the space name of the web service then click ok, the Visual Basic generates different configuration files :

Add Service References

Add Service References

Now let’s write some code in the form to make the web service works correctly:

Public Class Form1
‘ ServiceReference1 is the name space that you chose
Public ws As New ServiceReference2.FootballPoolWebServiceSoapTypeClient

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

‘ define the staduim_lenght and the numbers of teams
Dim stadium_lenght, Team_count As Integer

stadium_lenght = ws.StadiumNames.Count
stadium_lenght -= 1

‘ add names of staduims from the web service to the combobox1
For i = 0 To stadium_lenght

ComboBox1.Items.Add(ws.StadiumNames.Item(i).Trim())
Next i

Team_count = ws.Teams.Count
Team_count -= 1

‘add names of teams from the web service to the combobox2

For j = 0 To Team_count

ComboBox2.Items.Add(ws.Teams.ElementAt(j).sName)
Next j
ComboBox1.SelectedIndex = 0
ComboBox2.SelectedIndex = 0
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

‘ Select then city name, staduim name, and the capacity of the stadium ‘chosen in combobox1

TextBox1.Text = ws.StadiumInfo(ComboBox1.SelectedItem.ToString()).sCityName
TextBox2.Text = ws.StadiumInfo(ComboBox1.SelectedItem.ToString()).sStadiumName
TextBox3.Text = ws.StadiumInfo(ComboBox1.SelectedItem.ToString()).iSeatsCapacity

End Sub
End Class

This is how the interface application looks at executing the program:

Executing Application

Executing Application

You created your first interaction with an existing web service (euro2008), if you have any comments or remarks post it in my blog or alert me by email.