|
I had the same need to bring in large amounts of XML. Here is the sub proc that I developed that can theoretically bring in 16MB. I have tried it with up to 11MB and it worked fine. The basic jist is that it reads it into a user space and then out to a file for your calling program to further process it. I think I have provided you most of the needed supporting sub procs. Let me know if you need any more. . . Just curious, how are you going to parse the XML after you have received it? P CGI_readToFile... P B EXPORT D CGI_readToFile... D PI N D pFileName 256A Value D error DS LikeDS(gAPIError) D bytesRead S 10I 0 D contentLength S 10I 0 D data S 32767A Based(ptr) D rc S 10I 0 D handle S 10I 0 D ptr S * D usrSpc DS Qualified Inz D lib 10A Inz('QTEMP') D name 10A Inz('CGIFN') /Free error.bytesProvided = %Size(error); Monitor; contentLength = CtoN(CGI_getEnvVariable(CONTENT_LENGTH)); On-Error; contentLength = 0; Error_throwError( '400': 'CGI_readToFile: No content was found in request'); EndMon; If contentLength > 0; Monitor; // Create the space needed for the standard input data by making use of // user spaces. UsrSpc_create( usrSpc.lib: usrSpc.name: ' ': contentLength: ' ': '*ALL': ' ': '*YES'); ptr = UsrSpc_retrievePointer(usrSpc.lib: usrSpc.name); qtmhRdStin(data: contentLength: bytesRead: error); If error.msgId <> ' '; Error_throwError('400': 'CGI_readToFile: ' + 'Error read Standard Input: ' + error.msgId + ':' + error.data); EndIf; handle = IFS_openFile(pFileName: 'RW C CP'); If handle < 0; Error_throwError('400': 'CGI_readToFile: ' + 'Unable to obtain a file handle with IFS_openFile.'); EndIf; rc = write(handle: ptr: bytesRead); rc = close(handle); UsrSpc_delete(usrSpc.lib: usrSpc.name); On-Error; Error_throwError( '400': 'CGI_readToFile: Error reading Standard Input'); EndMon; Return *On; EndIf; Return *Off; /End-Free P CGI_readToFile... P E //-------------------------------------------------------------------------- ------------------ // @Name - UsrSpc_retrievePointer // @Description - Retrieve Pointer to OS/400 UserSpace. // @Author - Aaron Bartell // @Usage - pointerToSpace = UsrSpc_retrievePointer(LibraryName: SpaceName) //-------------------------------------------------------------------------- ------------------ P UsrSpc_retrievePointer... P B Export D UsrSpc_retrievePointer... D PI * D pLibName 10A Value D pSpaceName 10A Value D spacePtr S * D qualifiedSpaceName... D S 20A /Free qualifiedSpaceName = pSpaceName + pLibName; qUsPtrUS(qualifiedSpaceName: spacePtr); Return spacePtr; /End-Free P UsrSpc_retrievePointer... P E //-------------------------------------------------------------------------- ------------------ // @Name - UsrSpc_delete // @Description - Delete OS/400 UserSpace. // @Author - Aaron Bartell // @Usage - UsrSpc_delete(LibraryName: SpaceName) //-------------------------------------------------------------------------- ------------------ P UsrSpc_delete B EXPORT D UsrSpc_delete PI D pLibName 10A Value D pSpaceName 10A Value D qualifiedSpaceName... D S 20A /Free qualifiedSpaceName = pSpaceName + pLibName; gAPIError = ' '; qUsDltUS(qualifiedSpaceName: gAPIError); Return; /End-Free P UsrSpc_delete E //-------------------------------------------------------------------------- ------------------ // @Name - // @Author - Aaron Bartell // @Description - // @Usage - //-------------------------------------------------------------------------- ------------------ P IFS_openFile... P B Export D IFS_openFile... D PI 10I 0 D pFile 256A Value D pFlags 15A Value D pCodePage 10I 0 Value Options(*NoPass) D rc S 10I 0 D handle S 10I 0 D IFSMODE C Const(511) D flags S 10I 0 D codePage S 10I 0 /Free If %Parms > 2; codePage = pCodePage; Else; codePage = CP_DOSASCII; EndIf; flags = 0; If %Scan('R': pFlags) > 0; flags = flags + O_RDONLY; EndIf; If %Scan('W': pFlags) > 0; flags = flags + O_WRONLY; EndIf; If %Scan('W': pFlags) > 0 and %Scan('R': pFlags) > 0; flags = O_RDWR; EndIf; If %Scan('A': pFlags) > 0; flags = flags + O_APPEND; EndIf; If %Scan('C': pFlags) > 0; flags = flags + O_CREAT; If %Scan('T': pFlags) > 0; flags = flags + O_TRUNC; EndIf; EndIf; If %Scan('CP': pFlags) > 0; flags = flags + O_CODEPAGE; EndIf; handle = open(%Trim(pFile): flags: IFSMODE: codePage); If handle < 0; Return handle; EndIf; rc = close(handle); // Take the necessary tags back out for the second open If %Scan('C': pFlags) > 0; flags = flags - O_CREAT; If %Scan('T': pFlags) > 0; flags = flags - O_TRUNC; EndIf; EndIf; If %Scan('CP': pFlags) > 0; flags = flags - O_CODEPAGE; EndIf; Return open(%Trim(pFile): flags + O_TEXTDATA: IFSMODE: codePage); /End-Free P IFS_openFile... P E -----Original Message----- From: Kevin Touchette [mailto:KTouchette@xxxxxxxxxxxx] Sent: Wednesday, December 03, 2003 9:54 AM To: web400@xxxxxxxxxxxx Subject: [WEB400] XML request processing. Can anyone tell me how to read an XML request sent from another web site into an rpg cgi program on my web site. I know how to process a query string to get input variables but what I really need to do is read the entire XML document into a variable so that I can parse the XML document into the correct variables. Currently I'm using CGIDEV2 but I'm open to whatever works. TIA. ___________________________________ Washington Corporations Kevin R. Touchette - Programmer/Analyst E-mail: KTouchette@xxxxxxxxxxxx Phone: (406) 523-1369 ___________________________________ _______________________________________________ This is the Web Enabling the AS400 / iSeries (WEB400) mailing list To post a message email: WEB400@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/web400 or email: WEB400-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/web400.
As an Amazon Associate we earn from qualifying purchases.
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.