Example of JavaScript to Invoke Web Services
The following code shows the use of the framework to invoke two web services from the Erewhon system, which is the Jade example system.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <title>JavaScript Web Service Consumer test</title> <script type="text/javascript" src="Classes.js"></script> <script type="text/javascript" src="WSUtil.js"></script> <script type="text/javascript" src="WebServiceOverHttpApp_types.js"></script> <script type="text/javascript" src="WebServiceOverHttpApp_api.js"></script> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> var client = new Jade.WebServiceOverHttpApp_Types.Client( { // Construct the parameter name:"Barry Ogen", address1:"123 Straight St", address2:"Newtown", address3:"Te Anau", home:"031234123", fax:"03987654", email:"barry@gmail.com", webSite:"www.BarryOgen.com"}); Jade.WebServiceOverHttpApp.updateClientWithProxy(client); // Invoke the service Jade.WebServiceOverHttpApp.getClient("Barry Ogen", {cache:true, callback:function(xml) { // invoke the service var email = $(xml).find("email").text(); // use jQuery to extract information we are interested in alert("Barry's email address is now: " + email);}}); </script> </head> <body> </body> </html>