相关疑难解决方法(0)

Service Reference使用Arrays而不是List <Type>,即使设置说使用List也是如此

我正在使用Visual Studio 2010,并且我已经获得了对我们创建的Web服务的服务引用.我们的方法返回包含通用List属性的对象:

public class ExampleResponse
{
  private System.Collections.Generic.List<int> intValues;

  [WCF::MessageBodyMember(Name = "IntValues")]
  public System.Collections.Generic.List<int> IntValues    
  {
    get { return intValues; }
    set { intValues= value; }
  }
}
Run Code Online (Sandbox Code Playgroud)

在客户端,它使用int []而不是List创建一个References.cs文件:

[System.ServiceModel.MessageBodyMemberAttribute(Namespace="SomeNamespace", Order=0)]
[System.Xml.Serialization.XmlArrayAttribute(IsNullable=true)]
[System.Xml.Serialization.XmlArrayItemAttribute(Namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays", IsNullable=false)]
public int[] IntValues;
Run Code Online (Sandbox Code Playgroud)

在服务引用设置上,"集合类型"设置为使用"列表",而不是"阵列".然而,它仍然这样做.

任何有关如何解决这个问题的信息都会非常有用,似乎毫无意义.

c# web-services

9
推荐指数
2
解决办法
1万
查看次数

标签 统计

c# ×1

web-services ×1