Posts Tagged ‘SoapException’


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);

}

 

 

Advertisements