![](/img/trans.png)
[英]Why is my WCF wshttpbinding client doesn't work at another computer?
[英]IOutputSessionChannel and IInputSessionChannel in wsHttpBinding, why it doesn't work?
有人知道为什么此代码的 output 只是:“已发送消息”吗? 输入通道的线程在 channel.Recieve() 上等待。
使用带有 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();
}
解决方案关闭通道上的安全,然后将消息版本更改为 Soap12Adressing10
binding.Security.Mode = SecurityMode.None; //Turn off the security
var messsage = System.ServiceModel.Channels.Message.CreateMessage(MessageVersion.Soap12WSAddressing10, "hello", "action"); //Change message version
谢谢,
这是一个快速的猜测:安全性可能会受到影响。 我认为 WSHttpBinding 默认是安全的。 尝试关闭安全性。 如果这使它起作用,下一步使它与安全性一起使用涉及使用 BindingParameters 来指定“操作”是此通道上消息的合法操作之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.