473,809 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

do u know to call async webmethod from javascript?

Hi

I am running asp.net ajax (vs 2008)
I have the following webservice listed below.
However, i have no idea how to call this from javascript.
Originally, before i started using the BeginXXX and EndXXX as per
http://msdn2.microsoft.com/en-us/library/aa480516.aspx
I could easily call the webmethod via in this case
"WebService_spe ech.GenerateSpe echDataForText"
but now im not sure how to call it.
Any ideas?
Thx for any help here...greatly appreciated
matt

WebService(Name space = "http://tempuri.org/")]
[WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
[System.Web.Scri pt.Services.Scr iptService]
public class WebService_spee ch : System.Web.Serv ices.WebService
{
public System.Speech.S ynthesis.Speech Synthesizer TtsVoice;

public WebService_spee ch()
{
//Uncomment the following line if using designed components
//InitializeCompo nent();
}

public delegate string GenerateSpeechD ataForTextAsync Stub(string
text);

//meat of the method (heavy lifting done here)
//where the actual speech data is extracted from the text
public SpeechData GenerateSpeechD ataForText(stri ng text)
{
//do speech stuff here
//i removed the processing code
return SpeechData_;
}

//state monitor for the GenerateSpeechD ataForText service
public class MyState
{
public object previousState;
public GenerateSpeechD ataForTextAsync Stub asyncStub;
}

//start the GenerateSpeechD ataForText method
[WebMethod]
public IAsyncResult BeginGenerateSp eechDataForText (string text,
AsyncCallback cb, object s)
{
GenerateSpeechD ataForTextAsync Stub stub = new
GenerateSpeechD ataForTextAsync Stub(GenerateSp eechDataForText );
MyState ms = new MyState();
ms.previousStat e = s;
ms.asyncStub = stub;
return stub.BeginInvok e(text, cb, ms);
}

//end the GenerateSpeechD ataForText method
[WebMethod]
public SpeechData EndGenerateSpee chDataForText(I AsyncResult call)
{
MyState ms = (MyState)call.A syncState;
return ms.asyncStub.En dInvoke(call);
}
}

Dec 12 '07 #1
1 2114
jo****@gmail.co m wrote in news:6e3b64fc-348f-45d8-885c-71a90b474574
@s19g2000prg.go oglegroups.com:
Hi

I am running asp.net ajax (vs 2008)
I have the following webservice listed below.
However, i have no idea how to call this from javascript.
Originally, before i started using the BeginXXX and EndXXX as per
http://msdn2.microsoft.com/en-us/library/aa480516.aspx
I could easily call the webmethod via in this case
"WebService_spe ech.GenerateSpe echDataForText"
but now im not sure how to call it.
I don't think Async callbacks are standards compliant... so I don't
think you'll be able to call them from AJAX...
Any ideas?
Thx for any help here...greatly appreciated
matt

WebService(Name space = "http://tempuri.org/")]
[WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
[System.Web.Scri pt.Services.Scr iptService]
public class WebService_spee ch : System.Web.Serv ices.WebService
{
public System.Speech.S ynthesis.Speech Synthesizer TtsVoice;

public WebService_spee ch()
{
//Uncomment the following line if using designed components
//InitializeCompo nent();
}

public delegate string GenerateSpeechD ataForTextAsync Stub(string
text);

//meat of the method (heavy lifting done here)
//where the actual speech data is extracted from the text
public SpeechData GenerateSpeechD ataForText(stri ng text)
{
//do speech stuff here
//i removed the processing code
return SpeechData_;
}

//state monitor for the GenerateSpeechD ataForText service
public class MyState
{
public object previousState;
public GenerateSpeechD ataForTextAsync Stub asyncStub;
}

//start the GenerateSpeechD ataForText method
[WebMethod]
public IAsyncResult BeginGenerateSp eechDataForText (string text,
AsyncCallback cb, object s)
{
GenerateSpeechD ataForTextAsync Stub stub = new
GenerateSpeechD ataForTextAsync Stub(GenerateSp eechDataForText );
MyState ms = new MyState();
ms.previousStat e = s;
ms.asyncStub = stub;
return stub.BeginInvok e(text, cb, ms);
}

//end the GenerateSpeechD ataForText method
[WebMethod]
public SpeechData EndGenerateSpee chDataForText(I AsyncResult call)
{
MyState ms = (MyState)call.A syncState;
return ms.asyncStub.En dInvoke(call);
}
}



--
sp**********@ro gers.com (Do not e-mail)
Dec 13 '07 #2

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

Similar topics

3
1967
by: Giovanni Bassi | last post by:
Hello Group, I am running an operation in a different thread. There are resources that are released when the thread is done running. This is done at the end of the execution as it raises an event, and then the operation handling this event calls threaded object's dispose method. The problem is: If an exception is thrown the event is never raised, the operation never executes dispose and my resources get stuck on the memory until the app...
4
3224
by: Paul | last post by:
Hi, I've been struggling with this today, I'm developing a DotNet2.0 website in C# that needs to call a long running data query. Obviously this is a good candidate for an Asynchronous call, so the page can carry on rendering whilst the call is taking place and also returning the ASP.NET worker thread to service another page request (for scalability). I have developed a very basic asynchronous object (for testing, that reproduces the same...
3
3599
by: KaNos | last post by:
Hi, "robot script pages" are html+javascript pages, can be played in aspx player. So in this tech, robot call aspx player's function (an interface is sheared) and wait a result synchronously with a javascript method. I try it with GetCallbackEventReference but this tech works async. Could I use a javascript function with a sync call ? Thaks for responses,
0
961
by: karlag92 | last post by:
Using .Net 1.1, in our Windows Forms Application we were taking advantage of the async functionality that is auto generated by c# for Web Service calls. We were doing it almost exactly like the first example here: http://msdn2.microsoft.com/en-us/library/55xs7d7f(VS.71).aspx Out WebMethod however had a definition like something like this:
2
5226
by: Zeba | last post by:
Hi guys! I'm new to JS / Ajax; I've been trying to do an Ajax call to my Webservice ( I'm using C# for code-behind). I'm not using any of the libraries available. I am sending my CustID to the webservice and the webservice returns a Dataset that contains various customer details taken from database. I have tested that the Webservice itself works. But my ajax call is not working. My ajax call is something like :
4
13039
by: faraz | last post by:
I have a javascript function that i want to call masterpage load method called. I cant add onLoad event of body or table in master page. I have put the call to script function in <form>, it works on every pageLoad. seems my problem is solved. But when the pages uses UpdatePanel and it gets asynchronously postback. the function call at master page doesnt execute????? thought master page Load event gets called even when pages are in...
2
5579
by: jojoba | last post by:
Hello to all! I have a fairly simple webservice running in asp.net ajax under c# (vs 2008). I built the service and it runs just dandy when i test it by itself in visual studio. However, to make it work, i had to break up the webmethod into the BeginXXX, EndXXX model as per http://msdn2.microsoft.com/en-us/library/aa480516.aspx But now, i can no longer call this method from javascript (since to
0
2404
by: anithaapr05 | last post by:
Dear All, I have try to call the webmethod inside a master page browser close javascript function.It not working. This is my scriptcode: function BrowserClose() { var getValues = "webmethod"; PageMethods.ClearValues(getValues,OnSucceeded);
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10114
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7651
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.