Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Please wait page while webservice returns

Posted on 2003-11-19
4
Medium Priority
?
300 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

688 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