WCF Channel 构造性能问题

发布于 2024-12-05 22:23:10 字数 1410 浏览 1 评论 0原文

我遇到了一个奇怪的情况,我希望有人经历过这种情况,并且可以帮助我。

我有一个托管在 IIS 上的 WCF 服务。 从一个客户端(Windows XP Pro SP3),一个简单的调用需要不到一秒的时间,但从另一个客户端(也是win xp pro sp3,但必须以某种方式使用另一个配置),在应用程序中进行第一次调用需要 7 秒。

我在应用程序中所做的就是实例化服务并进行简单的调用。 我尝试过进行诊断。 当我查看客户端服务日志时,我可以看到通道的构建大约需要 2 秒。 Open Client 库大约需要 2 秒,在服务中运行该方法大约需要 2 秒。

然后我关闭服务。

如果我再次拨打电话,则需要 0 秒,就像在另一台机器上一样。 如果我关闭应用程序,第一次运行将再次花费 7 秒。

从缓慢的 PC 调用到同一 IIS 上的 ASMX 服务总是运行得很快,但我想使用 WCF。

我使用基本的 IIS 身份验证,并使用下面的代码添加运行时凭据。但我在两台电脑上做同样的事情,所以......我必须以某种方式进行配置。

MyServiceClient client = new MyServiceClient();

ClientCredentials loginCredentials = new ClientCredentials();
loginCredentials.UserName.UserName = "theuser";
loginCredentials.UserName.Password = "thepass";

var defaultCredentials = client.Endpoint.Behaviors.Find<ClientCredentials>();
client.Endpoint.Behaviors.Remove(defaultCredentials); //remove default ones
client.Endpoint.Behaviors.Add(loginCredentials); //add required ones

client.Endpoint.Address = new System.ServiceModel.EndpointAddress(GetSVCUrl());
client.InnerChannel.OperationTimeout = new TimeSpan(0, 0, 60);
client.Endpoint.Binding.OpenTimeout = new TimeSpan(0, 0, 60);

配置设置为 <安全模式=“TransportCredentialsOnly”> <传输 clientCredentialType="Basic" 领域="" />

我在这个问题上搜索了很多,并尝试了与代理等相关的不同配置设置,但没有任何真正的突破。

我希望有人能给我正确方向的提示。

谢谢!

丹麦莫滕

I have a strange situation, and I hope someone has experienced this scenario, and can help me.

I have a WCF service hosted on IIS.
From one client (Windows XP Pro SP3), a simple call takes less than a second, but from another client (also win xp pro sp3 but must be with another config somehow), it takes 7 seconds to make the first call in the application.

What I do in the app, is instanciating the service, and making a simple call.
I have tried to do diagnostics.
When I look at the client service log, I can see that the construct of the channel takes about 2 seconds. Open Client base takes about 2 seconds and running the method in the service takes about 2 seconds.

Then I close the service.

If I make the call again, it take 0 seconds, like on the other machine.
If I close the application, the first run takes 7 seconds again.

From the slow PC calls to ASMX service on the same IIS allways run fast, but I want to use WCF.

I use basic IIS authentication, and I am adding credentials runtime with the code below. But I do the same thing, on both PC's, so... I must be configuration somehow.

MyServiceClient client = new MyServiceClient();

ClientCredentials loginCredentials = new ClientCredentials();
loginCredentials.UserName.UserName = "theuser";
loginCredentials.UserName.Password = "thepass";

var defaultCredentials = client.Endpoint.Behaviors.Find<ClientCredentials>();
client.Endpoint.Behaviors.Remove(defaultCredentials); //remove default ones
client.Endpoint.Behaviors.Add(loginCredentials); //add required ones

client.Endpoint.Address = new System.ServiceModel.EndpointAddress(GetSVCUrl());
client.InnerChannel.OperationTimeout = new TimeSpan(0, 0, 60);
client.Endpoint.Binding.OpenTimeout = new TimeSpan(0, 0, 60);

Configuration is set with
<security mode="TransportCredentialsOnly">
<transport clientCredentialType="Basic" realm="" />
</security>

I have googled a lot on the issue and have tried different configsettings related to proxy etc, but without any real breakthrough.

I hope someone can give me a hint in the right direction.

Thanks!

Morten, Denmark

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文