× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Seems to work nicely.

I will play with that.

I suppose specifying an exit program would be nice, however no program is ever complete :-)

Will this still suffer the same 15meg buffer limitation as the XML stream ?

Not a big deal. Just want to know my limits :-)

Regards,
Richard Schoen
RJS Software Systems Inc.
Where Information Meets Innovation
Document Management, Workflow, Report Delivery, Forms and Business Intelligence
Email: richard@xxxxxxxxxxxxxxx
Web Site: http://www.rjssoftware.com
Tel: (952) 736-5800
Fax: (952) 736-5801
Toll Free: (888) RJSSOFT
------------------------------

message: 4
date: Sun, 29 Jan 2012 16:25:04 +0100
from: Henrik R?tzou <hr@xxxxxxxxxxxx>
subject: Re: XMLSERVICE

Richard,

in basic it was simple, XMLCGI has the following code that sends the generated XML in the addr (pOClob( and size (szOClob) back to the browser:

// output
when status = RUN_CGI_OUTPUT;
// -----
// send header + end (LFLF)
respHead = 'Content-type: text/xml' + CRLF + CRLF + NULLTERM;
rn = writeIFS(1:%addr(respHead):strlen(%addr(respHead)));
// send return data
szOClob = strlen(pOClob);
rn = writeIFS(1:pOClob:szOClob);
status = RUN_CGI_FINISH;

I added a new parameter xFMT and changed the original code to:

// output
when status = RUN_CGI_OUTPUT;
status = RUN_CGI_FINISH;
szOClob = strlen(pOClob);

if xFMT <> '*json';

// ----- ORIGINAL XML

// send header + end (LFLF)
respHead = 'Content-type: text/xml' + CRLF + CRLF + NULLTERM;
rn = writeIFS(1:%addr(respHead):strlen(%addr(respHead)));
// send return data
rn = writeIFS(1:pOClob:szOClob);

else;

// ----- OUTPUT BY EXIT PROGRAM
// call exit program
xmlcgix2(pOClob:szOClob);

endif;

Then I made a little program (XMLCGIX2) that converts the XML result into JSON and then sends the new result to the browser:

* Standard powerEXT H-Spec's
/copy qsrc,pxapihdr General H-Spec's

* powerEXT API Connectors
/copy qsrc,pxapicgicn Basic HTTP connecter & Basic Services

d fieldName s 10a varying


* Program Entry
d PgmEntry pr extpgm('XMLCGIX2')
d *
d 10i 0

d PgmEntry pi
d pOClob *
d szOClob 10i 0

/free
clearSrvPgm();
setContent('text/html');
xmlReaderInz(pOClob:szOClob);
jsonNode('*object');
jsonNode('*boolean':'success':'true');
jsonNode('*array':'rows');
dow xmlReader = 0;
select;
when xmlGetNode = '%row';
jsonNode('*object');
when xmlGetNode = 'data' and xmlGetAttr = 'desc';
fieldName = xmlGetData;
when xmlGetNode = 'data' and xmlGetAttr = '';
if 0 <> %check('.-0123456789':xmlGetData)
or xmlGetData = '.'
or xmlGetData = '-'
or xmlGetData = '';
jsonNode('*string':fieldName:xmlGetData);
else;
jsonNode('*number':fieldName:xmlGetData);
endif;
when xmlGetNode = '/row';
jsonEndNode();
endsl;
enddo;
jsonEndNode();
jsonEndNode();
echoToClient();
return;
/end-free

If I should make a more generic solution I would probably not chose a xFMT parameter and a fixed program name but pass a parameter with the exit program name so I could have a number of exit programs that filter and/or convert the result to whatever I chose without having to change the code in XMLCGI.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.