topical media & game development

talk show tell print

professional-javascript-17-IEWebServiceExample.htm / htm

          <title>IE Web Service Example</title>
          <script type="text/javascript">
          var iCallID = null;
          var sWSDL = "";
          function callWebService() {        
              //get the value from the textbox
              var sZip = document.getElementById("txtZip").value;
              //get reference to the service element
              var oService = document.getElementById("service");
              //tell the service element to parse the WSDL file
              oService.useService(sWSDL, "Temperature");
              //make the call using the zip code the user entered
              iCallID = oService.Temperature.callService("getTemp", sZip);
          function onWebServiceResult() {
              var oResult = event.result;
              //make sure the result ID matches the call ID
              if ( == iCallID) {
                  //get the <div> to display results
                  var oDiv = document.getElementById("divResult");
                  //is there an error?
                  if (oResult.error) {
                      alert("An error occurred:" + oResult.errorDetail.string);        
                  } else {
                      alert("It is currently " + oResult.value + " degrees in that zip code.");
          <p><input type="text" id="txtZip" size="10" /><input type="button" value="Get Temperature" onclick="callWebService()" />
          <div id="service" style="behavior:url(" onresult="onWebServiceResult()"></div>

(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.