Thursday, 19 July 2012

Deploying a WCF Service in IIS Without an .svc File



The .svc file is a special content file that IIS uses to recognize a WCF service. It provides
the information that the hosting environment in IIS uses to activate the WCF runtime
and start the service. The .svc file always forms part of the address of a WCF service
hosted by using IIS (this is not the case with other hosting environments).
WCF 4.0 provides a feature called Configuration-Based Activation, with which you can
combine the information normally included in the .svc file directly into the Web.config
file for a WCF service hosted by IIS. To do this, you add a <serviceActivations> section to
the <serviceHostingEnvironment> part of the configuration file and provide values for
the relativeAddress and service elements. The relativeAddress element should be a string
that looks like a filename with the .svc extension, and the service element should specify
the fully qualified type that implements the WCF service. The following code fragment
shows an example that configures the ProductsService WCF service:
<?xml version=”1.0″?>
<configuration>

<system.serviceModel>

<serviceHostingEnvironment multipleSiteBindingsEnabled=”true”>
<serviceActivations>
<add relativeAddress=”NoServiceFile.svc”
service=”Products.ProductsServiceImpl” />
</servicaActivations>
</serviceHostingEnvironment>
</system.serviceModel>

</configuration>

No comments:

Post a Comment