0 Replies Latest reply on Jan 29, 2007 1:22 PM by Mark.P.

    soap headers -

    Mark.P. Level 1
      I've been trying for, way too long now, to convert this older ActionScript 2.0 from Flash into 3.0 for Flex. The real problem I'm having is I can't seem to pass the UserName and Password to my webservice as I'm doing here. Can anyone please help with this? If I can do it in Flash 7, I sure as heck should be able to do it with Flex.... Don't you think? I've seen others posting this around the web but have yet to come across someone that has done it with any level of success.

      Thanks




      function addSOAPHeaderFix() {
      if (mx.services.PendingCall.prototype.__encodeSOAPHeader__ != null) {
      return;
      }
      mx.services.PendingCall.prototype.__encodeSOAPHeader__ = mx.services.PendingCall.prototype.encodeSOAPHeader;
      mx.services.PendingCall.prototype.encodeSOAPHeader = function() {
      var theService = this.myCall.wsdlOperation.wsdl.serviceProxy.service;
      // here is how to do headers that apply to all calls
      for (var i = 0; i < theService.headersForAllCalls.length; i++) {
      this.addHeader(theService.headersForAllCalls );
      }
      // here is how to do headers that apply to only one specific call
      for (var j = 0; j < theService.headersForOneCall.length; j++) {
      this.addHeader(theService.headersForOneCall[j]);
      }
      theService.headersForOneCall = null;
      this.__encodeSOAPHeader__();
      };
      }
      addSOAPHeaderFix();
      var service:mx.services.WebService;
      service = new mx.services.WebService(" http://radar.us.na.ey.net/RadarXML.asmx?WSDL");
      var header1 = new XML('<AuthHeader xmlns=" http://tempuri.org/"><UserName>eyadmin</UserName><Password>eyadmin</Password></AuthHeader> ');
      service.headersForAllCalls = new Array();
      service.headersForAllCalls.push(header1);
      var myObj:mx.services.PendingCall = service.PullXML();
      //
      // IF no fault has occured then XML is received \\
      myObj.onResult = function(result) {
      // change results to Flash XML \\
      _global.theResults = new XML(result);
      // strip out any white space \\
      theResults.firstChild.stripWhite();
      //load necessary script \\
      loadAndSeperate();
      };
      // IF a fault occures get XML \\
      myObj.onFault = function(result) {
      _global.theResults = new XML();
      theResults.ignoreWhite = true;
      theResults.onLoad = function(success) {
      loadAndSeperate();
      };
      // load the XML into the XML object
      theResults.load("PublishXML/PublishedProjects.xml");
      };