DekGenius.com
[ Team LiB ] Previous Section Next Section

8.4 Windows Forms and Web Services

Previously, Windows DNA tended not to use fat clients, rich Windows applications on PCs, because of the need for an intrusive installation program. With .NET "copy" deployment, there is no such problem. Now fat Windows clients can interface easily with business logic in the middle tier through XML/HTTP. The rich client application will, in fact, perform better than a web-based front end. However, everything depends on the requirements of the application.

You can still add web references to web services that auto-generate proxy classes for use in your Windows Forms applications just as for Web Forms applications. This is further evidence that .NET as a whole is intended to embrace the Web. In Windows Forms, data binding is automatic once you've set the control's DataSource to the appropriate data source, as seen in the next block of code. Note that there is no explicit call to the DataBind method as in Web Forms data binding:

localhost.PubsWS ws = new localhost.PubsWS(  );
DataSet ds = ws.GetAuthors(  );
DataGrid1.DataSource = ds.tables[0].DefaultView;

Again, you can also generate the source for the proxy class yourself using the wsdl.exe tool, along with the WSDL obtained from the web service. You can then include this source to your Windows Forms project or compile the source into a DLL and add the DLL to the project as a reference.

    [ Team LiB ] Previous Section Next Section