我有一个与.NET 4 WCF Web服务进行通信的网站。该WCF服务连接到远程服务器上的Dynamics GP Web服务。这两个Web服务都是自托管的(没有IIS)。首次调用Dynamics GP 2010 Web服务需要10多秒
GP的第一个电话需要大约12秒才能完成!呼吁立即后(即使在另一个WCF请求)是100毫秒左右,但如果我等待调用之间一两分钟,这将需要10再次数秒
可能是什么问题的原因,如何我可以解决它吗?
我已经使用SvcUtil和VS 2010添加服务引用生成了一个代理,但两者都有同样的问题。动态GP代理文件是巨大的3MB,不知道这是相关的。
我运行Wireshark来分析网络流量,实际的tcp request-reply流似乎不到一秒钟。在请求发送之前似乎有一些事情要花费10秒钟。
下面是使用的代码:
Context context = new Context();
CompanyKey companyKey = new CompanyKey();
companyKey.Id = -1;
context.OrganizationKey = companyKey;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
_proxy = new DynamicsGPClient();
_proxy.ClientCredentials.Windows.ClientCredential.Domain = Domain;
_proxy.ClientCredentials.Windows.ClientCredential.UserName = Username;
_proxy.ClientCredentials.Windows.ClientCredential.Password = Password;
long openingMs = sw.ElapsedMilliseconds;
CustomerCriteria customerCriteria = new CustomerCriteria();
CustomerSummary[] gpCustomers = _proxy.GetCustomerList(customerCriteria, context);
long fctCallMs = sw.ElapsedMilliseconds;
...
if (_proxy != null && _proxy.State != System.ServiceModel.CommunicationState.Faulted) {
_proxy.Close();
}
这里的的app.config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="GPWebService" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.x.y:48620/Dynamics/GPService/GPService" binding="wsHttpBinding"
bindingConfiguration="GPWebService"
contract="DynamicsGpService.DynamicsGP" name="GPWebService">
<identity>
<userPrincipalName value="DEV\gpeconnect"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
我对Dynamics的所有知识都不了解,但这听起来像是第一次启动Dynamics服务的IIS应用程序池。这可能需要一些时间。假设是这种情况,您可能需要检查应用程序池上的超时设置。 IIS应用程序池的默认超时时间为20分钟,因此增加应减少必须经过此启动延迟的次数。 –
感谢Chris,但我不这么认为,Web服务(Dynamics和我自己)都是“自我托管”的。而且,远低于20分钟的标准,长时间的延迟回来了...... – dstj