Data Integrity in Web Services (turn two)

Source: Internet
Author: User
Tags web services wrapper
Services|web Although can create any client you desire for the Web service, in this example I have chosen to create a Windows application. To does 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-bottom left of this dialog box choose ' Web referances on loacal Web Se RVer ". Choose the Web Service we created in step one, then click OK.

The Below is the event handler code for the two buttons of the application. The rest of the code required for the application should is autogenerated by the form builder. Also Note "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;" and But you can find out the exact namespace from the Cl Ass View->localhost->personservice. Look in the top's this code file and the 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 are doing with the Web service, double click on the Persondata struct Sview of your application.


Taking a look around inside the class viewer is a excellent way to find out exactly what kinds of wrappers vs.net is Crea Ting for differant things your might be doing and'll generally give you a excellent idea of what to expect from your REM OTE objects.


Web Services are one of the hottest technologies going right now but there are a number of pitfalls so any programmer mu St be aware of. Data Integrity is important to any object's proper functioning and must be assured or it could corroupt a larger and generate a very difficult to trace error. By using the "techniques in" article you can keep your objects safe and your data assured.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.