繁体   English   中英

WCF代理生成

[英]WCF Proxy generation

我正在使用svcutil工具生成代理。 我的合同方法返回特定类型的对象。 但是,生成的代理客户端接口具有对象类型的返回值。 更重要的是,我得到消息异常:

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.

有什么想法吗?

听起来svcutil在理解您的类型时遇到问题。 如果您在其他程序集中定义了自定义类型,则可能需要使用[KnownType]属性来告诉svcutil发生了什么。

请参阅此处的MSDN参考。

嗯,我是WCF的新手,正在探索的项目...但是,我刚刚注意到,服务返回的数据类型没有用DataContract属性修饰。 那是问题吗?

暂无
暂无

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

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