XML representation of AMF messages

<AmfMessage version="3">
  - Attribute "version" specify the version of AMF used to encode value types 3 referer AMF 3, 0 referer AMF 0.

  <AmfHeader name="HeaderName" mustUnderstand="false">
    - A header's "name" typically identifies a remote operation or method to be invoked by this context header.
    - A header also includes a boolean "must understand" flag. If true, the flag instructs the endpoint to abort and generate an error if the header is not understood.

    <Amf0Data ... "AMF 0 value type" ... </Amf0Data>

  </AmfHeader>

  <AmfBody target="null" response="/1">
    - The "target" is an URI which describes which operation, function, or method is to be remotely invoked.
    - The "response" is an URI which specifies a unique operation name that will be used to match the response to the client invocation.

    <Amf0Data ... "AMF 0 value type" ... </Amf0Data>

  <AmfBody>

</AmfMessage>


AMF 0 value types:




AMF 0 references in AgileLoad XML structure:

Complex objects as Anonymous Object, Typed Object, Array or ECMA-Array can be referenced. This reference is a identifier set in the "referenceId" attribute. Use AMF 0 "reference" value type to refer to a Complex Object.


Example:

  <Amf0Data type="strict-array" referenceId="amf0obj1">
    <Amf0Data type="string">value1</Amf0Data>
    <Amf0Data type="string">value2</Amf0Data>
  </Amf0Data>

You can refer the array:

  <Amf0Data reference="amf0obj1"/>



AMF 3 value types:




AMF 3 references in AgileLoad XML structure:

Complex Objects as Anonymous Objects, Typed Objects, Arrays, Dates, XMLDocument, XML and ByteArrays can be referenced. This reference is an identifier set in the "referenceId" attribute. Use the "reference" attribute to refer to a Complex Object.


Example:

  <Amf3Data type="date" referenceId="date2">1225372901125</Amf3Data>

You can refer to this Date:

  <Amf3Data type="date" reference="date2"/>


Externalizable

The AMF 3 protocol allows to exchange personal objects. Theses objects are called 'externalizable' when they implement the 'flash.utils.IExternalizable' interface. These objects control the serialization of their members.

AgileLoad and Externalizable classes

Pour pouvoir visualiser en XML ces requetes, il faut ecrire une librarie de classes code en C-Sharp.

A partir du fichier source de la classe externalisable (fichier ActionScript, JAVA, CSharp, PHP, PERL, Python, Ruby, or ...), il faut transcoder en C-Sharp les methodes "readExternal" et "writeExternal".
Les classes transcoder doivent implementer les methodes de l'interface "
FlexParser.AMF3.IExternalizable".

Par exemple, pour sérialiser les membres privés, une classe doit utiliser l'interface flash.utils.IExternalizable. La classe suivante ne sérialisera aucun de ses membres, parce qu'ils sont privés. Cependant, si l'interface IExternalizable est implemente, il possible de lire et d'écrire dans le flux de données les membres privés de la classe, comme suit :

In order to be able to convert AMF requests into XML, a class library must be developed in C-Sharp language.
The "readExternal" and "writeExternal" methods of the externalizable class (ActionScript, JAVA, CSharp, PHP, PERL, Python, Ruby, or ...) must be writen in CSharp.
These classes must implement the methods of  th "FlexParser.AMF3.IExternalizable" interface .

For example, to serialize their private members, a ActionScript class must implement the 'flash.utils.IExternalizable' interface.
By default, the class shown below will not serialize any of its members because they are all private members. However, if the 'IExternalizable' interface is implemented, it is possible to read and write private members into the data flow: 


class Example implement flash.utils.IExternalizable {

  private var one:int;
  private var two:string;

  public function writeExternal(output:IDataOutput) {
    output.writeInt(one);
    output.writeUTF(two);
  }

  public function readExternal(input:IDataInput) {
    one = input.readInt();
    two = input.readUTF();
  }
}


ActionScript class converted to C-Sharp class with AgileLoad interfaces:

To allow AgileLoad to decrypt and encrypt 'flash.utils.IExternalizable' classes, a C-Sharp class must be developed. The ActionScript C-Sharp WriteExternal and ReadExternal methods must be developed:

ActionScript class converted to C-Sharp class with AgileLoad interfaces:


class Example : FlexParser.AMF3.IExternalizable
{
  private int one;
  private string two;

  void FlexParser.AMF3.IExternalizable.WriteExternal(FlexParser.AMF3.IDataOutput output)
  {
    output.WriteInt(one);
    output.WriteUTF(two);
  }

  void FlexParser.AMF3.IExternalizable.ReadExternal(FlexParser.AMF3.IDataInput input)
  {
    one = input.ReadInt();
    two = input.ReadUTF();
  }
}


A class library must be created to allow AgileLoad to convert AMF flows into XML tree.

Example of creation of a class library.

Details about each AgileLoad interfaces:

FlexParser.AMF3.IExternalizable
FlexParser.AMF3.IDataInput
FlexParser.AMF3.IDataOutput

These interfaces are referenced in the "FlexParser.dll" AgileLoad library located in the "AgileLoad\Bin" directory.

Binary conversion of Externalizable classes into XML




Created a Class Library for AgileLoad Flex Parser and configure AgileLoad.

Using Visual Studio and some source files of your application, you will be able to convert AMF personal flows into XML.
Using the following example will help you to develop your own lbrary:.

  1. Converting an ActionScript class to a C# class


  2. Creation of the library: Follow the ClockExt.dll  example and copy the created dll into the "AgileLoad/bin/FlexExt" folder.

  3. Configuration: AgileLoad Flex Parser settings.

    Your library must be declared in the FlexSettings.config file located in the "AgileLoad\Config\AgileLoad" directory

      <FlexSection ConvertClass="true" LogFilter="High">
        <ClassMapping>
          <add UserClass="FlexParser.AMF3.ArrayCollection" FlexClass="flex.messaging.io.ArrayCollection" />
          <add UserClass="FlexParser.AMF3.ByteArray" FlexClass="flex.messaging.io.ByteArray" />
          <add UserClass="FlexParser.AMF3.ObjectProxy" FlexClass="flex.messaging.io.ObjectProxy" />
          
          <add UserClass="FlexParser.Messaging.Messages.AcknowledgeMessageExt" FlexClass="DSK" />
          <add UserClass="FlexParser.Messaging.Messages.CommandMessageExt" FlexClass="DSC" />
          <add UserClass="FlexParser.Messaging.Messages.AsyncMessageExt" FlexClass="DSA" />
          
          <add UserClass="ConversionFlex.ClockExt" FlexClass="sample.ClockExt" />
        </ClassMapping>
        <FileMapping>
          <add File="FlexParser.dll" />
          <add File="FlexExt\ClockExt.dll" />
        </FileMapping>
      </FlexSection>


    LogFilter: High, Medium, Low or None
    ConvertClass: true or false
    FileMapping: List of flex decoding/encoding libraries which AgileLoad loads
    ClassMapping: convert a flex typed object into a C# user class




Go back to the Learning center:


Copyright © AgileLoad. All rights reserved.
Agile Load testing tool| Contact AgileLoad | Terms of Use | Sitemap