在不同时区访问WCF服务 [英] Access WCF Service in different timezone

查看:86
本文介绍了在不同时区访问WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,
我正在处理WCF应用程序.我面临着从具有不同时区的客户端访问WCF服务的问题.
当我在各种论坛上阅读时,我发现一个属性 "Maxclockskew" ,需要在客户端&服务器.我正在使用NetTCPBinding来应用以下解决方案来设置MaxClockSkew属性

公共类ClockSkew
{{ binding);
SecurityBindingElement bindingElement = customBinding.Elements.Find< SecurityBindingElement>();

如果(bindingElement!= null) > bindingElement.LocalClientSettings.MaxClockSkew = TimeSpan.MaxValue;结果,bindingElement.LocalClientSettings.SessionKeyRenewalInterval = TimeSpan.MaxValue;搜索结果bindingElement.LocalServiceSettings.DetectReplays = FALSE;结果,bindingElement.LocalServiceSettings.MaxClockSkew = TimeSpan.MaxValue ;
ing bindingElement.LocalServiceSettings.SessionKeyRenewalInterval = TimeSpan.MaxValue;
SecurityTokenParameters tokenParameters =((SymmetricSecurityBindingElement)bindingElement).ProtectionTokenParameters;结果,如果(tokenParameters是SecureConversationSecurityTokenParameters)结果,{结果SecureConversationSecurityTokenParameters SCT = tokenParameters作为SecureConversationSecurityTokenParameters;结果,bindingElement = sct.BootstrapSecurityBindingElement;搜索结果bindingElement.LocalClientSettings.DetectReplays = FALSE;结果,bindingElement.LocalClientSettings.MaxClockSkew = TimeSpan.MaxValue;结果,bindingElement.LocalClientSettings.SessionKeyRenewalInterval = TimeSpan.MaxValue;搜索结果bindingElement.LocalServiceSettings.DetectReplays = FALSE; <无线电通信绑定属性. meSpan.MaxValue;
}

}
返回customBinding;使用上面的代码设置MaxClockSkew后,它在几个时区都可以正常工作,但在所有情况下都不能正常工作.
我的要求是WCF服务应该可以从任何客户端(具有不同时区)访问.有什么解决办法吗?还是有什么方法可以删除时区限制以访问WCF服务?



Hi masters,
    I am working on WCF application. I am facing an issue of accessing WCF service from client with different timezone.
As i read on various forums, and i found a property "Maxclockskew" which needs to be set on client & server. I am using NetTCPBinding to i applied following solution to set MaxClockSkew property

public class ClockSkew
    {
        public static Binding AdjustClockSkew(Binding binding)
        {
            CustomBinding customBinding = new CustomBinding(binding);
            SecurityBindingElement bindingElement = customBinding.Elements.Find<SecurityBindingElement>();

            if (bindingElement != null)
            {
                bindingElement.LocalClientSettings.DetectReplays = false;
                bindingElement.LocalClientSettings.MaxClockSkew = TimeSpan.MaxValue;
                bindingElement.LocalClientSettings.SessionKeyRenewalInterval = TimeSpan.MaxValue;

                bindingElement.LocalServiceSettings.DetectReplays = false;
                bindingElement.LocalServiceSettings.MaxClockSkew = TimeSpan.MaxValue;
                bindingElement.LocalServiceSettings.SessionKeyRenewalInterval = TimeSpan.MaxValue;
                SecurityTokenParameters tokenParameters = ((SymmetricSecurityBindingElement)bindingElement).ProtectionTokenParameters;
                if (tokenParameters is SecureConversationSecurityTokenParameters)
                {
                    SecureConversationSecurityTokenParameters sct = tokenParameters as SecureConversationSecurityTokenParameters;
                    bindingElement = sct.BootstrapSecurityBindingElement;

                    bindingElement.LocalClientSettings.DetectReplays = false;
                    bindingElement.LocalClientSettings.MaxClockSkew = TimeSpan.MaxValue;
                    bindingElement.LocalClientSettings.SessionKeyRenewalInterval = TimeSpan.MaxValue;

                    bindingElement.LocalServiceSettings.DetectReplays = false;
                    bindingElement.LocalServiceSettings.MaxClockSkew = TimeSpan.MaxValue;
                    bindingElement.LocalServiceSettings.SessionKeyRenewalInterval = TimeSpan.MaxValue;
                }

            }
            return customBinding;
        }
    }


I want to set MaxClockSkew to maximum value. After setting MaxClockSkew using above code it works fine for few timezone but not in all cases(timezone).
My requirement is WCF service should be accessible from any client (Having different timezone). Is there any solution for that? or is there any way to remove timezone constraint to access WCF service?



推荐答案

这已在稍有不同的地方进行了讨论.方式,但解决方案在于:

This is already discussed in slightly different manner, but there in lies the solution:

http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/3e246fff-3ad3-4080-a1a6-927245f1c94f/


-Phani


这篇关于在不同时区访问WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆