簡體   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