Question Best Method for Changing XML Values Inside Program.

Courtney White

New Member
We need to interface our QAD 2012.EE system with our document control system, MasterControl.
We are working with OpenEdge Release 10.2B05.

First, we make a connection and request an XML file. We have to pull a fresh XML file each time, as there are unique identifiers:

Code:
    CREATE SERVER hWebTaskService.
    hWebTaskService:CONNECT("-WSDL 'http://slmmcwebtst.slm.moog.com/mctest/ws/Taskservice.cfc?wsdl'").

    RUN Taskservice SET hTaskservice ON hWebTaskService.

    RUN getProcess IN hTaskservice(INPUT connectionid, INPUT processRoute, OUTPUT getProcessReturn).

getProcess is a LONGCHAR that contains the xml info. See attachment for example.

We need to add values to some of the fields, then return it back to another process.

Code:
RUN launchProcess IN hTaskservice(INPUT connectionID, INPUT getProcessReturn, OUTPUT launchProcessReturn).

If I hand edit the XML or submit the unchanged XML, it creates the document, so the web elements work fine.

The question is, how do I change the values in the xml inside Progress? Would it be easier to save to a file and use an OS-COMMAND to use an external tool?

Thank You!
 

Attachments

Ended up using the following:

Code:
PERLCommand = "perl -p -0777 -e 's@H_Complaint Number</label><value xsi:type=\"xsd:string\"></value>@H_Complaint Number</label><value xsi:type=\"xsd:string\">" + ca_nbrDEBUG + "</value>@sg' '/srv/servicecalls/'" + ca_nbrDEBUG + ".xml >'/srv/servicecalls/'" + ca_nbrDEBUG + ".tmp && cp /srv/servicecalls/" + ca_nbrDEBUG + ".tmp /srv/servicecalls/" + ca_nbrDEBUG + ".xml".
            OS-COMMAND VALUE(PERLCOMMAND).

I understand there are risks to doing it this way, but the order and format of the XML should never change.
 
If you are going to do THAT, you could just manipulate the XML as text in Progress, in a similar way and hope for the best (as you are here). That would remove the dependency on Perl and risks of that screwing up (eg. not being available on the target machine, wrong permissions, etc.).

But the real issue is that doing simple text replacement is prone to failure if the tiniest thing changes, and figuring out what happened will be difficult because the error, if any, will be buried somewhere. So you are kind of setting yourself up for future hassles. The better solution would be using Progress XML manipulation functions, which are pretty good and more than up to a small task like this, and have ample room for error checking so you can say stuff like 'error, node X not found' and help your future self out.
 
I'm looking for a jumping in point on the Progress XML manipulation. I'm not very familiar with XML, in general.

What would be my first step after having the xml returned into the getProcessReturn LONGCHAR? Do I load it into a X-Document? Should have I declared getProcessReturn as a X-Document to begin with?
 
Back
Top