dynamics-crm-4soapexception

How to narrow down to the actual issue when you receive a generic SoapException: Server was unable to process request. from MS-CRM 4.0


I recently started programming against CRM 4.0 and I am issuing these requests using the CrmService. Often I get the wrong values in the some property of the dynamic entity that I am using when I send the request. Of course the request fails, am intercepting the exception and log it. The problem is that this is what I get:

System.Web.Services.Protocols.SoapException: Server was unable to process request.
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at Microsoft.Crm.SdkTypeProxy.CrmService.Execute(Request Request)
   at MyEntity.Employee.ExecuteCreateRequest(CrmService service, DynamicEntity entity) in c:\Workspaces\One\...\Employee.vb:line 351\nSystem.Xml.XmlElement

which is not much to go with.

Until now I was eliminating some properties by hunch and test it again and then tried to guess what might be wrong with the property's value. Is there another way to get some more detailed information of what cause the error so I can pinpoint the actual culprit faster.


Solution

  • You'll need your catch block to catch SoapException and then you can surface the Detail, or Message properties as required. The Details property likely contains the hints you are looking for...

    ...
    catch(SoapExcetion soapEx){
        console.writeLine("SoapException: " + soapEx.Detail);
    //    console.writeLine("SoapException: " + soapEx.Message);
    }
    catch(Exception ex){
        console.writeLine("Exception: " + ex.Detail);
    }
    

    You might also consider enabling Tracing on the CRM server and looking at the log files too.