When you run a solution that sets the state of a request or of a response for an entity in Microsoft Dynamics CRM 3.0, you receive the following error message:
This method can only be called in the context of web service request.
ErrorCode: -2147220970
If you have the DevErrors parameter enabled, the following error message is logged in the Web.config file:
Error code: 0x80040216 Description: An unexpected error occurred.
Platform:
Details: This method can only be called in the context of web service request.
at Microsoft.Crm.CrmTrace.Assert(Boolean condition, String message)
at Microsoft.Crm.BusinessEntities.SerializationState.ValidateInWebService()
at Microsoft.Crm.BusinessEntities.SerializationState.OnEndWebRequest()
at Microsoft.Crm.WebServices.CrmSoapExtension.ProcessMessage(SoapMessage message)
at System.Web.Services.Protocols.SoapMessage.RunExtensions(SoapExtension[] extensions)
at System.Web.Services.Protocols.SoapServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream)
at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues)
at System.Web.Services.Protocols.WebServiceHandler.Invoke()