473,472 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Calling an asynchronous web service synchronously

I have a windows client that calls web service 1 (Broker) synchronously, web
service 1 then calls web service 2 (Service) asynchronously, web service 2
sleeps its thread for 10 seconds. When I put a stopwatch on the windows
client the call to web service 1 takes a fraction over 10 seconds. What I
would think would happen is that I would get a return from web service 1
alsmost instantly. When I attach the debugger to web service 1, I even see
the return statement get hit instantly, yet the response waits until the
callback is complete. I want the answer to the client not wait for web
service 2 to complete.

-Can anyone help me understand why the call from the client takes 10 seconds
and is not "instant"?
-Is there any way to make the response to the client without waiting for the
callback?

Here is the relevant code:

Client making synchronous call (Broker is a proxy class generated by
wsdl.exe):
private void button3_Click(object sender, EventArgs e)
{
sw = new Stopwatch();
sw = Stopwatch.StartNew();

Broker broker = new Broker();
string temper = broker.SubmitReport("reportingData");

sw.Stop();

TimeSpan ts = sw.Elapsed;

String elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
MessageBox.Show(elapsedTime);
}

Here is the Broker code (Service is a proxy class generated by wsdl.exe)

[WebMethod]
public string SubmitReport(string reportData)
{
Service reporter = new Service();
reporter.GenerateReportCompleted += new
GenerateReportCompletedEventHandler(reporter_Gener ateReportCompleted);
reporter.GenerateReportAsync(reportData);

return reportData;
}
void reporter_GenerateReportCompleted(object sender,
GenerateReportCompletedEventArgs e)
{
string test = "test";
}

Here is the Service code:

[WebMethod]
public string GenerateReport(string reportingData)
{
System.Threading.Thread.Sleep(10000);
return waiter(reportingData);
}

As a note, I tried a counter as well becuase I thought the Sleep may be
sleeping the thread that Broker was running on.

DAvid
Oct 31 '08 #1
0 1237

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

Similar topics

0
by: Ollie Riches | last post by:
I have managed to get asycnhronous logging work for an asp.net application and I wanted some clarification on the method. Normally if the application is logging synchronously it has all the...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
2
by: Darryl A. J. Staflund | last post by:
Hi there, Can anyone tell me why invoking a single SQL insert statement (well, rather, a method that performs a SQL insert) using an asynchronous delegate should result in twice the number of...
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...
3
by: Thomas Nielsen | last post by:
Hi, I need to make a web page that wait for 3 asynchronous processes to finish. So I am considering these options 1) Poll the status of the processes from the web page using the "REFRESH"...
0
by: napssav | last post by:
Hello, I am trying to implement an out SOAP header in a web service function (that is, a SoapHeader with Direction=SoapHeaderDirection). It works fine when I call it synchronously, but...
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...
1
by: JamesK | last post by:
Hi there, Hoping someone might have an idea of whats going on here, I presume I'm in the right forum but not 100%. I have a java web service that I am using with a C# .NET client. ...
3
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi, I need to write asynchronous HTTPModule which will sometimes execute long job. I've written it using AddOnBeginRequestAsync but it still executes synchronously - I am checking performance...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.