如何为windowservice初始化ServiceHost? [英] How to initialize ServiceHost for windowservice ?

查看:175
本文介绍了如何为windowservice初始化ServiceHost?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请澄清我.

我正在初始化以下窗口服务的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆