ASP.Net with Asynchronous Web Service calls

Discussion in 'ASP .Net' started by =?Utf-8?B?VHJvdHNreQ==?=, Apr 30, 2004.

  1. Hi
    I have asked a similar question on the web services discussion group, but the question is a bit more related to ASP.Net. Basically I have a ASP.Net application that calls a web service asynchronously. This is fine. My problem is that when I make a call to the web service asynchronously when I get the return which is passed into a static method I cannot reference any Web Contorls to paste the return values into from within the static method.

    I have been advised to create a static field and add the value retuned to the static methos to the static field which should be referenceable from all methods. Again fine.

    However my question is how do I then tell the cntrol that will display my returned value to pick it up?

    A typical sequence would b

    1. Client makes async call. Passes in static methos name to send the results to on completion
    2. browser can do wor
    3. static method picks up result,
    4. needs to tell asp.net to now pick up the result and show it

    point 4 is my problem

    Any help appreciated
     
    =?Utf-8?B?VHJvdHNreQ==?=, Apr 30, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?VHJvdHNreQ==?=

    Rick Spiewak Guest

    You need to have your static method be part of a class, and create an event
    in the class. In your ASP.NET routine, attach a delegate (handler) to the
    event, and raise it when you have the results.

    "Trotsky" <> wrote in message
    news:...
    > Hi,
    > I have asked a similar question on the web services discussion group,

    but the question is a bit more related to ASP.Net. Basically I have a
    ASP.Net application that calls a web service asynchronously. This is fine.
    My problem is that when I make a call to the web service asynchronously when
    I get the return which is passed into a static method I cannot reference any
    Web Contorls to paste the return values into from within the static method.
    >
    > I have been advised to create a static field and add the value retuned to

    the static methos to the static field which should be referenceable from all
    methods. Again fine.
    >
    > However my question is how do I then tell the cntrol that will display my

    returned value to pick it up??
    >
    > A typical sequence would be
    >
    > 1. Client makes async call. Passes in static methos name to send the

    results to on completion.
    > 2. browser can do work
    > 3. static method picks up result,
    > 4. needs to tell asp.net to now pick up the result and show it.
    >
    > point 4 is my problem.
    >
    > Any help appreciated.
    >
    >
     
    Rick Spiewak, Apr 30, 2004
    #2
    1. Advertising

  3. Many thanks Ricky. Are you aware of any useful ( msdn ) references for this
     
    =?Utf-8?B?VHJvdHNreQ==?=, Apr 30, 2004
    #3
  4. =?Utf-8?B?VHJvdHNreQ==?=

    Rick Spiewak Guest

    Not for this specific case, but you might want to prowl around for general
    information about delegates and events.

    "Trotsky" <> wrote in message
    news:...
    > Many thanks Ricky. Are you aware of any useful ( msdn ) references for

    this?
    >
    >
     
    Rick Spiewak, May 1, 2004
    #4
  5. Thanks again. I had a go at this. However I have came across another issue. My app now does the followin

    1. Creates a class ( AsynCall.cs ) that takes care of the asynchronous web services call, and raising of events when the result is returned from the web service
    2. passes a reference from the .aspx.cs class ( this ) to the AsynCall object. This is because the .aspx.cs class will be listening for the reslt when it is available from the Asyn web services call
    3. The AsynCall class defines an event that is raised when the asynchronous call returns. The .aspx.cs class has a method that matches the method definition defined by a delegate in AsyncCall.cs, and has registered its method with the handler
    4. The aync result is returned and the appropriate event is raised, I can write to debug to check I am in the correct aspx.cs class and the correct result has been returned from the web service call
    5. When I try to then write the result to a label on the form nothing appears.

    point 5 is my problem

    again any help greatly appreciated
     
    =?Utf-8?B?VHJvdHNreQ==?=, May 2, 2004
    #5
  6. =?Utf-8?B?VHJvdHNreQ==?=

    Rick Spiewak Guest

    The page isn't being reloaded just because the event occurs. You might have
    to force this - try saving the result from the web service in session state,
    (or adding it to your page's URL as a query string) and then do a
    server.transfer back to the same page, pick up the value and put it into
    your control. (I haven't tried this <g>)

    "Trotsky" <> wrote in message
    news:...
    > Thanks again. I had a go at this. However I have came across another

    issue. My app now does the following
    >
    > 1. Creates a class ( AsynCall.cs ) that takes care of the asynchronous web

    services call, and raising of events when the result is returned from the
    web service.
    > 2. passes a reference from the .aspx.cs class ( this ) to the AsynCall

    object. This is because the .aspx.cs class will be listening for the reslt
    when it is available from the Asyn web services call.
    > 3. The AsynCall class defines an event that is raised when the

    asynchronous call returns. The .aspx.cs class has a method that matches the
    method definition defined by a delegate in AsyncCall.cs, and has registered
    its method with the handler.
    > 4. The aync result is returned and the appropriate event is raised, I can

    write to debug to check I am in the correct aspx.cs class and the correct
    result has been returned from the web service call.
    > 5. When I try to then write the result to a label on the form nothing

    appears.
    >
    > point 5 is my problem.
    >
    > again any help greatly appreciated.
    >
    >
     
    Rick Spiewak, May 3, 2004
    #6
  7. I tried your suggestion ( and also a simple redirect to a new page ) from my method in the original aspx.cs class that matches the delegates required signature, but nothing happened ( on the Page, it still logs to the debug window that it is in the correct method )
     
    =?Utf-8?B?VHJvdHNreQ==?=, May 3, 2004
    #7
  8. I went through the stack trace and for a redirect it ( the aspx page ) throws an exception stating

    "Response is not available in this context

    For the Server.Transfer I get "Error executing child request for". MSDN recommends redirect.

    http://support.microsoft.com/default.aspx?scid=kb;en-us;32043

    Regardless both fail
    The annoying this is when I look in the locals window I can see the result returned from the web service is assigned to the label control on the form. It just isn't reflected in the browser window.
     
    =?Utf-8?B?VHJvdHNreQ==?=, May 3, 2004
    #8
    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. zg_yuan
    Replies:
    0
    Views:
    387
    zg_yuan
    Aug 25, 2003
  2. Jonathan Trevor
    Replies:
    6
    Views:
    3,614
    sahar
    Nov 5, 2010
  3. Jonathan Trevor
    Replies:
    1
    Views:
    299
    Sami Vaaraniemi
    Feb 12, 2004
  4. Norton
    Replies:
    1
    Views:
    179
    Jeffrey Hasan
    Aug 3, 2004
  5. Doug Perkes

    handling exceptions in asynchronous web service calls

    Doug Perkes, Aug 6, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    186
    Jeffrey Hasan
    Aug 9, 2004
Loading...

Share This Page