0

.NET 4WCFWebサービスと通信するWebサイトがあります。そのWCFサービスは、リモートサーバー上のDynamicsGPWebサービスに接続します。両方のWebサービスは自己ホスト型です(IISなし)。

GPへの最初の呼び出しは完了するのに約12秒かかります!! 直後の呼び出し(別のWCF要求でも)は約100ミリ秒ですが、呼び出しの間に1〜2分待つと、再び10秒かかります...

問題の原因は何でしょうか。どうすれば解決できますか?

SvcUtilとVS2010Add Service Referenceの両方を使用してプロキシを生成しましたが、両方で同じ問題が発生しました。DynamicsGPプロキシファイルは3MBと巨大ですが、それが関係しているかどうかはわかりません。

Wiresharkを実行してネットワークトラフィックを分析しましたが、実際のtcp要求/応答ストリームは1秒未満で完了しているようです。リクエストが送信される前に、その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>
4

1 に答える 1

2

自己回答

コミュニティのために、これが私が見つけたものです(しかし、私は理由を説明できないので、尋ねないでください!;))

クライアントのapp.configで、useDefaultWebProxy="true"のように設定する必要がありますfalse...これにより、最初の呼び出しで7秒から約100ミリ秒までの非常に単純なHelloWorldWebサービスパスが作成されました。

クライアントのapp.configで、identity > userPrincipalNameセクションを完全に削除すると、最初のWCF呼び出しが10秒以上から1秒以内に渡されました。

于 2011-11-21T15:15:14.870 に答える