Date Format Issue with Web service
<p>I have a web service with input parameters.  The relevant XSD in the WSDL is below</p>

<p><a href="https://i.stack.imgur.com/NKUIg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NKUIg.png" alt="enter image description here"></a></p>

<p>When I added this WSDL as Service Reference in Visual Studio, it generated a class with the corresponding fields as<code>System.DateTime</code>.  Below is an example of the field in Reference class added for WSDL</p>

<pre><code>private System.Nullable&lt;System.DateTime&gt; startDateField;
</code></pre>

<p>My binding to the service to create client is CustomBinding below</p>

<pre><code> protected CustomBinding GetCustomBinding()
    {
        var customBinding = new CustomBinding() { Name = "CustomBinding" };

        customBinding.Elements.Add(new TextMessageEncodingBindingElement() { MessageVersion = MessageVersion.Soap11 });
        var securityBindingElement = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
        securityBindingElement.AllowInsecureTransport = true;
        securityBindingElement.EnableUnsecuredResponse = true;
        securityBindingElement.IncludeTimestamp = false;
        customBinding.Elements.Add(securityBindingElement);
        customBinding.Elements.Add(new HttpTransportBindingElement());

        return customBinding;
    }
</code></pre>

<p>My c# code to assign input</p>

<pre><code>myobject.input.endDate = Convert.ToDateTime(endDate);
</code></pre>

<p>After assigning input values, I called a web method to see in <code>Fiddler</code> that all date parameters are missing in Request.</p>

<p>I tried to test in SoapUI. It looks like the service expects date in the format <code>yyyy-MM-dd</code> though the type is of date.  The webservice returns data only when I supply date in the format <code>yyyy-MM-dd</code>.</p>

<p>I'm not sure if it is something to do with the expected date format by web service.  Obviously, I can't send in format yyyy-MM-dd as .Net generated reference class has <code>DateTime</code> but not <code>string</code> data type.</p>

<p>I tried to forcibly set <code>Specified</code> to true </p>

<pre><code>myobject.input.endDate = Convert.ToDateTime(endDate).Date;
myobject.input.endDateSpecified = true;
</code></pre>

<p>I got the below error: </p>

<pre><code>A value was being set that exceeded the maximum allowable field length.
</code></pre>

<p>Now, I suspect that the web service expects Date but .Net is trying to send DateTime which might be extending its length</p>