7. ASOLib—OpenROAD Server Library : XML Parameters for Use with GSCPs : How You Can Pass XML into a GSCP
 
Share this page                  
How You Can Pass XML into a GSCP
When a GSCP is created, it duplicates the underlying method/procedure parameter signature and automatically adds new optional parameters. These parameters facilitate 4GL-to-XML conversion and vice versa.
In a non-OpenROAD client, the following client VB code might typically be used to represent the by-value input parameters in a PDO:
Set byvalPDO = CreateObject("OpenROAD.ParameterData")
byvalPDO.DeclareAttribute "p_i_author_id" , "INTEGER"
Following these parameters, you would set the attribute values:
byvalPDO.SetAttribute "p_i_author_id", 101
However, if you wish to pass data in as XML, you must create an XML input document for the method's input parameters. In this example, the XML representation of parameter data would be:
Sample Input:
<?xml version="1.0"?>
<Root>
    <p_i_author_id>101</p_i_author_id>
</Root>
The <Root> tag is ignored. The tags within the root node represent the parameters.
Note:  The entity tag names must correspond exactly to the 4GL parameter names.
This XML parameter data must be passed to the OpenROAD Server within a string variable named "p_so_xmlin." In our example, the Parameter Data Object would be set up as follows:
Set byvalPDO = CreateObject("OpenROAD.ParameterData")
byvalPDO.DeclareAttribute "p_so_xmlin", "STRING"
byvalPDO.SetAttribute     "p_so_xmlin", my_xml_doc
where my_xml_doc is a string variable containing the input XML text.
When the GSCP is called, XML tag values are copied automatically to the corresponding 4GL parameters, leaving other 4GL parameters at their default value. 4GL parameters must meet the following criteria.
The parameter's data type must be one of the following:
varchar scalar, StringObject, or LongVcharObject
integer scalar or IntegerObject
float scalar or FloatObject
money scalar or MoneyObject
date scalar or DateObject
single user class
array of user class
The data type of a user class attribute must be one of the types shown in the preceding list. Nested user classes and arrays are supported, provided the structure is hierarchical and has no circular references.
4GL parameters that are not specified in the input XML document default to their normal 4GL default value. Tags that do not map to 4GL parameter names cause a runtime error, returned in the b_osca error structure.