title: Error in Nullable Value Types in WCF
body: <p>I am facing the below issue following</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/ms187557.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms187557.aspx</a> (Section "Input Parameter Handling", but the suggested solution seems NOT WORKING). It seems that the <strong>NullableInteger</strong> passed in is always treated as <strong>Empty String</strong> and NOT <strong>Null Value</strong></p>
  
  <p>I created a MessageContract which contains a nullable type for Integer as shown below:</p>
  
  <pre><code>&lt;xs:complexType&gt;
      &lt;xsTongue Tiedequence&gt;
  :
  &lt;xs:element minOccurs="0" maxOccurs="1" name="InputSub1" type="tnsTongue TiedubClass"/&gt;
  &lt;xs:element minOccurs="1" maxOccurs="1" name="NullableInteger" nillable="true" type="xs:int"/&gt;
      &lt;/xsTongue Tiedequence&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>I am using SoapUI to test for the nullable integer with following SOAP Request </p>
  
  <pre><code>&lt;soapenv:Envelope xmlnsTongue Tiedoapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:myw="MyWCFTest"&gt;
  &lt;soapenv:Header/&gt;
  &lt;soapenv:Body&gt;
    &lt;myw:MessageRequest&gt;
       &lt;myw:InputSub1&gt;
          &lt;mywTongue TiedubProperty1&gt;USD&lt;/mywTongue TiedubProperty1&gt;
       &lt;/myw:InputSub1&gt;
       &lt;myw:NullableInteger myw:nil="true" /&gt;
    &lt;/myw:MessageRequest&gt;
  &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>However, it always throws error with the following abbreviated description: </p>
  
  <blockquote>
    <p>Input string was not in a correct format.
                         at System.Number.StringToNumber(String str, NumberStyles options,
    NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal)
    at System.Number.ParseInt32(String s, NumberStyles style,
    NumberFormatInfo info)    at System.Xml.XmlConvert.ToInt32(String s)<br>
    at
    Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderIServiceDemo1.Read3_NullableOfInt32(Boolean
    checkType)    at
    Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderIServiceDemo1.Read5_MessageRequest()
    at
    Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer1.Deserialize(XmlSerializationReader
    reader)    at
    System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
    xmlReader, String encodingStyle, XmlDeserializationEvents
    events)
                         System.FormatException</p>
  </blockquote>
  
  <p><strong>Note:</strong> I am facing an exact same issue and when I google I found this was already posted here <a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/8f6fa48e-60b4-4034-9a46-c65f8185ff4d/problem-in-nullable-value-types-in-wcf?forum=wcf" rel="nofollow noreferrer">Error in Nullable Value Types in WCF</a> but with hardly any answer. I am posting it here(StackOverflow) to gain more attention.</p>