2017-06-15 75 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

嘿謝謝。我也有這個問題。 –