wsHttpBinding更改为客户端app.config中的basicHttpBinding

Cra*_*gly 5 .net wcf wcf-binding wcf-configuration

在WCF服务中,我将端点绑定设置为wsHttpBinding.但是,当我使用Visual Studio添加服务引用时,我的客户端app.config将绑定显示为basicHttpBinding.有人知道为什么会这样吗?

服务web.config中的My Endpoint(在IIS 7.5中托管).从baseAddresses获取地址

<endpoint address=""
    binding="wsHttpBinding"
    bindingConfiguration="wsHttpServiceBinding"
    contract="MyProject.IMyService" />
Run Code Online (Sandbox Code Playgroud)

客户端app.config:

<client>
    <endpoint address="http://example.com/MyService.svc"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_MyService"
    contract="Service.MyService" name="BasicHttpBinding_MyService" />
</client>
Run Code Online (Sandbox Code Playgroud)

Cra*_*gly 8

- Ladislav Mrnka用正确的方向指出了我.非常感谢.

我试图让问题变得简单,因为我认为答案可能是直截了当的.但是我应该更详细地解释一下我的设置,因为这是我的问题的答案所在.

我没有让我的服务合同(IMyService)驻留在我的WCF服务应用程序中,而是在另一个Domain项目中使用它,我保留了所有接口,以便它们可以在许多不同的项目中重用.在我的WCF服务应用程序.web.config中,我的服务名称指向接口项目而不是实现.这导致VS2010(svcutil.exe)基于默认设置创建代理和配置(我假设驻留在machine.config(对于WCF 4)).

因此,对于可能遇到此问题的任何其他人进行总结时,服务名称指向错误的位置.确保服务名称指向实现(通常在WCF服务应用程序 - MyProject.MyService中),并且端点协定指向服务合同(在WCF服务应用程序或外部项目中 - MyProject.IMyService或AnotherProject.Interfaces.IMyService ).

感谢你的帮助.