Frage

Ich versuche, Dateien mit WCF hochzuladen. Alles unter 16K funktioniert einwandfrei, aber alles über diesen Fehler wirft:

Es gab einen Fehler, der das Objekt des Typs des Typs des Typs entmündigte. Byte []. Die maximale Array -Länge -Quote (16384) wurde beim Lesen von XML -Daten überschritten. Diese Quote kann erhöht werden, indem die Eigenschaft maxArrayLength im XMLDictionaryReaderquotas -Objekt geändert wird, das beim Erstellen des XML -Lesers verwendet wird

Dies ist meine WCF Service App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IRAISAPI" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000"
          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
          allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="104857600"
            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" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="RAIS_WCF_Services.RAISAPI">
        <endpoint address="" binding="wsHttpBinding" contract="RAIS_WCF_Services.IRAISAPI">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/RAIS_WCF_Services/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

Und hier ist meine Client App.config

    <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
  </startup>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IRAISAPI" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000"
          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
          allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="104857600"
            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" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8732/Design_Time_Addresses/RAIS_WCF_Services/Service1/"
        binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IRAISAPI"
        contract="RAIS.IRAISAPI" name="WSHttpBinding_IRAISAPI">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>

Jede Hilfe wird sehr geschätzt! Vielen Dank.

War es hilfreich?

Lösung

Es sieht nicht so aus, als ob Ihr Dienst nicht ordnungsgemäß auf Ihre Bindungskonfiguration bezieht.

Suchen Sie in Ihrer Servicekonfiguration nach WSHTTPBINDING_IRAISAPI, und Sie werden sehen, was ich meine.

Du brauchst:

    <endpoint address="" binding="wsHttpBinding" 
              contract="RAIS_WCF_Services.IRAISAPI"  
              bindingConfiguration="WSHttpBinding_IRAISAPI">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>

Andere Tipps

Ich gehe davon aus, dass Sie meinen, dass die Einstellung von MaxArrayLength nach dem Hinzufügen einer Servicereferenz nicht automatisch in Ihrer Client -Konfiguration festgelegt wird und/oder sie nach der Aktualisierung der Servicereferenz Ihres Clients verloren geht? Wenn Sie dies erleben, ist dies das Design. Einstellungen wie Timeouts, MaxArrayLength usw. werden in WSDL nicht freigelegt und können daher nicht vom Dienst an den Client weitergegeben werden, wenn die Dienstreferenz erstellt/aktualisiert wird.

Versuchen Sie, dies hinzuzufügen Globale Konfiguration zu Ihrer serverseitigen Konfiguration. Dadurch wird Ihre Service -Bindung an eine Bindungskonfiguration verbunden.

<system.serviceModel>
    <protocolMapping>
      <remove scheme="http"/>
      <add scheme="http" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IRAISAPI" />
    </protocolMapping>
</system.serviceModel>

Sie können auch verwenden behaviors/serviceBehaviors/behavior/serviceMetadata/httpGetBindingConfiguration für eine lokalere Lösung.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top