2012-08-10 167 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. 确保您的枚举值与存储在表格中的值匹配。这是非常关键的情况,因为你不期望它。