473,666 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
+ 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(o bject sender, EventArgs e)
{
sw = new Stopwatch();
sw = Stopwatch.Start New();

Broker broker = new Broker();
string temper = broker.SubmitRe port("reporting Data");

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(st ring reportData)
{
Service reporter = new Service();
reporter.Genera teReportComplet ed += new
GenerateReportC ompletedEventHa ndler(reporter_ GenerateReportC ompleted);
reporter.Genera teReportAsync(r eportData);

return reportData;
}
void reporter_Genera teReportComplet ed(object sender,
GenerateReportC ompletedEventAr gs e)
{
string test = "test";
}

Here is the Service code:

[WebMethod]
public string GenerateReport( string reportingData)
{
System.Threadin g.Thread.Sleep( 10000);
return waiter(reportin gData);
}

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 1249

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

Similar topics

0
1533
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 settings for the logging application block in the app.config for the application. But if you want to use asynchronous logging you have to specify asynchronous logging for all logging types in the app.config of the application and then define the...
15
11762
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 performs the query is contained in a delegate function that I execute via a second thread. On 1 or 2 of the 600+ servers the query hangs. I've tried to use Thread.Join() coupled with a Thread.Abort() but this does not kill the thread. Based on...
2
2333
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 records being inserted? Am I just making a mistake somewhere? (though I don't get double the records if I call the method synchronously.) Thanks, Darryl
0
1548
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 off an Application.DoEvents() when system resources are low and the message loop has queued requests. Here are some snippets of code to describe the problem:
3
1429
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" metatag in HTML. 2) Synchronously call a monitor function on the server that poll the status of the processes, and returns when they are done.
0
1010
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 asynchronous way just does not work. When direction is Inout, web service gets it, but changes does not appear on client side. "In" header works fine. My question is: how to do it?
0
1233
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 asynchronously calls a web method in a "broker" web service that I've written. My broker service method in turn synchronously calls another web service to perform backend processing. This second, synchronous call can take up to a minute to return. My...
1
1566
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. Synchronously everything works fine, but Asynchronously I'm having problems. Intermittently I am getting the following error message in the asynchronous event handler for the call: "Unable to write data to the transport connection: An established...
3
4741
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 counters but after running X requests which executes this "asynchronous" module all other requests go to application queue - so it executes synchronously. Code is based on the following article...
0
8355
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8638
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6191
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5662
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.