Handling SOAP Exceptions In Microsoft Dynamics CRM

The only exception thrown by the CRM Web service is a common

SoapException whose message property is always “Server was unable to process

request.”

 

To handle that exception, catch the exception and display the InnerXml error

code, error text, and error description

 

Example

 

try

{

// Delete the non-existent Contact

service.Delete(EntityName.contact.ToString(), contactGuid);

}

catch (SoapException ex)

{

// This will contain the error message from the platform

Console.WriteLine(“Microsoft Dynamics CRM Error

Information:”);

Console.WriteLine(ex.Detail.InnerText);

// The InnerXml contains the details of the error in a

parsable XML format

XmlDocument error = new XmlDocument();

error.LoadXml(ex.Detail.InnerXml);

// Render out the details of the error

Console.WriteLine(“Error Code: ” +

error.SelectSingleNode(“/error/code”).InnerText);

Console.WriteLine(“Error Description: ” +

error.SelectSingleNode(“/error/description”).InnerText);

Console.WriteLine(“Error Type: ” +

error.SelectSingleNode(“/error/type”).InnerText);

}

 

 

Author: Arvind Singh

Microsoft Dynamics CRM Consultant

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s