问题解决_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>
复制代码

显示结果:

服务端异常,详细消息:

转载于:https://www.cnblogs.com/hhhh2010/p/6221758.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值