I have a web site that communicates with a .NET 4 WCF web services. That WCF service connects to Dynamics GP Web Services on a remote server. Both Web Services are self-hosted (no IIS).
The first call to GP takes around 12 seconds to complete!! Calls immediately after (even in another WCF request) are around 100ms, but if I wait a minute or two between calls, it will take again 10 seconds...
What could be the cause of the issue, how can I resolve it?
I've generated a proxy using both SvcUtil and VS 2010 Add Service Reference, but got the same problem with both. The Dynamics GP proxy file is huge 3MB, don't know if that's related.
I ran Wireshark to analyse network traffic and the actual tcp request-reply stream seems to take less than a second. There seems to be something going on before the request is sent that take up that 10 seconds.
Here is the code used:
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();
}
Here's the 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>