flerngobot
flerngobot

Reputation: 666

generating proxy class for WCF service using named pipes binding

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");

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.

Upvotes: 1

Views: 1052

Answers (3)

Ernest Gunning
Ernest Gunning

Reputation: 59

"Add Service Reference" only caters for http protocols

You need to configure your MEX (Meta Exchange) endpoint on your server configuration side. Once done you need to use SVCUtil.exe to generate you client proxy.

You can check out this link that should solve your issue : MSDN NamedPipe Activation

The link also explains how to make your service available in IIS using WAS (Windows Activation Services) which is a cleaner way of hosting your service. If you don't require WAS then forget the section were they configure IIS to enable named pipes as a protocol. If you still get stuck try to add a base address and use this address in your svcutil command like so:

  <system.serviceModel>
    <services>
      <service name="Subject.Service1">
        <endpoint address="net.pipe://AddressName" binding="netNamedPipeBinding" name="netPipe" contract="Subject.IService1" />
        <endpoint binding="mexNamedPipeBinding" name="mex" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>            
            <add baseAddress="net.pipe://localhost:9000/AddressName" />
          </baseAddresses>
        </host>
      </service>

    </services>
    <behaviors>...{config continues here}

SvcUtil Command: svcutil /d:"Directory Location to generate code to" /config:" name of your config file here : app.config or web.config" /o:ClientProxyFileName.cs net.pipe://localhost:9000/AddressName/mex

If you add all your config via code the you may also look at this example: MSDN NetNamedPipeBinding Class

Upvotes: 0

Sam
Sam

Reputation: 731

Example:

  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.

Upvotes: 0

Sam
Sam

Reputation: 731

You can define the binding, service, endpoint inside , then you can add the service using ServiceReference and generate the proxy.

It is still okay to use the Channel Factory. It would pull the information based on the service name (type).

Upvotes: 0

Related Questions