我正在尝试生成一个使用命名管道绑定的代理类,并通过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服务生成代理类
发布评论