1
我已經閱讀了多個類似的線程,但仍然不知道該怎麼辦。 我創建了簡單的WCF服務,它獲取一些xml數據(字符串) 一切工作正常,直到項目運行在Windows 7上。 現在,當我嘗試從客戶端發送數據到WCF服務時,我得到異常WCF配置文件413-請求實體太大
413,請求實體過大的
我已經試過這兩個參數添加到我的web.config的WCF服務
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
可有人p租賃看看我的配置,並試圖幫助我?
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>
(我用Visual Studio的上下文菜單編輯它的web.config文件)
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服務只是引用,並通過它連接:
Service1Client scl = new Service1Client();
bool? ok = false;
try
{
ok = scl.DodajInfoSprzet(IdKlienta, haslo, IdZgloszenia, HardwareInfoXML, SoftInfoXml);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
我konw,我已經粘貼了大量的代碼,但我不知道該怎麼做我的web.config文件
正在發送的數據不大,小於1 MB