none
Client Binding Versus Service Binding WCF RRS feed

  • Question

  • All,

    What is the difference between Client binding and Service Binding in WCF?

    Following are my questions:
    1. Can i set client binding with different values than the values in service binding?
    2. If Client binding doesnt match with Service binding will the communication happen?
    3. How is Client binding useful ?
    4. In the below scenario which configuration takes precedence is it Service binding or Client Binding?

    Following is a scenario:

    --Service with Binding as 'basicHttpBinding' without any 'bindingConfiguration' specified.
    <system.serviceModel>
    <services>
     <endpoint address="" binding="basicHttpBinding" contract="TestService.ITestContract" />
    </service>
    </services>
    </system.serviceModel>

    --Client with Binding as 'basicHttpBinding' and with 'bindingConfiguration' specified.
    <system.serviceModel>
    <bindings>
    <basicHttpBinding>
    <binding name="Binding1" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" maxReceivedMessageSize="12345" >
    </binding>
    </basicHttpBinding>
    </bindings>
    <client>
          <endpoint binding="basicHttpBinding" bindingConfiguration="Binding1" contract="TestService.TestContract" name="TestContract" />
    </client>
    </system.serviceModel>


    When service handles the request what are the values for the below paramters
    'closeTimeout', 'openTimeout', 'receiveTimeout', 'maxReceivedMessageSize'

    When client handles the response or sends the request what are the values for the below parameters
    'closeTimeout', 'openTimeout', 'receiveTimeout', 'maxReceivedMessageSize'


    Friday, February 5, 2010 4:09 AM

Answers

  • Hi,

    Generally, it is recommended that the client-side binding configuration matches the service-side binding. Also, for most cases, the client-side binding configuration is auto-generated when you use "Add SErviceReference" or svcutil.exe to create the WCF client proxy(the tool help generate the client-side configuration including the binding ...). As Yaron said, some of the settings are not forced to be identical, but some of them will result to error if it is mismatched between service and client.

    As for the scenario you mentioned that service using a basicHttpbinding without binding configuratin specified, that means the basicHttpBinding is using all the default settings, actually if you use "Add ServiceReference" to generate the service client proxy, you will find the client binding with all the default value explicitly specified(matching the service-side configuration).

    In short, the binding setting in service-side configuration means what the WCF service expects for any client consumers when connecting to the service. While the client-side binding setting means how the client should connect to the service, obviously they should match so as to cooperate correctly.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Monday, February 8, 2010 6:23 AM
    Moderator

All replies

  • Some changes in binding affect the "on the wire format". for example changing the authentication mode. Such setting needs to be identical in client and server.

    Some settings are more of a "policy", e.g. the max size of message allowed. In this case the settings can be different.

    In your example the communication should work fine.

    http://webservices20.blogspot.com/
    WCF Security, Performance And Testing Blog
    Friday, February 5, 2010 11:13 AM
  • Hi,

    Generally, it is recommended that the client-side binding configuration matches the service-side binding. Also, for most cases, the client-side binding configuration is auto-generated when you use "Add SErviceReference" or svcutil.exe to create the WCF client proxy(the tool help generate the client-side configuration including the binding ...). As Yaron said, some of the settings are not forced to be identical, but some of them will result to error if it is mismatched between service and client.

    As for the scenario you mentioned that service using a basicHttpbinding without binding configuratin specified, that means the basicHttpBinding is using all the default settings, actually if you use "Add ServiceReference" to generate the service client proxy, you will find the client binding with all the default value explicitly specified(matching the service-side configuration).

    In short, the binding setting in service-side configuration means what the WCF service expects for any client consumers when connecting to the service. While the client-side binding setting means how the client should connect to the service, obviously they should match so as to cooperate correctly.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Monday, February 8, 2010 6:23 AM
    Moderator