問題描述
在 Web 服務 (WSE) 中公開自定義類型(類) (exposing custom types (classes) in a web service (WSE))
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
‑‑‑‑‑
參考解法
方法 1:
If you are using the Data Contract serializer by default nothing is serialized ‑ this is the opposite of the older XmlSerializer ‑ which is the older asmx web service approach.
For WCF look at the DataContractAttribute for starters: link text
方法 2:
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.
(by boingboing、Richard、John Saunders)