I am referencing an external SOAP service (by external I mean created by another development team) as a service reference in my .NET Service Layer.
I have performed this type of operation many times before and typically the proxy that is generated would contain a class structure with data fields and then <FieldName>FieldSpecified
properties to allow selective population of those fields.
This approach works well as it is basically passing information back to another application to update certain fields in its database.
Below is a sample class that has been generated in the past with the desired behavior:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17929")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://www.sampleproxyclass.com/updatecustomer")]
public partial class Customer : object, System.ComponentModel.INotifyPropertyChanged {
private string CustomerName;
private System.Nullable<System.DateTime> dateOfBirthField;
private bool dateOfBirthFieldSpecified;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order=1)]
public string CustomerName{
get {
return this.CustomerName;
}
set {
this.CustomerName= value;
this.RaisePropertyChanged("CustomerName");
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(DataType="date", IsNullable=true, Order=4)]
public System.Nullable<System.DateTime> dateOfBirth{
get {
return this.dateOfBirthField;
}
set {
this.dateOfBirthField= value;
this.RaisePropertyChanged("dateofBirth");
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool dateOfBirthFieldSpecified{
get {
return this.dateOfBirthFieldSpecified;
}
set {
this.dateOfBirthFieldSpecified= value;
this.RaisePropertyChanged("dateOfBirthFieldSpecified");
}
}
}
For some reason this latest service will not generate the FieldSpecified
properties at all which is causing us a major integration headache. I have no control of the XSD specification or creation but I have been trying to help the team responsible for the XSD to change the definition so that it generates the proxy as above in my sample.
I thought that the key was to add minOccurs="0"
to the definition but that has not worked. I also got them to try nillable="true"
but again no joy.
So my question is what XSD configuration drives the creation of the FieldSpecified
properties when a service reference is added to a .NET project?
I am using VS2013, Framework 4.5.1.