2

誰でもWCF構成について教えてもらえますか? エラー(400) Bad Requestが発生し、トレース ビューアーから次のように言われました:

「受信メッセージの最大メッセージ サイズ クォータ (65536) を超えました。クォータを増やすには、適切なバインド要素で MaxReceivedMessageSize プロパティを使用してください。」

クライアントのapp.configを見て、それに応じてプロパティを変更しましたが、問題は残っていました。次に、サーバーのweb.configを調べましたが、<service>...</service>タグがまったくないことがわかったので、右クリックweb.configしてウィンドウを選択Edit WCF configurationして数回クリックすると、wcf サービス構成の準備ができましたが、スローが開始されました

「サーバーは意味のある応答を提供しませんでした。これは、コントラクトの不一致、時期尚早のセッションのシャットダウン、または内部サーバー エラーが原因である可能性があります」

トレース ビューアに 3 つの警告が表示されます。

「System.ServiceModel.ServiceHost を開けませんでした」

「障害が発生した System.ServiceModel.ServiceHost」

「ServiceHost に障害が発生しました」

これが私のサーバーのweb.configです:

バージョン 0 (機能しますが、制限があります):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\log\Traces1.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  <connectionStrings>
    <add name="PopulizerConnectionString" connectionString="Data Source=VM-LU4\SQLSERVER;Initial Catalog=Populizer;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
  </system.web>
  <system.serviceModel>
    <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="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
</configuration>

そして、3 つの警告を示すもの:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\log\Traces1.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  <connectionStrings>
    <add name="PopulizerConnectionString" connectionString="Data Source=VM-LU4\SQLSERVER;Initial Catalog=Populizer;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="NewServiceType">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:1948/Commander.svc" />
          </baseAddresses>
        </host>
      </service>
      <service name="Populator.Commander">
        <endpoint address="http://localhost:1948/Commander.svc" binding="basicHttpBinding"
          bindingConfiguration="" name="CommanderEndpoint" contract="Private.ICommander" />
      </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="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
</configuration>

編集

これは私の Web 構成のバージョン #3 ですが、TraceViewer で同じ 3 つの警告が引き続き表示されます。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\log\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  <connectionStrings>
    <add name="PopulizerConnectionString" connectionString="Data Source=VM-LU4\SQLSERVER;Initial Catalog=Populizer;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="httpBasicBinding_Service01" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
          maxBufferSize="655360000"
          maxBufferPoolSize="655360000" maxReceivedMessageSize="655360000">
          <readerQuotas maxDepth="655360000" maxStringContentLength="655360000"
            maxArrayLength="655360000" maxBytesPerRead="655360000" maxNameTableCharCount="655360000" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="NewServiceType">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:1948/Commander.svc" />
          </baseAddresses>
        </host>
      </service>
      <service name="Populator.Commander">
        <endpoint address="http://localhost:1948/Commander.svc" binding="basicHttpBinding"
          bindingConfiguration="httpBasicBinding_Service01" name="CommanderEndpoint" contract="Private.ICommander" />
      </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="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
</configuration>
4

3 に答える 3

0

バインディング構成を設定する必要があります。

あなたが書いた場所:

bindingConfiguration = ""

あなたは書くべきです:

bindingConfiguration="httpBasicBinding_Service01"

次に構成します。

<basicHttpBinding>
    <binding name="httpBasicBindingService 01" closeTimeout="00:10:00"
      openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
      maxBufferSize="655360000"
      maxBufferPoolSize="655360000" maxReceivedMessageSize="655360000">
      <readerQuotas maxDepth="655360000" maxStringContentLength="655360000"
        maxArrayLength="655360000" maxBytesPerRead="655360000" maxNameTableCharCount="655360000" />
    </binding>
  </basicHttpBinding>
于 2011-06-24T16:48:00.967 に答える
0

サーバー構成のバインド要素の最大引用符は何ですか? 以下の例をご覧ください。

<wsHttpBinding>
    <binding name="WSHttpBinding_ISomeService" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
      textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00"
        enabled="false" />
      <security mode="Message">
        <transport clientCredentialType="Windows" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true"
          algorithmSuite="Default" establishSecurityContext="true" />
      </security>
    </binding>
  </wsHttpBinding>
于 2011-06-24T16:46:55.883 に答える
0

構成の作業バージョンから非作業バージョンへの段階的な構成が役立ちました。サーバーの web.config は次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\log\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  <connectionStrings>
    <add name="PopulizerConnectionString" connectionString="Data Source=VM-LU4\SQLSERVER;Initial Catalog=Populizer;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding  name="ICommander_BindingConfiguration"
                  closeTimeout="01:00:00"
                  openTimeout="00:01:00"
                  receiveTimeout="00:10:00"
                  sendTimeout="00:01:00"
                  allowCookies="false"
                  bypassProxyOnLocal="false"
                  hostNameComparisonMode="StrongWildcard"
                  maxBufferSize="1048576"
                  maxBufferPoolSize="524288"
                  maxReceivedMessageSize="1048576"
                  messageEncoding="Text"
                  textEncoding="utf-8"
                  transferMode="Buffered"
                  useDefaultWebProxy="true"
        >
          <readerQuotas
              maxDepth="32"
              maxStringContentLength="1048576"
              maxArrayLength="1048576"
              maxBytesPerRead="4096"
              maxNameTableCharCount="1048576"
          />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding
          name="ICommunicator_BindingConfiguration"
          closeTimeout="01:00:00"
          openTimeout="00:01:00"
          receiveTimeout="00:10:00"
          sendTimeout="00:01:00"
          allowCookies="false"
          bypassProxyOnLocal="false"
          hostNameComparisonMode="StrongWildcard"
          maxBufferSize="1048576"
          maxBufferPoolSize="524288"
          maxReceivedMessageSize="1048576"
          messageEncoding="Text"
          textEncoding="utf-8"
          transferMode="Buffered"
          useDefaultWebProxy="true"
        >
          <readerQuotas
              maxDepth="32"
              maxStringContentLength="1048576"
              maxArrayLength="1048576"
              maxBytesPerRead="4096"
              maxNameTableCharCount="1048576"
          />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="Populator.Commander">
        <endpoint contract="Private.ICommander" binding="basicHttpBinding" bindingConfiguration="ICommander_BindingConfiguration" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="CommanderBehavior">
          <!-- 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="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
</configuration>
于 2011-06-27T16:22:38.133 に答える