Calling web-service from Axapta

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

  1. dzeaman

    dzeaman Guest

    Hi all

    I try to call the web-method, which works too long time.
    Is there any variants how to stop the web-service by, e.g., clicking "Stop"
    button on the custom form?

    Also it's interesting to know, if I can organize "callback" (I want Axapta
    to display what web-service do in real-time or something like real-time).

    Thank you for your comments.
    dzeaman, Dec 14, 2005
    #1
    1. Advertising

  2. dzeaman

    dzeaman Guest

    I didn't wait till replies but maybe my experience will be helpful for someone.

    I organize both "Stop"-button and CallBack.
    First I found the article of Matt Powell "Server-side asyncronous
    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
    #2
    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. hocho888
    Replies:
    1
    Views:
    611
  2. Michael Averstegge
    Replies:
    0
    Views:
    4,204
    Michael Averstegge
    Jan 10, 2006
  3. Replies:
    1
    Views:
    225
    Joe Kaplan \(MVP - ADSI\)
    Jun 14, 2006
  4. JC

    Calling a web service from a web service

    JC, Aug 16, 2003, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    116
    Tom Vande Stouwe MCSD.net
    Aug 20, 2003
  5. Mr. x

    calling web-service from another web-service

    Mr. x, Sep 29, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    116
    Mr. x
    Sep 29, 2003
Loading...

Share This Page