Scriptframe Top Tips

Some useful pointers for working with the MagooClient Scriptframe

1. Use the Script Generator to get started

The generated scripts will include JavaScript to create request message content, set up namespace variables, dispatch the request using an XMLHttpRequest object and perform request and response validation. Also note that if there are multiple possible paths through the request XML (e.g. choice, type substitutions etc) then the generator will create multiple script variants accordingly. The generator can be started using Tools->Generate Scripts from WSDL… from the main Scriptframe window. The Scriptframe is opened using the Testing ->Open Scriptframe… menu item in the main MagooClient window.


2. Create XMLObject content using the Message Editor

As XML message content can be quite complex, it is often easier to edit and validate and XML message using the MagooClient Message Editor. Create the required message content using the Message Editor. Then save it and then drag and drop the message from the MagooClient drafts folder into the JavaScript editor pane. The complete JavaScript required to build, populate, validate and send the XML message to the service endpoint will be automatically inserted into the script being edited.


3. Scriptframe.assertValid(XMLObject)

The Scriptframe.assertValid(XMLObject) function gives you the full power of the MagooClient WSDL/SOAP/XML validation engines using just a single line of JavaScript. Therefore, use the Scriptframe.assertValid(XMLObject) throughout your scripts to test XML objects for validity – for example, when creating a new request object or when checking the response back from a Server. Note that the Script generator automatically adds Scriptframe.assertValid(XMLObject) calls automatically before and after service invocation.


4. Requirements for XMLObject validation

For an XMLObject to be validated, it must have sufficient ‘content’ to be recognized by MagooClient and a corresponding Message Type mapping must be available within the Message Type Catalog. To recognize an XMLObject, MagooClient requires that the first element under the SOAP Body be present. The easiest way to ensure that message types are registered is to use Import WSDL… from the Configure->Message Types… menu item in the main MagooClient window. If you’ve generated scripts from WSDL then this is done automatically for you.


5. Drag and Drop accessor code

To generate the accessor code necessary to access an XML element or attribute within an XMLObject, open a similar message in a MagooClient Message Editor. Locate the required node in the left hand navigation panel representing the XML tree. Now drag and drop the required node from the tree navigation panel into the Scriptframe JavaScript Editor pane. The accessor code will be automatically expanded out and inserted into the JavaScript code.


6. Logging Request and Response messages

Use the Scriptframe.info() method as a convenient way to log/debug script execution. Scriptframe.info(XMLObject) can be used to trace actual message content to the Scriptframe log. When generating scripts from WSDL, you will be offered the option to include Scriptframe.info() calls for received messages within the script code.


7. Extend test reports using Properties

Properties can be added to the Scriptframe Log Entries to provide a useful input when generating reports. For example, invocation times for individual requests or specific items of data from a returned parameter set can be written as elements to the log. To log a property, simply use Scriptframe.logProperty(propertyName, propertyValue) within the script code.


8. Checking the Script History for errors

The Script History table has sortable columns. To quickly check for faults within the history, use the toggle on the ‘St’ column header to group fault warnings at the top of the list.