Passsing UCS2 data type between CLient and Server - SQLRPGLE program

Issue #4 wontfix
Former user created an issue

Hello,

Working on XMLSERVICE 1.9.2 Toolkit.

Looking to exchange UCS2 data type between client (SQLRPGLE) and server(SQLRPGLE) it does not work with the following XML definition in the client program:

<data type='100A' var='wrkUcs2Data' *after(13488/13488) >x</data>

Based on the documentation available on website: (http://youngiprofessionals.com/wiki/index.php/XMLService/DataTypes), don't see any data type definition for UCS2 variables.

Any example would be of help.

email address: chaks_gr@hotmail.com

Regards. Chaks.

Comments (4)

  1. Former user Account Deleted

    Thanks for the input.

    Summary ... Use case is client RPG (your program) to server RPG (my program xmlservice), using XML, and desire for Unicode (USC2).

    Protocol ... XMLSERVICE protocol is XML (possibly JSON future), so communication between client/server is a big string.

    Factors ...

    We must face IBM i does not allow Unicode CCSID for job description. Therefore, end-2-end coverage 'pure Unicode' is simply NOT possible. In short, always conversion in any practical application (including green screen).

    I am no expert in NLS, but based on my Unix background, i believe UTF-8 is 'best' fit a increasingly Linux focused world (IBM powerpc Linux among many). UTF-8 appears even more popular in any web context (web site, mobile, etc.).

    My usual answer is 'forced' conversion at connection level ctl="pase(x) before(x/x) after(x/x)", NOT at the <data> level. The idea is to convert entire XML document before XMLSERVICE starts passing to other called xmlservice services DB2, PASE, PGM, etc. Have you tried this 'global or control' sort of solution below (variation for RPG-2-RPG)??

    Example French:
    
    ctl = "*pase(1208) *before(297/37) *after(37/297)"
    

    However a bug was found in *before, so you will have to use a new version of xmlservice (1.9.5+ latest).

    Also, there is the idea of using xmlservice 'private' jobs. Idea is you send language match to the correct match xmlservice private job. Have you tried this 'pre-start private job' sort of solution below??

    =========
    server -- pre-started XTOOLKIT jobs
    =========
    pre-started Japan XTOOLKIT jobs ...
    SBMJOB CMD(CALL PGM(XMLSERVICE/XMLSERVICE) PARM('/tmp/JP5035-1')) JOBD(MYLIB/MY5035) ... Japan 1 (works Japan)
    SBMJOB CMD(CALL PGM(XMLSERVICE/XMLSERVICE) PARM('/tmp/JP5035-2')) JOBD(MYLIB/MY5035) ... Japan 2 (works Japan)
    :
    SBMJOB CMD(CALL PGM(XMLSERVICE/XMLSERVICE) PARM('/tmp/JP5035-n')) JOBD(MYLIB/MY5035) ... Japan n (works Japan)
    
    pre-started China xTOOLKIT jobs
    SBMJOB CMD(CALL PGM(XMLSERVICE/XMLSERVICE) PARM('/tmp/CN1388-1')) JOBD(MYLIB/MY1388) ... China 1 (works China)
    SBMJOB CMD(CALL PGM(XMLSERVICE/XMLSERVICE) PARM('/tmp/CN1388-2')) JOBD(MYLIB/MY1388) ... China 2 (works China)
    :
    SBMJOB CMD(CALL PGM(XMLSERVICE/XMLSERVICE) PARM('/tmp/CN1388-n')) JOBD(MYLIB/MY1388) ... China n (works China)
    
    Add languages pre-started xTOOLKIT jobs with any matching JOBD(s) /tmp/Russia, /tmp/German, /tmp/klingon ...
    
    =====
    client -- simply pick correct XTOOLKIT jobs to match language, based on input, yes???
    =====
           // use XMLSERVICE to match correct language
           if myinput = 5035:
             myIPC = '/tmp/JP5035-' + randomNumber();
           else:
             myIPC = '/tmp/CN1388-' + randomNumber();  
           // --or-- SBJJOB for both PHP and this module
           myCtl = '*sbmjob';
    
           // call XMLSERVICE/ZZCALL(...) using XML only
           myXmlIn = 
             '<?xml version="1.0" encoding="ISO-8859-1"?>'         + x'0D'
           + '<script>'                                            + x'0D'
           + '<pgm name="ZZCALL" lib="XMLSERVICE">'                + x'0D'
             :
           + '</script>'                                           + x'00';
    
           // XML will be returned 
           myXmlOut = *BLANKS; 
    
           // make call to XMLSERVICE provided stored procedure(s
           // sizes from iPLUG4k to iPLUG15M (see crtsql xmlservice package)
           Exec Sql call XMLSERVICE/iPLUG15M(:myIPC,:myCtl,:myXmlIn,:myXmlOut);
    

    Again, i am no expert in NLS. If you can describe a better solution, this is the correct place.

  2. chaks_gr

    In my example below client RPGLE program is one of the tiers in n-tier application architecture, catering the webservice request, HTTP request...

    With IBMi support for unicode (UTF8, UTF16 encoding), processing multi-lingual data is no more a barrier. (Of course displaying multi-lingual data on green screen is still a distant dream).

    Following are the changes recommended to overcome the job CCSID issue to process multi-lingual data. Goal is to provide unicode (UTF8/UTF16-encoding) support for communication between client and server.

    Step1- SQL Stored Procedures: ## Create new SQL stored procedures IPLUGxxY_UTF8 (for UTF8 as transport medium) and iPluGxx_UTF16 (for UTF16 as transport medium).

    i.e. myXmlInp and myXmlOut should be created with CLOB(xx) CCSID(1208) for UTF8 and myXmlInp and myXmlOut should be created with DBCLOB(xx) for UTF16.

    CREATE PROCEDURE QXMLSERV/IPLUG65K_UTF8 ( IN IPC CHAR(1024) , IN CTL CHAR(1024) , IN CI CLOB(66560) CCSID 1208, OUT CO CLOB(66560) CCSID 1208) LANGUAGE RPGLE SPECIFIC QXMLSERV/IPLUG65K_UTF8 NOT DETERMINISTIC MODIFIES SQL DATA CALLED ON NULL INPUT EXTERNAL NAME 'QXMLSERV/XMLSTOREDP(iPLUG65K_UTF8)' PARAMETER STYLE GENERAL ;

    CREATE PROCEDURE QXMLSERV/IPLUG65K_UTF16 ( IN IPC CHAR(1024) , IN CTL CHAR(1024) , IN CI DBCLOB(66560) , OUT CO DBCLOB(66560) ) LANGUAGE RPGLE SPECIFIC QXMLSERV/IPLUG65K_UTF16 NOT DETERMINISTIC MODIFIES SQL DATA CALLED ON NULL INPUT EXTERNAL NAME 'QXMLSERV/XMLSTOREDP(iPLUG65K_UTF16)' PARAMETER STYLE GENERAL ;

    Step2 - Client side: ##

    • Declare xmyXmlInp and myXmlOut as CCSID(1208) for UTF8 and CCSID(1200) for UTF16

    Note: ### V7R2 support CCSID(1208) as RPGLE variable, for earlier versions can try iconv api or SQL CAST at parm level

    • Build xmyXmlInp string with encoding UTF8/UTF16 as required. • Invoke the iPluGxx_UTF8 / iPluGxx_UTF16 procedure • Process xmyXmlOut string with encoding UTF8/UTF16 as appropriate

    Step3 - Server side:

    • Allow support for new data types (C-UCS2 and G-Graphic) with CCSID(xxx) • XMLSERVICE reads the myXmlInp and builds the string to invoke the program (RPGLE,...).

    Note: ### While preparing the string based on the data type and CCSID (convert UTF8/UTF16 string to appropriate CCSID(xxx))

    • XMLSERVICE Process the requested program (RPGLE...) • XMLSERVICE build the output string in (UTF8 / UTF16) encoding and return it to client

    Note: ### SQL can used for converting any data in CCSID(xxx) to UTF8/UTF16 encoding and viceversa. Are any other api/utility like iconv….

  3. chaks_gr

    FYI, displaying multi-lingual data on green screen is now possible with IBMi Access Client Solution.

  4. Former user Account Deleted
    • edited description
    • changed status to wontfix

    This is an exception case. The much greater majority (95%) will use standard ASCII<>EBCDIC. We will not penalize others for the exception.

  5. Log in to comment