Hi!
Is it possible to use both DataContractSerializer and XmlSerializer (combine them) in a WCF-service, and maybe also in one method?
I have a project with approximately 50 classes marked with DataContract-attributes. I altso have some external XSD-schemas I have to use wich is not compatible with DataContractSerializer (collections are not grouped in a tag). I have generated classes (another 50) marked with XmlSerializer-attributes from these schemas. My solution looks similar to this:
Classes marked as DataContracts:
- Driver
- Wheel
- ConnectionInfo
Classes marked as XmlSerializable:
- StandarizedCar
- MyCustomCar : StandarizedCar
So, Standarized car is generated from XSD and marked with XmlSerializable-attributes. I made a class MyCustomCar wich extends StandarizedCar and adds some properties (like wheels and a driver, notice that Wheel is a DataContract). I want to make a service with the following methods:
void:Connect(ConnectionInfo info)
MyCustomCar:GetCustomCar(int carID)
void:AddWheel(Wheel wheel)
My question(s):
1. Can my Service use both DataContractSerializer and XmlSerializer?
2. Can my method GetCustomCar() use both DataContractSerializer and XmlSerializer, or do I have to choose one for each method?
3. Can I mark Wheel with both DataContractSerializer-attributes AND XmlSerializer attributes?
4. Will GetCustomCar work if I mark it with [XmlSerializerFormat] even though Wheels don't have any XmlSerializer-attributes)?