2017-09-29 21 views
1

私は同じようなスレッドを複数読み込んでいますが、何をすべきかはまだ分かりません。 いくつかのXMLデータを文字列で取得しているシンプルなWCFサービスを作成しました プロジェクトがWindows 7で実行されるまではすべて正常に動作していました。 クライアントからWCFサービスにデータを送信しようとすると、例外が発生しますWCF設定ファイル413-request-entity-too-large

413-要求エンティティ大きすぎる私は、WCFサービス

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

ことができる人pに私のweb.configファイルにこれら2つのパラメータを追加しようとしました

私の設定を見てリースし、私を助けてみませんか?

WCFサービスコード:

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 
     } 
} 

、ここでは私のWCF web.configファイルである:

<?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> 

(私はweb.configファイルにVisual Studioのコンテキストメニューで、それを編集した)

WCFサービスは

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(); 
      } 
} 
    } 
} 
によって実行されています

とクライアントのWebサービスへの参照のみを持っているとことで、それを接続します。私は多くのコードを貼り付けていることをkonw、しかし、私は私のweb.configファイル

をどうするか見当がつかない

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

送信中のデータが大きくない、1 MB未満

答えて

0

この設定をweb.configに入れましたか?

コンソールアプリケーションとしてWCFをホストしているので、ホスティングアプリケーションのApp.configで設定を行う必要があります。

関連する問題