Solved

Please wait page while webservice returns

Posted on 2003-11-19
4
295 Views
Last Modified: 2012-05-04
I invoke a webservice from a webapplication, this webservice contains an image which is realtime created, and takes quite a while.

I would like to ask you if you know a method how to show a "Please wait" page while the webservice returns.
In steps:
1. on the first page user clicks to a link which transfers the user to the page that would use the webservice.
2 I should display a page that says please wait the websevice is loading, or something like that
3 I show the page with the the result of the webservice

One more thing: I use a businesslayer object that invokes the webservices, I use the aspx files and their cs files just for representation.


0
Comment
Question by:baloghp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 4

Expert Comment

by:wile_e_coyote
ID: 9779367
You can invoke web services asynchronously using the web service proxy created by .NET.   Check out the following link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnservice/html/service09032002.asp
0
 
LVL 1

Author Comment

by:baloghp
ID: 9805741
Thanks,

But I found an easier way to do this, and I share it with you.

So If you wanna get a picture from websevice, but it takes long the following is a working solutin:
create a storage for the pic in an object that is stored sessiontime.

like:
class BusinessLayer
{
       public byte[] pic= null;
       public void íinvokeWebServiceThatRetrievesTheImage()
       {
                //call the webservice and store it in pic.
        }

}

Create an aspx(let's say preview.aspx) which will show the image; on it's onload do the following:

 BusinessLayer bl =(BusinessLayer)Session["BL"];
Page.BufferOutput = false;

if (bl.pic==null)
{
      Response.WriteFile("SomePicWhichIsSmall.jpg");
     bl.invokeWebServiceThatRetrievesTheImage();
}
else
{
     Response.WriteBinary(bl.pic);
}

All you have to do now is to set the source of the IMG tag in the containing page to preview.aspx; and write a little javascript that also sets it to preview.aspx?[some random number or the actual time]. make this javascript to run on Body onload. And you're ready.
Now a little explanation: first when the page loads to the client's browser you haven't even called the webservice. The bl.pic is null. So it will show "SomePicWhichIsSmall.jpg". But because the bufferOutput is turned off it won't wait untill the whole Page_OnLoad is fully finished, it will push the image to the browser immediately. Then, the webservice can take it's time to retrieve your image. When it's finished (and everithing is finished loading on that page) the browser will run your javascript which sets the source of your preview image to the same aspx file but with a so far unknown parameter. This parameter we only need to trick the browser's cache, so it will turn to the server again. This time since your webservice has already been called the bl.pic is not empty but containes the webservice's image. This time this image will be pushed to the browser.
And we got whar we wanted. First an image that says "please wait I'm working" only as long as the job really takes, and as soon as we got the real picture we show it.
One more thing before I finish. Don't ever forget to empty the pic buffer before calling the webservice again, or else it will give the previous webservice picture instead of the "please wait I'm working"  picture.

It took me a while to figure this out but this works fine. Hope someone else can also us the idea. It can be generalized for any kinda information that comes through webservices and takes a while untill you can show it to the user.
Bye now.
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 11747199
PAQed, with points refunded (250)
ee_ai_construct - CS Mod
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question