C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » Webservices »

Calling web service mehod asynchronously..


Posted Date: 24 Oct 2009      Posted By: Ron Kittu      Member Level: Silver     Points: 1   Responses: 3



hi,
how do we call a method (web service method) from a client application asynchronously..?? what are the syntactical diff between doing it normally and assynchronously......??





Responses

Author: Naganathan    24 Oct 2009Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

using callback function and delegates we can consume webservice asynchronously .

Regards,
Naganathan



Author: Chandru    28 Oct 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

Try to use ajax goto http://netprogramminghelp.com,you can find article.

Chandru
SilverlightScripting.com



Author: Joby    17 Nov 2009Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

The method which invok the webservice
private void button1_Click(object sender, System.EventArgs e)
{
peter.Service1 ws = new CSharpTester.peter.Service1();
//GetDataSet() is the method in the webservice. Webservice //automatically expose BeginGetDataSet() and EndGetDataSet() for my //GetDataSet() method. Intellisence will give you both these method //when ur typying the webservice object.(here ws.)
//"Testing 1234" is the parameter whis is expected by webmethod
//WsCallback is the callback method given below, which is defined by //me
ws.BeginGetDataSet("Testing 1234",new AsyncCallback(WsCallback),ws);
}

private void WsCallback( IAsyncResult ar)
{
//Create an object of wesrvice of callback method's IAsyncResult //param
peter.Service1 ws = (peter.Service1)ar.AsyncState;
//EndGetDataSet() is exposed by system itself.
DataSet ds = ws.EndGetDataSet(ar);
private void button1_Click(object sender, System.EventArgs e)
{
peter.Service1 ws = new CSharpTester.peter.Service1();
ws.BeginGetDataSet("Testing 1234",new AsyncCallback(WsCallback),ws);
}

private void WsCallback( IAsyncResult ar)
{
peter.Service1 ws = (peter.Service1)ar.AsyncState;
//The webmethod GetDataSet() is returning a dataset.
DataSet ds = ws.EndGetDataSet(ar);
//Just assigning the value to label
this.label1.Text=(string)ds.Tables[0].Rows[0]["test"];
}



Post Reply
You must Sign In to post a response.
Next : Web service proxy
Previous : Webservices Data Types
Return to Discussion Forum
Post New Message
Category: Webservices

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use