wshtpbinding在客户端app.config中对basichtpbinding的更改
-
15-10-2019 - |
题
在WCF服务中,我有一个端点绑定集作为wshtpbinding。但是,当我使用Visual Studio添加服务参考时,我的客户config将绑定显示为basichttpbinding。有人知道为什么会发生这种情况吗?
我在service web.config中的终点(在IIS 7.5中托管)。从baseaddresses获取地址
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="wsHttpServiceBinding"
contract="MyProject.IMyService" />
客户端app.config:
<client>
<endpoint address="http://example.com/MyService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_MyService"
contract="Service.MyService" name="BasicHttpBinding_MyService" />
</client>
解决方案
- Ladislav mrnka向我指出了正确的方向。非常感谢。
我试图使这个问题保持简单,因为我认为答案可能很直接。但是,我应该更细节地解释了我的设置,因为这是我问题的答案。
我没有在WCF服务应用程序中拥有我的服务合同(Imyservice),而是在另一个域项目中保留所有界面,以便可以在许多不同的项目中重复使用它们。在我的WCF Service应用程序.Web.Config中,我的服务名称指向接口项目,而不是在实现中。这导致VS2010(svcutil.exe)创建基于默认设置的代理和配置(i Pruce putsions.config(对于WCF 4))。
因此,总结可能遇到此问题的任何其他人,它是指向错误位置的服务名称。 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 )。
感谢你的帮助。