How to: Configure COM+ Service Settings

When an application interface is added or removed by using the COM+ Service Configuration tool, the Web service configuration is updated within the application's configuration file. In the COM+ hosted mode, the Application.config file is placed in the Application Root Directory (%PROGRAMFILES%\ComPlus Applications\{appid} is the default). In either of the Web-hosted modes, the Web.config file is placed in the specified vroot directory.

Note

Message signing should be used to protect against tampering of messages between a client and a server. Also, message or transport layer encryption should be used to protect against information disclosure from messages between a client and a server. As with Windows Communication Foundation (WCF) services, you should use throttling to limit the number of concurrent calls, connections, instances, and pending operations. This helps prevent over-consumption of resources. Throttling behavior is specified through service configuration file settings.

Example

Consider a component that implements the following interface:

[Guid("C551FBA9-E3AA-4272-8C2A-84BD8D290AC7")]  
public interface IFinances  
{  
    string Debit(string accountNo, double amount);  
    string Credit(string accountNo, double amount);  
}  

If the component is exposed as a Web service, the corresponding service contract that is exposed, and that clients would need to conform to, is as follows:

[ServiceContract(Session = true,  
Namespace = "http://tempuri.org/C551FBA9-E3AA-4272-8C2A-84BD8D290AC7",  
Name = "IFinances")]  
public interface IFinancesContract : IDisposable  
{  
    [OperationContract]  
    string Debit(string accountNo, double amount);  
    [OperationContract]  
    string Credit(string accountNo, double amount);  
}  

Note

IID forms part of the initial namespace for the contract.

Client applications that use this service would need to conform to this contract, along with using a binding that is compatible with the one specified in the application configuration.

The following code example shows a default configuration file. Being a Windows Communication Foundation (WCF) Web service, this conforms to the standard service model configuration schema and can be edited in the same way as other WCF services configuration files.

Typical modifications would include:

  • Changing the endpoint address from the default ApplicationName/ComponentName/InterfaceName form to a more usable form.

  • Modifying the namespace of the service from the default http://tempuri.org/InterfaceID form to a more relevant form.

  • Changing the endpoint to use a different transport binding.

    In the COM+-hosted case, the named pipes transport is used by default, but an off-machine transport like TCP can be used instead.

<?xml version="1.0" encoding="utf-8"?>  
<configuration>  
    <system.serviceModel>  
        <bindings>  
            <netNamedPipeBinding>  
                <binding name="comNonTransactionalBinding" />  
                <binding name="comTransactionalBinding" transactionFlow="true" />  
            </netNamedPipeBinding>  
        </bindings>  
        <comContracts>  
            <comContract contract="{C551FBA9-E3AA-4272-8C2A-84BD8D290AC7}"  
                name="IFinances" namespace="http://tempuri.org/C551FBA9-E3AA-4272-8C2A-84BD8D290AC7"  
                requiresSession="true">  
                <exposedMethods>  
                    <add exposedMethod="Debit" />  
                    <add exposedMethod="Credit" />  
                </exposedMethods>  
            </comContract>  
        </comContracts>  
        <services>  
            <service name="{DCDB24CC-0B19-4534-95CD-FBBFF4D67DD9},{C942B840-AD54-4A44-B5F7-928130980AB9}">  
                <endpoint address="IFinances" binding="netNamedPipeBinding" bindingConfiguration="comNonTransactionalBinding"  
                    contract="{C551FBA9-E3AA-4272-8C2A-84BD8D290AC7}" />  
                <host>  
                    <baseAddresses>  
                        <add baseAddress="net.pipe://localhost/ServiceModelDocSampleApp/ServiceModelDocSample.esFinance" />  
                    </baseAddresses>  
                </host>  
            </service>  
        </services>  
    </system.serviceModel>  
</configuration>  

See also