After receiving response data, you can map elements in the XML response to objects in the application. If the target object is a CDF component, the data must be transformed into CDF to be displayed in your application. A CDF document is created and stored in the local data cache where the component can access it.
Transformation is a two-step process:
- Map response elements to the equivalent CDF structures.
- Map GUI components to the CDF structures.
 | This section uses the General Interface WSDL Mapping 2 sample located in workspace/JSXAPPS/samples/WSDL_Mapping_2. By default, this sample runs in Static Mode, rendering the results of a sample message on screen. To run against the Xignite web service in Live Mode, register for a license key at http://www.xignite.com/xhistorical.asmx?op=xRegister. Then set the project to Live Mode on the Deployment panel of the Project Settings dialog (Project > Project Settings > Deployment) and reload your browser. |
Map Response Elements to CDF Equivalents
Response elements can be mapped to CDF structures using the XML Mapping Utility. In the WSDL Mapping 2 sample, the GetHistoricalQuotes operation includes a repeating rule in the response message named HistoricalQuote. When a concrete message is processed by this rule, a new CDF record is created for each repeating instance. Then, various fields in the concrete message are appended as attributes to the generated records.

To map response elements to CDF, complete the following steps:
- In the Rules Tree panel of the XML Mapping Utility, select the immediate parent of the element that corresponds to a record in the CDF document.
In this example, the parent element is GetHistoricalQuotesResult, because it contains the repeating HistoricalQuote elements that will map to records in the CDF document.
- In the Mappings table of the Settings panel, select CDF Document from the drop-down list in the Type column of the Mappings table.
- Type a cache ID string for the CDF document in the Path/Value column.
For the WSDL Mapping 2 example, type historicals.
This value becomes the cache ID of the CDF document, which appears in the Local Data Cache palette after the response is received and inbound mapping logic is applied. If the file exists, it's overwritten. If the file doesn't exist, a new file is created in the cache.
In the WSDL Mapping 2 example, the rules file looks like this:

- Select the element in the Rules Tree panel that corresponds to a record in the CDF document.
In the WSDL Mapping 2 example, the element that corresponds to a CDF record is HistoricalQuote, which is the repeating rule.
- Select CDF Record from the drop-down list in the Type column in the Mappings table. It's not necessary to specify a value in the Path/Value column for this exercise.
 | You can also select an element in the rules tree and choose Map > CDF Record. |
 | Although the Path/Value field is not required, it can be used to support recursion or hand off processing to another rule. For example, if there is another rule in your mapping rules file that has a CDF Record mapping, you can enter the jsxid for that rule. To find the jsxid (Rule ID), select the rule that you wish to call and click the Rule Node Profile radio button. |
When a repeating rule is mapped to a CDF record, by default the rules file automatically iterates through each corresponding node in the concrete message.
In the WSDL Mapping 2 example, the rules file looks like this:

- Select an element to map in the Rules Tree panel. For example, select Date.
- Select CDF Attribute from the Type drop-down list in the Mappings table.
- Type a string value in the Path/Value field. This value becomes the attribute name in the CDF document. For example, type Date for the Date element.
 | You can also select an element in the Rules Tree panel and choose Map > CDF Attribute. The attribute name is automatically generated in the Path/Value field. |
In the WSDL Mapping 2 example, the rules file looks like this:

- Follow the same process to create mappings for other elements to include in the CDF document: select the element, select CDF Attribute as the Type, and enter a name for the corresponding CDF attribute.
 | To add multiple CDF attribute mappings at once, use Ctrl+click or Shift+click to select multiple rules and select Map > CDF Attribute in the Rules Tree panel menu. |
In the WSDL Mapping 2 example, the rules file looks similar to this:

If the response has nested rules, you can replicate the nested structure using CDF Record and CDF Attribute mappings.
The jsxid attribute, which is required in every CDF document, acts as a key. You can map an existing element that acts as a key value, such as a date or other unique value, to jsxid. If no such mapping exists, the XML Mapping Utility automatically adds a jsxid attribute to the CDF document and generates a unique value.
- Save the mappings file.
Map GUI Components to CDF Equivalents
After transforming the XML response to CDF, you need to map the CDF GUI components that will consume CDF data. This example uses a Matrix component to show how to create the mappings.
To map GUI components to CDF elements, complete these steps:
- Select the top-level GUI object that will consume data in the Component Hierarchy palette. In the WSDL Mapping 2 example, the top-level object is a Matrix component, gridResults, with six columns.
- Open the Properties Editor palette and specify the name of the cache document for the XML Cache ID property. In the XML Mapping Utility, this is the value in the Path/Value column for the CDF Document mapping. In this example, the value is historicals :

- Select the GUI object in the Component Hierarchy palette that will display the data series. In the WSDL Mapping 2 example, the object is a column in the matrix, such as date, security, open, and so on.
- Open the Properties Editor palette and type the attribute name in the Value field of the Att Name property.
In this example, choose date in the Component Hierarchy palette and type Date, the attribute name, in the Att Name field to map the date component to the CDF Date attribute.

- Repeat the process for other GUI objects until all series mappings are complete: select each object in the Component Hierarchy palette and type the appropriate CDF attribute name in the Value field of the Att Name property.
Next, you need to test the rules file to be sure the mappings are correct. To test the rules file, see Running a Quick Test.
|
|