0 Replies Latest reply on Oct 15, 2010 7:36 PM by metal_312

    Web Service problem

    metal_312

      Hi everyone,

       

      I'm a newbie in AS2.0. I tried to test the SOAP with Webservice using 2 methods: Webservice class and XML's SendAndLoad method.

       

      The first one i use webservice class and run correctly


      import mx.services.*;

      celsius_txt.border=true;
      // ignore XML white space
      XML.prototype.ignoreWhite = true;
      var ConvertService = new WebService("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL");

      ConvertService.onLoad=trace("loading")
      // Construct an XML object to hold the server's reply

      // this function triggers when the login_btn is clicked
      send_btn.onRelease = function() {
      trace("1");
      resultObject = ConvertService.CelsiusToFahrenheit(celsius_txt.text);
      resultObject.onResult=function(result){
         trace(result);
        
      }
      };

       

      The second one i use XML's SendAndLoad method to send and XML document to the Web service, but error ocurr

       

      celsius_txt.border=true;

      // ignore XML white space
      XML.prototype.ignoreWhite = true;
      // Construct an XML object to hold the server's reply
      var respondXML:XML = new XML();
      var requestXML:XML = new XML();
      // this function triggers when an XML packet is received from the server.
      respondXML.onLoad = function(success:Boolean) {
      if (success) {
      trace(respondXML);
      trace("3");
      }
      };
      requestXML.onLoad = function(success:Boolean) {
      if (success) {
      //loginXML.send("http://www.w3schools.com/webservices/tempconvert.asmx/CelsiusToFahrenheit");
      requestXML.sendAndLoad("http://tempuri.org/CelsiusToFahrenheit",respondXML);
      trace("2");
      }
      };
      send_btn.onRelease = function() {
      requestXML.load("SendAndLoad.xml");
      trace("1");
      };

       

      The error display when i run this script is : "Error Opening URL". I guess i have enter a wrong server address at

       

      requestXML.sendAndLoad("http://tempuri.org/CelsiusToFahrenheit",respondXML);

       

      This URL i got when i read the WSDL:

      http://www.w3schools.com/webservices/te ... .asmx?WSDL

       

       

      i have tried some other address, but could not figure it out.

       

      I attach my 2 program here, can you help me to make it work?

       

      Thank you very much!