title: Pass date to web service as object property
body: <p>i'm new to web services and i try to find solution but cudn't find any solution.</p>
  
  <p>i'm trying send object as a parameter to web service.</p>
  
  <pre><code>    [WebMethod]
      public bool CreatePatientService(Patient p)
      {
          AdminService AsRef = new AdminService();
          return AsRef.CreatePatient(p);
      }
  </code></pre>
  
  <p>my patient class is as follows:</p>
  
  <pre><code>[Serializable]
  public class Patient
  {
  
      public string NIC { get; set; }
      public string FullName { get; set; }
      public string FirstName { get; set; }
      public string Surname { get; set; }
      public string Title { get; set; }
      public string Gender { get; set; }
      public string CivilStatus { get; set; }
      public DateTime DOB { get; set; }
      public string Address1 { get; set; }
      public string Address2 { get; set; }
      public string Address3 { get; set; }
  }
  </code></pre>
  
  <p>then i used SOAPUi to called Web service.</p>
  
  <p>i called the request as below :</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;tem:CreatePatientService&gt;
           &lt;!--Optional:--&gt;
           &lt;tem:p&gt;
              &lt;!--Optional:--&gt;
              &lt;tem:NIC&gt;15487236&lt;/tem:NIC&gt;
              &lt;!--Optional:--&gt;
              &lt;tem:FullName&gt;awdss&lt;/tem:FullName&gt;
              &lt;!--Optional:--&gt;
              &lt;tem:FirstName&gt;qewretr&lt;/tem:FirstName&gt;
              &lt;!--Optional:--&gt;
              &lt;tem:Surname&gt;qscv&lt;/tem:Surname&gt;
              &lt;!--Optional:--&gt;
              &lt;tem:Title&gt;Mr&lt;/tem:Title&gt;
              &lt;!--Optional:--&gt;
              &lt;tem:Gender&gt;M&lt;/tem:Gender&gt;
              &lt;tem:CivilStatus&gt;S&lt;/tem:CivilStatus&gt;
              &lt;tem:DOB&gt;01/02/2002&lt;/tem:DOB&gt;
              &lt;!--Optional:--&gt;
              &lt;tem:Address1&gt;nikhno&lt;/tem:Address1&gt;
              &lt;!--Optional:--&gt;
              &lt;tem:Address2&gt;asdf&lt;/tem:Address2&gt;
              &lt;!--Optional:--&gt;
              &lt;tem:Address3&gt;125&lt;/tem:Address3&gt;
           &lt;/tem:p&gt;
        &lt;/tem:CreatePatientService&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>then its give following error. how can i solve it ?</p>
  
  <pre><code>&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
     &lt;soap:Body&gt;
        &lt;soap:Fault&gt;
           &lt;faultcode&gt;soap:Client&lt;/faultcode&gt;
           &lt;faultstring&gt;System.Web.Services.Protocols.SoapException: Server was unable to read request. ---&gt; System.InvalidOperationException: There is an error in XML document (19, 49). ---&gt; System.FormatException: Input string was not in a correct format.
     at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp;amp; number, NumberFormatInfo info, Boolean parseDecimal)
     at System.Number.ParseUInt32(String value, NumberStyles options, NumberFormatInfo numfmt)
     at System.UInt16.Parse(String s, NumberStyles style, NumberFormatInfo info)
     at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read2_TblPatient(Boolean isNullable, Boolean checkType)
     at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read7_CreatePatientService()
     at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer8.Deserialize(XmlSerializationReader reader)
     at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
     --- End of inner exception stack trace ---
     at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
     at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
     --- End of inner exception stack trace ---
     at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
     at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()&lt;/faultstring&gt;
           &lt;detail/&gt;
        &lt;/soap:Fault&gt;
     &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p><strong>If i removed DOB (Date) then its working properly.</strong></p>
  
  <p>i refer following post. but cudn't work it.</p>
  
  <p><a href="https://stackoverflow.com/questions/1109958/proper-datetime-format-for-a-web-service">Proper DateTime Format for a Web Service</a></p>
  
  <p>please help.. Thanks...</p>