报错信息:协定需要双工,但是绑定“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();
WCFC#asp.netiis
<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();
WCFC#asp.netiis
解决方案 »
- 请大家帮忙给我讲一下执行过程
- 时有时无的问题! 已有与此命令相关联的 DataReader,必须首先将关闭
- VS 2005中新建了一个控制台项目,后来加入了Windows窗体,运行时会显示DOS窗口,如何去除DOS窗口?
- 如何取消listview的SelectedIndexChanged事件
- 求web services的不同方法参数名要求一致怎么做
- 讨论:研究System.Dianostics命名空间--为windows和web应用程序提供一个安全网的特殊功能
- 请问只能输入大于0的正整数的正则表达式怎么写?
- 求助一检测html代码不规则的正则表达式
- 怎么写一个自动登陆程序??
- B/S是什么,学软件架构应该看什么书呢
- js选项卡问题
- 如何将MouseEventArgs和KeyEventArgs输出到文本?
报错很明白了,basicHttpBinding不支持双工通信
用WSDualHttpBinding和NetTcpBinding这两个支持双工通信
我配置的是WSDualHttpBinding啊