Greetings.  Another option....
   The xstoolkit only provides the simplified interfaces to call IBM i native
   code. It does not fully support the optional parameter groups. We can use
   the iPgm interface to customize the function by ourselves. Below is an
   example to access keyed data queue.
   Create the data queue --
     * CRTDTAQ DTAQ(XUMENG/TESTQ) MAXLEN(50) SEQ(*KEYED) KEYLEN(3)
   Access it using Node.js --
     * var xt =
       require('/QOpenSys/QIBM/ProdData/Node/os400/xstoolkit/lib/itoolkit.js');
       var conn = new xt.iConn("*LOCAL");
       var errno = [
           [0, "10i0"],
           [0, "10i0", {"setlen":"rec2"}],
           ["", "7A"],
           ["", "1A"]
         ];
       function toJson(str) {
         console.log(JSON.stringify(xt.xmlToJson(str)));
       }
       function sendDq(name, lib, data, key) {
         var pgm = new xt.iPgm("QSNDDTAQ", {"lib":"QSYS"});
         pgm.addParam(name, "10A");
         pgm.addParam(lib == ""?"*CURLIB":lib, "10A");
         pgm.addParam(data.length, "5p0");
         pgm.addParam(data, data.length + "A");
         pgm.addParam(key.length, "3p0");
         pgm.addParam(key, key.length + "A");
         conn.add(pgm.toXML());
         conn.run(toJson);
       }
       function getDq(name, lib, length, key, sender) {
         var pgm = new xt.iPgm("QRCVDTAQ", {"lib":"QSYS"});
         pgm.addParam(name, "10A");
         pgm.addParam(lib == ""?"*CURLIB":lib, "10A");
         pgm.addParam(length, "5p0");
         pgm.addParam("", length + 1 + "A");
         pgm.addParam(0, "5p0");
         pgm.addParam("EQ", "2A");
         pgm.addParam(key.length, "3p0");
         pgm.addParam(key, key.length + "A");
         pgm.addParam(0, "3p0");
         pgm.addParam(sender, sender.length + "A");
         conn.add(pgm.toXML());
         conn.run(toJson);
       }
       function clrDq(name, lib, key) {
         var pgm = new xt.iPgm("QCLRDTAQ", {"lib":"QSYS"});
         pgm.addParam(name, "10A");
         pgm.addParam(lib == ""?"*CURLIB":lib, "10A");
         pgm.addParam("EQ", "2A");
         pgm.addParam(key.length, "3p0");
         pgm.addParam(key, key.length + "A");
         pgm.addParam(errno, {"io":"both", "len" : "rec2"});
         conn.add(pgm.toXML());
         conn.run(toJson);
       }
       sendDq("TESTQ", "XUMENG", "Hello World![Sync]", "AAA");
       getDq("TESTQ", "XUMENG", 20, "AAA", "XUMENG");
       clrDq("TESTQ", "XUMENG", "AAA");
   Tim Rowe, timmr@xxxxxxxxxx
   Business Architect Application Development & Systems Management for IBM i
   IBM i Development Lab, Rochester, MN
   (507) 253-6191 (Tie) 553-6191
   
http://www-03.ibm.com/systems/power/software/i/are/index.html
     ----- Original message -----
     From: Kevin Turner <kevin.turner@xxxxxxxxxxxxxxxxxxxx>
     Sent by: "WEB400" <web400-bounces@xxxxxxxxxxxx>
     To: "Web Enabling the IBM i (AS/400 and iSeries)" <web400@xxxxxxxxxxxx>
     Cc:
     Subject: Re: [WEB400] Who knows all about XMLSERVICE?
     Date: Sun, Aug 23, 2015 9:53 AM
     Yes that is definitely the issue - I thought/hoped it would be something
     daft.  It would be useful to be able to get something more meaningful
     than this back from the interface though (it doesn't really mention
     anything about what the cause may be, and the job log is empty).  I am
     assuming the is some option I can use on the interface to make the
     response more verbose?
     <?xml version='1.0'?><myscript><pgm name='QRCVDTAQ' lib='QSYS'
     error='fast'> <error><![CDATA[*** error QSYS QRCVDTAQ ]]></error>
     <version>XML Toolkit 1.8.5</version> <error>
     <errnoxml>1100016</errnoxml> <xmlerrmsg><![CDATA[XML run pgm
     failed]]></xmlerrmsg> <xmlhint><![CDATA[<pgm name='QRCVDTAQ' lib='QSYS'
     error='fast'><parm><data ty]]></xmlhint> </error> <error>
     <errnoxml>1000006</errnoxml> <xmlerrmsg><![CDATA[PGMCALL
     failed]]></xmlerrmsg> <xmlhint><![CDATA[QRCVDTAQ]]></xmlhint> </error>
     <error> <errnoxml>1100016</errnoxml> <xmlerrmsg><![CDATA[XML run pgm
     failed]]></xmlerrmsg> <xmlhint><![CDATA[<pgm name='QRCVDTAQ' lib='QSYS'
     error='fast'><parm><data ty]]></xmlhint> </error> <jobinfo>
     <jobipc>undefined</jobipc> <jobipcskey>FFFFFFFF</jobipcskey>
     <jobname>QSQSRVR</jobname> <jobuser>QUSER</jobuser>
     <jobnbr>176544</jobnbr> <jobsts>*ACTIVE</jobsts>
     <curuser>KTURNER</curuser> <ccsid>285</ccsid> <dftccsid>285</dftccsid>
     <paseccsid>0</paseccsid> <langid>ENU</langid> <cntryid>US</cntr
      yid> <sbsname>QSYSWRK</sbsname> <sbslib>QSYS</sbslib> <curlib></curlib>
     <syslibl>QSYS QSYS2 QHLPSYS QUSRSYS</syslibl> <usrlibl>QGPL
     QTEMP</usrlibl> <jobcpffind>see log scan, not error list</jobcpffind>
     </jobinfo> </pgm> </myscript>
     -----Original Message-----
     From: WEB400 [[1]mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of Mark S
     Waterbury
     Sent: 23 August 2015 15:49
     To: Web Enabling the IBM i (AS/400 and iSeries)
     Subject: Re: [WEB400] Who knows all about XMLSERVICE?
     Kevin:
     Looking at the code you posted (below), it appears that you are trying
     to invoke QRCVDTAQ with only eight (8) parameters. According to the API
     documentation, QRCVDTAQ requires five (5) parameters for the "normal"
     non-keyed case, or ten (10) parameters for the "keyed" data queue case,
     or thirteen (13) parameters, if you want to specify "*NO" for "remove
     message" or if you want to specify the "size of data receiver" or to
     provide the standard API error code data structure to detect any errors.
     (If the error code data structure is not provided, the API will throw
     *ESCAPE messages if errors are detected.)
     So, you appear to be "missing" the "sender length" and "sender data"
     parameters.  If you do not want the "sender information", you  must
     still pass those parameters, and pass a value of "zero" for "sender
     length."
     Hope that helps,
     Mark S. Waterbury
      > On 8/23/2015 7:04 AM, Kevin Turner wrote:
     > ...(snip)...
     > =================================================================
     > Here is the code in my little worker.js child process.  I am hoping I
     > have just made a mistake somewhere, but the error response is not
     > telling me much.  I tried debugging the XMLSERVICE code but it seems
     > that the source is out of sequence with the executable.  I just kept
     > stepping into comments etc :)
     >
     > // This tiny node app will wait for an entry on a queue and pass it to
     > the process that spawned (forked) it
     >
     > var dq =
     > require('/QOpenSys/QIBM/ProdData/Node/os400/xstoolkit/lib/idataq');
     > var xt =
     require('/QOpenSys/QIBM/ProdData/Node/os400/xstoolkit/lib/itoolkit');
     > var    DBname = "*LOCAL ";
     >
     > //Add a new function for keyed data queues
     > dq.iDataQueue.prototype.receiveFromKeyedDataQueue = function(name,
     lib, length, wait, keyOp, keyLen, key, cb) {
     >         // TODO Replace QRCVDTAQ with a call to an RPGLE program that
     will do the job
     >         var pgm = new xt.iPgm("QRCVDTAQ", {"lib":"QSYS"});
     >         pgm.addParam(name, "10A");
     >         pgm.addParam(lib == ""?"*CURLIB":lib, "10A");
     >         pgm.addParam(length, "5p0");
     >         pgm.addParam("", length + 1 + "A");
     >         pgm.addParam(wait, "5p0");
     >         pgm.addParam(keyOp, "2A");
     >         pgm.addParam(keyLen, "3p0");
     >         pgm.addParam(key, key.length + "A")
     >
     >         this.conn.add(pgm.toXML());
     >         var async = cb && xt.getClass(cb) == "Function"; //If there is
     a callback function param, then it is in asynchronized mode.
     >         var rtValue;  // The returned value.
     >         var stop = 0;  // A flag indicating whether the process is
     finished.
     >         var retry = 0;  // How many times we have retried.
     >         function toJson(str) {  // Convert the XML output into JSON
     >                var output = xt.xmlToJson(str);
     >                if(output[0].success)
     >                       rtValue = output[0].data[3].value;
     >                else
     >                       rtValue = str;
     >                if(async)     // If it is in asynchronized mode.
     >                       cb(rtValue);  // Run the call back function
     against the returned value.
     >                stop = 1;
     >         }
     >         function waitForResult() {
     >                retry++;
     >                if(stop == 0)
     >                       setTimeout('waitForResult()', retryInterval);
      // Check whether the result is retrieved
     >                else if(retry >= retryTimes)
     >                       return timeoutMsg;
     >                else
     >                       return rtValue;
     >         }
     >         this.conn.run(toJson);  // Post the input XML and get the
     response.
     >         if(!async)  // If it is in synchronized mode.
     >                return waitForResult();  // Run the user defined call
     back function against the returned value.
     > }
     >
     > // When we get some data, start listening to the queue
     > process.on('message', function(dqObj) {
     >         // Wait for stuff to arrive on a data queue also
     >         var    conn = new xt.iConn(DBname);
     >         var dtaq = new dq.iDataQueue(conn);
     >         var dtaqN = dqObj.name;
     >         var lib = dqObj.lib;
     >
     >
     >         function cb(str) {
     >                if (str) {
     >                       // Pass results back to parent process
     >                       process.send(str);
     >                }
     >                // Wait again
     >                dtaq.receiveFromKeyedDataQueue(dtaqN, lib, 64512, 1,
     'EQ', 6, 'THEKEY', cb);
     >         }
     >
     >         // Wait for something to arrive on the queue, timing out every
     1 second to allow
     >         // us to check other stuff
     >         dtaq.receiveFromKeyedDataQueue(dtaqN, lib, 64512, 1, 'EQ', 6,
     > 'THEKEY', cb);
     >
     > });
     >
     >
     >
     >
     >
     >
     >
     > -----Original Message-----
     > From: WEB400 [[2]mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of
     Kevin
     > Turner
     > Sent: 22 August 2015 20:11
     > To: Web Enabling the IBM i (AS/400 and iSeries)
     > Subject: [WEB400] Who knows all about XMLSERVICE?
     >
     > A bit of background:
     >
     > I am trying to access a keyed data queue from a node.js function using
     the IBM toolkit provided.   Not entirely unexpectedly,  the
     documentation with the toolkit is pretty sparse on examples
     [3]
https://www.ibm.com/developerworks/ibmi/library/i-native-js-app-ibmi-with-nodejs/
     >
     > They provide a script called "idataq.js" that shows examples of
     sending and receiving data to a non-keyed data queue.  It appears to use
     XMLSERVICE under the covers to do so, and it works as far as my testing
     goes. However, that is no good if you want to access a keyed data queue.
     >
     > I figured I would just create a modified version of the supplied
     "receiveFromDataQueue" function to include the extra parameters needed
     for a keyed data queue, but it fails miserably.  The XML error response
     from XMLSERVICE is virtually useless, but I have managed to glean the
     fact that it expects only 5 parameters, not the 8 I want to send it.
      Does anyone know how to make the error responses more meaningful?
     >
     > The code appears to just create an XML interface to the QRCVDTAQ
     program, so why would it complain about only wanting 5 parameters unless
     it is some sort of hardcoded limit for the API built in to XMLSERVICE
     somewhere?  Does anyone know if this is the case. The basic code for the
     version that works looks like this:
     >
     > var xt = require('./itoolkit');
     >
     > var pgm = new xt.iPgm("QRCVDTAQ", {"lib":"QSYS"}); pgm.addParam(name,
     > "10A"); pgm.addParam(lib == ""?"*CURLIB":lib, "10A");
     > pgm.addParam(length, "5p0"); pgm.addParam("", length + 1 + "A");
     > pgm.addParam(0, "5p0");this.conn.add(pgm.toXML());
     >
     > this.conn.run(toJson);
     >
     > but calling QSNDDTAQ like this does not work var xt =
     > require('./itoolkit'); var pgm = new xt.iPgm("QRCVDTAQ",
     > {"lib":"QSYS"}); pgm.addParam(name, "10A"); pgm.addParam(lib ==
     > ""?"*CURLIB":lib, "10A"); pgm.addParam(length, "5p0");
     > pgm.addParam("", length + 1 + "A"); pgm.addParam(5,
     > "5p0");this.conn.add(pgm.toXML());
     >
     > pgm.addParam(keyOp, "2A");
     >
     > pgm.addParam(keyLen, "3p0");
     >
     > pgm.addParam(key, key.length + "A")
     >
     > this.conn.run(toJson);
     >
     > I thought I would try to write my own program to see if that would
     work (rather than using QRCVDTAQ directly) but I cannot find any
     examples of what my program signature should look like.  I have looked
     at the documentation for XMLTOOLKIT for examples but (IMHO) the
     documentation is pretty dreadful.....not an uncommon complaint for IBM
     stuff.
     >
     > Just a simple RPG example program would be useful.
     >
     > Thanks
     >
     > ...(snip)...
     --
     This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
     list To post a message email: WEB400@xxxxxxxxxxxx To subscribe,
     unsubscribe, or change list options,
     visit: [4]
http://lists.midrange.com/mailman/listinfo/web400
     or email: WEB400-request@xxxxxxxxxxxx
     Before posting, please take a moment to review the archives at
     [5]
http://archive.midrange.com/web400.
     ___________________________________________
     This email has been scanned by iomartcloud.
     [6]
http://www.iomartcloud.com/
     ________________________________
     NOTICE: The information in this electronic mail transmission is intended
     by CoralTree Systems Ltd for the use of the named individuals or entity
     to which it is directed and may contain information that is privileged
     or otherwise confidential. If you have received this electronic mail
     transmission in error, please delete it from your system without copying
     or forwarding it, and notify the sender of the error by reply email or
     by telephone, so that the sender's address records can be corrected.
     --------------------------------------------------------------------------------
     CoralTree Systems Limited
     Company Registration Number 5021022.
     Registered Office:
     12-14 Carlton Place
     Southampton
     Hampshire
     SO15 2EA
     VAT Registration Number 834 1020 74.
     --
     This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
     list
     To post a message email: WEB400@xxxxxxxxxxxx
     To subscribe, unsubscribe, or change list options,
     visit: [7]
http://lists.midrange.com/mailman/listinfo/web400
     or email: WEB400-request@xxxxxxxxxxxx
     Before posting, please take a moment to review the archives
     at [8]
http://archive.midrange.com/web400.
References
   Visible links
   1. mailto:web400-bounces@xxxxxxxxxxxx
   2. mailto:web400-bounces@xxxxxxxxxxxx
   3. 
https://www.ibm.com/developerworks/ibmi/library/i-native-js-app-ibmi-with-nodejs/
   4. 
http://lists.midrange.com/mailman/listinfo/web400
   5. 
http://archive.midrange.com/web400
   6. 
http://www.iomartcloud.com/
   7. 
http://lists.midrange.com/mailman/listinfo/web400
   8. 
http://archive.midrange.com/web400
As an Amazon Associate we earn from qualifying purchases.