Re: Asynchronous web service calls

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Sami Vaaraniemi (samivanospam_at_pleasejippii.fi)
Date: 08/05/04


Date: Thu, 5 Aug 2004 14:04:44 +0300

Some of the web method calls are probably failing - my guess is its the "The
request failed with HTTP status 403" exception (i.e., you're exceeding the
web request queue in the server).

To see the errors, modify your code like so:

private void btnRun_Click(object sender, System.EventArgs e)
{
    localhost.SimpleService service = new localhost.SimpleService();
    for (int index = 0; index < 50; index++)
    {
        System.Diagnostics.Debug.WriteLine("Begin Do Nothing");
        service.BeginDoNothing(new AsyncCallback(this.AWSCallback),
service); // <= note the 'service' parameter
    }
}

private void AWSCallback(IAsyncResult ar)
{
    try
    {
        localhost.SimpleService service =
(localhost.SimpleService)ar.AsyncState;
        service.EndDoNothing(ar);
        System.Diagnostics.Debug.WriteLine("End Do Nothing");
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine(ex.ToString());
    }
}

hth,
Sami

"Russell Mason" <google@russellmason.com> wrote in message
news:5efeca96.0408050154.57605e91@posting.google.com...
> Hi
>
> I am trying to do some tests using asynchronous web service calls and
> have hit a problem. I have reduced the problem to the minimum so
> hopefully someone will be able to spot what's going on.
>
> I have a web service with 1 method:
>
> [ WebMethod() ]
> public void DoNothing()
> {
> System.Diagnostics.Debug.WriteLine("-- Doing Nothing");
> }
>
>
> and a Windows form client that calls the web service:
>
> private void btnRun_Click(object sender, System.EventArgs e)
> {
> localhost.SimpleService service = new localhost.SimpleService();
> for (int index = 0; index < 50; index++)
> {
> System.Diagnostics.Debug.WriteLine("Begin Do Nothing");
> service.BeginDoNothing(new AsyncCallback(this.AWSCallback), null);
> }
> }
>
> private void AWSCallback(IAsyncResult ar)
> {
> System.Diagnostics.Debug.WriteLine("End Do Nothing");
> }
>
> When I run this I get 50 "Begin Do Nothing" outputs to the debug
> window and 50 "End Do Nothing" outputs, but I only get a few (maybe
> 10, maybe 15) "-- Doing Nothing" outputs.
>
> When I look at the soap messages using MSSoapT I can see the that 50
> requests are being made, but after 10 or 15 calls the normal message:
>
> <?xml version="1.0" encoding="utf-8"?>
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <soap:Body>
> <DoNothing xmlns="http://tempuri.org/" />
> </soap:Body>
> </soap:Envelope>
>
> becomes:
>
> </Message>
>
> which is obviously invalid and no more calls are processed. Sometimes,
> maybe after 30 calls, the message seems to be in the correct format
> again but the call is still not processed. Sometimes once a messages
> becomes invalid all subsequent messages are invalid. I can't see a
> clear pattern.
>
> This works fine if called synchronously or if I call it asynchronously
> but put Thread.Sleep(1000) between calls (defeats the purpose of
> asynchronous calls but illustrates a point)
>
>
> Does anyone know what is happening here?
>
> Thanks
> Russell Mason



Relevant Pages

  • Re: Problem with Exception Handling using Web Services
    ... private void checkPassword ... The Exception is definitely thrown, but when I run it in a web browser it ... >> Microsoft Visual C#.NET to interact with the web service. ... >> Adrian Burka ...
    (microsoft.public.dotnet.framework.webservices)
  • RE: Detailed ASP.Net info not displaying in browser
    ... app to refer to this web method on new PC. ... the exception came back in a Microsoft Development Environment ... I recommend you use the simplest web service to diagnose this issue: ... the first pc should only report ...
    (microsoft.public.dotnet.xml)
  • Invoking long running web request asynchronously.
    ... I set oneway attribute in web method. ... What i want is once client called this web method this should start ... connection with web service. ... But in above case exception is also not raised. ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Invoking long running web request asynchronously.
    ... I set oneway attribute in web method. ... What i want is once client called this web method this should start ... connection with web service. ... But in above case exception is also not raised. ...
    (microsoft.public.dotnet.framework.webservices)
  • Workaround to Assembly reference for Managed/Unmaged C++ dll in ASP.Net
    ... Calling C++ library from ASP.NET web service ... (Exception from HRESULT: 0x8007007E) ... 2005 Runtime Libraries on the machine)? ... assemblyName, Boolean starDirective) +32 ...
    (microsoft.public.dotnet.framework.webservices)