Asynchronous web service calls by TCP

Hello,

I need to make multiple simultaneous asynchronous calls to a web service using WSE 3.0. To make the asynchronously call I use the event based approach by registering a handler for FooCompleted events and calling FooAsync like this:

proxy.FooCompleted += new FooCompletedEventHandler (OnFooCompleted);
proxy.FooAsync (...);
...
void OnFooCompleted (Object source, FooCompletedEventArgs e)
{
    // Called when Foo completes
}

This work fine for a single call. But when I call FooAsync() multiple times simultaneous, like this:

// Distinguish among asynchronous operation by providing a unique //Guid.NewGuid() vallue for each call
for(int i=0; i<=10; i++)
   proxy.FooAsync (Guid.NewGuid());

I get the following exception

[System.InvalidOperationException] = {"WSE102: The asynchronous operation has already completed. Invoke just once the End portion of an asynchronous operation, with an instance of IAsyncResult."}

It is worth motioning that everything works fine when we use HTTP to call the web service. That is when we call the web service without using WSE.

We used the WSE tool to generate the proxy client:
>Wsewsdl3.exe soap.tcp://localhost:2100/MyWebService /type:webClient

Thanks on before hand
/Ershad



Answer this question

Asynchronous web service calls by TCP

  • AmyD

    We are unable to get that working too. Even using multiple Proxies does not seem to work properly when communicating with a remote server.

    I would love to see sample code that spawns multiple threads, each thread creating its own proxy instance, and asynchronously calling the same remote web service method.

    We simply cause WSE2127 Operation Timed Out consistantly.

    The only way we were able to accomplish it was be creating multiple PROCESSES....

    Has anybody been able to do it successfully

    Thanks,

    -Mark


  • ati9200

    Hello

    Thanks a lot for your answer but this is really not convenient. As Web Service "Enhancement", it is better to have the same behaviour as Web Service asynchronous calls by HTTP at least. Do you think that this is something to be fixed in the WSE 3.0 service pack   < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

    Thanks


  • Amith

    "you are not able to have overlapping asynchronous calls from a single proxy"

    Wow. This is a big deal. Was anyone else caught off-guard by this, or should I feel like an idiot for not noticing this in the documentation Of course, I can find this warning now that I specifically search for it, but I read a lot of WSE documentation and never knew WSE proxies couldn't make multiple async calls at once. It's not mentioned in the "Known Issues" or readme: http://msdn2.microsoft.com/en-us/webservices/aa740669.aspx

    Is it considered bad practice to keep one instance of the proxy class and reuse it for multiple calls That's what I've been doing in all my applications. The existence of the "userState" parameter suggested to me that this was the normal way to do things.

    Edit: After further investigation, multiple async calls on the same proxy seem to be working fine. Either this has been fixed, or I'm just not able to find the right conditions to reproduce it.


  • Paul Misoni

    The WSE 3.0 proxies are not thread safe and therefore you are not able to have overlapping asynchronous calls from a single proxy. If you want to have multiple async calls from the same client, you need to have separate proxies for each request.

    This is a limitation of the proxies that are generated via wsewsdl3.exe

    Thanks, Mark Fussell

    WSE Program Manager



  • Asynchronous web service calls by TCP