簡體   English   中英

創建長期運行的工作流服務

[英]Creating a long-running Workflow Service

我試圖在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/}IService} {http://tempuri.org/}IStartOrder (默認情況下通常為{http://tempuri.org/}IService} )。 ReceiveAddItem活動( IAddItem )執行相同的操作。

重建解決方案。 在控制台項目中,右鍵單擊OrderService服務引用並進行更新。

注意:本教程充滿了錯誤,我仍在研究中。 一旦成功完成並記錄了缺少的步驟和不准確之處,我將更新此答案,並可能包括帶有修訂后的教程的博客文章鏈接。

對於嘗試執行本教程的任何人,更好的選擇是遵循本更新的教程

我將此代碼用作主要方法

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM