I have a DTO type declared as follows:
[Serializable]
public class PersonDTO
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
I have a WCF service whose operation contract reads as follows:
[OperationContract]
public PersonDTO GetPerson(int id);
The problem that I have is when I consume this service by using 'Add Service Reference', the wsdl contains as follows:
<xs:schema elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/Test.DTO">
−
<xs:complexType name="PersonDTO">
−
<xs:sequence>
<xs:element name="_x003C_Id_x003E_k__BackingField" nillable="true" type="xs:int"/>
<xs:element name="_x003C_FirstName_x003E_k__BackingField" nillable="true" type="xs:string"/>
<xs:element name="_x003C_LastName_x003E_k__BackingField" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="IVQueueDTO" nillable="true" type="tns:IVQueueDTO"/>
</xs:schema>
When I try to reference on the WCF client, instead of getting person.Id and person.FirstName, I'm getting person.Idk__BackingField, person.FirstNamek_BackingField, etc.
What should I do to get the exact type as I defined on the WCF service side? I'm using Serializable attribute on PersonDTO, because, this service needs to be interoperable with java. I'm using .NET Framework 4.0, C#, Visual Studio 2010, Win XP SP3. The WCF service exposes http endpoint and uses basicHttpBinding.