开发者

Web service response for Null DateTime?

When a web service contains a DateTim开发者_高级运维e datatype and the datatime has not been set, ie its a null value. What is the standard response provided by the web service?

1) <Timestamp>1900-01-01T00:00:00.0000000+10:00</Timestamp>

OR

2) <Timestamp></Timestamp>


The standard response would be to not return the element. If it's an attribute, then the response would be to not include the attribute.

There are no good reasons to include an empty element.


Depends on the declaration, if you used a nullable type (Nullable<TimeStamp>) then it should serialize with either no element present, or an empty element like:

<Timestamp/>

See more about Nullable<> here:

http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜