title: Setting minOccurs="0" (not required) on web service parameters of type int
body: <p>I have an ASP.NET 2.0 web method with the following signature:</p>
  
  <pre><code>[WebMethod]
  public QueryResult[] GetListData(
      string url, string list, string query, int noOfItems, string titleField)
  </code></pre>
  
  <p>I'm running the disco.exe tool to generate .wsdl and .disco files from this web service for use in SharePoint. The following WSDL for the parameters is being generated:</p>
  
  <pre><code>&lt;s:element minOccurs="0" maxOccurs="1" name="url" type="s:string" /&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="list" type="s:string" /&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="query" type="s:string" /&gt;
  &lt;s:element minOccurs="1" maxOccurs="1" name="noOfItems" type="s:int" /&gt;
  &lt;s:element minOccurs="0" maxOccurs="1" name="titleField" type="s:string" /&gt;
  </code></pre>
  
  <p>Why does the int parameter have <strong>minOccurs set to 1</strong> instead of 0 and <strong>how do I change it</strong>?</p>
  
  <p>I've tried the following without success:</p>
  
  <ul>
  <li><p><code>[XmlElementAttribute(IsNullable=false)]</code> in the parameter declaration: makes no difference (as expected when you think about it)</p></li>
  <li><p><code>[XmlElementAttribute(IsNullable=true)]</code> in the parameter declaration: gives error "IsNullable may not be 'true' for value type System.Int32.  Please consider using Nullable instead."</p></li>
  <li><p>changing the parameter type to int? : keeps <code>minOccurs="1"</code> and adds <code>nillable="true"</code></p></li>
  <li><p><code>[XmlIgnore]</code> in the parameter declaration: the parameter is never output to the WSDL at all</p></li>
  </ul>