WCF错误400错误的请求时,POST一些数据

我有一个WCF服务在我的本地机器,就像一个客户端应用程序和远程数据库之间的“桥梁”。

WCF服务可以与实体框架类和时,你得到的数据,但后期的时候什么都不工作,我得到一个错误信息工作正常“(400)错误的请求”。

这是我的客户端代码:

//Connect to WCF Service CHS_Local.ServiceFrontalClient proxy = new CHS_Local.ServiceFrontalClient(); //Get a "Client" class wich ClientID == 1 CHS_Local.Client client = proxy.GetClient(1); //Change some stuff client.Name = "change someting"; //Send the modified class to service to update the database proxy.UpdateClient(client);

这是我的<system.serviceModel>在WCF配置文件标记:

<system.serviceModel> <services> <service name="CentralizedHostingService.ServiceFrontal"> <endpoint address="" binding="wsHttpBinding" contract="CentralizedHostingService.IServiceFrontal"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="http://localhost:8732/Design_Time_Addresses/CentralizedHostingService/Service1/" /> </baseAddresses> </host> </service> </services> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="True" /> <serviceDebug includeExceptionDetailInFaults="False" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel>

而我app.config在客户端应用程序:

<system.serviceModel> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_IServiceFrontal" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="5000000" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> <security mode="Message"> <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /> <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" /> </security> </binding> </wsHttpBinding> </bindings> <client> <endpoint address="http://localhost:8732/Design_Time_Addresses/CentralizedHostingService/Service1/" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IServiceFrontal" contract="CHS_Local.IServiceFrontal" name="WSHttpBinding_IServiceFrontal"> <identity> <dns value="localhost" /> </identity> </endpoint> </client> </system.serviceModel>

服务接口:

[OperationContract] Client GetClient(int clientID); [OperationContract] void UpdateClient(Client editedClient);

在一审我虽然这个问题驻留在请愿书的重量,但我看到使用招的字节发送的请愿书只是115.903字节(〜0.11MB)。 任何想法?

正如你所看到的是一个简单的例子,但不工作:(

感谢您的帮助! :)

--------------解决方案-------------

必须设置maxReceivedMessageSizereaderQuotas从客户端发送的数据时,该服务(如果需要)。 您的客户端的配置已经修改maxReceivedMessageSize它适用于从服务中获取数据,但是当你发送大量的数据到服务,您必须修改它的配置也是如此。

就像是:

<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="myBinding" maxReceivedMessageSize="500000" />
</wsHttpBinding>
</bindings>
<services>
<service name="CentralizedHostingService.ServiceFrontal">
<endpoint bindingConfiguration="myBinding" ... />
...
</service>
</services>
...
</system.serviceModel>

分类:。净 时间:2015-03-15 人气:0
本文关键词: .NET,WCF
分享到:

相关文章

Copyright (C) 55228885.com, All Rights Reserved.

55228885 版权所有 京ICP备15002868号

processed in 2.363 (s). 10 q(s)