Reputation: 1393
I'm converting my asmx web services to WCF. Does this inherently mean the file type needs to change from .asmx to .svc?
Upvotes: 3
Views: 6302
Reputation: 24558
Every WCF service needs to have a host process : a windows service,IIS or any other .NET program. This host will create an instance of the System.ServiceModel.ServiceHost (or any custom System.ServiceModel.ServiceHostBase) and will manage the service configurations, behaviors, channels.
However, when a service is hosted in IIS it behaves a little bit differently. By default, we need to create a physical file with .svc extension. It's a pure IIS requirement. There's a module within IIS that handles the .svc file type. This file is just a declaration of the service type and optionnaly service host factory type.
<%@ ServiceHost Language="C#" Debug="true" Factory="System.ServiceModel.Activation.ServiceHostFactory" Service="MyFamousCalculatorService" CodeBehind="MyFamousCalculatorService.svc.cs" %>
Since WCF 4.0, we can create and deploy services in IIS without a physical .svc file.This can be done using the serviceActivations
configuration in the system.serviceModel
configuration section.
<configuration>
<system.serviceModel>
<serviceHostingEnvironment>
<serviceActivations>
<add relativeAddress="MyFamousCalculatorService.svc" service="MyFamousCalculatorService"/>
</serviceActivations>
</serviceHostingEnvironment>
</system.serviceModel>
</configuration>
Upvotes: 10