|
I removed the JSON hard coding and replaced it with code that uses the YAJL procedures to build/send the JSON.
Now I am receiving the following error.
java.lang.RuntimeException: Invocation of program failed. AS400Message (ID: MCH3401 text: Cannot resolve to object YAJL. Type and Subtype X'0203' Authority X'0000'.):com.ibm.as400.access.AS400Message@ff387934
YAJL is not in the initial library list but I did change the configuration file to include it:
<Directory /qsys.lib/cgiobjf.lib>
SetEnv QIBM_CGI_LIBRARY_LIST “YAJL;LIBHTTP”
Order Allow,Deny
Allow From All
</Directory>
I also include YAJL in the CRTPGM:
CRTPGM PGM(MTDOBJF/OSR0001) MODULE(MTDOBJF/OSR0001) BNDSRVPGM((QHTTPSVR/QZHBCGI) (YAJL/YAJLR4) (YAJL/YAJL)) ACTGRP(ORDERS)
How can I resolve this error message?
________________________________
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxx> on behalf of Bradley Stone <bvstone@xxxxxxxxx>
Sent: Friday, July 27, 2018 3:51 PM
To: Midrange Systems Technical Discussion
Subject: Re: REST service not sending JSON response body
If they do, then that's not the problem. Just throwing ideas out there,
Jon. Something is wrong with the code.
Bradley V. Stone
www.bvstools.com<http://www.bvstools.com>
GreenTools for G Suite/Google Apps <https://www.bvstools.com/g4g.html>:
Easy to use interfaces for GMail, Google Drive, Calendar, Contacts and
Cloud Print! <\body> <\html>
On Fri, Jul 27, 2018 at 2:34 PM Jon Paris <jon.paris@xxxxxxxxxxxxxx> wrote:
Those two protos produce identical results Brad so how can it help?--
Jon Paris
www.partner400.com<http://www.partner400.com>
www.SystemiDeveloper.com<http://www.SystemiDeveloper.com>
On Jul 27, 2018, at 3:03 PM, Bradley Stone <bvstone@xxxxxxxxx> wrote:of
I'd look into your definition for QtmhWrStout, then.
dcl-pr QtmhWrStout extproc('QtmhWrStout');
dtaVar char(65535) options(*varsize) const;
dtaCarLen int(10) const;
errorCode char(8000) options(*varsize);
end-pr;
vs
dcl-pr QtmhWrStout extproc('QtmhWrStout');
dtaVar pointer;
dtaCarLen int(10) const;
errorCode char(8000) options(*varsize);
end-pr;
and use:
QtmhWrstout( %addr(data) : %len(%trimr(data) : errorCode );
vs
QtmhWrStout(data: %len(%trim(data)): err);
I would also debug and right before you call QtmhWrStout debug the value
data and it's length (which you'd need a variable for). My bet is it'swrote:
either one or the other or both of those things.
On Fri, Jul 27, 2018 at 9:20 AM Rich Dotson <rich_dotson@xxxxxxxxxxx>
captureThanks for the response Bradley.
1. Sent my URL through Postman:
* Body: Nothing was returned
* Header: content-language -> en-US
content-length --> 0
date --> Fri, 27 Jul 2018 14:09:41 GMT
x-powered-by --> IBM i
2. The JSON that will be returned is already being generated using YAJL.
It is currently being written to the IFS and picked up by a network
scheduled job. Once I get this REST pgm working I was going to
everythingthat JSON and send it back as the response.
________________________________
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxx> on behalf of Bradley
Stone <bvstone@xxxxxxxxx>
Sent: Friday, July 27, 2018 9:46 AM
To: Midrange Systems Technical Discussion
Subject: Re: REST service not sending JSON response body
A couple things.
Can you send a response from Postman or Chrome debugger to see
withbeing returned?
2nd, I would strongly suggest you use something like Scott Klements YAJL
for this instead of calling the raw APIs, especially for building the
JSON. There is also a function in YAJL that will write out your JSON
inheaders.
Using CGIDEV2 or eRPGSDK will also make things easier, such as reason
responses or any data parms passed in through a GET or POST.
I understand it's just a proof of concept. :)
Bradley V. Stone
www.bvstools.com<http://www.bvstools.com>
GreenTools for G Suite/Google Apps <https://www.bvstools.com/g4g.html>:
Easy to use interfaces for GMail, Google Drive, Calendar, Contacts and
Cloud Print! <\body> <\html>
On Fri, Jul 27, 2018 at 7:20 AM Rich Dotson <rich_dotson@xxxxxxxxxxx>
wrote:
I am creating a proof-of-concept REST application on our iSeries and I
have the majority of it working but I am not getting the JSON returned
knowthe response body. I added code that sends a message to QHST so I
listthe service is getting called and the URI retrieved in the code isbody.
correct. I've include the code below. When I execute the endpoint
http://iSeriesName/web/services/ORDERS/123456789123 from Fiddler the
Response Header returned is HTTP/1.1 200 OK but there is no response
How do I return my JSON in the response body?TOMSGQ(QHST)';
This is what appears in QHST showing the program variables retrieved:
---> Version 1.0 <---
/web/services/ORDERS/123456789123
refOrderNumber: 123456789123
Building data field
--->Send Response Data Field: Status: 500 Invalid URI??Content-type:
text/json????{ "success": false, "errmsg": "Invalid URI!"}??
This is the program code:
**free
ctl-opt BndDir('QC2LE': 'COMBNDDIR')
PgmInfo(*pcml: *module) DecEdit('0.');
dcl-pr getenv pointer extproc(*dclcase);
var pointer value options(*string);
end-pr;
dcl-pr QtmhWrStout extproc('QtmhWrStout');
dtaVar char(65535) options(*varsize) const;
dtaCarLen int(10) const;
errorCode char(8000) options(*varsize);
end-pr;
dcl-pr SysCmd int(10) extproc('system');
*n pointer value options(*string);
end-pr;
dcl-s sysErrMsg char(7) import('_EXCP_MSGID');
dcl-ds err qualified;
bytesProv int(10) inz;
bytesAvail int(10) inz;
end-ds;
dcl-s bigCharVar char(100000) inz;
dcl-s httpHeader char(500) inz;
dcl-s charVar char(500) inz;
dcl-s data char(5000) inz;
dcl-s lengthOfJSON int(10) inz;
dcl-s msgQHST char(512) inz;
dcl-c CRLF const(X'0d25');
dcl-c q const(X'7D');
dcl-s uri varchar(5000) inz;
dcl-s httpStatus packed(3: 0) inz;
dcl-s success ind inz(*On);
dcl-s errMsg varchar(500) inz;
dcl-s refOrderNumber char(15) inz;
dcl-s refOrderStartPos int(10) inz;
dcl-s refOrderEnd int(10) inz;
*InLR = *On;
msgQHST = 'SNDMSG MSG(' + q + '---> Version 1.0 <---' + q + ')
TOMSGQ(QHST)';
SysCmd(msgQHST);
uri = %str(getenv('REQUEST_URI'));
msgQHST = 'SNDMSG MSG(' + q + %Trim(uri) + q + ') TOMSGQ(QHST)';
SysCmd(msgQHST);
refOrderStartPos = %Scan('/ORDERS/': uri) + %len('/ORDERS/');
refOrderNumber = %Trim(%SubSt(uri: refOrderStartPos));
msgQHST = 'SNDMSG MSG(' + q + 'refOrderNumber: ' +
%Trim(refOrderNumber) + q + ') TOMSGQ(QHST)';
SysCmd(msgQHST);
msgQHST = 'SNDMSG MSG(' + q + 'Building data field' + q + ')
SysCmd(msgQHST);list
data = 'Status: 500 Invalid URI' + CRLF
+ 'Content-type: text/json' + CRLF + CRLF
+ '{ "success": false, "errmsg": "Invalid URI!" }' + CRLF;
msgQHST = 'SNDMSG MSG(' + q + '--->Send Response data field: ' +
%Trim(data) + q + ') TOMSGQ(QHST)';
SysCmd(msgQHST);
QtmhWrStout(data: %len(%trim(data)): err);
msgQHST = 'SNDMSG MSG(' + q + 'err: ' +
%Trim(err) + q + ') TOMSGQ(QHST)';
SysCmd(msgQHST);
return;
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
To post a message email: MIDRANGE-L@xxxxxxxxxxxx--
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
listTo post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
abilityTo post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
Bradley V. Stone
www.bvstools.com<http://www.bvstools.com>
MAILTOOL Benefit #2 <https://www.bvstools.com/mailtool.html>: The
to specify a "From" and/or "Reply To" email address!list
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
To post a message email: MIDRANGE-L@xxxxxxxxxxxxquestions.
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related
Help support midrange.com by shopping at amazon.com with our affiliatelink: http://amzn.to/2dEadiD
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link: http://amzn.to/2dEadiD
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.