【问题标题】:.net web service call with callbacks.net 带有回调的 Web 服务调用
【发布时间】:2015-09-04 07:10:55
【问题描述】:

有谁知道如何向 Web 服务发送各种“回调”参数,以便在完成某个操作时,Web 服务可以调用回调,而无需从该操作返回值。

例如进度百分比,或者更类似于我的问题:

  • 你有 3 种水果(苹果、橙子和柠檬)
  • 您询问所有水果(3 种水果)的信息

我希望 Web 服务在知道每个水果的答案后立即返回每个值,而且保持在同一个动作调用中,所以我没有记录大量不同调用的问题(在实际上,有超过 3 种水果),因为客户端与日志记录的某些方面进行交互,这可能会非常令人困惑

 static void ClientFunction()
    {
        WebServiceFunction(Letters.All);
    }
    static bool WebServiceFunction(Letters whatLetters)
    {

        bool checkA = whatLetters == Letters.A, checkB = whatLetters == Letters.B, checkC = whatLetters = Letters.C,
            checkAll = whatLetters == Letters.All;

        //async wrapped
        if(checkA || checkAll)
        {
            // do something A
            // and send the answer to the client as soon as it is known
        }

        //async wrapped
        if (checkB || checkAll)
        {
            // do something B
            // and send the answer to the client as soon as it is known
        }

        //async wrapped
        if (checkC || checkAll)
        {
            // find out something about c
            // and send the answer to the client as soon as it is known
        }



        // lets say this is a generic return value ( for whatever the service does)
        return true;

    }

    enum Letters
    {
        A,
        B,
        C,
        All
    }

谢谢

【问题讨论】:

  • 您的意思是网络服务应该在服务器端执行回调,还是应该让调用者知道他现在可以执行回调。你也有一些代码吗?
  • 我刚刚用一些示例代码编辑了这个问题

标签: c# .net web-services


【解决方案1】:

【讨论】:

  • 问题是Web服务已经被各方配置和使用。所以改变服务类型是不可能的(新的解决方案也是如此)
猜你喜欢
  • 2016-09-14
  • 1970-01-01
  • 2012-01-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多