如何为windowservice初始化ServiceHost? [英] How to initialize ServiceHost for windowservice ?
问题描述
请澄清我.
我正在初始化以下窗口服务的ServiceHost,并对httpUrl感到困惑.
ServiceHost主机=新的ServiceHost(typeof((WCFWindowsHositngService.SimpleCalculator),httpUrl);
如何编写httpUrl
1. Uri httpUrl =新的Uri("http://localhost:8090/MyService/SimpleCalculator");
或
2. Uri httpUrl =新的Uri("C:/MyService/SimpleCalculator");
或
3. Uri httpUrl = new Uri("computerno//C:/MyService/SimpleCalculator");
Please clarify me.
I am inintializing ServiceHost for windowservice as following and confused about httpUrl.
ServiceHost Host = new ServiceHost(typeof(WCFWindowsHositngService.SimpleCalculator), httpUrl);
How can i write httpUrl
1. Uri httpUrl = new Uri("http://localhost:8090/MyService/SimpleCalculator");
or
2. Uri httpUrl = new Uri("C:/MyService/SimpleCalculator");
Or
3. Uri httpUrl = new Uri("computerno//C:/MyService/SimpleCalculator");
推荐答案
如果您使用的是netTCPBinding,则url格式类似于
net.tcp://服务器名称:端口号/服务名称
用于Http协议(basichttp,wshttp)
http://服务器名:端口号/服务名
用于netnamedpipebinding.
net.pipe://localhost/Servicename
if you are using netTCPBinding, url format will be like
net.tcp://servername:portnumber/ServiceName
for Http Protocol (basichttp,wshttp)
http://servername:portnumber/Servicename
for netnamedpipebinding.
net.pipe://localhost/Servicename
这取决于您用于WCF服务的绑定.如果使用basicHttpBinding,并且服务侦听端口8090,则选项1是您应使用的URL.
It depends on the binding that you are using for your WCF service. If you use basicHttpBinding and your service listens on port 8090, option 1 is the URL that you should use.
这篇关于如何为windowservice初始化ServiceHost?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!