使用命名管道绑定为WCF服务生成代理类 [英] generating proxy class for WCF service using named pipes binding

查看:128
本文介绍了使用命名管道绑定为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="http://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服务生成代理类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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