Serializing Callouts

banner art

The XML string passed to the callouts is a serialized DynamicEntity.


The following method can be used in your callout code to deserialize the XML string into an instance of a DynamicEntity class.

using System.IO;
using System.Xml.Serialization;
using CrmSdk;

class module1
    public DynamicEntity DeserializeDe(string des)
        TextReader sr = new StringReader(des);

        // De-serialize the XML stream using the XmlSerializer class.
        XmlSerializer xmlSerializer = 
            new XmlSerializer(typeof(BusinessEntity),
        BusinessEntity entity =

        DynamicEntity myDE = entity as DynamicEntity;
        return myDE;
Imports System.IO
Imports System.Xml.Serialization
Imports CrmSdk

Module Module1
    Public Function DeserializeDE(ByVal des As String) As DynamicEntity
        Dim sr As TextReader = New StringReader(des)

        ' De-serialize the XML stream using the XmlSerializer class.
        Dim xmlSerializer As New xmlSerializer(GetType(BusinessEntity),
        Dim entity As BusinessEntity = 
            CType(xmlSerializer.Deserialize(sr), BusinessEntity)

        Dim myDE As DynamicEntity = CType(entity, DynamicEntity)
        Return myDE
    End Function
End Module

For more information, see Using DynamicEntity to Access Entities at Runtime and how to Deserialize XML into an instance of BusinessEntity.

© 2007 Microsoft Corporation. All rights reserved.