2017-09-29 1 views
1

Ich habe mehrere ähnliche Threads gelesen, aber immer noch nicht wissen, was zu tun ist. Ich habe einfachen WCF-Dienst erstellt, der einige XML-Daten (in Strings) bekommt Alles funktionierte gut, bis Projekt auf Windows 7 lief. Jetzt, wenn ich versuche, Daten vom Client zum WCF-Dienst zu senden, bekomme ich AusnahmeWCF-Konfigurationsdatei 413-Request-Entity-Too-Large

413-Anfrage-Einheit allzu große

ich habe versucht,

maxBufferSize="2147483647"  
    maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 

Kann jemand p diese beiden Parameter zu meinem web.config auf WCF-Dienst hinzufügen Lease schau auf meine Config und versuche mir zu helfen?

WCF Servicecode:

public class Service1 : IService1 
    { 
     public static Konfiguracja config; 
     public static DBqueries queries; 
     public void WczytajKonfiguracje() 
     { 
      config = new Konfiguracja(); 
      queries = new DBqueries(); 
     } 
     public bool? DodajInfoSprzet(int idKlienta, string haslo, int id_zgloszenia, string HardwareInfoXML, string SoftInfoXML) 
     { 
     ...and some code 
     } 
} 

und hier ist meine Wcf web.config-Datei:

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

    <connectionStrings> 
    <add name="ProjektSerwisConnectionString" connectionString="Data Source=.\sql12;Initial Catalog=ProjektSerwis;Integrated Security=True" 
     providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.6.1" /> 
    <httpRuntime targetFramework="4.6.1"/> 
    </system.web> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding maxBufferPoolSize="2147483647" 
     maxReceivedMessageSize="2147483647" /> 
     </basicHttpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https" /> 
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <!-- 
     To browse web app root directory during debugging, set the value below to true. 
     Set to false before deployment to avoid disclosing web app folder information. 
     --> 
    <directoryBrowse enabled="true"/> 
    </system.webServer> 

</configuration> 

(i es, indem Sie auf Datei web.config Visual Studio Kontextmenü bearbeitet haben)

WCF-Dienst wird von

namespace SelfService 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      Uri baseAddress = new Uri("http://localhost:55555/WcfStart/"); 
      ServiceHost selfHost = new ServiceHost(typeof(Service1), baseAddress); 

      try { 
      selfHost.AddServiceEndpoint(typeof(IService1), new WSHttpBinding(), "WmiService"); 
      ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); 
      smb.HttpGetEnabled = true; 
      selfHost.Description.Behaviors.Add(smb); 
      selfHost.Open(); 
      while(true) 
      { 
       Console.WriteLine("Usługa działa"); 
       Console.WriteLine("Wpisz quit aby zakończyć działanie"); 
       string command = string.Empty; 
       command=Console.ReadLine(); 
       if (String.Equals(command.ToLower(), "quit".ToLower())) 
         break; 
      } 
       // Close the ServiceHostBase to shutdown the service. 
       selfHost.Close(); 
      } 
      catch (CommunicationException ce) 
      { 
       Console.WriteLine("An exception occurred: {0}", ce.Message); 
       selfHost.Abort(); 
      } 
} 
    } 
} 
läuft

und Client hat nur Verweise auf Web-Service und verbinden Sie ihn durch:

Service1Client scl = new Service1Client(); 
      bool? ok = false; 
      try 
      { 
       ok = scl.DodajInfoSprzet(IdKlienta, haslo, IdZgloszenia, HardwareInfoXML, SoftInfoXml); 
      } 
      catch (Exception ex) 
      { 
       throw new Exception(ex.Message); 
      } 

i konw, dass ich eine Menge Code eingefügt haben, aber ich habe keine Ahnung, was mit meiner Datei web.config

zu tun

die Daten, die gesendet werden, ist nicht groß, es ist weniger als 1 MB

Antwort

0

Haben Sie gerade diese Konfiguration in der web.config?

Da Sie Ihren WCF als Konsolenanwendung hosten, müssen Sie die Konfiguration in der App.config der Hostanwendung vornehmen.