I am integrating with a web service (i dont have control to this web service) using wsdl provided. While calling a method, i need to pass DateTime in request. The request needs to contain datetime in UTC format (with Z in the end). The request contains below field,
[System.Xml.Serialization.XmlElementAttribute(DataType="date", Order=0)]
public System.DateTime date
{
get
{
return this.dateField;
}
set
{
this.dateField = value;
}
Please note the xsd datatype is a date.
I construct the request to pass DateTime
as Utc,
request.date = DateTime.SpecifyKind(DateTime.Parse(DateTime.Now.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'")), DateTimeKind.Utc);
The problem i have is even though i pass DateTime
as Utc, the soap request appears without the time zone. For eg, the request gets generated as shown below,
<GetRequest xmlns=" http://soa.company.com/services/example/v2">
<date>2001-01-01</date>
</GetRequest>
My expectation is to get,
<GetRequest xmlns=" http://soa.company.com/services/example/v2">
<date>2001-01-01Z</date>
</GetRequest>
I think this is due to roundtrip during datetime serialization. Has anybody faced this kind of issue?