简体   繁体   English

wsHttpBinding中的IOutputSessionChannel和IInputSessionChannel,为什么不起作用?

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

Does somebody know why the output of this code is only: "Message Sended"?有人知道为什么此代码的 output 只是:“已发送消息”吗? The thread of the input channel wait on channel.Recieve().输入通道的线程在 channel.Recieve() 上等待。

I have not this problem using basicHttpBinding with IRequest/ReplyChannel !使用带有 IRequest/ReplyChannel 的 basicHttpBinding 没有这个问题!

    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解决方案关闭通道上的安全,然后将消息版本更改为 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.我认为 WSHttpBinding 默认是安全的。 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.如果这使它起作用,下一步使它与安全性一起使用涉及使用 BindingParameters 来指定“操作”是此通道上消息的合法操作之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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