62,046
社区成员
发帖
与我相关
我的任务
分享
System.ServiceModel.EndpointNotFoundException: 没有终结点在侦听可以接受消息的 http://localhost:9090/RequestReplyService 。这通常是由于不正确的地址或者 SOAP 操作导致的。
BindingElement[] be = new BindingElement[2];
be[0] = new TextMessageEncodingBindingElement();
be[1] = new HttpTransportBindingElement();
CustomBinding binding = new CustomBinding(be);
using (Message m = Message.CreateMessage(binding.MessageVersion, "sendMessage", "Message Body"))
{
//创建ChannelFactory
IChannelFactory<IRequestChannel> factory =
binding.BuildChannelFactory<IRequestChannel>(new BindingParameterCollection());
factory.Open();
//创建IRequestChannel
IRequestChannel recChannel =
factory.CreateChannel(new EndpointAddress("http://localhost:9090/RequestReplyService"));
recChannel.Open();
Message response = recChannel.Request(m);
Console.WriteLine("已经成功发送消息!");
Console.WriteLine("接收到一条返回的消息,action为:{0},body为:{1}",response.Headers.Action,response.GetBody<string>());
recChannel.Close();
factory.Close();