Library tutorials & articles
Data Integrity in Web Services
- Introduction
- Creating the web service
- The Test Client
- Conclusion
The Test Client
Although you can create any client you desire for the web service, in this example I have chosen to create a Windows Application. To do so, simply go to File->New Project and choose Windows Application. Drag and drop the items on the form to look something like the figure below.
Now choose Project->Add Web Referance and in the bottom left of this dialog box choose "Web Referances on Loacal Web Server". Choose the Web Service we created in step one, then click on OK.
Below is the event handler code for the two buttons of the application. The rest of the code required for the application should be autogenerated by the form builder. Also note you'll need to include the namespace of the web service in order to use the wrapper objects. It should look something like "using WindowsApplication1.localhost;", but you can find out the exact namespace from the Class View->localhost->PersonService. Look at the top of this code file and see what namespace VS.NET gave this wrapper.
private void GetterButton_Click(object sender, System.EventArgs e)
{
PersonData pd = ps.GetPersonData();
FirstNameField.Text = pd.FirstName;
LastNameField.Text = pd.LastName;
YearsExperienceField.Text = ""+ pd.YearsExperience;
}
private void SetterButton_Click(object sender, System.EventArgs e)
{
PersonData pd = new PersonData();
pd.FirstName = FirstNameField.Text;
pd.LastName = LastNameField.Text;
pd.YearsExperience = Int32.Parse(YearsExperienceField.Text);
try
{
ps.SetPersonData(pd);
MessageBox.Show("Person Set");
}
catch(Exception exx) { MessageBox.Show("Error Setting Data:"+ exx); }
}
|
To drive the point home as to what VS.NET is doing with the web service, double click on the PersonData struct in the ClassView of your application.
Taking a look around inside the class viewer is an excellent way to find out exactly what kinds of wrappers VS.NET is creating for differant things you might be doing and will generally give you an excellent idea of what to expect from your remote objects.
Related articles
Related discussion
-
MOS Protocol - Anyone used it?
by alexnavarro38 (5 replies)
-
Read HSQLDB data into a webpage
by joe90 (3 replies)
-
VB.NET Simple Client / Server Communication
by r0bbyw (3 replies)
-
Dot NET questions.
by amohanece (0 replies)
-
ListView-How to use it?
by imiazlina (8 replies)
Related podcasts
-
Remoting Pt. 2
Podcast (MP3): Download Hosts: Markus Michael Guests: Recording venue: This is the second part of the remoting infrastructures discussion started in Episode 9. We take a look at how remoting infrastructures such as CORBA, .NET Remoting or Web Service...
Events coming up
-
Nov
18
15 Minutes of Fame
Dresher, United States
This is a yearly tradition. We select 10 of the favorite speakers from monthly meetings, code camps, and hands on labs. Each one does a 15 minute talk on their favorite .NET technology. This is our 10th anniversary so we plan a gala event with special prizes and refreshments.
This thread is for discussions of Data Integrity in Web Services.