[progress Communities] [progress Openedge Abl] Forum Post: Re: Service Callouts

Status
Not open for further replies.
M

mparish

Guest
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 might have to use XPATH commands ( http://stackoverflow.com/questions/2811001/how-to-read-xml-using-xpath-in-java ) 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. More detail here community.progress.com/.../1267 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= " " + " " + " " + " " + " " + " " + " {!age} " + " {!name} " + " {!membership#value} " + " " + " " + " " + " " + " "; var url = " corticon-demo.dyndns.org:8860/.../Corticon"; /*Corticon URL*/ var params = {"SOAPAction":" soap.eclipse.corticon.com","Content-Type":"text/xml"}; 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); See also community.progress.com/.../1455

Continue reading...
 
Status
Not open for further replies.
Top