【精华】WCF IIS宿主 多服务 不同binding 报错的问题

wosliuxiang 2013-06-28 11:20:46
报错信息:协定需要双工,但是绑定“BasicHttpBinding”不支持它或者因配置不正确而无法支持它。

怀疑:难道是IIS宿主不支持多种不同的binding?

服务端配置web.config

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="webbehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="webbehavior" name="nt.web.WCF.User">
<host>
<baseAddresses>
<add baseAddress="http://192.168.0.212:1912/WCF/"/>
</baseAddresses>
</host>
<endpoint binding="basicHttpBinding" contract="nt.WcfContract.IUser" name="user_contract" address="User.svc"></endpoint>
</service>
<service behaviorConfiguration="webbehavior" name="nt.web.WCF.Communication">
<host>
<baseAddresses>
<add baseAddress="http://192.168.0.212:1912/WCF/"/>
</baseAddresses>
</host>
<endpoint binding="wsDualHttpBinding" contract="nt.WcfContract.ICommunicationContract" name="user_communication" address="Communication.svc"></endpoint>
</service>
</services>
</system.serviceModel>


服务端契约

[ServiceContract(CallbackContract = typeof(IServerCallback))]
public interface ICommunicationContract
{
[OperationContract(IsOneWay = true)]
void HeartBeat(Model_User user);

[OperationContract(IsOneWay = true)]
void LoginOut();
}


契约实现

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, ConfigurationName = "user_communication")]
public class Communication : ICommunicationContract
{

public void HeartBeat(WCFModel.Model_User user)
{
//Logic_DesktopUser.UserHeartBeat(user);

}

public void LoginOut()
{
//Logic_DesktopUser.LoginOut(user);
var callback = OperationContext.Current.GetCallbackChannel<nt.WcfContract.IServerCallback>();
callback.CallBack();

}
}


客户端调用

DuplexChannelFactory<nt.WcfContract.ICommunicationContract> duplex = new DuplexChannelFactory<ICommunicationContract>(new InstanceContext(new ServerCallback()), "user_communication");
var bll = duplex.CreateChannel();
bll.LoginOut();




...全文
150 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wosliuxiang 2013-06-28
  • 打赏
  • 举报
回复
引用 1 楼 newxdlysk 的回复:
报错信息:协定需要双工,但是绑定“BasicHttpBinding” 报错很明白了,basicHttpBinding不支持双工通信 用WSDualHttpBinding和NetTcpBinding这两个支持双工通信
我配置的是WSDualHttpBinding啊
newxdlysk 2013-06-28
  • 打赏
  • 举报
回复
报错信息:协定需要双工,但是绑定“BasicHttpBinding” 报错很明白了,basicHttpBinding不支持双工通信 用WSDualHttpBinding和NetTcpBinding这两个支持双工通信

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧