Organizing asynchronous web-service and callback using SoapClient

Discussion in 'ASP .Net Web Services' started by dzeaman, Dec 24, 2005.

  1. dzeaman

    dzeaman Guest

    Hi all!

    Maybe my experience will be helpful for someone.

    I tried to create server-side asynchronous web-service.
    First I found the article of Matt Powell "Server-side asynchronous
    web-methods". He advice to use BeginInvoke and EndInvoke for
    delegate-methods. But I didn't found how to stop delegate in runtime.

    So I try to use method that is not described in MSDN for web-services. Of
    course, I didn't invent something new. I just use threading.

    First of all I created the private-class TestThread with methods start(),
    init() and getResult(). Disadvantage of this method is that you can't send
    parameters directly into method, so you need to create init() method for that.

    Than I created the thread and web-methods start(), result(), isAlive() and
    abort(). Here're they:

    private static TestThread testThread;
    public static Thread thread;

    [WebMethod]
    public bool start( string _param )
    {
    testThread = new TestThread();
    testThread.init( _param );
    thread = new Thread( new ThreadStart( testThread.start ) );
    thread.Start();
    return true;
    }

    [WebMethod]
    public bool result()
    {
    return testThread.getResult();
    }

    [WebMethod]
    public bool isAlive()
    {
    return thread.IsAlive;
    }

    [WebMethod]
    public bool abort()
    {
    thread.Abort();
    return true;
    }

    I realize you'll understand this idea.



    Callback is also not so hard.

    private static ProcessInfo processInfo;

    [WebMethod]
    public string getProcessInfo()
    {
    return processInfo.getInfo();
    }

    And the class:

    public class ProcessInfo
    {
    private static string info;

    public string getInfo()
    {
    string result = info;
    info = "";
    return result;
    }

    public string addInfo( string _info )
    {
    info += _info;
    return info;
    }
    }

    That's all.

    Best regards,
    Andrey Dzizenko.
     
    dzeaman, Dec 24, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Spam Catcher

    Organizing Large Web Service

    Spam Catcher, Apr 18, 2008, in forum: ASP .Net
    Replies:
    5
    Views:
    407
    George Ter-Saakov
    Apr 21, 2008
  2. Asha
    Replies:
    0
    Views:
    342
  3. Christopher Crooker

    WSE 2.0 SP1 SoapClient/Service and NAT

    Christopher Crooker, Aug 1, 2004, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    156
    Christopher Crooker
    Aug 3, 2004
  4. Jack Wright
    Replies:
    1
    Views:
    310
    Jack Wright
    Aug 25, 2004
  5. KodeCruncher
    Replies:
    2
    Views:
    233
    John Fullmer
    May 16, 2006
Loading...

Share This Page