gpt4 book ai didi

c# - 为什么 Microsoft Dynamics CRM 4.0 在调用 RetrieveMultiple Web 服务时偶尔会失败?

转载 作者:行者123 更新时间:2023-11-30 18:05:52 26 4
gpt4 key购买 nike

我有 C# 使用 CRM RetrieveMultiple 网络服务来更新潜在客户实体记录。 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

下面是调用网络服务的代码:

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 本身的问题。,,我无法以可控的方式重现错误。如果您有提示、想法或解决方案,请告知!

谢谢

最佳答案

您多久检索一次记录?之后你也更新它们吗?在高容量下(并且使用默认的 IIS/Windows Server 设置)我看到服务器用完可用端口,因为每次调用 CRM 服务(即使使用相同的服务对象)CRM 都会打开另一个端口。

关于c# - 为什么 Microsoft Dynamics CRM 4.0 在调用 RetrieveMultiple Web 服务时偶尔会失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5122682/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com