简体   繁体   English

WCF代理生成

[英]WCF Proxy generation

I'm generating proxy using svcutil tool. 我正在使用svcutil工具生成代理。 My contract methods return objects of particular type. 我的合同方法返回特定类型的对象。 However generated proxy client interface has return value of type object. 但是,生成的代理客户端接口具有对象类型的返回值。 What is more I get exception with message: 更重要的是,我得到消息异常:

System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail] : The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:name. The InnerException message was 'XML 'Element' 'http://tempuri.org/:name' does not contain expected attribute 'http://schemas.microsoft.com/2003/10/Serialization/:Type'. The deserializer has no knowledge of which type to deserialize. Check that the type being serialized has the same contract as the type being deserialized.'.  Please see InnerException for more details.

Any ideas what's going on? 有什么想法吗?

It sounds like svcutil has problems understanding your types. 听起来svcutil在理解您的类型时遇到问题。 If you have custom types defined in other assemblies you may need to use the [KnownType] attribute to tell svcutil what's going on. 如果您在其他程序集中定义了自定义类型,则可能需要使用[KnownType]属性来告诉svcutil发生了什么。

See the MSDN reference here . 请参阅此处的MSDN参考。

Hmmm, I'm new to WCF and project I'm exploring... However I have just noticed that data type which is returned by the service is not decorated with DataContract attributes. 嗯,我是WCF的新手,正在探索的项目...但是,我刚刚注意到,服务返回的数据类型没有用DataContract属性修饰。 Is that the issue? 那是问题吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM