我有一個WCF客戶端使用[DataContract]
類型的一個WCF服務進行通信,並且我得到一個序列化錯誤:爲什麼我的無效WCF消息被記錄?
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://www.example.com/2007/09/Example:ExampleResult . The InnerException message was 'Deserialized object with reference id 'i3' not found in stream.'. Please see InnerException for more details.
通常情況下,我會簡單地殺青跟蹤,看看到底發生了什麼,但在這種情況下,我無法獲得在日誌中出現的違規(響應)消息。
我的配置是這樣的:
<system.serviceModel>
... (more stuff)
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true"
logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="true"
maxMessagesToLog="10000" maxSizeOfMessageToLog="81920000" />
</diagnostics>
</system.serviceModel>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="wcf_listener" />
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="wcf_listener" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="wcf_listener" initializeData="tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener" />
</sharedListeners>
</system.diagnostics>
在生成的日誌文件,我得到的出站消息記錄,然後異常記錄。我從來沒有看到傳入的消息。我在這裏做錯了什麼?
可以嘗試使用「秩序」參數中的數據成員的屬性。如果出於某種原因,在序列化/反序列化過程中元素會混淆,這應該是照顧它的。例如:'[DataMember(Order = 1)] public string Something {get;組; }'這可能有幫助。 – Vex
我不想解決反序列化錯誤(事實上,它已經解決了......),我正在尋求解決日誌記錄問題。 – Mark
您是否嘗試將'switchValue'更改爲''All「'並查看消息是否被記錄? – sinelaw