WCF服务的第一个请求大约需要5-6秒,毕竟调用执行得非常快。下面是我的WCF服务的客户端配置。
使用IIS宿主。
WSHttpBinding binding = new WSHttpBinding();
binding.SendTimeout = TimeSpan.FromMinutes(1);
binding.OpenTimeout = TimeSpan.FromMinutes(1);
binding.CloseTimeout = TimeSpan.FromMinutes(1);
binding.ReceiveTimeout = TimeSpan.FromMinutes(1);
binding.AllowCookies = false;
binding.BypassProxyOnLocal = false;
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
binding.MessageEncoding = WSMessageEncoding.Mtom;
binding.TextEncoding = System.Text.Encoding.UTF8;
binding.UseDefaultWebProxy = true;
binding.Name = "BasicHttpBinding_ILearningService";
binding.Security.Mode = SecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
binding.Security.Transport.Realm = "";服务器端配置
<services>
<service behaviorConfiguration="LearningServiceServiceBehavior" name="LearningService">
<host>
<baseAddresses>
<add baseAddress="https://xxxxx/LearningService.svc" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="ILearningSuiteService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="TransportSecurity" messageEncoding="Mtom" sendTimeout="00:1:00" openTimeout="00:2:00">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="LearningServiceServiceBehavior">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" httpGetUrl="http://xxxxxxx/Metadata" httpsGetUrl="https://xxxxxxxx/Metadata" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
发布于 2011-06-16 20:03:55
您可能会看到的另一个问题是,当您使用传输安全性时,每次创建新代理时都会在客户机上进行证书验证。有没有可能证书验证是昂贵的,比方说,由于证书的吊销列表没有及时提供?
尝试关闭安全性,看看这是否会改变行为
发布于 2011-06-16 18:59:11
虽然不能完全确定,但它看起来像是IIS主机(我说不能确定,因为在IIS主机中baseAddresses不是由您指定的,而是实际的.svc文件是服务的基地址)
假设您正在托管IIS,您是否看到工作进程的启动时间?根据您使用的Windows版本,您可以在第一次请求之前使用Windows Server AppFabric自动启动服务
发布于 2011-07-14 08:19:06
第一次进行调用时,客户端建立到服务器的连接,服务器进行必要的身份验证,这可能需要一些时间。根据我在我的项目中发现的,如果您的合同很大,WCF序列化在第一时间可能会花费很多时间。在此之后,序列化可以快得多。
https://stackoverflow.com/questions/6370626
复制相似问题