使用命名管道绑定为WCF服务生成代理类

编程入门 行业动态 更新时间:2024-10-25 00:29:01
本文介绍了使用命名管道绑定为WCF服务生成代理类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试生成一个使用命名管道绑定的代理类,并通过Windows服务在本地托管.我对如何执行此操作感到困惑,因为我没有指向svcutil命令指向的URL.下面是我用于通过Windows服务打开主机的方法.

I am trying to generate a proxy class which uses named pipes binding, and is hosted locally via a Windows Service. I am confused on how to do this since I don't have a URL to point the svcutil command to. Below is the method I used for opening the host via the Windows Service.

host = new ServiceHost(typeof(MyCoolService.MyCoolService), new Uri[] { new Uri("net.pipe://localhost") }); _host.AddServiceEndpoint(typeof(IMyCoolServiceObj), new NetNamedPipeBinding(), "MyCoolServicePipe");

当前,我正在使用ChannelFactory从客户端进行连接,但是遇到了一些问题,其中我发送给服务方法的参数在服务端被接收为空字符串.因此,我认为我应该尝试使用代理类来确保接口完全正确.

Currently I am using ChannelFactory to connect from my client, but am coming across issues where the parameter I am sending to the service method is received as an empty string on the service side. So I am thinking I should try using a proxy class to ensure the interfaces are exactly correct.

推荐答案

示例:

using (System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(typeof(SERVICETYPE), new Uri[] { })) <services> <service name="SERVICETYPE" behaviorConfiguration="serviceBehavior"> <host> <baseAddresses> <add baseAddress="localhost:8000"/> </baseAddresses> </services> <endpoint address="/END" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="YOUR INTERFACE"/>

完成此操作后,要使用添加服务参考"来创建代理.

After you do that, yon create use "Add Service Reference" to generate your proxy.

更多推荐

使用命名管道绑定为WCF服务生成代理类

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

发布评论

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

>www.elefans.com

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