473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 1443
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.