如何使用web.config为Web服务器托管的.xamlx服务添加自定义PersistenceIOParticipant [英] How do I add a custom PersistenceIOParticipant for webserver hosted .xamlx services using the web.config
本文介绍了如何使用web.config为Web服务器托管的.xamlx服务添加自定义PersistenceIOParticipant的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于我使用的是网络服务器托管的.xamlx服务,因此我尝试使用web.config复制以下功能
I'm trying to duplicate the functionality below using web.config since I'm using webserver hosted .xamlx services
host.WorkflowExtensions.Add(new HiringRequestInfoPersistenceParticipant());
我已经尝试根据收集的内容尝试了以下方法,但并不满意.
I've tried the following from what I've been able to gather searching, but no satisfaction.
<extensions>
<behaviorExtensions>
<add name="sqlTracking"
type="ApprovalService.Persistence.HiringRequestInfoPersistenceParticipant, ApprovalService.Persistence" />
</behaviorExtensions>
</extensions>
任何帮助将不胜感激.
这是我更新的web.config
Here is my updated 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>
所有这些都可以编译并运行,但是自定义持久性对象永远不会被调用.
This all compiles and runs but the custom persistance object never get's called.
推荐答案
您是否已将sqlTracking行为添加到服务行为部分?
Did you add the sqlTracking behavior to your service behavior section?
以下是一个有效的示例
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:
And the 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>
这篇关于如何使用web.config为Web服务器托管的.xamlx服务添加自定义PersistenceIOParticipant的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文