問題解決_WCF_WCF 接收我服務的 HTTP 響應時發生錯誤


 原文地址:http://www.cnblogs.com/tianma3798/p/5470974.html

錯誤內容:

復制代碼
System.ServiceModel.CommunicationException: 接收對 https://xx.com/xx.svc的 HTTP 響應時發生錯誤。這可能是由於服務終結點綁定未使用 HTTP 協議造成的。
這還可能是由於服務器中止了 HTTP 請求上下文(可能由於服務關閉)所致。有關詳細信息,請參見服務器日志。
---> System.Net.WebException: 基礎連接已經關閉: 接收時發生錯誤。
---> System.IO.IOException: 無法從傳輸連接中讀取數據: 遠程主機強迫關閉了一個現有的連接。。
---> System.Net.Sockets.SocketException: 遠程主機強迫關閉了一個現有的連接。 在 System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult) 在 System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) --- 內部異常堆棧跟蹤的結尾 --- 在 System.Net.Security._SslStream.EndRead(IAsyncResult asyncResult) 在 System.Net.TlsStream.EndRead(IAsyncResult asyncResult) 在 System.Net.PooledStream.EndRead(IAsyncResult asyncResult) 在 System.Net.Connection.ReadCallback(IAsyncResult asyncResult) --- 內部異常堆棧跟蹤的結尾 --- 在 System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) 在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result) --- 內部異常堆棧跟蹤的結尾 --- Server stack trace: 在 System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) 在 System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) 在 System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) 在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeEndService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: 在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 在 Sinopec.UC.Client.Groups.ChatGroupSev.IChatGroupPersistence.EndGetGroupListByMember(IAsyncResult result) 在 Sinopec.UC.Client.Groups.ChatGroupSev.ChatGroupPersistenceClient.OnEndGetGroupListByMember(IAsyncResult result) 在 System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
復制代碼

解決方法1:

此類型錯誤發生時,有許多方案。

首先檢查您提供適當的 [DataContract] 和 [DataMember] 是否這不提供然后這種類型的錯誤發生。您必須編寫 [DataContract] 以上類,您傳遞的響應,並寫入 [DataMember] 以上類成員,是去客戶端響應。

復制代碼
[DataContract]
class Program
{
  [DataMember] 
  public string Exampl{get;set}
}
復制代碼

解決方法2:

詳細監聽客戶端請求過程

如果一些 minvalue 的數據類型是通過,檢查響應中。這意味着一些時間數據成員不是初始化,時間它采取它 Minvalue。eg MinValue int 的是 '-2147483648',所以一段時間不能序列化並引發錯誤。

如果您有跟蹤這種類型的錯誤,然后寫下你的服務器端 web.config 中的代碼下面的

復制代碼
<system.diagnostics>
<sources>
  <source name="System.ServiceModel" switchValue="Information, ActivityTracing"    propagateActivity="true">
    <listeners>
      <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener"      initializeData= "D:\Traces.svclog"/>
    </listeners>
  </source>
</sources>
復制代碼

顯示結果:

服務端異常,詳細消息:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM