I have downloaded a layered sample from Codeplex from this link: https://layersample.codeplex.com/releases/view/107797
This contain a WCF service with this structure:
Question: in the web host project, there is no .SVC
file and it only contains configuration in the web.config
file.
Can anyone guide me how it works or how I could consume/add service reference in a client application/how to host this on IIS.
This is the web.config
file :
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<serviceActivations>
<add factory="System.ServiceModel.Activation.ServiceHostFactory"
relativeAddress="./LeaveService.svc"
service="LeaveSample.Services.LeaveService" />
<add factory="System.ServiceModel.Activities.Activation.WorkflowServiceHostFactory"
relativeAddress="./LeaveWorkflowService.svc"
service="LeaveSample.Workflows.LeaveWorkflowService" />
</serviceActivations>
</serviceHostingEnvironment>
<services>
<service name="LeaveSample.Services.LeaveService"
behaviorConfiguration="DefaultServiceBehavior">
<endpoint name="basicHttpLeaveService"
address=""
binding="basicHttpBinding"
contract="LeaveSample.Services.Contracts.ILeaveService" />
<endpoint
address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<service name="LeaveWorkflowService">
<endpoint name="basicHttpWorkflowService"
address=""
binding="basicHttpBinding"
contract="ILeaveWorkflowService" />
<endpoint
address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<sqlWorkflowInstanceStore connectionStringName="workflowStore"
hostLockRenewalPeriod="00:00:30"
runnableInstancesDetectionPeriod="00:00:05"
instanceCompletionAction="DeleteAll"
instanceLockedExceptionAction="AggressiveRetry"
instanceEncodingOption="GZip" />
<workflowUnhandledException action="Cancel"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<extensions>
<behaviorExtensions></behaviorExtensions>
</extensions>
<tracking>
<profiles></profiles>
</tracking>
</system.serviceModel>
Thank you
The project you downloaded is using "fileless activation":
<serviceActivations>
<add factory="System.ServiceModel.Activation.ServiceHostFactory"
relativeAddress="./LeaveService.svc"
service="LeaveSample.Services.LeaveService" />
<add factory="System.ServiceModel.Activities.Activation.WorkflowServiceHostFactory"
relativeAddress="./LeaveWorkflowService.svc"
service="LeaveSample.Workflows.LeaveWorkflowService" />
</serviceActivations>
The above portion of the configuration file defines two service activation endpoints, without having to have a physical .svc file.
It is hosted and consumed like any other WCF service using IIS - the only difference is there is no .svc file.
File-less activation was one of several WCF features introduced with WCF 4.0. You can read about it (and the other features) here - A Developer's Introduction to to Windows Communication Foundation 4.