I have a WCF endpoint as shown below
<service name="MyApp.Server.Endpoint.Orange" behaviorConfiguration="MyTio.Server.Endpoint.OrangeBehavior">
<endpoint address="" binding="basicHttpBinding" contract="Host.Server.Contract.IMyAppApi" bindingNamespace="http://host.com/myapp">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
when I add "Service Refrence" in .NET 3.5, we get the following proxy class that works great:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="GetMemberBillersRequest", Namespace="http://schemas.datacontract.org/2004/07/Contract.MemberBillers")]
[System.SerializableAttribute()]
public partial class GetMemberBillersRequest : WCFClient.MyRequest {
[System.Runtime.Serialization.OptionalFieldAttribute()]
private int ApplicationIdField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private int ProductIdField;
[System.Runtime.Serialization.DataMemberAttribute()]
public int ApplicationId {
get {
return this.ApplicationIdField;
}
set {
if ((this.ApplicationIdField.Equals(value) != true)) {
this.ApplicationIdField = value;
this.RaisePropertyChanged("ApplicationId");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public int ProductId {
get {
return this.ProductIdField;
}
set {
if ((this.ProductIdField.Equals(value) != true)) {
this.ProductIdField = value;
this.RaisePropertyChanged("ProductId");
}
}
}
}
the problem is that you are adding a link to the same service, but in .NET 2.0
you get the following proxy for the same contract:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3082")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.datacontract.org/2004/07/Contract.MemberBillers")]
public partial class GetMemberBillersRequest : MyRequest {
private int applicationIdField;
private bool applicationIdFieldSpecified;
private int productIdField;
private bool productIdFieldSpecified;
public int ApplicationId {
get {
return this.applicationIdField;
}
set {
this.applicationIdField = value;
}
}
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool ApplicationIdSpecified {
get {
return this.applicationIdFieldSpecified;
}
set {
this.applicationIdFieldSpecified = value;
}
}
public int ProductId {
get {
return this.productIdField;
}
set {
this.productIdField = value;
}
}
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool ProductIdSpecified {
get {
return this.productIdFieldSpecified;
}
set {
this.productIdFieldSpecified = value;
}
}
}
both are identical, except for the proxy generated through .NET 2.0, it has two additional fields:
productIdFieldSpecified and applicationIdFieldSpecified. The problem with these two fields is that if you do not manually set them to true, the corresponding fields (ApplicationId, ProductId) will not be serialized and transferred to the server!
can someone explain to me what is going on here?
EDIT:
, int, !
[DataContract]
public class GetMemberBillersRequest : MyRequest
{
[DataMember]
public int ApplicationId { get; set; }
[DataMember]
public int ProductId { get; set; }
}