.netwcfwcf-bindingwcf-configuration

wsHttpBinding changes to basicHttpBinding in client app.config


In a WCF service I have an endpoint binding set as wsHttpBinding. However when I use Visual Studio to Add Service Reference my clients app.config shows the binding as basicHttpBinding. Does anybody know why this may be happening?

My Endpoint in the service web.config (hosted in IIS 7.5). Gets address from baseAddresses

<endpoint address=""
    binding="wsHttpBinding"
    bindingConfiguration="wsHttpServiceBinding"
    contract="MyProject.IMyService" />

Client app.config:

<client>
    <endpoint address="http://example.com/MyService.svc"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_MyService"
    contract="Service.MyService" name="BasicHttpBinding_MyService" />
</client>

Solution

  • -- Ladislav Mrnka pointed me in the right direction with this. Thanks very much.

    I tried to keep the question simple as I thought the answer may be straight forward. However I should have explained my set up in a little bit more detail as this is where the answer to my problem lay.

    Instead of having my service contract (IMyService) residing in my WCF Service Application I had it in another Domain project where I keep all my interfaces so that they can be reused throughout many different projects. In my WCF Service Application .web.config I had the service name pointing at the interface project rather than at the implementation. This caused VS2010 (svcutil.exe) to create a proxy and config based on default settings (I presume reside in the machine.config (for WCF 4)).

    So to summarise for anybody else who may come across this issue it was service name pointing to the wrong location. Ensure that the service name points to the implementation (usually in the WCF Service Application - MyProject.MyService) and that the endpoint contract points to the service contract (In the WCF Service Application or external project - MyProject.IMyService or AnotherProject.Interfaces.IMyService).

    Thanks for all your help.