簡體   English   中英

我的app.config工作正常嗎? 截斷的數據

[英]Is my app.config working? Truncated data

這是我第一個同時編寫客戶端和服務器端的WCF服務項目。 我來自Windows Forms背景。 我認為我一直在遇到數據包/接收緩沖區大小方面的問題,但是我不知道如何測試我的app.config是否正常工作或做錯了什么。

客戶端項目的app.config設置如下,其testproj.exe.config正確反映了內容

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IPulseWebService"
                 closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
            messageEncoding="Text" textEncoding="utf-8"
            useDefaultWebProxy="true">
          <readerQuotas
    maxArrayLength="2147483647"
    maxBytesPerRead="2147483647"
    maxDepth="2147483647"
    maxNameTableCharCount="2147483647"
    maxStringContentLength="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="blah"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPulseWebService"
            contract="ServiceReference1.IPulseWebService" name="WSHttpBinding_IPulseWebService">
            <identity>
                <dns value="localhst" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

我的Web服務的webservice.dll.config包含以下service.serviceModel部分

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IPulseWebService"
                 closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
            messageEncoding="Text" textEncoding="utf-8"
            useDefaultWebProxy="true">
          <readerQuotas
         maxArrayLength="2147483647"
         maxBytesPerRead="2147483647"
         maxDepth="2147483647"
         maxNameTableCharCount="2147483647"
         maxStringContentLength="2147483647" /> 
        </binding>
      </wsHttpBinding>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IPulseWebService" 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="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>  
    </bindings>

  <services>
    <service name="SmartcentreWcfLib.PulseWebService">
      <host>
        <baseAddresses>
          <add baseAddress="http://l0calhost:8732/Design_Time_Addresses/SmartcentreWcfLib/PulseWebService/" />
        </baseAddresses>
      </host>
      <!-- Service Endpoints -->
      <!-- Unless fully qualified, address is relative to base address supplied above -->
      <endpoint  address="" binding="wsHttpBinding"
                 bindingConfiguration="WSHttpBinding_IPulseWebService"
                 contract="SmartcentreWcfLib.IPulseWebService">
        <!-- 
            Upon deployment, the following identity element should be removed or replaced to reflect the 
            identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
            automatically.
        -->
        <identity>
          <dns value="l0calhost" />
        </identity>

      </endpoint>
      <!-- Metadata Endpoints -->
      <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
      <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    </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>

在我的服務器端wcf dll中,我具有以下功能,作為測試以返回一些數據行。 每行是存儲在字典中的一組鍵/值對。 每個對象應為簡單的byte []或變量類型。

  List<IDictionary<string, object>> IAuditV1.ReadAuditForStaffMember(long staffId, DateTime startDate, 
    DateTime endDate, Int32 recordCount)
  {
      List<TableAdminAudit> tempResult = DatabaseInterface.Instance.AuditQueries.ReadAdminAudit(staffId, startDate,
        endDate, recordCount);
      return tempResult.Select(record => record.PrepareForWebInterface()).Cast<IDictionary<string, object>>().ToList();
  }// function

在我的客戶端應用程序中,我正在運行以下循環,該循環僅增加了已接收記錄的數量。

      Int32 totalRecords = 0;
      while (true)
      {
        results = client.ReadAuditForStaffMember(1, DateTime.MinValue, DateTime.Now, totalRecords);
        totalRecords += 10; //results.Length;
        if (totalRecords == 0) break;
      }

在第三個循環上,當返回的緩沖區達到30條記錄的大小時,我收到以下錯誤消息。 我查找了該錯誤,並在論壇上提出了建議,該錯誤與接收到完整數據之前的連接關閉有關,因此請更改各種緩沖區大小等。從配置文件中可以看到,我已經提高了所有我知道的值到2147483647,但沒有用。 所以我不知道從這里去哪里。 有人可以幫忙嗎?

System.ServiceModel.CommunicationException occurred
  HResult=-2146233087
  Message=An error occurred while receiving the HTTP response to blah2/Design_Time_Addresses/SmartcentreWcfLib/PulseWebService/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
  Source=mscorlib
  StackTrace:
    Server stack trace: 
       at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
       at System.ServiceModel.Channels.HttpChannelFactory`1.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.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 WcfTester.ServiceReference1.IPulseWebService.ReadAuditForStaffMember(Int64 staffId, DateTime startDate, DateTime endDate, Int32 startIndex)
       at WcfTester.ServiceReference1.PulseWebServiceClient.ReadAuditForStaffMember(Int64 staffId, DateTime startDate, DateTime endDate, Int32 startIndex) in W:\Projects\pulse.smartcentre.root\pulse.smartcentre\WcfTester\Service References\ServiceReference1\Reference.cs:line 481
       at WcfTester.Program.Main(String[] args) in W:\Projects\pulse.smartcentre.root\pulse.smartcentre\WcfTester\Program.cs:line 40
  InnerException: System.Net.WebException
       HResult=-2146233079
       Message=The underlying connection was closed: An unexpected error occurred on a receive.
       Source=System
       StackTrace:
            at System.Net.HttpWebRequest.GetResponse()
            at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
       InnerException: System.IO.IOException
            HResult=-2146232800
            Message=Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
            Source=System
            StackTrace:
                 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)
            InnerException: System.Net.Sockets.SocketException
                 HResult=-2147467259
                 Message=An existing connection was forcibly closed by the remote host
                 Source=System
                 ErrorCode=10054
                 NativeErrorCode=10054
                 StackTrace:
                      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)
                 InnerException:** 

從未使用文件something.dll.config 您需要將這些設置復制到web.config或servicehost.exe.config文件中。

從第一天開始,.NET就是這樣工作的,並且不特定於WCF。 請考慮一個給定的DLL可以由多個“可執行文件”使用,並且每個DLL可能具有不同的設置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM