Quirk in 'Add Service Reference'

Topics: General Discussion Forum, July and December Releases Forum
Jul 30, 2007 at 7:02 PM
Hello,
I have this web service created using WSSF with the WCF guidance. I have a Service Contract consisting of an Operation called AddLogEntry() which takes in an as a request an object. For e.g. say I have the object called Activity which has properties, the Business Entity is as follows:

private System.Int32 activityIdField;

public System.Int32 ActivityId
{
get { return this.activityIdField; }
set { this.activityIdField = value; }
}

The corresponding XSD serialized object in the DataContracts is as follows:

private int activityIdField;

System.Xml.Serialization.XmlAttributeAttribute()
public int ActivityId
{
get
{
return this.activityIdField;
}
set
{
this.activityIdField = value;
}
}

Now when I add a Service Reference to the Web Service from my Smart Client application, the stubs generated have the fields as:


private int activityIdFieldField;

System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)
public int activityIdField
{
get
{
return this.activityIdFieldField;
}
set
{
this.activityIdFieldField = value;
}
}

Shouldn't it just generate the properties similar to the existing XSD on the Service end? Has anyone else encountered this problem?
Jul 30, 2007 at 8:45 PM
I solved this problem. To those who are wondering why this happens, apparently the answer lies in the conversion from XSD to a DataContract. Apparently, the recipe doesn't allow you to directly serialize the XSD into DataContracts.

So I went ahead and generated the classes from XSD using XSD.exe and then used "Decorate type as DataContract" and that seemed to take care of it.