1

WCF クライアントでのテスト中に、wcf サービスで問題が発生しました。デバッグすると、関数からデータが返されますが、応答中にエラーが発生します。誰かが私が欠けているものを理解するのを手伝ってくれますか?

ここに私のサービスと設定ファイルがあります:

public List<PO> GetAllPOs()
{
    var data = new List<PO>();
    try
    {
        var manager = new EntityReaderManager<PO>(ConfigurationManager.AppSettings("FilemakerDB"]);
        data = manager.GetEntityList();
    }
    catch (Exception ex)
    {
        ILogger logger = new Logger(typeof(FilemakerDataService)); 
        logger.Error(ex.Message);

    }

   return data;
}

設定ファイルは次のとおりです。

<system.serviceModel>    
    <diagnostics>
      <messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true"
        logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"
        maxSizeOfMessageToLog="2147483647" />
      <endToEndTracing propagateActivity="true" activityTracing="false"
        messageFlowTracing="true" />
    </diagnostics>

    <bindings>
    <wsHttpBinding>
      <binding name="Custom.WSHTTPBinding.Configuration" closeTimeout="10:10:00"
        openTimeout="10:10:00" receiveTimeout="10:10:00" sendTimeout="10:10:00"
        maxBufferPoolSize="655360" maxReceivedMessageSize="655360">

        <security mode="None" />
      </binding>
    </wsHttpBinding>
  </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
    <services>
      <service behaviorConfiguration="Custom.ServiceBehavior" name="AerWorldwide.Service.Web.FilemakerData.FilemakerDataService">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="Custom.WSHTTPBinding.Configuration"
          name="Custom.WSHTTPBinding.Configuration" contract="AerWorldwide.Service.Web.FilemakerData.IFilemakerDataService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="Custom.ServiceBehavior">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>    
</system.serviceModel>

エラー:

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) 
4

1 に答える 1

4

まず、サービスでトレースを有効にし、例外の原因を確認します。

また、サーバー側とクライアント側で ReaderQuotas を増やして、より大きなデータが問題なく渡されるようにすることも検討してください。以下にサンプルを示します。

<wsHttpBinding>
      <binding name="Custom.WSHTTPBinding.Configuration" closeTimeout="10:10:00"
        openTimeout="10:10:00" receiveTimeout="10:10:00" sendTimeout="10:10:00"
        maxBufferPoolSize="655360" maxReceivedMessageSize="655360">
         <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
              maxArrayLength="2147483647" maxBytesPerRead="2147483647"
              maxNameTableCharCount="2147483647" />
        <security mode="None" />
      </binding>
    </wsHttpBinding>

また、エンティティ フレームワークによってフェッチされたオブジェクトを直接渡していることがコードでわかります。エンティティ フレームワーク オブジェクトが逆シリアル化されず、例外が発生する可能性がある状況があります。単純な POCO を作成し、フェッチしたデータを入力して POCO を返します。

于 2012-06-07T10:07:43.603 に答える