0

アプリケーションで WCF を使用しています。アプリケーションから I WCF を介してバックエンドで処理するリストを渡します。リスト内の行数が多い場合、サービスは「リモート サーバーが予期しない応答を返しました: (400) 不正な要求」という例外をスローします。

以下は私のUI Web構成です

<system.serviceModel>

<bindings>

  <basicHttpBinding>

    <binding name="BasicHttpBinding_IService1" closeTimeout="10:20:00"
      openTimeout="10:20:00" receiveTimeout="10:20:00" sendTimeout="10:20:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">

      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="None">

        <transport clientCredentialType="Windows" proxyCredentialType="Windows"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />

      </security>

    </binding>
    <binding name="BasicHttpBinding_IErrorService" closeTimeout="10:20:00"
      openTimeout="10:20:00" receiveTimeout="10:20:00" sendTimeout="10:20:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">

      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

      <security mode="None">

        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />

      </security>

    </binding>
    <binding name="BasicHttpBinding_IService11" closeTimeout="10:20:00"
      openTimeout="10:20:00" receiveTimeout="10:20:00" sendTimeout="10:20:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">

      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

      <security mode="None">

        <transport clientCredentialType="Windows" proxyCredentialType="Windows"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />

      </security>

    </binding>
    <binding name="BasicHttpBinding_ISecurityUserService" closeTimeout="10:20:00"
      openTimeout="10:20:00" receiveTimeout="10:20:00" sendTimeout="10:20:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">

      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

      <security mode="None">

        <transport clientCredentialType="Windows" proxyCredentialType="Windows"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />

      </security>

    </binding>

  </basicHttpBinding>
</bindings>

<client>

  <endpoint address="http://localhost:6789/Service1.svc" binding="basicHttpBinding"
    bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
    name="BasicHttpBinding_IService1" />
  <endpoint address="http://localhost:6789/ErrorService.svc" binding="basicHttpBinding"
    bindingConfiguration="BasicHttpBinding_IErrorService" contract="ErrorServiceReference.IErrorService"
    name="BasicHttpBinding_IErrorService" />
  <endpoint address="http://localhost:6789/SecurityUserService.svc"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISecurityUserService"
    contract="SecurityUserServiceReference.ISecurityUserService"
    name="BasicHttpBinding_ISecurityUserService" />
  <endpoint address="http://localhost:6789/Service1.svc" binding="basicHttpBinding"
    bindingConfiguration="BasicHttpBinding_IService11" contract="ServiceReference.IService1"
    name="BasicHttpBinding_IService11" />

</client>

</system.serviceModel>

また、以下のタグを WCF Web 構成および UI Web 構成に追加しました

<system.web>

      <httpRuntime maxRequestLength="512000" />

  </system.web>

私のサービス構成は以下の通りです

  <httpRuntime maxRequestLength="512000" />

サービスモデル:

<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>      
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

<modules runAllManagedModulesForAllRequests="true"/>

サービスの Web 構成 を変更しました。それでも私は同じ問題を抱えています。これについて私を助けてください

<services>

  <service name="BasicHttpBinding_IService1" behaviorConfiguration="Behavior">
    <endpoint address=""
              binding="basicHttpBinding"
              bindingConfiguration="BasicHttpBinding_IService1"
              contract="ServiceReference1.IService1"/>        
  </service>
  <service name="BasicHttpBinding_IErrorService" behaviorConfiguration="Behavior">
    <endpoint address=""
              binding="basicHttpBinding"
              bindingConfiguration="BasicHttpBinding_IErrorService"
              contract="ErrorServiceReference.IErrorService"/>

  </service>
  <service name="BasicHttpBinding_ISecurityUserService" behaviorConfiguration="Behavior">
    <endpoint address=""
              binding="basicHttpBinding"
              bindingConfiguration="BasicHttpBinding_ISecurityUserService"
              contract="SecurityUserServiceReference.ISecurityUserService"/>

  </service>

</services>

and bindings

<bindings>

 <basicHttpBinding>
  <binding name="BasicHttpBinding_IService1" closeTimeout="10:20:00"
    openTimeout="10:20:00" receiveTimeout="10:20:00" sendTimeout="10:20:00"
    allowCookies="false" bypassProxyOnLocal="false"      hostNameComparisonMode="StrongWildcard"
    maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
    useDefaultWebProxy="true">
    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    <security mode="None">
      <transport clientCredentialType="Windows" proxyCredentialType="Windows"
        realm="" />
      <message clientCredentialType="UserName" algorithmSuite="Default" />
    </security>
  </binding>
    <binding name="BasicHttpBinding_IErrorService" closeTimeout="10:20:00"
      openTimeout="10:20:00" receiveTimeout="10:20:00" sendTimeout="10:20:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
    <binding name="BasicHttpBinding_ISecurityUserService" closeTimeout="10:20:00"
      openTimeout="10:20:00" receiveTimeout="10:20:00" sendTimeout="10:20:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="None">
        <transport clientCredentialType="Windows" proxyCredentialType="Windows"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>

</bindings>
4

1 に答える 1

0

サービス構成でエンドポイントまたはバインディングが定義されていないようです。これは、デフォルトのエンドポイントとバインディングを取得していることを意味します。サービスはデフォルトのバインディングとそのデフォルト値を使用しているため、大きなメッセージを受信できません。

namebinding 要素の属性を省略して、デフォルトのバインディング設定をオーバーライドできます。ただし、あなたの場合、3 つの定義済みバインディング (少なくともセキュリティ部分) に異なる設定があります。そのため、バインディングを定義してエンドポイントに割り当てる必要があります。

次のようなことを試してください:

<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_IService1" .....>
  </basicHttpBinding>
</bindings>

バインディング宣言のほとんどを省略しました。クライアント構成から単純にコピーできます。

bindingConfig次に、サービスで、エンドポイント要素の属性を使用して、次のように特定のバインディング構成を割り当てます。

<services>
  <service .... >
    <endpoint address="http://localhost:6789/Service1.svc"  
              binding="basicHttpBinding"
              bindingConfiguration="BasicHttpBinding_IService1" 
              contract="ServiceReference1.IService1" 
              name="BasicHttpBinding_IService1" />
  </service>
</services>

ここでも、簡単にするために構成コードのほとんどを省略しました。

ここで重要な点は、デフォルトよりも大きなメッセージを受け入れるように構成されたバインディングがサービスに必要であるということです。ランタイムの を増やしてもmaxRequestLength、WCF サービスには直接影響しません (もちろん、HTTP ランタイムの値よりも大きなリクエストがない限り)。

既定のエンドポイントとバインディングの詳細については、こちら - A Developer's Introduction to Windows Communication Foundation 4 を参照してください。

于 2013-04-10T21:30:15.770 に答える