Web服务协议中的区域设置? [英] Regional settings in webservice protocol?

查看:77
本文介绍了Web服务协议中的区域设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个JavaScript代码,可以序列化对象以及其他类型的日期字符串(美国格式).它使用此对象调用Web服务. Web服务将对象反序列化,并且日期字符串仍为美国格式.但是随后它将日期字符串传递给函数,参数为DateTime.

如果客户端计算机的区域设置为英语(美国)",则该日期将正确显示.但是,如果区域设置为英语(英国)"(并且如果浏览器为IE),则该日期将转换为英国日期.

区域设置在客户端,而强制转换在服务器上进行.因此,我是否假定在Web服务协议中传递了区域设置?而且只有在浏览器是IE的情况下?

感谢您的帮助.

Roy.

Hi,

I have javascript code that serializes an object with, among other thins, a date string in it (US format). It calls a web service, with this object. The web service deserializes the object, and the date string is still in US format. But then it passes the date string to a function, with the parameter as DateTime.

If the client machine has regional setting as "English (United States)", the date casts fine. But if the regional setting is "English (United Kingdom)", (and if the browser is IE), then the date casts as a UK date.

The regional setting is at the Client, and the casting is happening at the Server. So am I to assume that the regional settings are being passed in the web service protocols? And only if the browser is IE?

Thanks for your help.

Roy.

推荐答案

在Web服务中使用System.DataTime,而不使用其字符串表示形式.在这种情况下,通过服务代理进行的调用将返回二进制时间数据,并且传输中的序列化和反序列化将自动以与文化无关的形式进行.您永远不要直接使用序列化表格.您的客户还应该在所有计算中使用二进制System.DataTime结构,直到需要在屏幕上显示字符串的最后时刻.目前,无论使用哪种文化中立的,自定义的,特定于文化的格式,它都不会影响功能.

—SA
Work with System.DataTime in your Web service, not with its string representation. In this case, calls via the service proxy will return binary time data, and the serialization and deserialization in transport will be done in culture-independent form, automatically. You should never work with serialized form directly. Your client should also use binary System.DataTime structure in all calculations, up to the very last moment when a presentation of a string on screen is needed. At this moment, use either culture-neutral, custom, of culture-specific formatting, it won''t affect functionality.

—SA


这篇关于Web服务协议中的区域设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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