472,977 Members | 1,686 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,977 software developers and data experts.

Confusion over Asynchronous Web Methods

I am building Web Services using Visual Basic 2005 in VB.Net 2.0 and based on
MSDN Help and various other books I am lead to believe that when I generate a
proxy I should have a BeginMethodName and EndMethodName for each web method
that I build.

What I find is that when I consume the Web Service with a Web Form Client
the methods are there but when I consume the same Web Service with a Windows
Client the Begin/End methods are not there. I do see a MethodNameAsync
method and wondering if that is the same as the BeginMethodName.

Does anyone have any explaination for this?

George

Jun 7 '06 #1
2 1425
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!!!

Jun 8 '06 #2
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!!!

Jun 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: hs | last post by:
H I am using the articles by Matt Powell about server side asynchronous web methods (as well as the client side article) However i dont see any improvements to the speed of my application. I'm...
8
by: Z D | last post by:
Hello, I'm having a strange problem that is probably due to my lack of understanding of how threading & COM Interop works in a WinForms.NET application. Here's the situation: I have a 3rd...
1
by: Julian Hershel | last post by:
Reading about asynchronous programming (ms-help://MS.NETFrameworkSDK/cpguidenf/html/cpconasynchronousdesignpatterno verview.htm) I could not clarify some doubts. Hope you can help me. 1) Are...
5
by: rgarf | last post by:
I have a C++ application that consumes a web service. I would like to call the web service asynchronously so my C++ application can do other processing in between. My proxy file does not have any...
1
by: org | last post by:
Hi, I'm developing a web service with should be used by an .NET CF2 client and an .NET 2.0 Windows client. I've tried to put all the connection logic into one class, which could be used in...
4
by: taskswap | last post by:
I have a legacy application written in C that I'm trying to convert to C#. It processes a very large amount of data from many clients (actually, upstream servers - this is a mux) simultaneously. ...
1
by: dba123 | last post by:
I need to perform Asynchronous Inserts using DAAB. So far I have a method which does an insert but how can I do this Asyncronously so that it does not affect the load on our public production...
3
by: archana | last post by:
Hi all, I have one confusion regarding threading in windows service which is developed in c#. What i am doing is on 'onstart' event i am starting one thread. In thread procedure i am...
4
by: Varangian | last post by:
Hello, the subjects says much I think. Basically I want to create my own long running tasks asynchronously. I want to have a BeginMyOwnLongTediousMethod and EndMyOwnLongTediousMethod You...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.