简体   繁体   中英

IOutputSessionChannel and IInputSessionChannel in wsHttpBinding, why it doesn't work?

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,

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM