为什么Microsoft Dynamics CRM 4.0在调用RetrieveMultiple Web服务时偶尔会失败?
我使用CRM RetrieveMultiple Web服务C#来更新Lead实体记录。一切都在80%的时间内完美运作。
大约20%的时间,它失败了。失败时,这里是SoapException Detail.InnerText属性:
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
以下是进行Web服务调用的代码:
local.mycompany.crm.CrmAuthenticationToken token;
local.mycompany.crm.CrmService service;
local.mycompany.crm.lead tourRequestLead = new local.mycompany.crm.lead();
tourRequestLead.emailaddress1 = "xxxxxxx@mycompany.com";
token = new local.mycompany.crm.CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = "mycompanyCRM";
service = new local.mycompany.crm.CrmService();
service.CrmAuthenticationTokenValue = token;
service.UnsafeAuthenticatedConnectionSharing = true;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.Url = "http://crm.mycompany.local/mscrmservices/2007/crmservice.asmx";
// Create the ColumnSet that indicates the properties to be retrieved.
local.mycompany.crm.ColumnSet cols = new local.mycompany.crm.ColumnSet();
// Set the properties of the ColumnSet.
cols.Attributes = new string[] { "emailaddress1", "new_initialtourrequestlistingid", "description" };
// Create the ConditionExpression.
local.mycompany.crm.ConditionExpression condition = new local.mycompany.crm.ConditionExpression();
// Set the condition for the retrieval to be when the contact's address' city is Sammamish.
condition.AttributeName = "emailaddress1";
condition.Operator = local.mycompany.crm.ConditionOperator.Equal;
condition.Values = new string[] { tourRequestLead.emailaddress1 };
// Create the FilterExpression.
local.mycompany.crm.FilterExpression filter = new local.mycompany.crm.FilterExpression();
// Set the properties of the filter.
filter.FilterOperator = local.mycompany.crm.LogicalOperator.And;
filter.Conditions = new local.mycompany.crm.ConditionExpression[] { condition };
// Create the QueryExpression object.
local.mycompany.crm.QueryExpression query = new local.mycompany.crm.QueryExpression();
// Set the properties of the QueryExpression object.
query.EntityName = local.mycompany.crm.EntityName.lead.ToString();
query.ColumnSet = cols;
query.Criteria = filter;
// Retrieve the leads.
local.mycompany.crm.BusinessEntityCollection retrieveLeads = null;
try
{
retrieveLeads = service.RetrieveMultiple(query);
}
catch (Exception exp)
{
Console.WriteLine("RetrieveMultiple " + exp);
CountError += 1;
}
if ((retrieveLeads != null) && (retrieveLeads.BusinessEntities.Length > 0))
{
try
{
foreach (local.mycompany.crm.lead rlead in retrieveLeads.BusinessEntities)
{
string strNotes = rlead.description;
}
}
catch (Exception exp)
{
Console.WriteLine("Reard " + exp);
CountError += 1;
}
}
我几乎已经排除了VPN或CRM 4.0本身的问题。我无法以受控方式重现错误。如果您有提示,想法或解决方案,请告知我们!
谢谢
没有找到相关结果
已邀请:
1 个回复
素汞读