Wcf wsHttpBinding中的IOOutputSessionChannel和IIInputSessionChannel,为什么它不';不行?
有人知道为什么这个代码的输出只有:“MessageSend”吗? 输入通道的线程在channel.Recieve()上等待 我在IRequest/ReplyChannel中使用basicHttpBinding时没有这个问题Wcf wsHttpBinding中的IOOutputSessionChannel和IIInputSessionChannel,为什么它不';不行?,wcf,Wcf,有人知道为什么这个代码的输出只有:“MessageSend”吗? 输入通道的线程在channel.Recieve()上等待 我在IRequest/ReplyChannel中使用basicHttpBinding时没有这个问题 static void Main(string[] args) { WSHttpBinding binding = new WSHttpBinding(); binding.ReliableSession.Enabled = t
static void Main(string[] args)
{
WSHttpBinding binding = new WSHttpBinding();
binding.ReliableSession.Enabled = true;
binding.ReliableSession.Ordered = true;
var messsage = System.ServiceModel.Channels.Message.CreateMessage(MessageVersion.Soap11, "hello", "action");
var senderFacto = binding.BuildChannelFactory<IOutputSessionChannel>();
var recieveFacto = binding.BuildChannelListener<IInputSessionChannel>(new Uri("http://localhost:9393"));
senderFacto.Open();
recieveFacto.Open();
var sender = senderFacto.CreateChannel(new System.ServiceModel.EndpointAddress("http://localhost:9393"));
sender.Open();
sender.BeginSend(messsage, (o) =>
{
sender.EndSend(o);
Console.WriteLine("Message Sended");
sender.Close();
},null);
recieveFacto.BeginAcceptChannel((o) =>
{
var channel = recieveFacto.EndAcceptChannel(o);
channel.Open();
var message = channel.Receive();
Console.WriteLine("Message Recieved");
},null);
Console.Read();
}
谢谢,这里有一个快速的推测:安全性可能会成为障碍。我认为WSHttpBinding在默认情况下是安全的。试着关掉保安。如果这使它能够工作,那么下一步要使它与安全性一起工作,需要使用BindingParameters来指定“action”是该频道上消息的合法操作之一。!通过关闭安全性,sender.BeginSend抛出了一个exeption,表示要使用SOAP12Addressing10消息版本。关闭安全性并更改消息版本解决了问题。谢谢你!
binding.Security.Mode = SecurityMode.None; //Turn off the security
var messsage = System.ServiceModel.Channels.Message.CreateMessage(MessageVersion.Soap12WSAddressing10, "hello", "action"); //Change message version