1 Reply Latest reply on Oct 27, 2011 2:37 AM by mauprice

    Parsing a string variable as baseURL

    mauprice

      I want to use a httpService request to read an XML file which retreives data from the xml file which is the path i want to parse to the Super_Sample1 Class / Function rather than having it as a hard coded path.

       

      I can read the XML file and display the path in a text field.

       

      Once the XML file resoonse is received it then triggers the HTTPService to receive the data using the path from the XLM file.

       

      I get an error when ever I modify the hard coded path to a variable like the {mypath.lastResult} which is where the XML path is returned to.

       

      I hope I explained this clear enough.

       

      Any suggestions on parsing this path to the Function shown below?

       

       

      package services.sample1

      {

      import com.adobe.fiber.core.model_internal;

      import com.adobe.fiber.services.wrapper.HTTPServiceWrapper;

      import mx.rpc.AbstractOperation;

      import mx.rpc.AsyncToken;

      import mx.rpc.http.HTTPMultiService;

      import mx.rpc.http.Operation;

       

      [ExcludeClass]

      internal class _Super_Sample1 extends com.adobe.fiber.services.wrapper.HTTPServiceWrapper

      {

       

       

          // Constructor

          public function _Super_Sample1()

          {

              // initialize service control

              _serviceControl = new mx.rpc.http.HTTPMultiService("http://ibm/sample01-debug/"); <<<<<< This is what I want to replace with a string variable

               var operations:Array = new Array();

               var operation:mx.rpc.http.Operation;

               var argsArray:Array;

       

       

               operation = new mx.rpc.http.Operation(null, "Operation");

               operation.url = "mytest.php";

               operation.method = "GET";

               operation.resultType = Object;

               operations.push(operation);

       

               _serviceControl.operationList = operations; 

       

               preInitializeService();

               model_internal::initialize();

          }

         

          //init initialization routine here, child class to override

          protected function preInitializeService():void

          {

           

          }

         

          /**

            * This method is a generated wrapper used to call the 'Operation' operation. It returns an mx.rpc.AsyncToken whose

            * result property will be populated with the result of the operation when the server response is received.

            * To use this result from MXML code, define a CallResponder component and assign its token property to this method's return value.

            * You can then bind to CallResponder.lastResult or listen for the CallResponder.result or fault events.

            *

            * @see mx.rpc.AsyncToken

            * @see mx.rpc.CallResponder

            *

            * @return an mx.rpc.AsyncToken whose result property will be populated with the result of the operation when the server response is received.

            */

          public function Operation() : mx.rpc.AsyncToken

          {

              var _internal_operation:mx.rpc.AbstractOperation = _serviceControl.getOperation("Operation");

                          var _internal_token:mx.rpc.AsyncToken = _internal_operation.send() ;

              return _internal_token;

          }

          

      }

       

       

      }

        • 1. Re: Parsing a string variable as baseURL
          mauprice Level 1

          It's ok, I have solved it now. I just needed to add another function to load the XML path as below.

           

          public function _Super_Sample1()

              {

                      loadXML();

                    }

                    public function loadXML(url:String=""){

           

                  // initialize service control

                  _serviceControl = new mx.rpc.http.HTTPMultiService();

                   var operations:Array = new Array();

                   var operation:mx.rpc.http.Operation;

                   var argsArray:Array;

           

           

                   operation = new mx.rpc.http.Operation(null, "Operation");

                   operation.url = url;

                   operation.method = "GET";

                   operation.serializationFilter = serializer0;

                   operation.resultElementType = valueObjects.Mytest_return;

                   operations.push(operation);

           

           

                   _serviceControl.operationList = operations; 

           

                   preInitializeService();

                   model_internal::initialize();

              }

             

              //init initialization routine here, child class to override

              protected function preInitializeService():void

              {

               

              }