7

現在、webHttpバインディングを使用するWCFサービスがあります。構成のデフォルト設定を上書きして、サービスに入力できる最大サイズを増やしようとしています。次のようなことを試みました。

  <system.serviceModel>
<bindings>
<webHttpBinding>
  <binding name="webHttp" >
  <security mode="Transport">
      <transport clientCredentialType = 
             "None"
            proxyCredentialType="None"
            realm="string" />
  </security>
  </binding>

</webHttpBinding>
</bindings>
<services>

  <service name="PrimeStreamInfoServices.Service1" behaviorConfiguration="PrimeStreamInfoServices.Service1Behavior">
    <!-- Service Endpoints -->
    <endpoint address="" binding="webHttpBinding"  contract="PrimeStreamInfoServices.IService1">
      <!-- 
          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.
      -->
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="PrimeStreamInfoServices.Service1Behavior">
      <!-- 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>
<diagnostics>

メッセージサイズに関連する他のさまざまなプロパティを設定しますが、どれも機能していないようです。webHttpバインディングのメッセージサイズを変更することもできますか?助言がありますか?ありがとう!

4

3 に答える 3

12

設定によっては影響を与える可能性のある設定が多数あります。これを試してください。

<bindings>
  <webHttpBinding>
    <binding name="LargeWeb"
             maxBufferPoolSize="1500000"
             maxReceivedMessageSize="1500000"
             maxBufferSize="1500000">
      <readerQuotas 
            maxArrayLength="656000"
            maxBytesPerRead="656000"
            maxDepth="32"
            maxNameTableCharCount="656000"
            maxStringContentLength="656000"
            />
    </binding>
  </webHttpBinding>
</bindings>

webHttpBindingの「バージョン」を定義し、それらすべてのパラメーターをより高い値に設定することにより、(ほぼ)任意のメッセージサイズを通過できるはずです。

注意:これにより、システムが巨大なメッセージで溢れ、ひざまずく可能性があります(従来のサービス拒否攻撃)。これが、これらの制限がかなり低く設定されている理由です。目的。

それらをより高い値に変更することができます-あなたがしていることと、もしそうなら、セキュリティリスクが何であるかだけに注意してください!

マーク

PS:これらの設定を利用するには、もちろん、サーバー側とクライアント側の構成でそのバインディング構成を参照する必要があります。

<client>
  <endpoint address="http://localhost"
            binding="webHttpBinding" bindingConfiguration="LargeWeb"
            contract="IMyService" />
</client>
<services>
  <service>
    <endpoint address="http://localhost"
              binding="webHttpBinding" bindingConfiguration="LargeWeb"
              contract="IMyService" />
  </service>
</services>
于 2009-07-27T16:26:28.763 に答える
0

WCFRestサービスの最大メッセージとバッファーサイズの設定webhttpbinding

<bindings>
  <webHttpBinding>
    <binding maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="200" maxStringContentLength="83886089" maxArrayLength="163841" maxBytesPerRead="2147483647" maxNameTableCharCount="16384"/>
    </binding>
  </webHttpBinding>
</bindings>
于 2017-08-26T09:04:26.973 に答える
0

モデルで[DataContract]デコレータを使用している場合は、dataContractSerializerをweb.configに追加する必要があります。

例:

  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpsGetEnabled="false"   httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </serviceBehaviors>
于 2020-09-07T23:34:55.727 に答える