473,396 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ASP.Net with Asynchronous Web Service calls

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
Nov 18 '05 #1
8 2291
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" <an*******@discussions.microsoft.com> wrote in message
news:9D**********************************@microsof t.com...
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.

Nov 18 '05 #2
Many thanks Ricky. Are you aware of any useful ( msdn ) references for this
Nov 18 '05 #3
Not for this specific case, but you might want to prowl around for general
information about delegates and events.

"Trotsky" <an*******@discussions.microsoft.com> wrote in message
news:34**********************************@microsof t.com...
Many thanks Ricky. Are you aware of any useful ( msdn ) references for this?

Nov 18 '05 #4
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
Nov 18 '05 #5
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" <an*******@discussions.microsoft.com> wrote in message
news:68**********************************@microsof t.com...
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.

Nov 18 '05 #6
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 )
Nov 18 '05 #7
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...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.
Nov 18 '05 #8
i have a similar problem, i can see the result in the debug view but the result does not get displayed on the web page

Any solution

Thanks. Karim.
Nov 18 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Marty McDonald | last post by:
I create and start several threads, each thread executes the same method - within the method, a web service is invoked. I find that the more threads I use, the longer it takes for all of the...
0
by: orekinbck | last post by:
Hi There This question is about calling an asynchronous web service from the UI thread. Unless I am making a fundamental error, it appears that the asynchronous web service call seems to spark...
0
by: Jonathan Trevor | last post by:
Hi, I've found what appears to be a bug with ASP.NET web service method invocation - making it impossible to invoke and get the result of a synchronous web call after an asynchronous call has...
1
by: Alexander Kaplunov | last post by:
I have two different scenarios: 1. I have an application that calls a web service and passes an object. Web Service takes that object and does some stuff with it, which could take...
5
by: rgarf | last post by:
I have a C++ application that consumes a web service. I would like to call the web service asynchronously so my C++ application can do other processing in between. My proxy file does not have any...
5
by: SenthilVel | last post by:
Hi Can any one let me know how i can perform a Asychronous calll in a web service ? or using a thread in Asmx a better solution than the async call ? pls send me any link to example, where...
0
by: Ken T. | last post by:
I have questions regarding what happens on the web server side during an asynchronous web method call when the client aborts its request via .Abort() call. Background: My client app...
7
by: jtbjurstrom | last post by:
Bear with me because we are new to WCF and have been going through documentation and samples trying to absorb as much as possible in a short amount of time. Any suggestions would be much...
1
by: jan.loucka | last post by:
I'm developing WinForms application in .NET 2.0 that talks to web service. The automatically generated proxy (reference class) has got methods for both synchronous and asynchronous invocations of...
1
by: jan.loucka | last post by:
I'm developing WinForms application in .NET 2.0 that talks to web service. The automatically generated proxy (reference class) has got methods for both synchronous and asynchronous invocations of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.