Asynchronous web service calls

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default Asynchronous web service calls

    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
    Russell Mason Guest

  2. Similar Questions and Discussions

    1. Asynchronous calls from Java?
      Hi, I want to listen for events on the java side and have a flex method called when something happens. How would I do this? This should be...
    2. Web service calls asynchronous vs synchronous
      The best solution is to design you architecture using the observer pattern(GOF) K,Browne Developer
    3. handling exceptions in asynchronous web service calls
      I have a win forms application that calls a web service asynchronously. Occassionally, the web service call with raise an exception. Unfortunately,...
    4. Asynchronous web service calls, will you still have timeouts
      If I am calling web services asynchronously, will I still have to be concerned with the request timing out? If IIS starts a process (calling a web...
    5. Blocking problem/bug with enableSession=true and asynchronous web service calls?
      Hi, I've found what appears to be a bug with ASP.NET web service method invocation - making it impossible to invoke and get the result of a...
  3. #2

    Default Asynchronous web service calls

    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
    Russell Mason Guest

  4. #3

    Default Re: Asynchronous web service calls

    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.c om...
    > 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

    Sami Vaaraniemi Guest

  5. #4

    Default Re: Asynchronous web service calls

    Thanks, that gets me the exception I was looking for.

    I assumed that sort of exception would be thrown on the call rather
    than the callback. I thought the End... call was only required if you
    wanted to pick up the results.

    Thanks
    Russell Mason



    "Sami Vaaraniemi" <samivanospam@pleasejippii.fi> wrote in message news:<cet3v3$54m$1@phys-news1.kolumbus.fi>...
    > 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.c om...
    > > 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
    Russell Mason Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139