【问题标题】:WCF exception - Fault occurred while processing the request.WCF 异常 - 处理请求时发生错误。
【发布时间】:2015-12-26 06:52:54
【问题描述】:

我正在尝试通过网络服务访问数据。我的网络服务调用工作得很好,但有时它会在处理请求时抛出错误。 See fault detail for additional information exception

这是我的错误堆栈跟踪:

  at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
  at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
  at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
  at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

我尝试增加绑定中的 readerQuotas。这是我的绑定的样子

<bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IWS" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
          <readerQuotas
           maxDepth="2147483647"
           maxStringContentLength="2147483647"
           maxArrayLength="2147483647"
           maxBytesPerRead="2147483647"
           maxNameTableCharCount="2147483647" />
          <security mode="TransportWithMessageCredential" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://xxxx.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWS"
        contract="ABC.IWS" name="BasicHttpBinding_IWS" />
    </client>

我在这里缺少一些配置吗?

【问题讨论】:

  • 我遇到了完全相同的问题。我怀疑反序列化响应存在一些问题,但目前我没有解决方案。

标签: c# web-services wcf wcf-data-services wcf-binding


【解决方案1】:

我遇到了同样的问题,解决方案是设置被调用服务的所有参数。使用 SOAPUI 应用程序,您可能不会注意到它一次。但和往常一样,提琴手说的是实话。例如,起初您认为“important_parameters”足以设置调用服务。而且您认为网络服务认为(/设置自己)“EndTo”参数为0...错误!你应该故意设置它,否则你会得到这篇文章中提到的错误。

...
<important_parameters>
   ....
</important_parameters>
<Paging>
   <EndTo>0</EndTo>
</Paging>
...

【讨论】:

    【解决方案2】:

    对我来说,故障排除的第一步是获取有关错误的更多信息。由于任务响应的工作方式,可能存在许多内部异常。所以更改处理代码以记录内部异常。

    var responseTask = client.someRemoteCall(request);
    
    responseTask.ContinueWith(t =>
    {
        switch (t.Status)
        {
            case TaskStatus.Faulted:
                foreach (var exception in t.Exception.Flatten().InnerExceptions)
                {
                    log.Error(exception.Message);
    
                    if (exception.InnerException != null)
                    {
                        log.Error(exception.InnerException.Message);
                    }
                }
                break;
            case TaskStatus.RanToCompletion:
                {your success code}
            default:
                {some deafult error is thrown}
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2012-01-20
      • 1970-01-01
      • 2021-08-01
      • 2020-11-14
      • 1970-01-01
      • 1970-01-01
      • 2020-06-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多