HighTechTalks DotNet Forums  

do u know to call async webmethod from javascript?

Dotnet Framework (Webservices) microsoft.public.dotnet.framework.webservices


Discuss do u know to call async webmethod from javascript? in the Dotnet Framework (Webservices) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
jojoba@gmail.com
 
Posts: n/a

Default do u know to call async webmethod from javascript? - 12-11-2007 , 07:47 PM






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_speech.GenerateSpeechDataForText"
but now im not sure how to call it.
Any ideas?
Thx for any help here...greatly appreciated
matt

WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class WebService_speech : System.Web.Services.WebService
{
public System.Speech.Synthesis.SpeechSynthesizer TtsVoice;

public WebService_speech()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}

public delegate string GenerateSpeechDataForTextAsyncStub(string
text);

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

//state monitor for the GenerateSpeechDataForText service
public class MyState
{
public object previousState;
public GenerateSpeechDataForTextAsyncStub asyncStub;
}

//start the GenerateSpeechDataForText method
[WebMethod]
public IAsyncResult BeginGenerateSpeechDataForText(string text,
AsyncCallback cb, object s)
{
GenerateSpeechDataForTextAsyncStub stub = new
GenerateSpeechDataForTextAsyncStub(GenerateSpeechD ataForText);
MyState ms = new MyState();
ms.previousState = s;
ms.asyncStub = stub;
return stub.BeginInvoke(text, cb, ms);
}

//end the GenerateSpeechDataForText method
[WebMethod]
public SpeechData EndGenerateSpeechDataForText(IAsyncResult call)
{
MyState ms = (MyState)call.AsyncState;
return ms.asyncStub.EndInvoke(call);
}
}


Reply With Quote
  #2  
Old   
Spam Catcher
 
Posts: n/a

Default Re: do u know to call async webmethod from javascript? - 12-13-2007 , 12:05 AM






jojoba (AT) gmail (DOT) com wrote in news:6e3b64fc-348f-45d8-885c-71a90b474574
@s19g2000prg.googlegroups.com:

Quote:
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_speech.GenerateSpeechDataForText"
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...



Quote:
Any ideas?
Thx for any help here...greatly appreciated
matt

WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class WebService_speech : System.Web.Services.WebService
{
public System.Speech.Synthesis.SpeechSynthesizer TtsVoice;

public WebService_speech()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}

public delegate string GenerateSpeechDataForTextAsyncStub(string
text);

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

//state monitor for the GenerateSpeechDataForText service
public class MyState
{
public object previousState;
public GenerateSpeechDataForTextAsyncStub asyncStub;
}

//start the GenerateSpeechDataForText method
[WebMethod]
public IAsyncResult BeginGenerateSpeechDataForText(string text,
AsyncCallback cb, object s)
{
GenerateSpeechDataForTextAsyncStub stub = new
GenerateSpeechDataForTextAsyncStub(GenerateSpeechD ataForText);
MyState ms = new MyState();
ms.previousState = s;
ms.asyncStub = stub;
return stub.BeginInvoke(text, cb, ms);
}

//end the GenerateSpeechDataForText method
[WebMethod]
public SpeechData EndGenerateSpeechDataForText(IAsyncResult call)
{
MyState ms = (MyState)call.AsyncState;
return ms.asyncStub.EndInvoke(call);
}
}




--
spamhoneypot (AT) rogers (DOT) com (Do not e-mail)


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.