【问题标题】:Creating a long-running Workflow Service创建长期运行的工作流服务
【发布时间】:2013-05-23 12:23:49
【问题描述】:

我正在尝试学习本教程On MSDN,以了解有关工作流服务及其工作原理的更多信息。现在我可能疯了,但我在教程的客户端部分遇到了问题(我很想把这个问题归咎于教程而不是我自己)。我在 StartOrderClient 初始化和 AddItemClient 上遇到了参考错误。这只是教程中的一个稍微不完整的步骤,还是我遗漏了什么?

提前非常感谢你。

以下是我的订单客户端控制台程序

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
using System.ServiceModel.Activities;

namespace OrderClient.OrderService
{
    class Program
    {
        static void Main(string[] args)
        {
            // Send initial message to start the workflow service
            Console.WriteLine("Sending start message");
            StartOrderClient startProxy = new StartOrderClient();
            string orderId = startProxy.StartOrder("Kim Abercrombie");

            // The workflow service is now waiting for the second message to be sent
            Console.WriteLine("Workflow service is idle...");
            Console.WriteLine("Press [ENTER] to send an add item message to reactivate the workflow service...");
            Console.ReadLine();

            // Send the second message
            Console.WriteLine("Sending add item message");
            AddItemClient addProxy = new AddItemClient();
            AddItem item = new AddItem();
            item.p_itemId = "Zune HD";
            item.p_orderId = orderId;

            string orderResult = addProxy.AddItem(item);
            Console.WriteLine("Service returned: " + orderResult);
        }
    }
}

这里是错误。我不相信在教程中定义了 StartOrderClient 和 AddItemClient。

找不到类型或命名空间名称“StartOrderClient”(您是否缺少 using 指令或程序集引用?)

找不到类型或命名空间名称“AddItemClient”(您是否缺少 using 指令或程序集引用?)

【问题讨论】:

  • 什么样的参考错误?也就是说,具体来说,您的错误是什么?
  • 错误发生的地点/时间?
  • 好的......你仍然需要更具体。错误窗口应该告诉您找不到什么类型或命名空间。我需要这些信息来帮助你。
  • 问的很明显,但是您是否添加了对工作流服务的服务引用并将OrderService 指定为命名空间?
  • @IvanS 如果您已将服务引用添加到客户端项目,则需要添加“使用”语句,例如 using OrderService

标签: c# workflow-foundation workflowservice


【解决方案1】:

要解决此错误,请打开 Service1.xamlx 文件。单击ReceiveStartOrder 并将ServiceContractName 属性更改为{http://tempuri.org/}IStartOrder(通常默认为{http://tempuri.org/}IService})。对 ReceiveAddItem 活动 (IAddItem) 执行相同的操作。

重建解决方案。在控制台项目中,右键单击OrderService 服务引用并更新它。

注意:本教程充满了错误,我仍在努力。一旦我成功完成并记录了缺失的步骤和不准确之处,我将更新此答案,并可能包含一个带有修订教程的博客文章链接。

对于任何尝试学习本教程的人,更好的选择是关注this updated tutorial

【讨论】:

    【解决方案2】:

    我将此代码用于 main 方法

    static void Main(string[] args)
        {
            // Send initial message to start the workflow service
            Console.WriteLine("Sending start message");
    
            ServiceClient proxy = new ServiceClient();
            string orderId = proxy.StartOrder("Kim Abercrombie");
    
            // The workflow service is now waiting for the second message to be sent
            Console.WriteLine("Workflow service is idle...");
            Console.WriteLine("Press [ENTER] to send an add item message to reactivate the workflow service...");
            Console.ReadLine();
    
            // Send the second message
            Console.WriteLine("Sending add item message");
            AddItem item = new AddItem();
            item.p_itemId = "Zune H";
            item.p_orderId = orderId;
    
            string orderResult = proxy.AddItem(item);
            Console.WriteLine("Service returned: " + orderResult);
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-13
      • 2017-01-15
      • 2016-02-13
      • 2023-03-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多