Hosting WCF in COM+ with different transports

Hosting WCF in COM+ with different transports

  • Comments 5

I have had some questions around how to use COM+ Integration's "COM+ hosting mode" usually with the goal of using other, faster transports than HTTP. This post will demonstrate exactly how this can be done with no new code using the IIS hosted “Integrating with a COM+ Application as a Windows Communication Foundation Service” sample from the January CTP SDK as a starting point. The steps to go through are as follows:

 

1)     Uninstall the IIS hosting

2)     Reconfigure the calculator app

3)     Generate the default COM+ hosted namedpipes binding

4)     Edit the client configuration to use the namedpipes binding – stop there if that is what you want

5)     Edit the server’s namedpipes binding to TCP

6)     Edit the client configuration to use the TCP binding

 

 

1) Uninstall the COM+ IIS hosting with the ComSvcConfig tool as follows:

 

ComSvcConfig.exe /uninstall /application:ServiceModelSample

/contract:ServiceModelSample.esCalculator,ICalculator /hosting:was

/webDirectory:ServiceModelSamples /mex /verbose

 

Expected output:

Microsoft (R) COM+ Service Model Integration Configuration Tool

[Microsoft (R) .NET Framework, Version 2.0.50727.154]

Copyright (c) Microsoft Corporation. All rights reserved.

 

Removed endpoint for interface ServiceModelSample.esCalculator,ICalculator.

Updated file: C:\inetpub\wwwroot\ServiceModelSamples\web.config

 

2) To reconfigure the calculator app, modifying the ServiceModelSample properties and set it to be a “Server application” on the Activation tab in the COM+ MMC. On the Advanced tab, set the Server Process Shutdown to “Leave running when idle”

 

3) Generate the default COM+ hosted namedpipes binding using the ComSvcConfig tool as follows:

 

ComSvcConfig.exe /install /application:ServiceModelSample

/contract:ServiceModelSample.esCalculator,ICalculator /hosting:complus

/verbose

 

Expected output:

Microsoft (R) COM+ Service Model Integration Configuration Tool

[Microsoft (R) .NET Framework, Version 2.0.50727.154]

Copyright (c) Microsoft Corporation. All rights reserved.

 

Generated endpoint for interface ServiceModelSample.esCalculator,ICalculator.

Created directory: C:\Program Files\ComPlus Applications\{e146e066-d3d1-4e0e-b175-30160bd368de}\

Created file: C:\Program Files\ComPlus Applications\{e146e066-d3d1-4e0e-b175-30160bd368de}\application.config

Created file: C:\Program Files\ComPlus Applications\{e146e066-d3d1-4e0e-b175-30160bd368de}\application.manifest

Warning: COM+ application ServiceModelSample should be restarted for configuration changes to take effect.

 

Using the COM+ MMC, “Start” the application and the ball should spin without error.

 

 

4) Edit the client’s configuration file (app.,config) to use the corresponding namedpipes binding with the address matching the configured service address:

 

<?xml version="1.0" encoding="utf-8"?>

<configuration>

   <system.serviceModel>

     <client>

        <endpoint name="" address="net.pipe://localhost/ServiceModelSample/ServiceModelSample.esCalculator/ICalculator" binding="netNamedPipeBinding" bindingConfiguration="comNonTransactionalBinding" contract="ICalculator"/>

     </client>

     <bindings>

        <netNamedPipeBinding>

          <binding name="comNonTransactionalBinding"/>

          <binding name="comTransactionalBinding" transactionFlow="true"/>

          <binding name="comMexBinding"/>

        </netNamedPipeBinding>

     </bindings>

   </system.serviceModel>

</configuration>

 

At this point you should be able to rerun the client and observe the same output as before but the traffic is flowing over the namedpipes transport:

 

Add(100,15.99) = 115.99

Subtract(145,76.54) = 68.46

Multiply(9,81.25) = 731.25

Divide(22,7) = 3.14285714285714

 

Press <ENTER> to terminate client.

 

 

5) Edit the server’s configuration file (%PROGRAMFILES%\ComPlus Applications\{e146e066-d3d1-4e0e-b175-30160bd368de}\application.config) to change from a namedpipes binding to a TCP binding:

 

<?xml version="1.0" encoding="utf-8"?>

<configuration>

   <system.serviceModel>

     <behaviors/>

     <comContracts>

        <comContract contract="{C551FBA9-E3AA-4272-8C2A-84BD8D290AC7}" namespace="http://tempuri.org/C551FBA9-E3AA-4272-8C2A-84BD8D290AC7" name="ICalculator">

          <exposedMethod name="Add"/>

          <exposedMethod name="Subtract"/>

          <exposedMethod name="Multiply"/>

          <exposedMethod name="Divide"/>

        </comContract>

     </comContracts>

     <services>

        <service type="{E146E066-D3D1-4E0E-B175-30160BD368DE},{BE62FF5B-8B53-476B-A385-0F66043049F6}">

          <endpoint address="net.tcp://localhost/ServiceModelSample/ServiceModelSample.esCalculator/ICalculator" bindingConfiguration="comNonTransactionalBinding" binding="netTcpBinding" contract="{C551FBA9-E3AA-4272-8C2A-84BD8D290AC7}"/>

        </service>

     </services>

     <bindings>

        <netTcpBinding>

          <binding name="comNonTransactionalBinding"/>

          <binding name="comTransactionalBinding" transactionFlow="true"/>

          <binding name="comMexBinding"/>

        </netTcpBinding>

     </bindings>

   </system.serviceModel>

</configuration>

 

Using the COM+ MMC, “Shut down” then “Start” the application to apply to updated configuration and again the ball should spin without error.

 

6) Edit the client’s configuration file (app.,config) to use the corresponding TCP binding with the address matching the configured service address:

 

<?xml version="1.0" encoding="utf-8"?>

<configuration>

   <system.serviceModel>

     <client>

        <endpoint name="" address="net.tcp://localhost/ServiceModelSample/ServiceModelSample.esCalculator/ICalculator" binding="netTcpBinding" bindingConfiguration="comNonTransactionalBinding" contract="ICalculator"/>

     </client>

     <bindings>

        <netTcpBinding>

          <binding name="comNonTransactionalBinding"/>

          <binding name="comTransactionalBinding" transactionFlow="true"/>

          <binding name="comMexBinding"/>

        </netTcpBinding>

     </bindings>

   </system.serviceModel>

</configuration>

 

At this point you should be able to rerun the client and observe the same output as before but the traffic is flowing over the TCP transport:

 

Add(100,15.99) = 115.99

Subtract(145,76.54) = 68.46

Multiply(9,81.25) = 731.25

Divide(22,7) = 3.14285714285714

 

Press <ENTER> to terminate client.

 

And you are done - you have COM+ hosting with your transport of choice. Any channel that supports sessions should work just fine. COM+ Integration over channels without sessions will be in the next CTP but more on that very soon.

  • Yeah, I am back on the ES kick again.&amp;nbsp; Some EnterpriseServices links to ponder.
    Using Distributed...
  • This article will (slowly) grow into a collection of bits and pieces that will help you in getting to

Page 1 of 1 (5 items)