我遇到一个问题,wcf响应包含日期时间戳作为
1978-05-05 t11:12:00+2:00
我想检索与1978-05-5T11:12:00相同的响应。
请注意,此偏移量(上例中为+02:00(值可能会因不同的响应而更改。所以值可能是
1978-05-05 t11:12:00+2:00
1978-05-05 t11:12:00+5:00
1978-05-05 t11:12:00+6:00
以下是我修复此问题的方法。。。
从更新wsdl文件
<xs:element name="start" type="xs:date"/>
至
<xs:element name="start" type="xs:string"/>
并生成代理。。现在,使用此代理返回的值与起始字段中的1978-05-5T11:12:00+2:00类似。我使用字符串函数来提取所需的部分。
或者,可以从更新代理文件
[XmlAttribute( type = "Date", ElementName = "start" )]
public DateTime start {
..
}
至
[XmlAttribute( type = "string", ElementName = "start" )]
public string start {
...
}