Search

in a WSDL generated proxy, setting the field value should also set the Specified flag for fields that get specified flags by zak1

Closed
as Won't Fix Help for as Won't Fix

3
Sign in to vote
0
Sign in to vote
Sign in
to vote
Type: Bug
ID: 90727
Opened: 8/9/2004 10:29:25 AM
Access Restriction: Public
0
Workaround(s)
1
User(s) can reproduce this bug
When a WSDL defines an element that has a minOccurs='0' you get an additional specified flag for that field that indicates if you want to actually send the field. The setter for the field value should also set the specified flag as well, If i've set a value in the field then its because i want to send it. This makes it vastly more natural to work with.
Details (expand)
Product Language
English
Version
Visual Studio 2005 Beta 1
Category
Other
Operating System
Windows XP Professional
Operating System Language
US English
Steps to Reproduce
generate a WSDL that contains this complexType definition

<xsd:complexType name="address">
<xsd:sequence>
<xsd:element name="Rating" type="xsd:int" nillable='true' minOccurs='0'/>
</xsd:sequence>
</xsd:complexType>

generate a client side proxy from the WSDL using wsdl.exe
Actual Results
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://samples.pocketsoap.com/dn2/")]
public class address {

private System.Nullable<int> ratingField;

private bool ratingSpecified;

[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
public System.Nullable<int> Rating {
get {
return this.ratingField;
}
set {
this.ratingField = value;
}
}

[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool RatingSpecified {
get {
return this.ratingSpecified;
}
set {
this.ratingSpecified = value;
}
}
}
Expected Results
The setting for the field value (Rating.set) should also set the ratingSpecified field, e.g.

[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://samples.pocketsoap.com/dn2/")]
public class address {

private System.Nullable<int> ratingField;

private bool ratingSpecified;

[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
public System.Nullable<int> Rating {
get {
return this.ratingField;
}
set {
this.ratingField = value;
RatingSpecified = true;
}
}

[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool RatingSpecified {
get {
return this.ratingSpecified;
}
set {
this.ratingSpecified = value;
}
}
}
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 8/14/2004 at 5:20 PM
Thank you for the suggestion.
This would be nice enhancement, but unfortunately this also is a breaking change: in the previous versions of the .net framework setting value of 'xxx' field did not toggle the xxxSepcified value, so if we change this runtime behavior of some existing applications may change and will require user code change to run the same way as before.
Posted by ryanvs on 4/1/2008 at 11:31 AM
This would be very useful and could easily be implemented through optional parameters to the wsdl.exe tool. The optional parameters would not affect current implementation and everyone would be happier. Enhancing functionality does not always have to be a breaking change! Also, I would alter the statement to: this.ratingSpecified = (value != null);