[英]Creating a long-running Workflow Service
I'm trying to follow this tutorial On MSDN in order to learn more about workflow services and how they work. 我试图在MSDN上关注本教程,以了解有关工作流服务及其工作方式的更多信息。 Now I'm possibly crazy but I'm having problems with the client section of the tutorial (I'm tempted to blame the tutorial and not myself for this issue).
现在,我可能疯了,但是本教程的客户端部分出现了问题(我很想将此问题归咎于本教程,而不是我本人)。 I'm getting refrence errors on the StartOrderClient initialization and the AddItemClient.
我在StartOrderClient初始化和AddItemClient上出现引用错误。 Is this just a case of a slightly incomplete step in the tutorial or am I missing something?
这是只是本教程中的步骤稍微不完整的一种情况,还是我缺少了什么?
I thank you greatly in advance. 我非常感谢你。
Below is my Order Client Console Program 以下是我的订单客户端控制台程序
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);
}
}
}
Here are the errors. 这是错误。 StartOrderClient and AddItemClient which I don't believe get defined in the tutorial.
我不相信在教程中定义了StartOrderClient和AddItemClient。
The type or namespace name 'StartOrderClient' could not be found (are you missing a using directive or an assembly reference?) 找不到类型或名称空间名称“ StartOrderClient”(您是否缺少using指令或程序集引用?)
The type or namespace name 'AddItemClient' could not be found (are you missing a using directive or an assembly reference?) 找不到类型或名称空间名称“ AddItemClient”(您是否缺少using指令或程序集引用?)
To resolve the error, open up the Service1.xamlx file. 要解决该错误,请打开Service1.xamlx文件。 Click on
ReceiveStartOrder
and change the ServiceContractName
property to {http://tempuri.org/}IStartOrder
(it is usually {http://tempuri.org/}IService}
by default). 单击
ReceiveStartOrder
然后将ServiceContractName
属性更改为{http://tempuri.org/}IService}
{http://tempuri.org/}IStartOrder
(默认情况下通常为{http://tempuri.org/}IService}
)。 Do the same thing for the ReceiveAddItem
activity ( IAddItem
). 对
ReceiveAddItem
活动( IAddItem
)执行相同的操作。
Rebuild the solution. 重建解决方案。 In the console project, right-click the
OrderService
service reference and update it. 在控制台项目中,右键单击
OrderService
服务引用并进行更新。
Note: the tutorial is filled with errors, and I'm still working through it. 注意:本教程充满了错误,我仍在研究中。 Once I successfully complete it and document the missing steps and inaccuracies, I will update this answer and may include a blog post link with a revised tutorial.
一旦成功完成并记录了缺少的步骤和不准确之处,我将更新此答案,并可能包括带有修订后的教程的博客文章链接。
For anyone attempting to do this tutorial, a better option is to follow this updated tutorial . 对于尝试执行本教程的任何人,更好的选择是遵循本更新的教程 。
I use this code for main method 我将此代码用作主要方法
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.