java调用c# webserve 接口时,datetime字段create_date,报错:服务器无法读取请求。 ---> XML 文档(,)中有错误,字符串“2015-01-12 17:26:52”不是有效的 AllXsd 值。

错误原因:上边xml时间格式不正确所以反序列化失败

处理办法

(1):将时间写成以下这种格式:2010-03-12T00:00:00 。添加红字与下划线标注的部分

(2):在反序列化这边修改

例如:

[XmlRoot("response")]
public class MyPayResponse
{
    public string account { get; set; }
    public string @operator { get; set; }
    public int amount { get; set; }
    [XmlIgnore]
    public DateTime addtime { get; set; }

    [XmlElement("addtime")]
    public string addtime2
    {
        get { return addtime.ToString("yyyy-MM-dd HH:mm:ss"); }
        set { addtime = DateTime.Parse(value); }
    }
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2021-11-10
  • 2022-02-05
猜你喜欢
  • 2021-06-03
  • 2022-02-19
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案