在不同时区访问WCF服务

编程入门 行业动态 更新时间:2024-10-27 22:23:47
本文介绍了在不同时区访问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 propertypublic 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?

推荐答案

这已在稍有不同的地方进行了讨论.方式,但解决方案在于: social.msdn.microsoft/Forums/zh-CN/wcf/thread/3e246fff-3ad3-4080-a1a6-927245f1c94f/ - Phani This is already discussed in slightly different manner, but there in lies the solution:social.msdn.microsoft/Forums/en-US/wcf/thread/3e246fff-3ad3-4080-a1a6-927245f1c94f/-Phani

更多推荐

在不同时区访问WCF服务

本文发布于:2023-10-24 07:47:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1523350.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时区   WCF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!