2017-06-15 56 views
1

我有一个wcf项目,我正在创建一个客户端来测试它。出于某种原因,在我的本地机器上,我只能在Visual Studio的IIS Express中运行该服务。我启动项目后,我试图连接到来自客户端的服务,但我得到一个错误:WCF:与IISExpress中的tcp绑定问题

You have tried to create a channel to a service that does not support .Net Framing. It is possible that you are encountering an HTTP endpoint.

我读过thisthis,但他们正在讨论有关IIS和不IIS Express。

这里是从客户端我的代码:

NetTcpBinding binding = new NetTcpBinding(); 
EndpointAddress address = new EndpointAddress("net.tcp://localhost:64255/MyService.svc"); 
ChannelFactory<IMyInterface> channelFactory = new ChannelFactory<IMyInterface>(binding, address); 

channelFactory.Open(); 
IMyInterface _clientProxy = channelFactory.CreateChannel(); 
((IClientChannel)_clientProxy).Open(); 

,当我调用该方法Open,我得到上述错误...

请注意,该服务只接受net.tcp协议。

我需要更改以从我的客户端调用托管在IIS Express中的此服务?

编辑:当我运行从Visual Studio项目,在浏览器中我看到的网址:http://localhost:64255/MyService.svc

回答

1

长话短说:IIS Express不支持非HTTP协议,如的net.tcp 。 IIS Express仅支持HTTP和HTTPS协议

+0

嘿谢谢。我也有这个问题。 –