Hi @ll,
I've a question regarding the behavior of an HTTPGETBLOB call.
I created an SQL UDF which is calling an web-service:
and a RPG-Program with embedded SQL and also Serviceprogram (for use in other sql statements):
In the procedure INIT_ENV there are some calls to set up the environment:
CALL QCMDEXC('ADDENVVAR ENVVAR(JAVA_HOME) VALUE(''/QOpenSys/QIBM/ProdData/JavaVM/jdk60/64bit'') REPLACE(*YES)');
CALL QCMDEXC('ADDENVVAR ENVVAR(QIBM_JAVA_PROPERTIES_FILE) VALUE(''/QIBM/userdata/java400/my.properties'') REPLACE(*YES)');
The web service is designed to return a 404 message if no data was found (e.g. invalid personnel number).
The return value is then as follows:
- 38000(-443)[IBM][System i Access ODBC Driver]SQL0443 (0,60 secs)
- S1000(-4302)[IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL4302 - Die gespeicherte Java-Proz. oder benutzerdef. Funktion SYSTOOLS.HTTPGETBLOB mit dem spezifischen Namen HTTPG00001 wird mit der Ausnahmebed. https://xxx:xxx@xxx.de/employee-data...ate=2017-11-16 abgebrochen. (0,48 secs)
Is this behavior normal? Did I do something wrong?
I am grateful for any help!
Best regards,
BM
I've a question regarding the behavior of an HTTPGETBLOB call.
I created an SQL UDF which is calling an web-service:
Code:
CREATE FUNCTION PGM.MYFUNC (
PNR DECIMAL(7, 0) )
RETURNS CHAR(50)
LANGUAGE RPGLE
SPECIFIC PGM.MYFUNC
NOT DETERMINISTIC
NOT FENCED
READS SQL DATA
RETURNS NULL ON NULL INPUT
EXTERNAL NAME 'PGM/MYFUNC(SQL_FUNC)'
PARAMETER STYLE GENERAL ;
Code:
PSQL_FUNC B EXPORT
DSQL_FUNC PI 50A
D PNR 7 0
*
D WEB_URL S 255C
D VALIDITY_DTE S D
D SQL_RTN S 50A
*
C MONITOR
*
C TIME VALIDITY_DTE
/FREE
CALLP INIT_SAP_ENV();
WEB_URL = 'https://xxx:xxx@xxxx.de/' +
'employee-data-transfer/api/employee/' + %CHAR(PNR) +
'/birthplace?validityDate=' + %CHAR(VALIDITY_DTE);
/END-FREE
*
C/EXEC SQL
C+ SELECT RESULT.* into :SQL_RTN
C+ FROM XMLTABLE(
C+ '$result'
C+ PASSING
C+ XMLPARSE(DOCUMENT SYSTOOLS.HTTPGETBLOB(
C+ cast(:WEB_URL as char(255) ccsid 273), '')
C+ ) as "result"
C+ COLUMNS birthplace CHAR(50) PATH 'birthplace'
C+ ) AS result
C/END-EXEC
C IF SQLCOD = *ZEROS
C RETURN SQL_RTN
C ENDIF
*
C ON-ERROR
C RETURN *BLANKS
*
C ENDMON
*
PSQL_FUNC E
CALL QCMDEXC('ADDENVVAR ENVVAR(JAVA_HOME) VALUE(''/QOpenSys/QIBM/ProdData/JavaVM/jdk60/64bit'') REPLACE(*YES)');
CALL QCMDEXC('ADDENVVAR ENVVAR(QIBM_JAVA_PROPERTIES_FILE) VALUE(''/QIBM/userdata/java400/my.properties'') REPLACE(*YES)');
The web service is designed to return a 404 message if no data was found (e.g. invalid personnel number).
The return value is then as follows:
- 38000(-443)[IBM][System i Access ODBC Driver]SQL0443 (0,60 secs)
- S1000(-4302)[IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL4302 - Die gespeicherte Java-Proz. oder benutzerdef. Funktion SYSTOOLS.HTTPGETBLOB mit dem spezifischen Namen HTTPG00001 wird mit der Ausnahmebed. https://xxx:xxx@xxx.de/employee-data...ate=2017-11-16 abgebrochen. (0,48 secs)
Is this behavior normal? Did I do something wrong?
I am grateful for any help!
Best regards,
BM


Comment