[WCF接收HTTP响应时发生服务错误

问题描述 投票:-1回答:1

由于服务端点绑定未使用HTTP协议,因此在收到HTTP响应时发生错误。这也可能是由于服务器中止了HTTP请求上下文。无法从传输连接中读取数据。现有连接被远程主机强行关闭

WEB客户端配置

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="basicHttpBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
                    <message clientCredentialType="UserName" algorithmSuite="Default"/>
                </security>
            </binding>
        </basicHttpBinding>         
    </bindings>
    <endpoint address="http://WCFService:8086/WCFBase" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="WCFBase.IWCFBase" name="basicHttpBinding"/>
    <endpoint address="http://WCFService:8087/WCFExtra" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="WCFExtra.IWCFEXTRA" name="basicHttpBinding"/>
</system.serviceModel>

WCF服务配置

<system.serviceModel>
    <extensions>
      <behaviorExtensions>
        <add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      </behaviorExtensions>
    </extensions>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding" transferMode="Streamed" />        
      </basicHttpBinding>     
    </bindings>
    <services>      
      <service behaviorConfiguration="WCFService.Web.Behavior" name="WCFService.Web.Service.WCFBase">
        <endpoint address="" binding="basicHttpBinding" name="basicHttpBinding" contract="WCFService.Web.Service.IWCFBase" behaviorConfiguration="WsdlSampleEndpointBehavior" />
        <host>
          <baseAddresses>
            <add baseAddress="http://WCFService:8086/WCFBase" />
          </baseAddresses>
        </host>
      </service>
      <service behaviorConfiguration="WCFService.Web.Behavior" name="WCFService.Web.Extra.WCFExtra">
        <endpoint address="" binding="basicHttpBinding" name="basicHttpBinding" contract="WCFService.Web.Extra.IWCFExtra" behaviorConfiguration="WsdlSampleEndpointBehavior" />
        <host>
          <baseAddresses>
            <add baseAddress="http://WCFService:8087/WCFExtra" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="WsdlSampleEndpointBehavior">
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="WCFService.Web.Behavior">
          <serviceMetadata httpGetEnabled="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <serviceThrottling maxConcurrentCalls="3000"     
              maxConcurrentSessions="3000" maxConcurrentInstances="3000"/>
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

Web客户端错误

http://webclient/Common/Login.aspx|System.ServiceModel.CommunicationException:收到对http://wcfservice:8086/WCFBase的HTTP响应时发生错误。这可能是由于服务端点绑定未使用HTTP协议。这也可能是由于服务器终止了HTTP请求上下文(可能是由于服务关闭了)。有关更多详细信息,请参见服务器日志。 ---> System.Net.WebException:基础连接已关闭:接收时发生意外错误。 ---> System.IO.IOException:无法从传输连接读取数据:远程主机强行关闭了现有连接。 ---> System.Net.Sockets.SocketException:现有的连接被远程主机强行关闭在System.Net.Sockets.Socket.Receive(Byte []缓冲区,Int32偏移量,Int32大小,SocketFlags socketFlags)在System.Net.Sockets.NetworkStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)---内部异常堆栈跟踪的结尾---在System.Net.Sockets.NetworkStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)在System.Net.PooledStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)在System.Net.Connection.SyncRead(HttpWebRequest请求,布尔userRetrievedStream,布尔probeRead)---内部异常堆栈跟踪的结尾---在System.Net.HttpWebRequest.GetResponse()在System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan超时)---内部异常堆栈跟踪结束---

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 WCFBase.IWCFBase.PerformUserLogin(UserLoginVO aUserLoginVO)
   at WCFBase.WCFBaseClient.PerformUserLogin(UserLoginVO aUserLoginVO) in c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\WebClient\ec042b76\af1d169c\App_WebReferences.39m1idzl.0.cs:line 36589
   at Web.Client.Common_Login.pLogin(Boolean aIsFroceLogin) in d:\webclient\Common\Login.aspx.cs:line 178
wcf-data-services wcf-binding
1个回答
0
投票

默认情况下,WCF项目不支持多重服务合同。您如何通过多个服务合同托管WCF服务?客户端配置有问题。客户端配置是否通过Adding Service Reference工具自动生成?在致电之前,请确保该服务能够正常工作。enter image description here请随时让我知道问题是否仍然存在。

© www.soinside.com 2019 - 2024. All rights reserved.