.NET web service reference generated classes not working with dateTime type

I had a dateTime element which was not mandatory in the wsdl, and even though I set the property on the .NET-object that would be sent, it was not passed on as XML. (I did the debugging with .NET Trace log viewer).

Later I realized I had to set the boolean that was supplied next to the DateTime-property to true, and it would work. xxxSpecified. See code below.

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order=6)]
public System.DateTime Created {
    get {
        return this.createdField;
    }
    set {
        this.createdField = value;
        this.RaisePropertyChanged("Created");
    }
}

/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool CreatedSpecified {
    get {
        return this.createdFieldSpecified;
    }
    set {
        this.createdFieldSpecified = value;
        this.RaisePropertyChanged("CreatedSpecified");
    }
}

I have ran into this problem before and after a lot of hard work I found one end of the communication was using a UK (dd/MM/yyyy) Date format and the other was using a US (MM/dd/yyyy) format. This is set in globalization culture on the machine ( like the answer from @Gaurav ) however, the following wasn't so obvious:

when I ran my code under VS I run as myself and therefore my own culture of en-GB. As you may know when I run the code under IIS it is run under the ASPNET account (or NETWORK SERVICE, etc depending on the version of IIS). It turns out that the ASPNET account has a culture of en-US, hence the problem.

The simple solution is to add a globalisation tag to the Web.config and set the culture and uiculture attributes.


I was working with Livecycle on a JBoss machine. I connected the web services from there to .net. I found that DateTime and Booleans did not translate correctly. I know that it is not good form, but I put the serialize datatype attribute to string. That was the way that I could get the data to go across.

I would check what kroonwijk wrote. Fiddler is a nice tool for checking the comings and goings of services.