Giulio Petrucci wrote:
Hi there,
I'm quite a newbie in Web Service programming/using and I'm sorry if my
question could sound quite "stupid". ;-)
As they say, "there are no stupid questions".
Based on past experience with a small minority of questioners, I might
amend that, qualifying the statement with "...as long as the questions
are asked in earnest and the questioner is open to the answers, even if
they don't necessarily like the answer". But IMHO, this qualification
is almost always assumable. :)
I'm working on an application which should request a service to a
WebService, calling its method "FooMethod(...args...)". I've imported
the web reference within my VisualStudio project and tryed to invoke the
method. I noticed that the intellisense expose also:
- an "AsyncFooMethod(...args...(+1 overloads))";
- a "CompleteFooMethod" event;
I haven't used WebService. Sounds like an ASP.NET-specific thing, and
if so there is a newsgroup that is specific to ASP.NET questions that
might be a better place to ask that.
That said...
I supposed they're for async method invocation, right?
So, could you suggest me any "for-very-dummy" resource to learn how to
use them? Expecially examples and code snippets would be appreciated.
MSDN has many good code samples, IMHO. In a cursory search, I wasn't
able to find anything related to WebService that looked like the naming
pattern you describe, so I can't confirm for the specific things you're
talking about. If you're having trouble finding or using the code
samples, you might want to post actual names of classes and methods
you're trying to use.
The basic idea, however, should be simple and should follow the same
asynchronous design other parts of .NET have. Specifically, you call a
method that starts with "Begin..." or "Async...", providing a callback
delegate method (generally you can just write as a parameter the name of
the method you want called when the operation completes). Then in that
callback method, you call the "End..." or "Complete..." method to finish
the operation.
(Note: I'm making some assumptions about the "Async..." and
"Complete..." versions, that they are similar if not identical to the
"Begin..." and "End..." pattern. I haven't actually run into the
Async/Complete naming scheme before, so hopefully it's a valid
assumption to make :) ).
If the operation uses the IAsyncResult interface, you can also check for
completion using an event handle or flag property found in the
IAsyncResult instance, but IMHO the callback is usually the more
convenient and practical mechanism to use.
Pete