Manage named pipe name when placing WCF net.pipe bindings in IIS

I have a service available through http and net.pipe. It is hosted on IIS 7 (Server 2008). I can host different instances of this service for multiple clients on the same computer, and therefore HTTP is configured with virtual host names, etc. It all works fine.

I thought that I would do this to bind the necessary network using some form of virtual client host in a named base address, which allows me to access different client instances with different net.pipe urns (I understand the names of net.pipe are URN, and not URLs, so they can be almost arbitrary, but I thought I would follow a similar pattern with HTTP addresses).

Here is my web.config

<service name="Administration" behaviorConfiguration="AdministrationBehavior"> <endpoint address="" binding="wsHttpBinding" bindingConfiguration="normalWsBinding" contract="IAdministration" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> <endpoint address="" binding="netNamedPipeBinding" bindingConfiguration="normalNetNamedPipeBinding" contract="IAdministration" /> <endpoint address="mex" binding="mexNamedPipeBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="http://virtualhostname.com/service" /> <add baseAddress="net.pipe://virtualhostname.com/administration/service" /> </baseAddresses> </host> </service> 

However, when accessing the WSDL for the service - the base address for net.pipe seems to be IIS ignored. Instead, I get the real hostname of the machine and net.pipe address URN, which seems to be fully formatted by IIS.

 <wsdl:port name="NetNamedPipeBinding_IAdministration" binding="tns:NetNamedPipeBinding_IAdministration"> <soap12:address location="net.pipe://realhostname/service/Administration.svc"/> <wsa10:EndpointReference> <wsa10:Address>net.pipe://realhostname.com/service/Administration.svc</wsa10:Address> <Identity> <Spn>host/realhostname.com</Spn> </Identity> </wsa10:EndpointReference> </wsdl:port> 

Without control over how net.pipe names are generated, I will not recognize between multiple instances of customer service on the machine. Does anyone know how a network-linked URN can be controlled in an IIS environment?

(I do a lot of autonomous hosting of net.pipe during testing (i.e. the new ServiceHost ()) so I know that my net.pipe bindings work outside of IIS and allow me to control the exact named URN pipe)

If the names cannot be controlled in IIS - does anyone have experience with hosting and access to several separate instances of the net.pipe service on the same machine?

+6
iis named-pipes wcf
source share
2 answers

This is an old question, but I decided that I would add my answer, since I also needed an answer to this question (and maybe there are others who need it too).

The base address of the WCF service that supports IIS is managed by IIS and cannot be redefined in web.config. Instead, you can manage your base addresses by updating the IIS site binding information for the site where your service is hosted.

Most of the documentation I found on the Internet suggests using * as the binding configuration for net.pipe. But if you instead use "virtualsite.com" as the binding configuration value, the base address of the net.pipe endpoint will be "virtualsite.com", not the machine name.

Here is an example of using appcmd to configure a site in IIS with the correct net.pipe binding:

 %windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.pipe',bindingInformation='virtualhostname.com'] 

One note about HostnameComparisonMode , it does not affect IIS according to MSDN :

These values โ€‹โ€‹have no effect when used within the hosting environment of IIS or the Windows Activation Service (WAS). In these cases, WCF uses any method of comparing host names provided by the IIS website that hosts WCF services.

Instead, you should use the mechanism described above. I figured this out by exploring how hostname binding works in HTTP for IIS. Unfortunately, I could not find the official documentation for this IIS-based scenario for other WCF migrations.

+2
source share

It appears that part of the node name of the URI is ignored and replaced by an implementation based on the HostNameComparisonMode channel binding. You can try changing it to "Fine" through the service configuration ...

http://msdn.microsoft.com/en-us/library/system.servicemodel.netnamedpipebinding.hostnamecomparisonmode.aspx

NetNamedPipeBinding.HostnameComparisonMode A HostnameComparisonMode value that indicates whether the host name is used to access the service when matching the URI. The default value is StrongWildcard (), which ignores the host name in the match.

See the configuration syntax here: http://msdn.microsoft.com/en-us/library/ms731291.aspx

0
source share

All Articles