-1

我已经从这个链接从 Codeplex 下载了一个分层示例:https ://layersample.codeplex.com/releases/view/107797

这包含具有以下结构的 WCF 服务:

  1. 服务合同库
  2. 服务实现库
  3. 网络主机项目

问题:在虚拟主机项目中,没有.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>

谢谢

4

1 回答 1

0

您下载的项目使用“无文件激活”:

<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 功能之一。您可以在此处阅读有关它(和其他功能)的信息 - Windows Communication Foundation 4 开发人员简介

于 2014-06-29T16:49:05.833 回答