OK, Thanks for clearing that up. I was very confused becuase the Begin/End
methods are available for the Web Clients and Async for the Windows Clients.
I dug a little more in MSDN help (where sometimes it shows the old way and
sometimes the new) and found the following MSDN Topic to the most helpful for
my situation:
How to: Access an XML Web Service Asynchronously in Managed Code link is
internally at
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_radcon/html/0311dbe2-e7dc-43e0-915a-ff3e35aee084.htm
My VB client side code turned out something like this:
At the top of my class...
Dim WithEvents myWebService As New SecurityService.SecurityService
'Event that fires when the service method is finished and contains the results
Private Sub ApplicationOptionComplete(ByVal sender As Object, _
ByVal completed As
SecurityService.ApplicationOption_GetRecordsComple tedEventArgs) _
Handles myWebService.ApplicationOption_GetRecordsCompleted
' Insert code to implement the method here
Try
'The passed back information is contained in the .Result property
Dim MyAppOptionCol As New
ApplicationOptionCollection(completed.Result)
Dim MyAppSetting As ApplicationSetting
MyAppSetting = mAppSettingCol.GetByOid(NodeIndex)
PopulateForm(MyAppSetting, MyAppOptionCol)
System.Windows.Forms.Cursor.Current = Cursors.Default
Catch ex As Exception
HandleError(ex)
End Try
End Sub
Code that fires the Asynch method:
'Asynch Call
myWebService.Credentials =
System.Net.CredentialCache.DefaultCredentials
myWebService.ApplicationOption_GetRecordsAsync(Get UserGuid, AppSettingOid)
I hope this might help someone else.
George
"Giulio" wrote:
Hi, I had the same problem a few days ago... I learned about
asyncronous call (on MSDN) from client to web service, but the methods
"begininvoke" end "endInvoke" are supported and automatically created
only in .NET 2003!
In Visual Studio 2005 it is quite different and very simple. This is my
code client-side (C#, non VB, but the same logic...):
try
{
mywebServiceInstance.WebMethodNameCompleted +=
new
localhost.WebMethodNameCompletedEventHandler(myweb ServiceInstance_WebMethodNameCompleted);
mywebServiceInstance.WebMethodNameAsync(parameters );
}
//the autogenerated method WebMethodNameAsync is the equivalent of
//Begin... and End..., and it returns void
catch (SoapException se)
{
MessageBox.Show(se.Message, "SoapException");
}
//this is my handler of async transaction completed
private void mywebServiceInstance_WebMethodNameCompleted(object
sender, localhost.WebMethodNameCompletedEventArgs e)
{
Variable result;
try
{
result = e.Result;
}
...
It works good!
Tell me if you understood...
Ciao!!!