2013-10-03 26 views
0

我有Wcf休息服務。 我在控制檯應用程序中託管它。 當我嘗試從我的本地計算機訪問服務時,它的工作原理,但是當我從遠程 計算機嘗試找不到服務時。 這裏是代碼:遠程計算機沒有找到wcf休息終點

服務定義:

[ServiceContract] 
public interface IInstagramCallbackService 
{ 
    [OperationContract] 
    [WebInvoke(Method = "GET", UriTemplate = "url/?hub.mode={mode}&hub.challenge={challenge}&hub.verify_token={token}")]  
    string CheckServiceAvailability(string mode, string challenge, string token); 
} 

public class InstagramCallbackService : IInstagramCallbackService 
{ 
    public string CheckServiceAvailability(string mode, string challenge, string token) 
    { 
     return challenge; 
    } 
} 

託管:

ServiceHost host = new ServiceHost(typeof(InstagramCallbackService),new Uri[]{}); 

WebHttpBinding binding = new WebHttpBinding(WebHttpSecurityMode.None); 

ServiceEndpoint endPoint = new ServiceEndpoint(
    ContractDescription.GetContract(
     typeof(InstagramCallbackService)), binding, new EndpointAddress(
      "http://127.0.0.1:6064/InstagramCallbackService")); 

WebHttpBehavior webBehavior = new WebHttpBehavior(); 
endPoint.Behaviors.Add(webBehavior); 
host.AddServiceEndpoint(endPoint); 
host.Open(); 
Console.WriteLine("ready"); 
Console.ReadLine(); 

回答

0

127.0.0.1是本地地址。這就像是說localhost或「這臺電腦」。你不能從另一臺電腦上打127.0.0.1,因爲127.0.0.1來自另一臺電腦只會是電腦。當然你的機器有其他的地址你可以使用,但不是?從命令行嘗試ipconfig

+0

當我從另一臺計算機上進入時,我輸入了正確的IP地址.. –

+0

當我從其他計算機上撥號時,我輸入了正確的地址。 –

+0

您使用的是「127.0.0.1」嗎?因爲這隻能從您當前使用的計算機上看到。你至少應該有一個額外的'169.254.x.x'地址在本地網絡中可見。 – sircodesalot