Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Serializing Callouts

CRM 1.2
banner art

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

Example

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

[C#]
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),
            "http://schemas.microsoft.com/crm/2006/WebServices");
        BusinessEntity entity =
            (BusinessEntity)xmlSerializer.Deserialize(sr);

        DynamicEntity myDE = entity as DynamicEntity;
        return myDE;
    }
}
[VB.NET]
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),
            "http://schemas.microsoft.com/crm/2006/WebServices")
        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.


Show:
© 2015 Microsoft