Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / December 2007

Tip: Looking for answers? Try searching our database.

do u know to call async webmethod from javascript?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jojoba@gmail.com - 12 Dec 2007 00:47 GMT
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(GenerateSpeechDataForText);
       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);
   }
}
Spam Catcher - 13 Dec 2007 05:05 GMT
jojoba@gmail.com wrote in news:6e3b64fc-348f-45d8-885c-71a90b474574
@s19g2000prg.googlegroups.com:

> Hi
>
[quoted text clipped - 6 lines]
> "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...

> Any ideas?
> Thx for any help here...greatly appreciated
[quoted text clipped - 53 lines]
>     }
> }

Signature

spamhoneypot@rogers.com (Do not e-mail)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.