我从此链接下载了Codeplex的分层示例:https://layersample.codeplex.com/releases/view/107797
这包含具有以下结构的WCF服务:
问题:在Web主机项目中,没有.SVC
文件,它只包含web.config
文件中的配置。
任何人都可以指导我如何工作或如何在客户端应用程序中使用/添加服务引用/如何在IIS上托管它。
这是web.config
文件:
<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>
谢谢
答案 0 :(得分:0)
您下载的项目正在使用&#34;无文件激活&#34;:
<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>
配置文件的上述部分定义了两个服务激活端点,而不必具有物理.svc文件。
它像使用IIS的任何其他WCF服务一样托管和使用 - 唯一的区别是没有.svc文件。
无文件激活是WCF 4.0引入的几个WCF功能之一。你可以在这里阅读它(和其他功能) - A Developer's Introduction to to Windows Communication Foundation 4。