2012-07-05 1 views
1

이미지를 업로드하기 위해 WCF 서비스를 만들었습니다. 작은 이미지가 다양 할 때 잘 동작합니다. 하지만 800KB와 같은 이미지로 시도하면 "원격 서버에서 오류 (400)가 잘못되었습니다."가 표시됩니다. 로그 파일을 볼 때이 예외가 표시됩니다. ThrowMaxReceivedMessageSizeExceeded() maxRequestLength와 몇 가지 다른 설정을 포함하여 여러 가지를 시도해 보았습니다.wcf가 포함 된 큰 이미지 - ThrowMaxReceivedMessageSizeExceeded()

내 웹 사이트에는 WCFApp, WebApplocation, 서비스 요청이있는 BLClient에는 classLibrary가 있습니다.

이 내 설정 파일과 같습니다 WCFApplication의

의 Web.config : 웹 응용의

<?xml version="1.0"?> 
    <configuration> 
    <connectionStrings> 
    <add name="photoShopEntities" 
     connectionString="metadata=res://*/photoShop.csdl| 
     res://*/photoShop.ssdl| 
     res://*/photoShop.msl; 
     provider=System.Data.SqlClient;provider connection string='Data Source=.\SQLEXPRESS;AttachDbFileName=|DataDirectory|photoShop.mdf;Integrated Security=True;User Instance=True'" 
     providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- 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="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 

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

</configuration> 

의 Web.config :

<?xml version="1.0"?> 

<!-- 
    For more information on how to configure your ASP.NET application, please visit 
    http://go.microsoft.com/fwlink/?LinkId=169433 
    --> 

<configuration> 
    <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" /> 

    <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="true"> 
     <providers> 
     <clear /> 
     <add connectionStringName="ApplicationServices" applicationName="/" 
      name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" /> 
     <add applicationName="/" name="AspNetWindowsTokenRoleProvider" 
      type="System.Web.Security.WindowsTokenRoleProvider" /> 
     </providers> 
    </roleManager> 


    </system.web> 

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



    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IBLServer" 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="2147483647" maxNameTableCharCount="2147483647" /> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" 
       realm="" /> 
      <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:50739/PhotoShopWS.svc" binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_IBLServer" contract="PhotoShopWS.IBLServer" 
      name="BasicHttpBinding_IBLServer" /> 
    </client> 
    </system.serviceModel> 
</configuration> 

의 App.config of classLibrary :

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IBLServer" 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="2147483647" maxNameTableCharCount="2147483647" /> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" 
       realm="" /> 
      <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:50739/PhotoShopWS.svc" binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_IBLServer" contract="PhotoShopWS.IBLServer" 
      name="BasicHttpBinding_IBLServer" /> 
    </client> 
    </system.serviceModel> 
</configuration> 

나는 그것에 대해 많은 답변을 보았지만 문제는 해결되지 않았습니다. 도움을 주시면 대단히 감사하겠습니다!

+0

모든 것을 최대 값으로 설정하는 것에주의하십시오. http://stackoverflow.com/questions/835114/wcf-readerquotas-settings-drawbacks –

답변

3

당신이에 maxReceivedMessageSize을 지정해야 높은 가치.

Ex.

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding transferMode="Streamed" 
        maxReceivedMessageSize="67108864"> 
       <!-- other config here --> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
</system.serviceModel> 
+0

대단히 감사합니다 !!! 나는 이것과 readerQuotas 태그를 추가하여 작동한다 !! –

0

확인

그것은 classLibrary의의 App.config에, httpTransport 요소에 존재하는 경우 : 그것은 WCF 응용 프로그램의 Web.config의에

maxReceivedMessageSize="104857600" 
+0

감사합니다. replay.Still 원격 서버에서 오류를 반환했습니다. (400) 불량 의뢰. 로그 파일 예외는 다음으로 변경됩니다. System.ServiceModel.Channels.HttpChannelUtilities.CreateUnexpectedResponseException (WebException responseException, HttpWebResponse response). 너 나 좀 도와 줄 수있어? –

1

마크 도움말을 사용 했으므로 이제 내 사이트에서 큰 이미지를 업로드 할 수 있습니다.

변경 후 내 WCFAppication의 web.config입니다.

<?xml version="1.0"?> 
<configuration> 
    <connectionStrings> 
    <add name="photoShopEntities" 
     connectionString="metadata=res://*/photoShop.csdl| 
     res://*/photoShop.ssdl| 
     res://*/photoShop.msl; 
     provider=System.Data.SqlClient;provider connection string='Data Source=.\SQLEXPRESS;AttachDbFileName=|DataDirectory|photoShop.mdf;Integrated Security=True;User Instance=True'" 
     providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    <httpRuntime maxRequestLength="2147483647"/> 
    </system.web> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding transferMode="Streamed" 
       maxReceivedMessageSize="67108864"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" 
      maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
      <!-- other config here --> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 

      <!-- 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="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 

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

</configuration> 

감사합니다.

관련 문제