小编use*_*649的帖子

WCF服务自托管url没有获取wsdl文件

namespace helloserviceSelfHostingDemo
{
    [ServiceContract]
    interface IhelloService
    {
        [OperationContract]
        string sayhello(string name);
    }

public class HelloService : IhelloService
{

    public string sayhello(string name)
    {
        return "hello " + name;
    }
}
class Program
{
    static void Main(string[] args)
    {
        ServiceHost host = new ServiceHost(typeof(HelloService));
        BasicHttpBinding bind = new BasicHttpBinding();
        host.AddServiceEndpoint(typeof(IhelloService), bind, "http://8080/myhelloservice");
        host.Open();
        Console.WriteLine("hello service is running");
        Console.ReadKey();
    }
}
Run Code Online (Sandbox Code Playgroud)

}

这段代码运行良好但是当我复制时,浏览器中的这个地址没有得到服务

.net c# wcf self-hosting

6
推荐指数
1
解决办法
2855
查看次数

标签 统计

.net ×1

c# ×1

self-hosting ×1

wcf ×1