WCF服务引用生成和泛型类型 [英] WCF service reference generation and generic types

查看:196
本文介绍了WCF服务引用生成和泛型类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,
如果使用以下合同创建简单的WCF服务

 [OperationContract] 

string GetData2(Test< CompositeType> value);

 [DataContract(Name =" Test {0}",IsReference = true)] 

public class Test< T>

{

[DataMember]

public T P1 {get;组; }

}


然后 wsdl看起来像


- < xs:complexType 名称 =" CompositeType " >




- < xs:sequence >

解决方案

有s对于通用数据合同的ome规则,其不允许"T"。您必须使用DataContract的Name属性来设置要在客户端显示的名称。

请参阅"通用类型的数据合同名称"在以下链接中

http://msdn.microsoft.com/en-us /library/ms731045.aspx


Hello,
If you create a simple WCF service with the following contract 

[OperationContract]

string GetData2(Test<CompositeType> value);

 

[DataContract(Name = "Test{0}", IsReference = true)] 

 public class Test<T> 

{ 

[DataMember] 

 public T P1 { get; set; } 

 }

 

then the wsdl looks like

 

- <xs:complexType name="CompositeType">

- <xs:sequence>

解决方案

There are some rules for generic datacontract which doesn't allow "of T". You have to Name property of DataContract to set the name to be displayed on client side.


Please refer "Data Contract Names for Generic Types" in following link

http://msdn.microsoft.com/en-us/library/ms731045.aspx


这篇关于WCF服务引用生成和泛型类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆