tags:

views:

167

answers:

2

Does somebody know why the output of this code is only : "Message Sended" ? The thread of the input channel wait on channel.Recieve().

I have not this problem using basicHttpBinding with 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();
 }

Solution Turn off the security on the channel, then change the message version to Soap12Adressing10

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

Thanks,

+1  A: 

Here is a quick speculation: security might be in the way. I think WSHttpBinding is secure by default. Try turning off security. If that makes it work, next step to make it work with security involves using BindingParameters to specify that "action" is one of the legal actions for Messages on this channel.

Brian
Great speculation ! By turning off security, an exeption was thrown by sender.BeginSend wich say to use Soap12Adressing10 message version.Turning off the security and changing the message version solved the problem. Thanks you !
Nicolas Dorier
A: 

Thanks Brain.

Clangon