Ale*_*gas 4 asp.net web-services
我有一个带有以下签名的ASP.NET 2.0 Web方法:
[WebMethod]
public QueryResult[] GetListData(
string url, string list, string query, int noOfItems, string titleField)
Run Code Online (Sandbox Code Playgroud)
我正在运行disco.exe工具从此Web服务生成.wsdl和.disco文件,以便在SharePoint中使用.正在生成以下用于参数的WSDL:
<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" />
Run Code Online (Sandbox Code Playgroud)
为什么int参数将minOccurs设置为1而不是0,我该如何更改?
我试过以下但没有成功:
[XmlElementAttribute(IsNullable=false)] 在参数声明:没有区别(当你想到它时,预期)
[XmlElementAttribute(IsNullable=true)] 在参数声明中:给出错误"对于值类型System.Int32,IsNullable可能不是'true'.请考虑使用Nullable代替."
将参数类型更改为int?:保持minOccurs="1"并添加nillable="true"
[XmlIgnore] 在参数声明中:参数永远不会输出到WSDL
这是因为a int必须至少出现一次是不可为空的,所以设置IsNullable=false可能不会改变任何东西.也就是说,我很确定IsNullable=true也没有帮助,也没有使对象可以为空.
从记忆中,我认为你可以做这样的事情
[XmlIgnore]
public bool noOfItemsSpecified { get; set; }
public int noOfItems { get; set; }
Run Code Online (Sandbox Code Playgroud)
也就是说,当然,如果将参数包装在一个可以添加此代码的对象中.
| 归档时间: |
|
| 查看次数: |
7673 次 |
| 最近记录: |