簡體   English   中英

413請求實體太大錯誤-WCF服務

[英]413 Request Entity Too Large error- WCF Service

當我放置大容量數據的請求消息時,我有一個wcf服務(我的請求包含base64字符串,並且此請求是長文本)
我收到此錯誤“ 413請求實體太大”。
幫我打電話給這項服務。
這是我的WCF配置

<?xml version="1.0"?>

<system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <httpRuntime maxRequestLength="2097150"/>
</system.web>
<system.serviceModel>
    <services>
        <service behaviorConfiguration="ServiceBehaviour" name="ApiFrame.ApiFrame">
            <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding"
             contract="ApiFrame.IApiframe" />
            <endpoint address="soap" binding="basicHttpBinding" contract="ApiFrame.IApiframe" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="ServiceBehaviour">
                <!-- 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>
        <endpointBehaviors>
            <behavior name="jsonBehavior">
                <enableWebScript/>
                <!-- use JSON serialization -->
            </behavior>
            <behavior name="xmlBehavior">
                <webHttp/>
                <!-- use XML serialization -->
            </behavior>
            <behavior name="web">
                <webHttp/>
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <!--<serviceHostingEnvironment multipleSiteBindingsEnabled="false"/>-->
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="ServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
                receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
        <webHttpBinding>
            <binding
              maxBufferPoolSize="2147483647"
              maxReceivedMessageSize="2147483647"
              maxBufferSize="2147483647" transferMode="Streamed">
            </binding>
        </webHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://10.16.8.54/T24WebServices/Service.asmx"
            binding="basicHttpBinding" bindingConfiguration="ServiceSoap"
            contract="ConnectT24_54.ServiceSoap" name="ServiceSoap" />
    </client>
</system.serviceModel>

這是我的客戶端應用程序配置:

<?xml version="1.0"?>

<connectionStrings>
    <add name="ApplicationServices"
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
         providerName="System.Data.SqlClient" />
</connectionStrings>

<system.web>
    <compilation debug="true" targetFramework="4.0" />

    <httpRuntime requestValidationMode="2.0" maxRequestLength="2147483647"/>

    <pages validateRequest="false">
    </pages>
    <authentication mode="Forms">
        <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>

    <membership>
        <providers>
            <clear/>
            <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
                 enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
                 maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
                 applicationName="/" />
        </providers>
    </membership>

    <profile>
        <providers>
            <clear/>
            <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
        </providers>
    </profile>

    <roleManager enabled="false">
        <providers>
            <clear/>
            <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
            <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
        </providers>
    </roleManager>

</system.web>

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>

    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IApiframe" closeTimeout="00:01:00" openTimeout="00:01:00"
            receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
            bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true">
                <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

            </binding>
        </basicHttpBinding>

    </bindings>
    <client>
        <endpoint address="http://localhost:10832/ApiFrame.svc/soap"
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IApiframe"
          contract="ApiServices.IApiframe" name="BasicHttpBinding_IApiframe" />
    </client>
</system.serviceModel>

您增加了綁定屬性的大小,但從未綁定分配給端點,因此WCF使用指定綁定的默認值。 要解決此問題,請在服務的配置中使用<endpoint>元素上的bindingConfiguration屬性,如下所示:

<endpoint address="soap" 
          binding="basicHttpBinding" 
          bindingConfiguration="ServiceSoap"
          contract="ApiFrame.IApiframe" />

請注意,您的客戶端配置已將指定的綁定分配給客戶端端點。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM