WCF 400 Bad Request Error When POST Some Data

I have a WCF service on my local machine, which works as a "bridge" between the client application and the database on the remote computer.

The WCF service works with Entity Framework classes and works fine when receiving data, but it does not work when it posts a message, and I get the following error message: "(400)" Bad request ".

This is my client code:

//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);

This tag <system.serviceModel>in the wcf configuration file:

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

And mine app.configin the client application:

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

Service Interface:

    [OperationContract]
    Client GetClient(int clientID);

    [OperationContract]
    void UpdateClient(Client editedClient);

In the first case, although the problem is related to the weight of the application, but I see that the use of Fiddler in bytes sent for the application is only 115.903 bytes (~ 0.11 MB). Any ideas?

, , : (

, !:)

+3
1

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>
+1

All Articles