Hi,
If I have custom types (classes) in my web service, do I have to mark with with special attributes so they are serialized properly?
i.e. [SomeAttribute] ?
Update I am using WSE at the moment
Hi,
If I have custom types (classes) in my web service, do I have to mark with with special attributes so they are serialized properly?
i.e. [SomeAttribute] ?
Update I am using WSE at the moment
You need to mark them with [DataContract]
and the member variables that you want to send over the wire with [DataMember]
(those attributes live in System.Runtime.Serialization
, not in System.ServiceModel
).
This will mean that svcutil
will generate a client-side proxy class with those matching members. It won't however be the same as passing the actual class (which wouldn't make sense anyway).
EG:
[DataContract]
public class Person
{
public Person()
{ }
[DataMember]
public string Name { get; set; }
public string ThisMethodNotExposedToWcf() { }
The obsolete WSE uses the XmlSerializer. It should serialize most public read/write properties of types that have a default constructor. For more details, look up XmlSerializer.
And convert from WSE to WCF as soon as possible, as WSE is obsolete.