创建长时间运行的工作流服务
本文关键字:工作流 服务 运行 长时间 创建 | 更新日期: 2023-09-27 18:14:56
我正在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指令或程序集引用?)
要解决此错误,请打开Service1。xamlx文件。单击ReceiveStartOrder
,将ServiceContractName
属性更改为{http://tempuri.org/}IStartOrder
(通常默认为{http://tempuri.org/}IService}
)。对ReceiveAddItem
活动(IAddItem
)做同样的事情。
重新构建解决方案。在控制台项目中,右键单击OrderService
服务引用并更新它。
注意:教程充满了错误,我仍在通过它。一旦我成功地完成了它,并记录了缺失的步骤和不准确的地方,我将更新这个答案,并可能包括一个博客文章链接与修订后的教程。
对于任何试图学习本教程的人来说,更好的选择是遵循这个更新的教程。
我将这段代码用于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);
}