Using the WebService component
Then use the document.getElementById() method to retrieve a reference:var oService = document.getElementById(“service”);
Next,you need to specify a Web service to use by calling useService().The useService() method accepts two parameters: the WSDL file describing the service and a friendly name for the service. A typical call looks like this:oService.useService(sUrl,“FriendlyName”);
This object has a method,callService(), that makes the actual request to the server.The method accepts a function name to call and any number of parameters to pass to that function.When executed, callService() returns a call ID that is necessary when you want to retrieve a value from the result. The format for this method call is as follows:iCallID = oService.FriendlyName.callService(sFuncName, sParam0, sParam1..sParamN);
When the result event is fired,it creates an event object with a special property called result. This property contains an object with all the details about the response.The properties of result are listed in the following table:
So how do you use this object?Here’s a simple example:
In this code, the onresult event handler first checks whether the result it’s handling is the response for the appropriate request (in this way,a single WebService object can handle multiple requests).If the ID of the result matches the call ID, the result is processed.The function ensures that there are no errors; if an error occurs,the detailed error message is returned; otherwise the returned value is displayed.
Of course,it is up to you if you want to use the value property directly or use the raw property to parse the returned SOAP code on your own.
WebService component example
This example uses the Temperature Service described in the sample WSDL earlier. Because the Microsoft WebService component requires you to know only the WSDL location and the name of the operation you want to call, you don’t need the WSDL to get this working.
The Web page for this example consists of a text box (with the ID “txtZip”) and a button (labeled “Get Temperature”).The user enters a zip code into the text box and then clicks the button to get the temperature in that zip code (he calls the Web service). Of course, you also need an element to which you can assign the WebService component. Here is the HTML:
The first function,callWebService(), gets the zip code from the text box and calls the Web service. It first loads the WSDL file with the friendly name Temperature. The next line uses the callService() method, passing in the operation name and the zip code.
The other function,onWebServiceResult(), displays the result of the call. This function uses the same basic algorithm as the example earlier to check whether the result ID is equal to the call ID.It then reports either an error or the returned value.
Java Script Related Tutorials
|Adv Java Tutorial||Core Java Tutorial|
|Java-Springs Tutorial||Java Servlets Tutorial|
|EJB(Enterprise JavaBeans) Tutorial||JavaServer Faces (JSF) Tutorial|
|Java Swing Tutorial||Java Tutorial|
|JavaMail API Tutorial||Java 8 Tutorial|
|Java XML Tutorial||Java Bean Utils Tutorial|
|The Java Debugger (JDB) Tutorial||Java.math Package Tutorial|
Java Script Related Interview Questions
|Java Script Interview Questions||Adv Java Interview Questions|
|Core Java Interview Questions||Java-Springs Interview Questions|
|Java Servlets Interview Questions||EJB(Enterprise JavaBeans) Interview Questions|
|JavaServer Faces (JSF) Interview Questions||Java Swing Interview Questions|
|Java 8 Interview Questions||Java XML Interview Questions|
|JavaFX Interview Questions||The Java Debugger (JDB) Interview Questions|
Java Script Related Practice Tests
|Java Script Practice Tests||Adv Java Practice Tests|
|Core Java Practice Tests||Java-Springs Practice Tests|
|Java Servlets Practice Tests||EJB(Enterprise JavaBeans) Practice Tests|
|JavaServer Faces (JSF) Practice Tests||Java 8 Practice Tests|
Java Script Tutorial
Browser And Operating System Detection
All About Events
Advanced Dom Techniques
Forms And Data Integrity
Drag And Drop
Interacting With Plugins
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.