- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
在本地环境中开发了一个包含两个 WCF 服务的系统并在另一个环境中对其进行了测试,我们最终将其部署到生产环境中,但显示了一个完全不同的错误。这两个服务运行在四台不同的机器上(每个服务运行在两台机器上,负载均衡)。
InvokeEventWithParameters 操作不工作:
[ServiceContract]
public interface IAccountManager
{
[OperationContract]
int InvokeEventWithParameters(string EventName, DateTime InitialDate, DateTime FinalDate, int InitialId, int FinalId, string Username);
[OperationContract]
int InvokeEvent(string EventName, string Username);
}
尝试运行服务时,返回以下错误:
The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'InvokeEventWithParameters'. The value '1/1/2014 12:00:00 AM' cannot be parsed as the type 'DateTime'.
错误显示在两个服务之间的通信上,在 SOAP 消息上。我无法检查 ISO 8601 是否在服务之间发送,因为它正在生产环境中运行。我已经使用嗅探器检查了测试环境,ISO 得到了尊重。
有趣的是错误上显示的日期格式为“en-US”,而系统和 IIS 配置为“pt-BR”,其格式应符合 ISO 标准。
我已经尝试更改机器文化配置、IIS 全局化配置和 web.config 文件中的文化。这些都不起作用。我已经在日期时间检查了整个项目的“.ToStrings”和“.Parses”,但没有找到它们,因此没有其他可能的异常来源。
在我看来,SOAP 消息的 DateTime 序列化和反序列化(使用 DataContractDeserializer)不应受到任何有关文化的配置的影响,但我在 google 和此处找到的所有内容都与这些设置有关。我的这个假设是否正确?
谢谢你的帮助,埃米利奥
最佳答案
我猜这是一个服务端错误,它正在等待一种日期时间格式,但它正在获取另一种格式。你能改变那个代码吗?如果是这样,请尝试将收到的日期解析为有效格式:
DateTime.ParseExact(yourDateParam, "M/d/yyyy hh:mm:ss t", new CultureInfo("en-US"));
注意 M/d,因为我不知道您是在 (d) 日之前发送月 (M) 还是反之亦然。
编码愉快!
关于c# - 将 DateTime 反序列化为 WCF SOAP 服务 C# 上的参数的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36902767/
出于好奇,我尝试了一些原型(prototype)制作,但似乎只允许在第一个位置使用子例程的原型(prototype) &。 当我写作时 sub test (&$$) { do_somethin
我需要开发一个类似于 Android Play 商店应用程序或类似 this app 的应用程序.我阅读了很多教程,发现几乎每个教程都有与 this one 类似的例子。 . 我已经开始使用我的应用程
考虑一个表示“事件之间的时间”的列: (5, 40, 3, 6, 0, 9, 0, 4, 5, 18, 2, 4, 3, 2) 我想将这些分组到 30 个桶中,但桶会重置。期望的结果: (0, 1,
我是一名优秀的程序员,十分优秀!