0

我创建了一个带有自定义实例存储的简单工作流服务(以支持 oracle)。自定义实例存储,我遵循 MSDN 的演示:[http://msdn.microsoft.com/en-us/library/ee829481.aspx][1] 但是当我调用服务 api 时,引发异常:

从实例存储中检索到错误类型的值。需要一个类型为 {/Default Web Site/}OrderService.svc 的值,但是却遇到了 null。

我尝试使用SqlWorkflowInstanceStore,没问题。服务没有问题。我再次使用自定义实例存储并调试,我发现LoadWorkflowCommand在SaveWorkflowCommand之前执行。我认为这是一个问题。需要你的帮助!

以下是我的代码片段:

1. Web Config:
<extensions>
      <behaviorExtensions>
        <add name="databaseWorkflowInstanceStore" type="Practices.Framework.Workflow.Configuration.DatabaseInstanceStoreElement, Practices.Framework" />
      </behaviorExtensions>
    </extensions>

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!--<sqlWorkflowInstanceStore connectionStringName="practicesDatabase" instanceCompletionAction="DeleteAll" instanceEncodingOption="GZip" />-->
          <databaseWorkflowInstanceStore database="practicesDatabase" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

2. DatabaseInstanceStore 
    public class DatabaseInstanceStore : InstanceStore
    {
    protected override IAsyncResult BeginTryCommand(InstancePersistenceContext context, InstancePersistenceCommand command, TimeSpan timeout, AsyncCallback callback, object state)
            {
                if (command is CreateWorkflowOwnerCommand)
                {
                    var instanceOwnerId = Guid.NewGuid();
                    context.BindInstanceOwner(instanceOwnerId, instanceOwnerId);
                }
                else if (command is LoadWorkflowCommand)
                {
                    var instanceData = this.LoadInstanceData();
                    context.LoadedInstance(InstanceState.Initialized, instanceData, null, null, null);
                }
                else if (command is SaveWorkflowCommand)
                {
                    var saveCommand = (SaveWorkflowCommand)command;
                    var instanceData = saveCommand.InstanceData;

                    this.SaveInstanceData(instanceData);
                }

                return new CompletedAsyncResult<bool>(true, callback, state);
            }

    ......
    }
4

2 回答 2

0

BeginTryCommand 的调用顺序如下: 1. CreateWorkflowOwnerCommand 2. LoadWorkflowCommand 3. SaveWorkflowCommand 4. SaveWorkflowCommand

所以对于 LoadWorkflowCommand:我需要在加载之前创建实例

http://social.msdn.microsoft.com/Forums/en/dublin/thread/e51d7b18-1e27-4335-8ad0-4ce76b9f8b91

于 2013-02-18T09:08:23.693 回答
0

MSDN 文章仅显示了您需要实现的最少命令。听起来您需要支持更多命令,因此我将检查已调度哪些命令您还不支持。有关命令列表,请参见此处

于 2013-02-05T13:15:08.357 回答