endpoint的作用就是发布服务,它必须包含WCF中A, B和C三个方面的定义,缺一不可。从配置文件上来看
<system.serviceModel>
    <services>
      <service name="MyNamespace.MyService">
        <endpoint contract = "MyNamespace.IMyService"
                        binding  = "wsHttpBinding"
                        address  = "http://localhost:8000/MyService" 
        />
      </service>
    </services>
</system.serviceModel>
相同的服务可以在多个endpoint上发布,但是要确保address不同,例如:
<system.serviceModel>
    <services>
      <service name="MyNamespace.MyService">
        <endpoint contract = "MyNamespace.IMyService"
                        binding  = "wsHttpBinding"
                        address  = "http://localhost:8001/MyService" 
        />
        <endpoint contract = "MyNamespace.IMyService"
                        binding  = "wsHttpBinding"
                        address  = "http://localhost:8002/MyService" 
        />
      </service>
    </services>
</system.serviceModel>
 
在self-host的情况下,可以用过代码配置endpoint
ServiceHost host = new ServiceHost(typeof(MyService));
Binding wsHttpBinding = new WSHttpBinding();
host.AddServiceEndpoint(typeof(IMyService),
                                      wsHttpBinding,
                                      new Uri("http://localhost:8086/MyService/"));
host.Open();
...            
host.Close();
 

 

 

相关文章:

  • 2021-08-27
  • 2022-01-13
  • 2022-03-08
  • 2021-08-31
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
相关资源
相似解决方案