2010-07-12 22 views
3

我需要測試WCF服務,但只有一臺計算機,所以我的服務和客戶端在同一臺計算機上運行。這裏是WCF服務的App.config中:
WCF:如何通過IP連接服務:端口

<host> 
    <baseAddresses> 
     <add baseAddress="http://localhost:8000/MyService"/> 
    </baseAddresses> 
</host> 
<endpoint address="" 
    binding="wsDualHttpBinding" 
    contract="MyService.IMyService"/> 

我需要從我的客戶通過IP連接到這個服務,所以我嘗試以下操作:

MyClient.Endpoint.Address = 
     new System.ServiceModel.EndpointAddress(
      new Uri("http://" + IP + "/" + Port + "/MyService")); 

其中IP =「127.0.0.1 「和端口=」8000「。我也嘗試使用我的真實IP地址而不是127.0.0.1,但它無法工作 - 客戶端無法連接到服務。

  1. 它可以通過IP,如果我使用wsDualHttpBinding連接,如果是,
  2. 我應該指定什麼Endpoint.Address它
+0

你是什麼意思,「不起作用」?是否有例外?發表它! – 2010-07-12 04:34:13

回答

2

你需要指定一個地址類似這樣的:

http://127.0.0.1:8000/MyService 

你需要把一個:的IP地址和端口號之間 - 而不是/,因爲你似乎使用(至少在你的文章)。

+0

非常感謝! soooo愚蠢的錯誤 – Nike 2010-07-12 04:54:10

相關問題