我正在使用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)
在服务引用设置上,"集合类型"设置为使用"列表",而不是"阵列".然而,它仍然这样做.
任何有关如何解决这个问题的信息都会非常有用,似乎毫无意义.