Setting minOccurs="0" (required) on web service parameters of type int

Posted by Alex Angas on Stack Overflow See other posts from Stack Overflow or by Alex Angas
Published on 2010-04-08T04:35:50Z Indexed on 2010/04/08 4:43 UTC
Read the original article Hit count: 280

Filed under:
|

I have an ASP.NET 2.0 web method with the following signature:

[WebMethod]
public QueryResult[] GetListData(
    string url, string list, string query, int noOfItems, string titleField)

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:

<s:element minOccurs="0" maxOccurs="1" name="url" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="list" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="query" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="noOfItems" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="titleField" type="s:string" />

Why does the int parameter have minOccurs set to 1 instead of 0 and how do I change it? I've tried using [XmlElementAttribute(IsNullable=false)] in the parameter declaration without success.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about web-services