Sounds like you are trying to create an association between the parent and its children in addition to setting attribute values
Here’s an example of how you can establish the associations:
// Create a customDataType called colorType and add it to the vocabulary
ICcDataObject colorType = aDataObjMgr.createEntity("CustomDataType");//
Create a CustomDateType entity
colorType.setAttributeValue("name",
"colorType"); // Set
its name to colorType
colorType.setAttributeValue("baseType",
"String");
// Set its base type to String
colorType.setAttributeValue("enumeration",
"Yes");
// Set its enumeration to Yes
colorType.setAttributeValue("constraint",
"");
// Set its constraint to empty
vocab.addAssociation("customDataTypes",
colorType); // Associate ColorType with the vocabulary V1 (role name is customDataTypes)
ICcDataObject llabelValue = aDataObjMgr.createEntity("LabelValuePair");//
Create a LabelValuePair entity
llabelValue.setAttributeValue("label",
"Red");
// Set its label to Red
llabelValue.setAttributeValue("value",
"Red");
// Set its value to Red
colorType.addAssociation("labelValuePairs",
llabelValue); // Associate it with the data type ColorType (role name is labelValuePairs)
As far as actually parsing the XML payload to locate the various attributes and their values – I’m afraid I don’t know any simple way to do that.
You also have to deal with matching up the returned values with the corresponding rule message.
One way to make this easier is to bypass the built in Corticon rule statements and create your own rule statements (by defining your own entity called Message and created
using the Corticon new operator) that are directly associated with the business objects – then they will automatically be matched up. If you do this then you can easily add any extra meta-data you need – something you cannot do with the built in rule statement/message
mechanism.
In javascript you can do something like this (this is an example from a Rollbase javascript trigger) – but I’m not sure if that helps with java parsing of XML.
Maybe some of the other SEs have some ideas on this.
var xmlRequest=
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<SOAP-ENV:Envelope" +
" <SOAP-ENV:Body>" +
" <CorticonRequest " +
" xmlns=\"urn:Corticon\" " +
" decisionServiceName=\"RollbaseRetirementEligibility\">" +
" <WorkDocuments>" +
" <Person id=\"Person_id_1\">" +
" <age>{!age}</age>" +
" <name>{!name}</name>" +
" <membershipMaintained>{!membership#value}</membershipMaintained>" +
" </Person>" +
" </WorkDocuments>" +
" </CorticonRequest>" +
" </SOAP-ENV:Body>" +
"</SOAP-ENV:Envelope>";
var response=rbv_api.sendJSONRequest(url,xmlRequest,"POST","text/xml;charset:UTF8",null,null,params);
rbv_api.println(response);
var root = rbv_api.parseXML(response);
var status = root.getElementsByTagName('ns1:normalAgeStatus').item(0).getFirstChild().getNodeValue();
rbv_api.setFieldValue('retiree', {!id}, 'status',status);
var message = root.getElementsByTagName('ns1:text').item(0).getFirstChild().getNodeValue();
rbv_api.setFieldValue('retiree', {!id}, 'reason',message);