2012-08-10 168 views
-1

在獲取此錯誤之前進行的修改。我在所有課程中都更改了byte[]Stream底層連接已關閉:連接意外關閉#2

System.ServiceModel.CommunicationException: The underlying connection was closed: The connection was closed unexpectedly. ---> System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.  
    at System.Net.HttpWebRequest.GetResponse()  
    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 

    --- End of inner exception stack trace ---  

Server stack trace:  
    at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)  
    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)  
    at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)  
    at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)  
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)  
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)  
    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)  
    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 


Exception rethrown at [0]:  
    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)  
    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)  
    at MyWCFServiceTest.MyWCFService.ICommonService.UploadDocument(UploadDocumentRequest request)  
    at MyWCFServiceTest.MyWCFService.MyServiceClient.MyWCFServiceTest.MyWCFService.ICommonService.UploadDocument(UploadDocumentRequest request) in C:\Users\KishoreJangid\Desktop\ChangeSAPTransactionStatus\MyWCFServiceTest - Copy\MyWCFServiceTest\Service References\MyWCFService\Reference.cs:line 2376  
    at MyWCFServiceTest.MyWCFService.MyServiceClient.UploadDocument(RequestHeader UploadDocumentReqHdr, Byte[]& UploadDocumentContent) in C:\Users\KishoreJangid\Desktop\ChangeSAPTransactionStatus\MyWCFServiceTest - Copy\MyWCFServiceTest\Service References\MyWCFService\Reference.cs:line 2383  
    at MyWCFService.Form1.DocumentUpload_Click(Object sender, EventArgs e) in C:\Users\KishoreJangid\Desktop\ChangeSAPTransactionStatus\MyWCFServiceTest - Copy\MyWCFServiceTest\Form1.cs:line 88 
+0

在失敗端點的* .config中啓用對WCF的跟蹤...您可能會得到更詳細的異常。您發佈的異常是通用/無用的。 – 2012-08-10 13:15:47

回答

1

從你想達到什麼樣的由於缺乏解釋,你有沒有更新所有的消費者使用新的類?我認爲你已經改變了數據合同,這打破了消費者。

如果不是,我會查看您要傳輸多少數據,請參考此blog post!似乎這是問題。

我有一些相同的問題,它可能是一個配置問題,或者如果您在IIS中託管,那麼有關權限的問題,請儘可能詳細說明。

0

如果您希望從被調用方法返回並使用WCF服務,那麼此錯誤背後的一個可能原因可能是您的對象序列化/反序列化問題。如果你的服務方法返回一些不能序列化的東西,那麼你的代理通道會產生這個錯誤。

爲了避免這種情況,剛入住

  1. 返回類型,並確保它是序列化。您可能必須將[Serializable]屬性與您的課程相關聯。
  2. [DataMember(IsRequired=true)],它告訴該值將在序列化時出現(它的下劃線屬性是非空值類型)。
  3. 確保您的枚舉值與存儲在表格中的值匹配。這是非常關鍵的情況,因爲你不期望它。