如何为windowservice初始化ServiceHost?

编程入门 行业动态 更新时间:2024-10-12 01:32:03
本文介绍了如何为windowservice初始化ServiceHost?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

请澄清我. 我正在初始化以下窗口服务的ServiceHost,并对httpUrl感到困惑. ServiceHost主机=新的ServiceHost(typeof((WCFWindowsHositngService.SimpleCalculator),httpUrl); 如何编写httpUrl 1. Uri httpUrl =新的Uri("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("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) 服务器名:端口号/服务名 用于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) 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?

本文发布于:2023-11-13 04:46:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583473.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:初始化   何为   windowservice   ServiceHost

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!