.net 发布某些数据时WCF错误400错误请求

.net 发布某些数据时WCF错误400错误请求,.net,wcf,.net,Wcf,我在本地机器上有一个WCF服务,它就像远程计算机中客户端应用程序和数据库之间的“桥梁” WCF服务与实体框架类一起工作,在获取数据时工作正常,但在发布任何内容和我收到下一条错误消息时不工作:“(400)错误请求” 这是我的客户代码: //Connect to WCF Service CHS_Local.ServiceFrontalClient proxy = new CHS_Local.ServiceFrontalClient(); //Get a "Client" class wich Cl

我在本地机器上有一个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);
wcf配置文件中的my
标记:

<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>
服务接口:

    [OperationContract]
    Client GetClient(int clientID);

    [OperationContract]
    void UpdateClient(Client editedClient);
在第一个例子中,我认为问题在于请愿书的权重,但我看到使用Fiddler发送请愿书的字节只有115.903字节(~0.11MB)。 有什么想法吗

如您所见,这是一个简单的示例,但不起作用:(


谢谢您的帮助!:)

从客户端发布数据时,您必须在服务上设置
maxReceivedMessageSize
readerQuotas
(如果需要)。您的客户端配置已修改了用于从服务获取数据的
maxReceivedMessageSize
,但当您向服务发送大量数据时,您还必须修改其配置

比如:

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

...
...

我在登台环境中也遇到了这个问题,因为我将通过线路发送更多字节

The remote server returned an unexpected response: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
下面是我在WCF web.config文件中所做的更改(在下面的配置中包括lessthen和greaterthen符号,因为标记不可见,所以无法添加)

发件人:

下面是上述绑定的端点地址标记

 endpoint address="" binding="basicHttpBinding" bindingConfiguration="**ServiceBinding**"
经过上述改变后,它的工作就像魅力

谢谢,
M.Amalraj

将您的服务交互放在此处我已经在客户端和服务器中更新了配置。但错误依然存在。

 binding name="ServiceBinding" maxReceivedMessageSize="**262144**"
 binding name="ServiceBinding" maxReceivedMessageSize="**2147483647**"
 endpoint address="" binding="basicHttpBinding" bindingConfiguration="**ServiceBinding**"