5 Replies Latest reply on Dec 18, 2013 1:54 AM by fiona Lee

    Extending HTTPService breaks <mx:request> style variables

    slaingod Level 1

      This is probably something simple I am doing wrong, or lack of understanding, but I have seen the question asked and not answered elsewhere on the interwebs.

       

      I want to extend HTTPService to add a globally set static rootURL for when the SWF is hosted on a CDN:

       

      package com.something.shared.util
      {
          import mx.rpc.http.mxml.HTTPService;
         
          public class StaticRootHTTPService extends HTTPService
          {
              public static var staticRootURL:String;
              public function StaticRootHTTPService(rootURL:String=null, destination:String=null)
              {
                  if((rootURL == null || rootURL == '') && staticRootURL != null && staticRootURL != '') {
                      rootURL = staticRootURL;
                  } 
                  super(rootURL, destination);
              }
          }
      }

       

      However when I do this, I can't seem to figure out what to do to get mxml style request definition working again:


          <util:StaticRootHTTPService id="models_edit"
              url="/{models}/{editingItem.id}.xml"           
              useProxy="false" method="POST"
              fault="FlexGlobals.topLevelApplication.faultHandler(event);"
              result="saveHandler(event)" showBusyCursor="true"
          >
              <util:request>

      //********* THESE BREAK ************

      // Could not resolve <_method> to a component implementation.
                  <_method>PUT</_method>
      // Could not resolve <company> to a component implementation.
                  <company>{model_name.text}</company>
      // Could not resolve <allowed_streams> to a component implementation.
                  <allowed_streams>{streams.value}</allowed_streams>

      //**********************************
              </util:request>
          </util:StaticRootHTTPService>

       

      Any quick solution? Thanks.

        • 1. Re: Extending HTTPService breaks <mx:request> style variables
          saisri2k2 Level 4

          try this

           

          <components:request>

          <fx:XML>

          <contentType>

          e4x

          </contentType>

          </fx:XML>

           

          </components:request>

           

          each of the request type ahs to bee xml document, so, you have to enclose the name value pair in fx:Xml . hopefully it has to work.

          • 2. Re: Extending HTTPService breaks <mx:request> style variables
            slaingod Level 1

            It is not clear what you are trying to say. This is a Flex 4.1 SDK project using the Flex 3.5 compatibility mode. The 'fx' namespace is not something this project uses currently.

             

            My question is:

            When I use HTTPService directly,

             

                    <mx:request>
                        <_method>PUT</_method>
                        <company>{model_name.text}</company>
                        <allowed_streams>{streams.value}</allowed_streams>
                    </mx:request>

             

            works as expected, but when I subclass HTTPService,

             

                    <util:request>
                        <_method>PUT</_method>
                        <company>{model_name.text}</company>
                        <allowed_streams>{streams.value}</allowed_streams>
                    </util:request>

             

            does NOT work correctly.

             

            How can I get this to work as it does with HTTPService, when I have extended that class?


            Thanks.

            • 3. Re: Extending HTTPService breaks <mx:request> style variables
              Flex harUI Adobe Employee

              Try using -keep-generated-actionscript MXMLC option when just using

              HTTPService to see what it generates.  You may just need to specify an

              <mx:Object> wrapper or <mx:XML> wrapper around those params.

              1 person found this helpful
              • 4. Re: Extending HTTPService breaks <mx:request> style variables
                slaingod Level 1

                Ok, so I think I finally figured out the workaround, tho it requires a lot of hand editing lol.

                 

                Both:

                 

                        <util:request>
                            <mx:Object company="{testBinding}" _method="PUT"/>
                        </util:request>

                 

                 

                 

                Or:

                 

                        <util:request xmlns="">
                            <mx:Object>
                                <mx:company>{testBinding}</mx:company>
                                <mx:_method>PUT</mx:_method>
                            </mx:Object>
                        </util:request>

                 

                Works.

                 

                Thanks for the guidance.

                • 5. Re: Extending HTTPService breaks <mx:request> style variables
                  fiona Lee

                  I have the same question.

                   

                  But I tried the second method and it doesn't work.

                  <base:request xmlns="">

                      <fx:Object>

                       <page>

                        {nowPage}

                       </page>

                      </fx:Object>

                     </base:request>

                  It doesn't works.

                   

                  <base:request xmlns="">

                      <fx:Object page="{nowPage}"/>

                     </base:request>

                  It works.