Welcome to MSDN Blogs Sign in | Join | Help

Activation Without .svc files – Config Based Activation (CBA)

.Svc files were perceived as a management overhead. In Net Framework 4.0, WCF  services hosted in WAS/IIS do not require .svc file anymore.

We can activates service through the  config Based Activation feature.

This feature allows for registration of services in web.config file. Here is a sample registration for two services in a single web.config file.

<system.serviceModel>
 <serviceHostingEnvironment>

<serviceActivations>

<add relativeAddress=”CreditCheckService.svc” service=”Microsoft.ServiceModel.Samples.CreditCheckService” />

<add relativeAddress=”Payment/Service.svc” service=”Microsoft.ServiceModel.Samples.PaymentCheckService” />

  </serviceActivations>
 </serviceHostingEnvironment>
</system.serviceModel>
 

 

 

Some details to remember about  config Based Activation feature

  1. serviceHostingEnvironment is an application level configuration. Please place the web.config containng the configuration under the root of the virtual Application.
  2. CBA supports activation over both http and non-http protocol
  3. CBA feature requires extensions in the relatativeAddress i.e. .svc, .xoml or .xamlx. You can map your own extensions to the know buildProviders which will then enable you to activate service over any extension.
  4. Upon confict, CBA overrides .svc registrations.
  5. serviceHostingEnvironment is a machinetoApplication inheritable section. If you register a single service in the root of the machine then every service in the application will inherit this service.

.NET 4.0 Beta1/Beta2 Web Application Configuration section missing declaration error

Symptoms

If you encounter the following error in your web application (things hosted in IIS) “The configuration section <sectionName> cannot be read because it is missing a section declaration " 

 

examples

“The configuration section 'standardEndpoints' cannot be read because it is missing a section declaration”

“The configuration section ‘tracking’ cannot be read because it is missing a section declaration”

then you need to install either SP2 of Vista/Win2k8 or the hotfix mentioned in KB article 958854.

 

I would actually recommend anyone trying out 4.0 Beta1 bits always install the hotfix below.

 

Issue

A cut and paste from the KB article

“A hotfix rollup is available for Internet Information Services (IIS) 7.0 to support the Microsoft .NET Framework 4.0. This hotfix rollup resolves the following issues that occur when you use the .NET Framework 4.0 with IIS 7.0:

    • You cannot use the IIS Manager UI (Inetmgr.exe) to manage both .NET Framework 2.0 applications and .NET Framework 4.0 applications.
    • You cannot use WMI to manage .NET Framework 4.0 configurations.
    • The managed runtime version is not set correctly in the worker process (W3wp.exe).
    • The IIS configuration system does not determine the correct managed runtime version.
    • You cannot use the IIS 7.0 command-line management tool (Appcmd.exe) to manage .NET Framework 4.0 configurations.
    • The IIS Manager UI (Inetmgr.exe) shows the .NET Framework 2.0 Provider features for .NET Framework 4.0 applications and site

 

Here is the link to the KB article

http://support.microsoft.com/default.aspx/kb/958854

Solution

 

Install Windows Server  2008 /Vista Sp2

http://technet.microsoft.com/en-us/dd727510.aspx

 

or

 

Install hotfix

http://support.microsoft.com/hotfix/KBHotfix.aspx?kbnum=958854&kbln=en-us

How can WCF support multiple IIS Binding specified per site ?

Background

IIS has web sites, which are containers for virtual applications which contain virtual directories. The application in a site can be accessed through one or more IIS binding.

IIS bindings provide two pieces of information – binding protocol and binding information. Binding protocol defines the scheme over which communication occurs, and binding information is the information used to access the site.

Example

Binding protocol – HTTP

Binding Information – IPAddress , Port, Hostheader

IIS supports specifying multiple IIS bindings per site, which results in multiple base addresses per scheme. A WCF service hosted under a site allows binding to only one baseAddress per scheme.

Solution in .Net Fx 3.0:Supporting Multiple IIS Bindings Per Site

Solution in .Net Fx3.5: BaseAddressPrefixFilters

 I am updating this blog entry with a better solution support for 3.5. This one does not require you to write custom factories

Say you want to host the service over http://payroll.myorg.com:80 and http://payroll.myorg.com:9000

Step1  set the baseAddressPrefix to one of the addresses   

Example

<system.serviceModel>

<serviceHostingEnvironment>

<baseAddressPrefixFilters>

        <add prefix=”http://payroll.myorg.com:8000”/>      

</baseAddressPrefixFilters>

</serviceHostingEnvironment>

</system.serviceModel>

Step 2 Set the endpoints in your web.config file to be absolute URIs

<services>

<service>

<endpoint address="http://payroll.myorg.com:8000/Service1.svc/EP1"  Binding="..." Contract="..." />

<endpoint address="http://payroll.myorg.com:9000/Service1.svc/EP12"  Binding="..." Contract="..." />

</service>

</services>

Solution in .Net Fx4.0: BaseAddressPrefixFilters

 Beta2 Fix

In the current  Beta2 release of the .NET Framework, we added  support for multiple site binding  . Just set the binding in IIS site and the service will inherit the address

  Final RTM Fix

In the final bits, we decided to make it an opt-in due to application compatability reasons. In order to enable multiple site binding, you need to set multipleSiteBindingEnabled to true in your application. Multiple site binding is supported only for Http protocol. The address of endpoints in the configuration file need to be complete URI. When porting your 3.0 or 3.5 workaround to 4.0 you need to keep this particular aspect.

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 

 

How do I set binding and enable protocols for Non-Http Transports in IIS?

 

Current in Vista the only mechanism for turning on the settings for Non-Http transports  is through AppCmd.exe  (For information on Hosting in WAS read - How to- Host a WCF Service in WAS) .This capability has been added in Windows Server 2008 and Windows Vista sp1. Through IIS Manager, you will be able to set binding on the site and enable the protocol on the Virtual Application. The screenshots below walk you through the steps.

 

Step 1 Set the Binding on the Site

 

image

 

 

Step 2 Enable the Protocol on the Virtual Application under the site

 

image

Tech Ed 2007

Tech Ed 2007 was in Florida this year and was attended by over 13,000 people . Wow! that is huge . Lots of teched content is still accessible online . Check out this site for more information  http://www.microsoft.com/events/teched2007/default.mspx

 

I gave a chalk talk on "Hosting WCF and WF applications in IIS" ,which was well received and did booth duty rest of the time. This gave me an opportunity to interact with many customers, understand their pain points and solve a few of their problems.

I also took some pictures at Tech-Ed .....

  Florida 079    Florida 071 Florida 083  Florida 061 Florida 090    Florida 043

 

 Portofino Bay at Universal (the last pic is the map of the hotel) is the resort hotel I stayed in Orlando; I highly recommend this place.

Technorati Tags:
Posted by Ram Poornalingam | 0 Comments
Filed under:

Supporting Multiple IIS Bindings Per Site

MultiplBinding

If you see this error when you are hosting in IIS then most probably you have multiple IIS bindings per scheme in your web site. WCF in .Net Framework 3.0 ,out of the box, does not support multiple binding per site, but this can enabled by extending the System.ServiceModel.Activation.ServiceHostFactory,  and providing a CustomServiceHostFactory. CustomServiceHostFactory  picks the appropriate base address for the application.  The Factory attribute in the ServiceHost directive is set to the CustomSerivceHostFactory.

The only drawback is every developer hosting their application will need to change the svc file to provide the CustomServiceHostFactory, which picks the appropriate base address.

 

Sample Code

public class MultipleIISBindingSupportServiceHostFactory : ServiceHostFactory

{

protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)

 {

      Uri[] requiredAddress = GetAppropriateBase(baseAddresses);

      return base.CreateServiceHost(serviceType, requiredAddress);

 

 

   }

Uri[] GetAppropriateBase(Uri [] baseAddresses)

{

        List<Uri> retAddress = new List<Uri>();

        foreach (Uri address in baseAddresses)

         {

            if (address.DnsSafeHost == "localhost")

            {

               retAddress.Add(address);

             }

 

         }

return retAddress.ToArray();

 }

}

In the svc file, fill in the Factory attribute

<%@ServiceHost Factory="NS.MultipleIISBindingSupportServiceHostFactory" Service="CalculatorService" %>

Posted by Ram Poornalingam | 6 Comments
Filed under: ,

.Net Framework 3.0 Shipped

This Entry is a bit late, but nevertheless .....

           This is an additive release to 2.0 which contains Windows Communication Foundation (WCF), Windows WorkFlow Foundation(WF)Windows Presentation Foundation (WPF) and Windows Cardspaces. No new features have been added to the base existing framework

           This is the Windows Vista SDK RTM release which also contains the SDK for .Net Framework 3.0 .

           Monthly refreshes of WCF SDK can retrieved from http://msdn2.microsoft.com/en-us/library/aa388579.aspx . MSDN Refreshes contain only conceptual and reference documentation updates. Most likely there are no issue with our tools ;)

           WCF SDK contains conceptual documentation, reference documentation, tools like Svcutil.exe etc., libs, and header files.

Posted by Ram Poornalingam | 0 Comments
Filed under:

Finally !!!

I am a Program Manager with the Connected Systems Division, and will be using this space to dump any use information WCF,WF and related technologies. I will try to keep my focus of the logs on hosting.

I also hope to seek your opinions,comments and feedback on various issues that I will be blogging.

 
Page view tracker