欢迎光临
我们一直在努力

Data Integrity in Web Services (转二)-.NET教程,Web Service开发

建站超值云服务器,限时71元/月

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 youll 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.

web services are one of the hottest technologies going right now but there are a number of pitfalls that any programmer must be aware of. data integrity is important for any objects proper functioning and must be assured or it could corroupt a larger program and generate a very difficult to trace error. by using the techniques in this article you can keep your objects safe and your data assured.

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Data Integrity in Web Services (转二)-.NET教程,Web Service开发
分享到: 更多 (0)