1 Reply Latest reply on Aug 9, 2010 9:47 PM by Balakrishnan V

    addsimpleHeader

    alrossers

      Fellow devs,

       

      I'm trying to call a web service by passing a SOAP parameter/header to the method, using the following code:


      import mx.rpc.soap.*;

      import mx.core.*;

      import mx.rpc.events.*;

      import fl.data.DataProvider;

      import com.adobe.crypto.WSSEUsernameToken;


      var myWebService = new WebService();

      myWebService.addSimpleHeader

      ("header3", "http://www.w3.org/2001/XMLSchema", "symbol","MSFT");

      myWebService.addEventListener("load", loadDone);


      //myWebService.loadWSDL("http://www.webservicex.net/country.asmx?WSDL");

      myWebService.loadWSDL("http://www.webservicex.net/stockquote.asmx?wsdl");


      var myOperation:Operation;


      function loadDone(evt:LoadEvent)

      {

      myOperation = Operation(myWebService.getOperation("GetQuote"));

      myOperation.addEventListener("fault", wsError);

      myOperation.addEventListener("result", wsResult);

      myOperation.send();

      }


      function wsError(evt:FaultEvent)

      {

       

      }


      function wsResult(evt:ResultEvent)

      {

      var xml:XML = XML(evt.result);

      Test.text = xml.toString();

      }

       

      If I just run that code without dealing with parameter/header (see commented out line), it runs fine.  But when I try to pass in a parameter via addsimpleheader, it always returns "exception".  The web service country.asmx returns all countries; it doesn't need any parameters.  That's the one that works fine, without the addsimpleHeader.  But stockquote.asmx requires you to pass in a parameter, which is why I'm trying to get addsimpleHeader to work.

       

      Any suggestions?

       

       

      Thanks,

       

      Alan