我遇到了一個問題,試圖返回一個對象,該對象包含一個可以容納一個孫集對象的集合的子對象。我收到一個錯誤,'主持人強行關閉連接'。WCF中的複雜數據類型?
有什麼辦法可以使這項工作?我現在有類似這樣的結構:
僞代碼:
Person:
IEnumerable<Order>
Order:
IEnumerable<OrderLine>
所有這三個對象具有DataContract屬性和所有的公共屬性我要暴露(包括了IEnumerable的)有數據成員的屬性。
我在我的服務上有多個OperationContract,並且所有方法都返回一個對象,或者一個對象的IEnumerable完美地工作。只有當我嘗試嵌套IEnumerable它變成壞。同樣在我的客戶服務參考中,我選擇了通用列表作爲我的集合類型。我只想強調,只有我的一個操作/方法失敗並出現此錯誤 - 其餘部分完美工作。
EDIT(更詳細的錯誤描述):
[SocketException (0x2746): An existing connection was forcibly closed by
the remote host]
[IOException: Unable to read data from the transport connection:
An existing connection was forcibly closed by the remote host.]
[WebException: The underlying connection was closed: An unexpected
error occurred on a receive.]
[CommunicationException: An error occurred while receiving the HTTP
response to http://myservice.mydomain.dk/MyService.svc. This could
be due to the service endpoint binding not using the HTTP protocol.
This could also be due to an HTTP request context being aborted by
the server (possibly due to the service shutting down). See server
logs for more details.]
我試圖尋找日誌,但我無法找到任何...還我使用的WSHttpBinding和HTTP端點。
您的對象中是否有不正確的序列化? – 2008-10-15 09:12:07
我不知道。我想也許嵌套的IEnumberable可能無法序列化?但是我怎麼知道?我可以一路調試到實際OperationContract的返回,一切都很好,但交通運輸似乎出了問題。我沒有序列化屬性,而是使用[DataMember] –
2008-10-15 09:21:21
我面臨着同樣的錯誤,因爲我..我的類也定義了枚舉屬性,但我沒有看到這是任何地方的問題..枚舉應該沒問題..你通過設置默認值是什麼意思?他們是價值類型,所以他們總是有一個默認值。我會嘗試刪除枚舉屬性,看看是否修復它..這裏是支持的數據約定類的一些信息http://msdn.microsoft.com/en-us/library/ms731923.aspx – 2010-10-29 00:17:36