6 Replies Latest reply: Apr 17, 2012 12:14 PM by pbeltranl RSS

    Most terrible bug you could expect!.

    pbeltranl Community Member

      Flex 4.6

      Windows 7 SP1

       

      Description:

       

      A variable points to an existing object and the same function returns a different value when it's called from the original object or from the variable pointing that object.

       

      Please, see the attached picture:

       

      incredible_bug.png

       

      Pablo.

        • 1. Re: Most terrible bug you could expect!.
          Flex harUI Adobe Employee

          Show parent,  node and name in the expressions window.

           

          Maybe also parent[name].toXMLString() and node.toXMLString();

          • 2. Re: Most terrible bug you could expect!.
            pbeltranl Community Member

            node is empty! while parent[name] not.

             

            parent:

            parent.png

            name:

            name.png

             

            node:

            node.png

            • 3. Re: Most terrible bug you could expect!.
              pbeltranl Community Member

              The problem seems related to the parent[name] object.

               

              Please, see the new attached picture.

               

              I've extended the SOAPEncoder class and overrided the getValue method. Then I set the Operation.encoder property with mine (FixedSOAPEncoder):

               

              When it's called, parent[name].length() is 1, but the l variable is set to 0!!

               

              wrong_length.png

              • 4. Re: Most terrible bug you could expect!.
                pbeltranl Community Member

                Another extrange issue:

                 

                trace(parent[name]) output (->Console) shows the parent element of parent[name].toString() (->Expressions)

                 

                more_issues.png

                workaroud?

                • 5. Re: Most terrible bug you could expect!.
                  pbeltranl Community Member

                  And finally a workaround (for my particular case: problems invoking some SharePoint web services):

                   

                  Use name.localName instead of name when name is QName.

                   

                  workaround.png

                   

                  I debugged the call to the BlazeDS server (useProxy=true) and the expected SOAP message is sent this time:

                   

                  DEBUG 2012-04-17 15:43:19,688 : >> "<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "  <SOAP-ENV:Header>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "    <tns:versions xmlns:tns="http://schemas.microsoft.com/sharepoint/dsp">[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "      <tns:version>1.0</tns:version>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "    </tns:versions>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "    <tns:request document="content" method="query" xmlns:tns="http://schemas.microsoft.com/sharepoint/dsp"/>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "  </SOAP-ENV:Header>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "  <SOAP-ENV:Body>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "    <tns:queryRequest xmlns:tns="http://schemas.microsoft.com/sharepoint/dsp">[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "      <tns:dsQuery resultContent="both" columnMapping="element">[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "        <tns:Query RowLimit="-1">[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "          <tns:Fields>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "            <tns:AllFields IncludeHiddenFields="false"/>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "          </tns:Fields>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "          <tns:Where>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "            <Where>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "              <Eq>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "                <FieldRef Name="ID"/>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "                <Value Type="counter">1</Value>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "              </Eq>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "            </Where>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "          </tns:Where>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "        </tns:Query>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "      </tns:dsQuery>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "    </tns:queryRequest>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "  </SOAP-ENV:Body>[\n]"

                  DEBUG 2012-04-17 15:43:19,688 : >> "</SOAP-ENV:Envelope>"

                  • 6. Re: Most terrible bug you could expect!.
                    pbeltranl Community Member

                    Ooopppss! There are still more issues....

                     

                    All the Previous posts were related to an awesome bug: the runtime and the debugger differ about some values. Following is a more typical development bug.

                     

                    The problem: previous workaround worked for elements, but not for attributes because the method:

                     

                    mx.rpc.xml.XMLEncoder.encodeAttribute(definition:XML, parent:XML, name:QName, value:*=null, restriction:XML=null):void

                     

                    also calls the same XMLEncoder.getValue(parent:*, name:*):* method. Thus, when parent is XML or XML list following code is used:

                     

                    ============================

                    ...

                    var value:*;

                     

                                        if (parent is XML || parent is XMLList)

                            {

                                var node:XMLList = parent[name];

                                if (node.length() > 0)

                                    value = node;

                            }

                    ...

                    ==============================

                     

                    and no attributes are found: he resulting SOAP message ignores custom attributes and default attributes values are always added.

                     

                    In this case, parent.attribute(name.localName) should be used.

                     

                    I did that change (by duplicating the getValue method) and, this time, the resulting SOAP message was the the expected, including the custom attributes.

                     

                    Pablo.