WCF:客户端上的集合代理类型
我在wsdl中有以下类型(由第三方工具生成):WCF:客户端上的集合代理类型,wcf,Wcf,我在wsdl中有以下类型(由第三方工具生成): 有时Visual Studio会生成: public class IntArray : System.Collections.Generic.List<int> {} public class IntArray : System.Collections.Generic.List<int> {} public class StringArray : System.Collections.Generic.List<
有时Visual Studio会生成:
public class IntArray : System.Collections.Generic.List<int> {}
public class IntArray : System.Collections.Generic.List<int> {}
public class StringArray : System.Collections.Generic.List<string> {}
数组中的公共类:System.Collections.Generic.List{}
有时它不为这个wsdl生成任何代理类型,只使用int[]
Web服务配置中的集合类型为System.Array
为什么会有这样的行为
编辑:
我找到了复制这种行为的方法
例如,我们有两种类型:
<xsd:complexType name="IntArray">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="Elements" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="StringArray">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="Elements" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
VS生成:
public class IntArray : System.Collections.Generic.List<int> {}
public class IntArray : System.Collections.Generic.List<int> {}
public class StringArray : System.Collections.Generic.List<string> {}
数组中的公共类:System.Collections.Generic.List{}
公共类StringArray:System.Collections.Generic.List{}
现在我更改StringArray类型:
<xsd:complexType name="StringArray">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="Elements" type="xsd:string" />
<xsd:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax" />
</xsd:sequence>
<xsd:anyAttribute namespace="##any" processContents="lax"/>
</xsd:complexType>
VS仅为StringArray生成代理类型。但不是为了IntArray
编辑:
Reference.svcmap:
<ClientOptions>
<GenerateAsynchronousMethods>false</GenerateAsynchronousMethods>
<EnableDataBinding>true</EnableDataBinding>
<ExcludedTypes />
<ImportXmlTypes>false</ImportXmlTypes>
<GenerateInternalTypes>false</GenerateInternalTypes>
<GenerateMessageContracts>false</GenerateMessageContracts>
<NamespaceMappings />
<CollectionMappings />
<GenerateSerializableTypes>true</GenerateSerializableTypes>
<Serializer>Auto</Serializer>
<ReferenceAllAssemblies>true</ReferenceAllAssemblies>
<ReferencedAssemblies />
<ReferencedDataContractTypes />
<ServiceContractMappings />
</ClientOptions>
假的
真的
假的
假的
假的
真的
自动的
真的
据我所知,代理类是由SvcUtil.exe生成的,为什么不使用reflector查看它…如果您查看项目的所有文件,然后查看名为Reference.svcmap的文件以获得适当的服务引用,请告诉我xml中的以下配置选项是什么
<ExcludedTypes />
<ImportXmlTypes>false</ImportXmlTypes>
<GenerateInternalTypes>false</GenerateInternalTypes>
<GenerateSerializableTypes>false</GenerateSerializableTypes>
<Serializer>Auto</Serializer>
假的
假的
假的
自动的
很抱歉把它作为一个答案,但它是可怕的无法阅读的评论
编辑
好的,这里发生的事情如下:
-LeighVS在生成代理时不使用svcutil。能否提供有关如何生成客户端代理的更多详细信息?我使用VS 2008“添加服务引用”:生成类的访问级别:public;异步操作:未选中;始终生成消息契约:未选中;集合类型:System.Array;字典集合类型:System.Collections.Generic.Dictionary;在所有引用的程序集中重用类型:选中。