2

我正在尝试使用 web.config 复制以下功能,因为我使用的是网络服务器托管的 .xamlx 服务

host.WorkflowExtensions.Add(new HiringRequestInfoPersistenceParticipant());

我已经从能够收集的搜索结果中尝试了以下内容,但并不满意。

<extensions>
        <behaviorExtensions>
            <add name="sqlTracking"
                 type="ApprovalService.Persistence.HiringRequestInfoPersistenceParticipant, ApprovalService.Persistence" />
        </behaviorExtensions>
    </extensions>

任何帮助将不胜感激。

这是我更新的 web.config

    <system.serviceModel>
    <extensions>
        <behaviorExtensions>
            <add name="sqlTracking"
                 type="ApprovalService.HiringInfoElement, ApprovalService"/>
        </behaviorExtensions>
    </extensions>
    <services>
        <service name="ApprovalService" behaviorConfiguration="ApprovalServiceBehavior">
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="ApprovalServiceBehavior">
                <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                <serviceMetadata httpGetEnabled="true" />
                <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                <serviceDebug includeExceptionDetailInFaults="false" />
                <sqlWorkflowInstanceStore connectionStringName="WorkflowPersistence" />
                <workflowIdle timeToPersist="0" timeToUnload="0:05:0"/>
                <sqlTracking/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

这一切都编译并运行,但自定义持久性对象永远不会被调用。

4

1 回答 1

3

您是否将 sqlTracking 行为添加到您的服务行为部分?

以下是一个工作示例

public class StringWriterElement : BehaviorExtensionElement
{
    public override Type BehaviorType
    {
        get { return typeof(StringWriterBehavior); }
    }

    protected override object CreateBehavior()
    {
        return new StringWriterBehavior();
    }
}

public class StringWriterBehavior : IServiceBehavior
{
    public void ApplyDispatchBehavior(ServiceDescription serviceDescription, 
                                                                  ServiceHostBase serviceHostBase)
    {
        var host = (WorkflowServiceHost)serviceHostBase;
        host.WorkflowExtensions.Add<TextWriter>(() => new StringWriter());
    }
}

和 web.config:

<system.serviceModel>
  <extensions>
    <behaviorExtensions>
      <add name="stringWriter"
           type=" MyWorkflowService.StringWriterElement, MyWorkflowService"/>
    </behaviorExtensions>
  </extensions>
  <services>
    <service name="OrderWorkflow“
             behaviorConfiguration="OrderWorkflowBehavior">
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="OrderWorkflowBehavior">
        <serviceMetadata httpGetEnabled="True"/>
        <stringWriter />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>
于 2011-09-26T19:40:19.113 回答