سؤال

لدي حاليا خدمة WCF مع ربط Webhttp، وأنا أحاول زيادة حجم الحد الأقصى الذي يمكن إدخاله على الخدمة عن طريق تجاوز الإعدادات الافتراضية في التكوين، لقد حاولت القيام بشيء مثل

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

ووضع خصائص أخرى مختلفة تتعلق بحجم الرسائل ولكن يبدو أن لا شيء يعمل، هل يمكن لمرء تغيير حجم M ESSAGE من ربط Webhttp؟ أي اقتراحات؟ شكرا!

هل كانت مفيدة؟

المحلول

هناك العديد من الإعدادات التي قد يكون لها تأثير اعتمادا على إعداداتك - جرب هذا:

<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 ووضع جميع المعلمات إلى قيم أعلى، يجب أن تكون قادرا على الوصول إلى أي حجم رسالة (تقريبا).

مانع لك: هذا يفتح نظامك إلى إمكانية غمرت المياه مع رسائل ضخمة وبالتالي يتم إرجاعها إلى ركبتيها (هجمات الإنكار الكلاسيكية) - وهذا هو السبب في أن هذه الحدود يتم تعيينها منخفضة إلى حد ما - حسب التصميم هدف.

يمكنك تغييرها إلى قيم أعلى - فقط كن على علم بما تفعله وما هي مخاطر الأمان، إذا قمت بذلك!

مارك

ملاحظة: من أجل الاستفادة من هذه الإعدادات، يجب عليك بالطبع أن تشير إلى أن تكوين الربط في الخادم الخاص بك والتشغيل الجانبي العميل:

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

نصائح أخرى

إعداد ماكس الرسالة وحجم المخزن المؤقت لخدمات الراحة WCF Webhttpbinding

<bindings>
  <webHttpBinding>
    <binding maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="200" maxStringContentLength="83886089" maxArrayLength="163841" maxBytesPerRead="2147483647" maxNameTableCharCount="16384"/>
    </binding>
  </webHttpBinding>
</bindings>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top