0

我正在调用我之前创建的 WCF 服务,该服务查询语义数据库并返回 dbpedia.org 链接,这些链接带有实体的名称,例如,您会找到“http://dbpedia.org/resource/ Barack_Obama”或“http://dbpedia.org/resource/Brazil”

我面临的问题是,在调用返回提到的 URI 的方法时,大多数情况下该方法都有效,但很少发生此错误:

底层连接已关闭:服务器关闭了预期保持活动状态的连接。

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.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)
   at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)
   at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.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.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 ComparisonServiceInterface.Compare(String[] URIs)
   at ComparisonServiceInterfaceClient.Compare(String[] URIs)

Inner Exception:
The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.
   at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)

Inner Exception:
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)

Inner Exception:
An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)

我想也许有些资源有不同的编码,比如'ü'字符的“http://dbpedia.org/resource/Sergio_Agüero”或者什么?

我在发回之前尝试对 uri 进行编码,它仍然抛出相同的异常。

服务配置文件如下所示:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true"/>
  </system.web>  
  <system.serviceModel>
    <services>
      <service name="mergedServices.MergedService">
        <endpoint address="" binding="wsHttpBinding" contract="mergedServices.RelationGeneratorServiceInterface">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="" binding="wsHttpBinding" contract="mergedServices.keywordSearchServiceInterface">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="" binding="wsHttpBinding" contract="mergedServices.QAServiceInterface">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="" binding="wsHttpBinding" contract="mergedServices.CompareWithOnePredicateServiceInterface">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="" binding="wsHttpBinding" contract="mergedServices.ComparisonServiceInterface">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="" binding="wsHttpBinding" contract="mergedServices.ProfileConstructorInterface">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/mergedServices/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
4

1 回答 1

0

在故障中临时包含异常详细信息,这将允许您获得真正的错误。此外,您应该在服务中重新抛出异常之前记录它们,这样您就知道真正的问题是什么,而无需在故障中包含异常详细信息。

<serviceDebug includeExceptionDetailInFaults="True"/>
于 2012-07-03T16:05:26.630 回答