XML 和 SOAP 序列化XML and SOAP serialization

XML 序列化會將物件的公用欄位和屬性,以及方法的參數和傳回值,轉換成符合特定 XML 架構定義語言 (XSD) 檔的 XML 資料流程,以將 (序列化) 。XML serialization converts (serializes) the public fields and properties of an object, and the parameters and return values of methods, into an XML stream that conforms to a specific XML Schema definition language (XSD) document. XML 序列化會產生強型別 (Strongly Typed) 類別,其中包含的公用屬性和欄位都轉換為序列格式 (此例為 XML) 以進行儲存或傳輸。XML serialization results in strongly typed classes with public properties and fields that are converted to a serial format (in this case, XML) for storage or transport.

因為 XML 為開放標準,無論是何種平台,XML 資料流都可依需要由任何應用程式處理。Because XML is an open standard, the XML stream can be processed by any application, as needed, regardless of platform. 例如,使用 ASP.NET 建立的 XML Web 服務以 XmlSerializer 類別建立 XML 資料流,在網際網路或內部網路的 XML Web 服務應用程式之間傳遞資料。For example, XML Web services created using ASP.NET use the XmlSerializer class to create XML streams that pass data between XML Web service applications throughout the Internet or on intranets. 相反地,還原序列化採用這樣的 XML 資料流並重建物件。Conversely, deserialization takes such an XML stream and reconstructs the object.

XML 序列化也可用來將物件序列化為與 SOAP 規格相符的 XML 資料流。XML serialization can also be used to serialize objects into XML streams that conform to the SOAP specification. SOAP 是以 XML 為基礎的通訊協定,特別設計來傳輸使用 XML 的程序呼叫。SOAP is a protocol based on XML, designed specifically to transport procedure calls using XML.

若要序列化或還原序列化物件,請使用 XmlSerializer 類別。To serialize or deserialize objects, use the XmlSerializer class. 若要建立要序列化的類別,請使用 XML 結構描述定義工具。To create the classes to be serialized, use the XML Schema Definition tool.

另請參閱See also