Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 6th, 2004, 07:41 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default Calling WS from javascript

Hi Experts,

I have written a .net Web Service. I want to invoke a web method from the webservice, pass parameters to the webservice and get the resultant value from the web service using javascript.

Can anyone tell me how to achieve this task?

Please Help....

Thanking you in advance

Regards
Ganesh
__________________
Regards
Ganesh
http://ganeshprof.blogspot.com
Find your solution here...
 
Old December 6th, 2004, 07:51 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If you want to use SOAP invocation then you need to examine the test page generated by going to your web service via IE. You can build this string in JavaScript and add in the parameters. You can then send this XML using the msxml2.XmlHttp class. A full treatment of this is show in the case studies part of Beginning XML.

You could also use the JavaScript web service htc


--

Joe (Microsoft MVP - XML)
 
Old December 7th, 2004, 12:35 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

Thanx Joe for the information.

Do you have any piece of code which can invoke the webservice from JavaScript using SOAP?

Thanx in advance

Regards
Ganesh
 
Old December 8th, 2004, 01:22 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

I got this code (The code is in VB Script) from one of the sites.

Code:
Sub Test()
    Const HOST = "http://localhost/"
    Const URL = "TestWS/TestWS.asmx"
    Const FORMAT = "dd-MMM-yy"

    Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
    xmlhttp.open "GET", HOST & URL & "/GetYourTime?format=" & FORMAT, false

    xmlhttp.send ""
    MsgBox xmlhttp.responseText
End Sub
However, When I run the program I get the following error:

      "Request format is unrecognized."

Can anyone tell me what the error is. Is there a better way of doing this??

Please Help...
Thanx in Advance

Regards
Ganesh
 
Old December 8th, 2004, 05:20 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Ganesh,

Take a look at this: http://imar.spaanjaars.com/QuickDocID.aspx?QUICKDOC=277

Somewhere 2 third down the article, under "Automatically Injecting the Track Info in my Signature", I link to a few other articles that explain how to call a Web Service from JavaScript code.
I used most of the code from those articles in my own and it has worked for me so far....

Cheers,

Imar
 
Old December 8th, 2004, 05:31 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

Thanx Imar for your reply...

I'll Checkout the link

Regards
Ganesh





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to INVOKE any WS on server by WS on client ? Abhinavnaresh ASP.NET 2.0 Professional 1 April 4th, 2008 01:09 PM
calling template with javascript smys123 XSLT 3 November 22nd, 2007 04:13 AM
Calling a javascript function from C# SebFr C# 0 November 3rd, 2006 12:05 PM
calling javascript from flash Adam H-W Flash (all versions) 2 March 17th, 2004 11:26 AM
calling webservices from Javascript.. wb25 J2EE 1 February 20th, 2004 10:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.