質問

WCFを使用してファイルをアップロードしようとしています。 16k未満のすべてが正常に機能しますが、このエラーを投げるものはすべてです。

タイプシステムのオブジェクトを偏った脱必要なエラーがありました。Byte[]。 XMLデータの読み取り中に、最大配列長クォータ(16384)を超えています。このクォータは、XMLリーダーを作成するときに使用されるXMLDictionaryReaderQuotasオブジェクトのMaxArrayLengthプロパティを変更することで増加する場合があります

これは私のWCFサービス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>

そして、これが私のクライアント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>

どんな助けも大歓迎です!ありがとう。

役に立ちましたか?

解決

サービスがバインディング構成を適切に指すものではないようには見えません。

wshttpbinding_iraisapiのサービス構成で検索すると、私が何を意味するかがわかります。

あなたが必要です:

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

他のヒント

サービスリファレンスを追加した後、および/またはクライアントのサービスリファレンスを更新した後に迷子になった後、MaxArrayLengthの設定がクライアントの構成で自動的に設定されていないことを意味すると思いますか?これがあなたが経験していることである場合、これは設計によるものです。タイムアウト、MaxArrayLengthなどの設定はWSDLで公開されていないため、サービスリファレンスが作成/更新されたときにサービスによってクライアントにプッシュすることはできません。

これを追加してみてください グローバル構成 サーバー側の構成に。これにより、バインディング構成にバインディングされます。

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

使用することもできます behaviors/serviceBehaviors/behavior/serviceMetadata/httpGetBindingConfiguration より局所的なソリューションのため。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top