DataContract
serializer is the default for WCF. There are several possible reasons why XML serializer is used in your case:
If the schema is not compatible with the DataContractSerializer, the XmlSerializer is selected. Check this article for details.
Attribute XmlSerializerFormat is applied on the service
Could you check whether one of above points is your case?
If it doesn't work for you, please provide definitions for UserPrivilegeInfo
and your service contract (both interface and implementing class)
UPDATE:
Ok, now we've identified that forced use of XmlSerializer was caused by returned DataSet.
It's generally a bad practice to return DataSet from WCF service.
These articles explain why:
Returning DataSets from WebServices is the Spawn of Satan and Represents All That Is Truly Evil in the World
Why returning dataset or data table from WCF service is not a good practice? What are the Alternatives?
Consider returning DTO (Data transfer object) instead of messy DataSet. You just fill DTO fields from the DataSet and transfer DTO to the client. The client accesses the data through strongly typed DTO by fields like Id
, Name
, etc.
In your case redefine method GetCenterWebUser()
in the following way:
[DataContract]
public class CenterWebUser
{
[DataMember]
public string Name { get; set; }
[DataMember]
public string Email { get; set; }
// Other fields for the user
}
public class SomeService : ISomeService
{
public CenterWebUser GetCenterWebUser()
{
DataSet ds = ...;
var userTable = ds.Tables["Users"];
var userRow = userTable.Rows[0];
return new CenterWebUser()
{
Name = userRow.Field<string>("Name"),
Email = userRow.Field<string>("Email")
// ...
};
}
}
}