A small but nice and very powerful new feature is intrinsic to the proxy generation process, again. I cannot count the number of emails and newsgroups postings I have read and answered regarding this problem. The standard proxy generation process in the 1.x version of the .NET Framework always emits public fields for complex types found in the serviceâs message contractâs data structures. This is of course a big disadvantage, at least when it comes to data binding â have you ever tried to bind Windows Forms controls to public data fields?
Version 2 now automatically and by default generates private fields encapsulated by public properties. This is a big win. The following code listing is the OrderStatusInfo class we have been talking a few times in former posts.
[System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute( Namespace="http://www.thinktecture.com/demos/Orders")] public class OrderStatusInfo {
private int orderNumberField;
private System.DateTime orderDateField;
private System.DateTime shipDateField;
/// <remarks/> public int OrderNumber { get { return this.orderNumberField; } set { this.orderNumberField = value; } }
/// <remarks/> public System.DateTime OrderDate { get { return this.orderDateField; } set { this.orderDateField = value; } }
/// <remarks/> public System.DateTime ShipDate { get { return this.shipDateField; } set { this.shipDateField = value; } }
Finally we have the desired behavior that makes data binding a breeze. And for those of you paying attention to the above code, you might have realized an additional attribute that can save a lot of people a lot of work: System.SerializableAttribute. This means that now by default our types are not only XML serializable by using the XmlSerializer but also runtime serializable by using one of the runtime formatters like SoapFormatter or BinaryFormatter.
To sum up all the new and important switches of wsdl.exe that have been introduced in this short overview, you can take a look at the following table.
Switch
Description
sqltypes
Generate SqlTypes for nillable primitive elements. The switch cannot be used with /server.
sharetypes
Turns on Proxy Type Sharing feature.
verbose
Displays extra information in the case /sharetypes switch were specified.
fields
Generate fields instead of properties.
Table: Important wsdl.exe switches
BTW, if you want or need those features, i.e. public fields and [Serializable] types - already with .NET 1.x you can try the WSCF tool.