带有时区的日期无法由C#

问题描述

我的C#客户端基于WSDL文件使用以下字段生成了服务:

    [System.Xml.Serialization.XmlElementAttribute(DataType="date",Order=6)]
    public System.DateTime SomeDate{
        get {
            return this.someDateField;
        }
        set {
            this.someDateField = value;
            this.RaisePropertyChanged("SomeDate");
        }
    }

    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public bool SomeDateSpecified {
        ...
    }

服务正在传递价值

<v12:SomeDate>1972-07-05+01:00</v12:SomeDate>

根据文档https://www.w3schools.com/xml/schema_dtypes_date.asp Xml DataType“日期”格式应接受时区,但是我收到错误

反序列化“ ...”操作的回复消息正文时出错。 ---> system.invalidOperationException:XML文档中有错误(2,2047)。 ---> System.FormatException:无法将字符串识别为有效的DateTime。 在System.DateTimeParse.ParseExactMultiple(String s,String []格式,DateTimeFormatInfo dtfi,DateTimeStyles样式)处

我知道我可以实现IClientMessageInspector并删除时区以便可以对其进行解析,但是我想避免这种情况。 WSDL是从客户那里以我的身份提供的

<xs:element name="SomeDate" type="xs:date" minOccurs="0">
      <xs:annotation>
          <xs:documentation>
              ...
          </xs:documentation>
      </xs:annotation>
  </xs:element>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)