消耗WCF服务问题,方法的输出类型已更改 [英] consuming WCF service Issue, the output type of Methods are changed
本文介绍了消耗WCF服务问题,方法的输出类型已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好.
我有Windows服务中托管的Wcf服务库,并且有一个方法名称"MyMethod",其输出类型是名为"my_struct"的自定义类,并且继承自List< t>.
当我想在另一个应用程序中使用此服务时,wsdl显示此方法"MyMethod"的输出为List< t>.必须是"my_struct".我应该怎么做才能解决这个问题?
谢谢您.
Hi everyone.
I have Wcf service lib which is hosted in a windows service and there is a method name "MyMethod" that the output type is my custom class named "my_struct" and it is inherited from List<t>.
when I want to consume this service in another application the wsdl shows the output of this method "MyMethod" is List<t> which must be "my_struct". What Should I do to solve this problem?
Thanks in advanced.
推荐答案
您的my_struct
必须描述为DataContract
.一旦定义了所有DataMember
,就可以在ServiceContract
中将其用作任何其他整数类型. VS将为您创建序列化程序和所有映射.
请参阅此处的示例 [
Yourmy_struct
must be described as aDataContract
. Once you define all yourDataMember
s on it you could use it in yourServiceContract
as any other integral type. VS will create serializer and all the mappings for you.
See sample here[^]
这篇关于消耗WCF服务问题,方法的输出类型已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文