2013-01-18 63 views
1

連接,我使用的WSHttpBinding創建WCF服務:製作WsHttpBinding的服務從外部

ServiceHost svh = new ServiceHost(typeof(MyService)); 
var httpLocation = "http://" + address + ":4041"; 
svh.AddServiceEndpoint(typeof(IMyService), new WSHttpBinding(SecurityMode.None), httpLocation); 
svh.Open(); 

,當我試圖連接到我和

netsh http add urlacl url=http://+:4041/ user=username 

它註冊系統它從本地主機,服務工作。

但是,當我將它放在其他電腦(與地址=「localhost」的或地址=「最機的ip-的」),連接失敗,以下情況除外:

There was no endpoint listening at http://192.168.44.128:4041/ that could accept 
the message. This is often caused by an incorrect address or SOAP action. See 
InnerException, if present, for more details. 

內部異常:

A connection attempt failed because the connected party did not properly respond 
after a period of time, or established connection failed because connected host 
has failed to respond 192.168.44.128:4041 

我試過將服務添加到防火牆,沒有幫助。

這裏有什麼問題?

UPDATE

下面是從netstat -ano相關entrys。第一種是HTTP端點,這是不能從外部連接的,第二個是一個的net.tcp端點,其正常工作:

TCP [::]:4041    [::]:0     LISTENING  4 
TCP 192.168.44.128:9939 0.0.0.0:0    LISTENING  2120 

回答

1

驗證用「NETSTAT -ano」從命令行提示的是你的服務正在監聽指定的端口。檢查完畢後,嘗試從客戶端框中Ping您的服務盒IP。如果兩者都成功,您最有可能在尋找防火牆和/或網絡交換機配置問題。

+0

嘿。感謝你,我發現了這個問題。顯然,防火牆被配置爲只允許來自我的軟件的請求,並且http偵聽器正在另一個進程(?)中運行。我爲所有流程打開了4041端口,這有所幫助。請更新答案,以便將其標記爲正確 –