如何在控制台应用程序中调用 Windows 服务?
我编写了一个 WCF 服务,我想将其称为网络管道绑定方式。 我已将其部署在 Windows 服务中。
我在我的 wcf 服务中编写了这个方法:
Add(2,1)
它应该返回 3
我不知道如何在我的客户端控制台应用程序中调用 Windows 中托管的服务。 我已经开始我的服务了。
注意:
我想从 Windows 服务中调用它。
I wrote a WCF service and I would like to call this the net pipe binding way. I have deployed this in a Windows service.
I wrote this method in my wcf service:
Add(2,1)
It should return 3
I don't know how to call the service hosted in windows in my client console application. I have started my service.
Note:
I would like to call this from a windows service.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
需要使用ChannelFactory创建代理,然后就可以使用该代理执行wcf任务。
http://www.switchonthecode.com/tutorials/wcf-tutorial-基本进程间通信
you need to use ChannelFactory to create a proxy, and then you can use the proxy to perform wcf tasks.
http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication
如果
IMyContract
是您的服务合约,您可以创建一个代理来使用 ChannelFactory 类调用您的服务:If
IMyContract
is your service contract, you can create a proxy to call your service using the ChannelFactory class:你想要这样的东西:
You want something like this: