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 frontend. However, everything depends on the requirements of the application.

You can still add web references to Web Services that autogenerate 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.

Get .Net Framework Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.