Flex/AMF3 Project Setup and Testing

Prerequisites

For testing Flex/AMF3 applications based on the Adobe or BlazeDS implementation, Java Development Kit 1.5 or later is required.

For testing Flex/AMF3 applications based on the GraniteDS implementation, Java Development Kit 1.6 or later is required.

Transformation is enabled for HTTP requests and responses that have the HTTP header Content-Type set to "application/x-amf". If you need to transform data with a different HTTP Content-Type header, see Transformation of Custom Content-Types.

Setting Up an Adobe Flex/AMF3 Project

For testing Flex/AMF3 applications based on the Adobe or BlazeDS implementation, select the Flex/AMF3 (Adobe) application type on the Outline Project dialog.

The Flex/AMF3 (Adobe) application type supports both AMF0 and AMF3. By selecting the Flex/AMF3 (Adobe) application type, several profile settings are automatically configured for you on the tab Profile > Web (Protocol Level) > Transformation:
  • The Flex/AMF3 (Adobe) transformation DLL is selected in the Type drop list.
  • Transform HTTP Requests is enabled
  • Transform HTTP Responses is enabled
  • Enable Java Virtual Machine usage is enabled. This setting is required because Flex/AMF3 requires a running JVM for accurate transformation of externalizable traits. This setting also causes transformed AMF3 traffic to appear in a readable XML representation that includes fewer AMF3 syntactical tags.

Setting Up a GraniteDS Flex/AMF3 Project

For testing Flex/AMF3 applications based on the GraniteDS implementation, select the Flex/AMF3 (GraniteDS) application type on the Outline Project dialog.

The Flex/AMF3 (GraniteDS) application type supports both AMF0 and AMF3. By selecting the Flex/AMF3 (GraniteDS) application type, several profile settings are automatically configured for you on the tab Profile > Web (Protocol Level) > Transformation:
  • The Flex/AMF3 (GraniteDS) transformation DLL is selected in the Type drop list.
  • Transform HTTP Requests is enabled
  • Transform HTTP Responses is enabled
  • Enable Java Virtual Machine usage is enabled. This setting is required because Flex/AMF3 requires a running JVM for accurate transformation of externalizable traits. This setting also causes transformed AMF3 traffic to appear in a readable XML representation that includes fewer AMF3 syntactical tags.

Configuring a Customized GraniteDS Configuration

If your application under test uses a customized GraniteDS configuration, you may find that an exception is reported in TrueLog Explorer, in the Recorder log or the virtual user log files. These exceptions resemble the following:
WebPagePost(WebEngine: 82 - Content transformation error, RESPONSE: AMF3: Java based XML generation failed, 
using fallback, reason: org.granite.messaging.amf.io.AMF3SerializationException 
…
Caused by: java.lang.RuntimeException: The ActionScript3 class bound to org.granite.example.addressbook.entity.Person 
(ie: [RemoteClass(alias="org.granite.example.addressbook.entity.Person")]) implements flash.utils.IExternalizable but 
this Java class neither implements java.io.Externalizable nor is in the scope of a configured externalizer 
(please fix your granite-config.xml)
…
To make Silk Performer aware of this custom configuration and to get rid of the exceptions, proceed as follows:
  1. Locate the customized configurations of your application under test. These can usually be found in granite-config.xml or granite-custom-config.xml, which is located in the application's classpath.
  2. In the Project menu tree, locate the granite-custom-config.xml file in the Data Files folder.
  3. Double-click granite-custom-config.xml to open it in the editor.
  4. Copy and paste the customized configurations that you located in step 1 into the granite-custom-config.xml data file and save your changes.

Modeling a Script

Using the JVM requires the configuration of Flex/AMF3 application-specific custom JAR files that contain the classes that are necessary for serialization into correct XML representation. For this reason, when modeling a Flex/AMF3 script, the Model Script dialog includes an Add Custom JAR File(s) button. Click this button to browse to and Add any custom JAR files that are specific to the application under test. Added JAR files are displayed within the Project tree Data Files node.

These required JAR files (or individual .class files) are located on the server to be tested. These files must be prepared manually and copied from the server to the Silk Performer controller machine. It may be that the only required task is to place individual .class files into an archive.

Note: JAR files must be placed in the Project folder.

Clicking Settings on the Model Script dialog links you directly to the current user profile, Java Settings tab. Use this to change Java settings for the currently selected user profile.

The Apache Flex 2, 3, 4 and BlazeDS 3.2.0 base JAR files are installed in the directory C:\Program Files(x86)\Silk\Silk Performer <version>\ClassFiles\Adobe-Flex. These JAR files are automatically added to the classpath. These files may be manually updated by copying new versions of flex-messaging-common.jar and flex-messaging-core.jar into the directory.

Make sure that you have the GraniteDS base JAR files on your machine and then add these JAR files to the classpath.

Note: Do not enable Use system classpath on the Java Settings tab. JAR files set in the system classpath may overrule manually configured JAR files.

Generating a Script from a Capture File

While recording a user transaction, the Silk Performer recorder creates a so-called Silk Performer capture file, which contains the entire traffic of the recorded session. After saving, the capture file is opened in the Workbench for further analysis and processing. Before generating a script from the captured traffic, you can configure recording rules and other settings, which are applied during the script generation process.

If any errors occur, click the buttons in the Resolve Problems area to resolve them. Then, click Generate Script to generate a script from the capture file.

On 64-bit operating systems, both a 32-bit and 64-bit Java installation are required. The 32-bit installation is used for replaying scripts, the 64-bit installation is used for generating scripts. If a 64-bit installation is not available, you can force Silk Performer to use a 32-bit process for script generation by setting the following registry key to 1: HKEY_LOCAL_MACHINE\SOFTWARE\Silk\SilkPerformer\<version>\Force32BitCaptureAnalyzer.
Attention: Using the 32-bit script generator can cause issues with large capture files.

Replaying a Script

If your Java configurations are incorrect (for example, if JAR files are missing), XML responses (only visible in TrueLog Explorer) will not be generated in an easily readable format. Also warnings or errors will be written to the Virtual User Output pane. Typically, errors and warnings indicate whether or not they were caused by requests (client to server) or responses (server to client).

Customizing AMF3 Scripts

Do not change the overall structure of XML objects within AMF3 scripts. It is okay to parse values or insert verification functions, but deleting or rearranging AMF3 XML elements will destroy a call. Also do not change the order of elements within arrays.

Code Examples

Command message example:

<AmfXml version="3">                                                            
  <Msg length="203" operation="null" responseURI="/1">                          
    <StrictArray nrElems="1">                                                   
      <Amf3>                                                                    
        <JavaObject>                                                            
          <flex.messaging.messages.CommandMessage>                              
            <destination></destination>                                         
            <messageId>3EE7E87A-96E6-3272-30F7-FFEF6B9EFE9E</messageId>         
            <timestamp>0</timestamp>                                            
            <timeToLive>0</timeToLive>                                          
            <headers>                                                           
              <entry>                                                           
                <string>DSId</string>                                           
                <string>nil</string>                                            
              </entry>                                                          
            </headers>                                                          
            <body class="flex.messaging.io.amf.ASObject" serialization="custom">
              <unserializable-parents></unserializable-parents>                 
              <map>                                                             
                <default>                                                       
                  <loadFactor>0.75</loadFactor>                                 
                  <threshold>12</threshold>                                     
                </default>                                                      
                <int>16</int>                                                   
                <int>0</int>                                                    
              </map>                                                            
              <flex.messaging.io.amf.ASObject>                                  
                <default>                                                       
                  <inHashCode>false</inHashCode>                                
                  <inToString>false</inToString>                                
                </default>                                                      
              </flex.messaging.io.amf.ASObject>                                 
            </body>                                                             
            <correlationId></correlationId>                                     
            <operation>5</operation>                                            
          </flex.messaging.messages.CommandMessage>                             
        </JavaObject>                                                           
      </Amf3>                                                                   
    </StrictArray>                                                              
  </Msg>                                                                        
</AmfXml>

Remoting message example:

<?xml version='1.0' encoding='UTF-8'?>                                              
<AmfXml version="3">                                                                
  <Msg length="394" operation="null" responseURI="/4">                              
    <StrictArray nrElems="1">                                                       
      <Amf3>                                                                        
        <JavaObject>                                                                
          <flex.messaging.messages.RemotingMessage>                                 
            <clientId class="string">208F18FC-6F0D-9964-3746-76438D73A6A3</clientId>
            <destination>myextservice</destination>                                 
            <messageId>A98651D4-690D-E530-B744-FFEF866937C7</messageId>             
            <timestamp>0</timestamp>                                                
            <timeToLive>0</timeToLive>                                              
            <headers>                                                               
              <entry>                                                               
                <string>DSId</string>                                               
                <string>208F0A62-A409-8994-08AF-223CD381602C</string>               
              </entry>                                                              
              <entry>                                                               
                <string>DSEndpoint</string>                                         
                <string>my-amf</string>                                             
              </entry>                                                              
            </headers>                                                              
            <operation>setMyExtClass</operation>                        
            <parameters>                                                            
              <com.borland.silkperformer.flex.samples.MyExt>                        
                <string>string1</string>                                               
                <string>string2</string>                                                
                <string>string3</string>                                                  
                <boolean>true</boolean>                                             
                <date>2009-03-13 14:05:01.545 CET</date>                            
              </com.borland.silkperformer.flex.samples.MyExt>                       
            </parameters>                                                           
          </flex.messaging.messages.RemotingMessage>                                
        </JavaObject>                                                               
      </Amf3>                                                                       
    </StrictArray>                                                                  
  </Msg>                                                                            
</AmfXml> 

Acknowledge message example:

<?xml version='1.0' encoding='UTF-8'?>                                            
<AmfXml version="3">                                                              
  <Msg operation="/5/onResult" responseURI="">                                    
    <Amf3>                                                                        
      <JavaObject>                                                                
        <flex.messaging.messages.AcknowledgeMessage>                              
          <clientId class="string">208F18FC-6F0D-9964-3746-76438D73A6A3</clientId>
          <messageId>20903C27-020C-F5E6-68E7-C8175449798D</messageId>             
          <timestamp>1236954453026</timestamp>                                    
          <timeToLive>0</timeToLive>                                              
          <body class="com.borland.silkperformer.flex.samples.MyExt">             
            <string>some string</string>                                             
            <com.borland.silkperformer.flex.samples.MyExt>                        
              <string>string1</string>                                               
              <string>string2</string>                                                
              <string>string3</string>                                                  
              <boolean>true</boolean>                                             
              <date>2009-03-13 14:04:58.14 CET</date>                             
            </com.borland.silkperformer.flex.samples.MyExt>                       
            <string>GET</string>                                                  
            <string>string</string>                                                    
            <boolean>true</boolean>                                               
            <date>2009-03-13 14:05:01.545 CET</date>                              
          </body>                                                                 
          <correlationId>C4BD7297-67CB-84AB-0C1A-FFEF8DEB3A97</correlationId>     
        </flex.messaging.messages.AcknowledgeMessage>                             
      </JavaObject>                                                               
    </Amf3>                                                                       
  </Msg>                                                                          
</AmfXml>