2009-02-25 43 views
0

有人知道爲什麼這個代碼的輸出只是:「消息發送」? 輸入通道的線程在channel.Recieve()上等待。wsHttpBinding中的IOutputSessionChannel和IInputSessionChannel,爲什麼它不起作用?

我沒有這個問題使用basicHttpBinding與IRequest/ReplyChannel!

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(); 
    } 

解決方案 關閉通道上的安全,然後更改消息版本Soap12Adressing10

binding.Security.Mode = SecurityMode.None; //Turn off the security 
var messsage = System.ServiceModel.Channels.Message.CreateMessage(MessageVersion.Soap12WSAddressing10, "hello", "action"); //Change message version 

感謝,

回答

1

下面是一個簡單的猜測:安全可能在路上。我認爲WSHttpBinding默認是安全的。嘗試關閉安全。如果這樣做起作用,下一步使其與安全性協同工作涉及使用BindingParameters指定「操作」是此通道上消息的合法操作之一。

+0

偉大的猜測!通過關閉安全性,發件人拋出了一個免除.BeginSend要求使用Soap12Adressing10消息版本。 關閉安全並更改消息版本解決了問題。謝謝 ! – 2009-02-25 10:17:39

相關問題