2013-12-13 118 views
27

私はFW4.0を使用してWCFアプリケーションサービスを構築しようとしています。 サーバーとクライアント間でEntiryFrameworkオブジェクトを転送するときに、私のサービスが正しく動作します。しかし、私はクライアントからサーバーにEFオブジェクトを渡す際に問題が発生しています。私の環境についてここでリモートサーバーが予期しない応答を返しました:(413)要求エンティティが大きすぎます。

いくつかの詳細: - サービスは、IIS 上でローカルデバッグモードで実行されている - 私は私のWindows 7 にこのすべてを実行しています - 私は、FW4.0にVisual Studio 2010を使用してい

オブジェクト(tblClient)をサーバーに送信してレコードを保存しようとしましたが、エラー(413)要求エンティティが大きすぎます。 ここでフルスタック:

System.ServiceModel.ProtocolException occurred 
     HResult=-2146233087 
     Message=The remote server returned an unexpected response: (413) Request Entity Too Large. 
     Source=mscorlib 
     StackTrace: 
     Server stack trace: 
      at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding) 
      at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
      at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 
      at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) 
      at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 
      at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
      at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 
     Exception rethrown at [0]: 
      at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
      at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
      at ClientApp.ServiceReference1.IService.SaveClient(tblClient client) 
      at ClientApp.ServiceReference1.ServiceClient.SaveClient(tblClient client) in C:\dufh\WPF Project\ClientApp\Service References\ServiceReference1\Reference.vb:line 2383 
      at ClientApp.ViewModel.ClientViewModel.SaveClient() in C:\dufh\WPF Project\ClientApp\ViewModel\ClientViewModel.vb:line 48 
     InnerException: System.Net.WebException 
      HResult=-2146233079 
      Message=The remote server returned an error: (413) Request Entity Too Large. 
      Source=System 
      StackTrace: 
       at System.Net.HttpWebRequest.GetResponse() 
       at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
      InnerException: 

私はMaxBufferSizeのにいくつかの研究と、すべてのポイントを行いましたおよび/またはmaxBufferPoolSizeおよび/またはmaxReceivedMessageSizeの魔女は、クライアントの設定はapp.configに十分な大きさではありません。だから私は最大値にそれらをinscresed: maxBufferSize = "2147483647" maxBufferPoolSize = "2147483647" maxReceivedMessageSize = "2147483647" しかし、まだエラーが残ります。

ここに私の完全なクライアントのApp.config

あなたは、あなたの中で定義されたものを意味し、明示的なエンドポイントを(持っていない
<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.diagnostics> 
    <sources> 
     <!-- This section defines the logging configuration for My.Application.Log --> 
     <source name="DefaultSource" switchName="DefaultSwitch"> 
     <listeners> 
      <add name="FileLog"/> 
      <!-- Uncomment the below section to write to the Application Event Log --> 
      <!--<add name="EventLog"/>--> 
     </listeners> 
     </source> 
    </sources> 
    <switches> 
     <add name="DefaultSwitch" value="Information" /> 
    </switches> 
    <sharedListeners> 
     <add name="FileLog" 
      type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" 
      initializeData="FileLogWriter"/> 
     <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log --> 
     <add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="MVVM Sampling"/> 
    </sharedListeners> 
    </system.diagnostics> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:7803/Service1.svc" binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_IService" contract="ServiceReference1.IService" 
      name="BasicHttpBinding_IService" /> 
    </client> 
    </system.serviceModel> 
</configuration> 

とフルのWeb.Config WCFサービスのWeb.Config

<?xml version="1.0"?> 
<configuration> 

    <system.web> 
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 

    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"> 
      <readerQuotas maxDepth="200" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" /> 
     </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="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 


    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
    <connectionStrings> 
    <add name="MaitreEntities" connectionString="metadata=res://*/Schemat.csdl|res://*/Schemat.ssdl|res://*/Schemat.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=INFOFILE2\SQL2008R2;initial catalog=0001ConneryFerland;user id=sa;password=kermit80;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
</configuration> 


Any help would be very welcome :-) 

答えて

58

。 サービスのWeb.Configにバインド情報がありません。 私はそれにこの情報を配置し、

<bindings> 
     <basicHttpBinding> 
     <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text"> 
      <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
     </binding> 
     </basicHttpBinding> 
</bindings> 

ここで、バインディングには名前が指定されていません。

+4

ありがとう! 「サービスからのweb.config」とは、「サーバー上のweb.config」を意味します。 –

+1

ありがとうございます。どのバインディングが見つからなかったかを調べようと数時間かけてきました。あなたの例のような名前のないサービス側のweb.configバインディングでした。 –

+0

ありがとうございます!私の場合、ノードも見つからないWebサービスがありました - ありがとう、Hugo! –

11

あなたが宣言したバインディング設定( "BasicHttpBinding_IService")が使用されていないようにしてください。 WCFは、既定のバインドと共に既定のエンドポイントを提供しています(basicHttpBinding、構成ファイルのprotocolMappingセクションにオーバーライドしない限り)。

あなたはあなたのサービスの設定ファイルでこれを解決するには2つの方法があります:あなたはname属性除去することにより、「BasicHttpBinding_IService」の設定をデフォルトにすることができます

を:

<binding maxBufferPoolSize="2147483647"..... 

するか、明示的にエンドポイントを定義しますconfigでバインド設定をエンドポイントのbindingConfiguration属性に割り当てます。私はそれを得たと思います、レコード

については

<services> 
    <endpoint address="" 
       binding="basicHttpBinding" 
       bindingConfiguration="BasicHttpBinding_IService"  
       contract="ServiceReference1.IService" /> 
</services> 
+0

助けてくれてありがとうTim。でも、まだエラーは残っています。しばらく私のWCFサービスを脇に置いておきます。 しばらく煮詰めましょう... – Hugo

0

カスタムバインディングを作成すると、MybasicBinding、

<basicHttpBinding> 
     <binding name="MybasicBinding" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00" 
       maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" > 
      <readerQuotas maxDepth="32" maxBytesPerRead="200000000" 
      maxArrayLength="200000000" maxStringContentLength="200000000" /> 
     </binding> 
    </basicHttpBinding> 

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="MybasicBinding" contract="WCFService.IService" /> 
1

、としてこれを修正し、持っているもう一つの方法をサービスエンドポイントためbindingConfiguration = "MybasicBinding"を指定するforegetはいけない、413エラーを回避するにはweb.configファイルを見て、 "Microsoft Service Configuration Editor"(C:¥Program Files(x86)¥Microsoft SDKs¥Windows¥v8.1A¥bin¥NETFX 4.5.1ツールを使用してweb.configファイルを編集する) \ SvcConfigEditor.exe)

関連する問題