gpt4 book ai didi

workflow-foundation-4 - 如何使用 web.config 为 Web 服务器托管的 .xamlx 服务添加自定义 PersistenceIOParticipant

转载 作者:行者123 更新时间:2023-12-04 06:12:54 25 4
gpt4 key购买 nike

我正在尝试使用 web.config 复制以下功能,因为我使用的是 webserver 托管的 .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>

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

最佳答案

您是否将 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>

关于workflow-foundation-4 - 如何使用 web.config 为 Web 服务器托管的 .xamlx 服务添加自定义 PersistenceIOParticipant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7558713/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com