1

WCF サービスを使用する Web アプリケーションがあります。この WCF サービスを介してクラウドに保存されているデータベースで何かを更新しようとしていますが、次のエラーが発生します:

リモート サーバーが予期しない応答を返しました: (400)

maxRequestLenght と他のパラメーターがどれほど大きくても、StackOverFlow を取得すると思います。

ここにいくつかのコードがあります:

エントリを更新する WCF メソッド:

  public void updateMember(Membership member)
    {
        _context.Memberships.ApplyCurrentValues(member);
        _context.SaveChanges();     
    }

WCF サービスを使用する編集方法:

 [HttpPost]
    public ActionResult Edit(Membership member)
    {
        Guid guid = AcsPrincipal.getGuid();
        Membership model = client.getMember(guid);
        model.Bikes = member.Bikes;
        model.City = member.City;
        model.Comment = member.Comment;
        model.Country = member.Country;
        model.Age = member.Age;
        if (ModelState.IsValid)
        {

            client.updateMember(model);
            return RedirectToAction("Details");
        }
        return View(model);
    }

私はここで数日間立ち往生しています...

どうもありがとう!

後で WCF web.config を編集します

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
<sources>
  <source name="System.ServiceModel"
          switchValue="Information, ActivityTracing"
          propagateActivity="true">
    <listeners>
      <add name="traceListener"
          type="System.Diagnostics.XmlWriterTraceListener"
          initializeData= "c:\log\Traces.svclog" />
    </listeners>
  </source>
</sources>
</system.diagnostics>
<system.web>
<customErrors mode="Off" />
<httpRuntime maxRequestLength="2147483647" />
<compilation debug="true" targetFramework="4.0">
  <assemblies> 
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </assemblies>
 </compilation>
 </system.web>
 <system.serviceModel>
 <bindings>
  <basicHttpBinding>
    <binding name="basicHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
  </binding>
</basicHttpBinding>
</bindings>

<behaviors>
<serviceBehaviors>
  <behavior>
    <serviceMetadata httpGetEnabled="true" />
    <serviceDebug includeExceptionDetailInFaults="true" />
  </behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />

ウェブアプリの構成:

<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<configSections>
<section name="microsoft.identityModel" type="Microsoft.IdentityModel.Configuration.MicrosoftIdentityModelSection, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<system.diagnostics>
<trace>
  <listeners>
    <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
      <filter type="" />
    </add>
  </listeners>
</trace>
</system.diagnostics>
<appSettings>
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="FederationMetadataLocation" value=" https://exciteaccesscontrol.accesscontrol.windows.net/FederationMetadata/2007-06/FederationMetadata.xml " />
</appSettings>
<location path="FederationMetadata">
<system.web>

  <authorization>
    <allow users="*" />
  </authorization>
</system.web>
</location>
<system.web>
<httpRuntime requestValidationMode="2.0" />
<authorization>
  <deny users="?" />
</authorization>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.0">
  <assemblies>
    <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </assemblies>
</compilation>
<!--Commented out by FedUtil-->
<!--<authentication mode="Forms"><forms loginUrl="~/Account/LogOn" timeout="2880" /></authentication>-->
<membership defaultProvider="DefaultMembershipProvider">
  <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="/" />-->
    <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
  </providers>
</membership>
<profile defaultProvider="DefaultProfileProvider">
  <providers>
    <clear />
    <!--<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />-->
    <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" applicationName="/" />
  </providers>
</profile>
<roleManager enabled="true" defaultProvider="DefaultRoleProvider">
  <providers>
    <clear />
    <!--<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />-->
    <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
    <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" applicationName="/" />
  </providers>
</roleManager>
<pages>
  <namespaces>
    <add namespace="System.Web.Helpers" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.WebPages" />
  </namespaces>
</pages>
<!--
        If you are deploying to a cloud environment that has multiple web server instances,
        you should change session state mode from "InProc" to "Custom". In addition,
        change the connection string named "DefaultConnection" to connect to an instance
        of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
  -->
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
  <providers>
    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
  </providers>
</sessionState>
<httpModules>
  <add name="WSFederationAuthenticationModule" type="Microsoft.IdentityModel.Web.WSFederationAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  <add name="SessionAuthenticationModule" type="Microsoft.IdentityModel.Web.SessionAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</httpModules>
</system.web>
<system.net>
<settings>
  <servicePointManager expect100Continue="false" />
</settings>
</system.net>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
  <add name="WSFederationAuthenticationModule" type="Microsoft.IdentityModel.Web.WSFederationAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler" />
  <add name="SessionAuthenticationModule" type="Microsoft.IdentityModel.Web.SessionAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler" />
</modules>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  </assemblyBinding>
  </runtime>
<microsoft.identityModel>
<service>
  <audienceUris>
    <add value="http://localhost:28547/" />
  </audienceUris>
  <federatedAuthentication>
    <wsFederation passiveRedirectEnabled="true" issuer="https://exciteaccesscontrol.accesscontrol.windows.net/v2/wsfederation" realm="http://localhost:28547/" requireHttps="false" />
    <cookieHandler requireSsl="false" />
  </federatedAuthentication>
  <applicationService>
    <claimTypeRequired>
      <!--Following are the claims offered by STS 'https://exciteaccesscontrol.accesscontrol.windows.net/'. Add or uncomment claims that you require by your application and then update the federation metadata of this application.-->
      <claimType type="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" optional="true" />
      <claimType type="http://schemas.microsoft.com/ws/2008/06/identity/claims/role" optional="true" />
      <!--<claimType type="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier" optional="true" />-->
      <!--<claimType type="http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider" optional="true" />-->
    </claimTypeRequired>
  </applicationService>
  <issuerNameRegistry type="Microsoft.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
    <trustedIssuers>
      <add thumbprint="363D1B4E8CF16B68C674B0FABEB7A692B52152C0" name="https://exciteaccesscontrol.accesscontrol.windows.net/" />
    </trustedIssuers>
  </issuerNameRegistry>
  <certificateValidation certificateValidationMode="None" />
 </service>
</microsoft.identityModel>
<system.serviceModel>

<behaviors>

  <endpointBehaviors>

    <behavior name="maxItemsInObjectGraphBehaviour">

      <dataContractSerializer maxItemsInObjectGraph="2147483646" />

    </behavior>

  </endpointBehaviors>

</behaviors>

<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_IService1" allowCookies="true"
             maxReceivedMessageSize="500000000"
             maxBufferSize="500000000"
             maxBufferPoolSize="20000000">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
    maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>

<client>
  <endpoint address="http://excitewcf.cloudapp.net/Service1.svc"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
    contract="Service.IService1" name="BasicHttpBinding_IService1" behaviorConfiguration="maxItemsInObjectGraphBehaviour" />
</client>
</system.serviceModel>
</configuration>
4

1 に答える 1

0

わかりました、2日後に私はそれを理解しました!

問題は次のとおりです。

_context.Memberships.ApplyCurrentValues(メンバー);

今、私は前にモデルを更新していて、変更を WCF に保存しています。

于 2012-11-16T21:57:33.660 に答える