WCF在随机调用中获取"在接收到HTTP响应时发生错误"

Fai*_*ani 5 wcf wcf-client wcf-configuration .net-4.5.2

我从客户端调用SOAP API时,随机接收(并非总是)"接收到HTTP响应出错".它不会每次都发生.我的应用程序本身是一个WCF服务.

客户端配置:

<binding name="AbcBinding" 
                 sendTimeout="00:02:45"
                 closeTimeout="00:02:45"
                 openTimeout="00:02:45"
                 receiveTimeout="00:10:00"
                 bypassProxyOnLocal="false"
                 maxBufferPoolSize="2147483647" 
                 maxReceivedMessageSize="2147483647">
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
                <security mode="Transport" >
                <transport clientCredentialType="Basic" />
                </security>
        </binding>

<client>
      <endpoint binding="basicHttpBinding" bindingConfiguration="AbcBinding"
                contract="AbcContract" name="AbcBinding" />
    </client>
Run Code Online (Sandbox Code Playgroud)

码:

var configFactory = new ConfigurationChannelFactory<AbcContract>("AbcBinding"), ConfigFile, "localhost:9198/AbcCall");

            #region Basic http authentication
            if (configFactory.Credentials != null)
            {
                    var defaultCredentials = configFactory.Endpoint.Behaviors.Find<ClientCredentials>();
                    configFactory.Endpoint.Behaviors.Remove(defaultCredentials);

                    var loginCredentials = new ClientCredentials();
                    loginCredentials.UserName.UserName = "UserName";
                    loginCredentials.UserName.Password = "Password";
                    configFactory.Endpoint.Behaviors.Add(loginCredentials);

            }
Run Code Online (Sandbox Code Playgroud)

编辑 在本地环境中,它可以正常工作,具有以下配置:useDefaultWebProxy="false" proxyAddress="http://127.0.0.1:8888"

但在部署服务器上,我遇到以上配置错误:

没有端点监听...可以接受该消息.这通常是由错误的地址或SOAP操作引起的.有关更多详细信息,请参阅InnerException(如果存在).

Aji*_*ith 1

“接收 HTTP 响应时发生错误..”当您的服务代码出现问题时,可能会出现此错误。

重新检查服务代码。

尝试在客户端和服务器中启用 svclog。跟踪日志可以提供一些想法