【问题标题】:wcf rest end point not found from remote computer未从远程计算机找到 wcf 休息端点
【发布时间】:2013-10-03 21:54:07
【问题描述】:

我有 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();

【问题讨论】:

    标签: c# wcf rest hosting


    【解决方案1】:

    127.0.0.1 是本地地址。这就像说localhost 或“这台电脑”。您不能从另一台计算机上点击127.0.0.1,因为另一台计算机上的127.0.0.1 只是那台 计算机。当然,您的机器有其他可以使用的地址吗?从命令行尝试ipconfig

    【讨论】:

    • 你在使用127.0.0.1吗?因为这仅在您当前使用的计算机上可见。您至少应该有一个额外的169.254.x.x 地址,该地址在您的本地网络中可见。
    猜你喜欢
    • 1970-01-01
    • 2017-03-12
    • 1970-01-01
    • 2012-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-30
    • 1970-01-01
    相关资源
    最近更新 更多