2013-12-13 7 views
27

मैं एफडब्ल्यू 4.0 का उपयोग कर डब्लूसीएफ एप्लीकेशन सेवा बनाने की कोशिश कर रहा हूं। सर्वर और क्लाइंट के बीच EntiryFramework ऑब्जेक्ट को स्थानांतरित करते समय मेरी सेवा सही तरीके से काम करती है। लेकिन मुझे क्लाइंट से सर्वर पर ईएफ ऑब्जेक्ट पास करने में समस्या हो रही है।रिमोट सर्वर ने एक अप्रत्याशित प्रतिक्रिया लौटा दी: (413) अनुरोध इकाई बहुत बड़ी है।

यहाँ

मेरी पर्यावरण के बारे में कुछ और अधिक विस्तार: - सेवा आईआईएस पर स्थानीय रूप से डिबग मोड में चल रहा है - मैं यह सब चल रहा हूँ मेरी विंडोज 7 - मैं FW4.0

पर दृश्य स्टूडियो 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 डायन के लिए सभी बिंदु करना है क्लाइंट config app.config में इतना बड़ा नहीं है। तो मैंने उन्हें अधिकतम मूल्य पर ले लिया: 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 बाध्यकारी जानकारी नहीं है। मैंने इस जानकारी को इसमें रखा, और voila!

<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

धन्यवाद! मेरे मामले में मेरे पास एक वेब सेवा थी जिसमें नोड भी अनुपलब्ध था - धन्यवाद ह्यूगो! –

11

आप एक स्पष्ट अंत बिंदु की जरूरत नहीं है (एक अर्थ में परिभाषित अपने कॉन्फ़िगरेशन फ़ाइल) आपकी सेवा के लिए, इसलिए आपके द्वारा घोषित बाध्यकारी कॉन्फ़िगरेशन ("BasicHttpBinding_IService") का उपयोग नहीं किया जा रहा है। डब्ल्यूसीएफ एक डिफ़ॉल्ट बाध्यकारी (basicHttpBinding के साथ एक डिफ़ॉल्ट एंडपॉइंट प्रदान कर रहा है जब तक कि आप इसे कॉन्फ़िगरेशन फ़ाइल के protocolMapping अनुभाग में ओवरराइड नहीं करते)।

आप "BasicHttpBinding_IService" विन्यास डिफ़ॉल्ट name विशेषता को हटाने के द्वारा कर सकते हैं:

आप अपनी सेवा के कॉन्फ़िग फ़ाइल में इसका समाधान करने के दो तरीके हैं

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

या आप स्पष्ट रूप से एक अंतिम बिंदु को परिभाषित कॉन्फ़िगरेशन में और एंडपॉइंट की bindingConfiguration विशेषता पर अपनी बाध्यकारी कॉन्फ़िगरेशन असाइन करें।

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

आपकी मदद के लिए धन्यवाद टिम, लेकिन त्रुटि अभी भी बनी हुई है। मैं थोड़ी देर के लिए अपनी डब्ल्यूसीएफ सेवा को अलग कर दूंगा। और इसे थोड़ी देर के लिए उबाल दें ... – 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> 

413 त्रुटि से बचने के लिए, सेवा समाप्ति बिंदु के रूप में के लिए bindingConfiguration = "MybasicBinding" निर्दिष्ट करने के लिए foreget मत करो,

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

एक और तरीका है इसे ठीक करने के लिए और एक के लिए web.config फ़ाइल पर बेहतर रूप से देखें, "माइक्रोसॉफ्ट सर्विस कॉन्फ़िगरेशन एडिटर" (सी: \ प्रोग्राम फ़ाइलें (x86) \ माइक्रोसॉफ्ट एसडीके \ विंडोज \ v8.1A \ bin \ NETFX 4.5.1 टूल्स के साथ web.config फ़ाइल को संपादित करना है। \ SvcConfigEditor.exe)

संबंधित मुद्दे