[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Help with a simple call to http_url_post_raw
Hello Everyone,
Thanks for helping me with the USPS call...
I'm learning as I go here. What I'm trying to do now is use the
http_url_post_raw procedure.
I'm getting an "rc" of 1 back after the call, but we don't see our
message show up in the ActiveMQ queue.
Here's the code I'm running. One question I have right away is, I see
others have posted a log file from HTTPAPI. I haven't had any luck
finding this log file in my IFS. Does anyone know where I might locate
that log? I would love to see the log, because when I run debug
through all of the services in HTTPAPI (and the others), it's not fast
enough to meet the timeout default of 60 seconds.
1) Do I need to encode the URL like I'm doing below?
Here's the code I'm running. Any help is greatly appreciated. Thanks!
H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('LIBHTTP/HTTPAPI')
D/copy qrpglesrc,httpapi_h
D Incoming PR 10I 0
D descriptor 10I 0 value
D data 8192A options(*varsize)
D datalen 10I 0 value
d Enc s like(HTTP_URL_ENCODER)
d url s 32767a varying
d urlValues s 32767a varying
d addressRequest s 32767a varying
d bigString s 32767a varying
D rc s 10I 0
D rc2 s N
D msg s 52A
D data S 32767A varying
D retdata S 32766A
D retlen S 10I 0
D nextpos S 10I 0 inz(1)
/free
http_debug(*on);
url = 'http://10.179.120.77:8161/demo/message/Ec3pl-850-OutboundOrders/';
data = '10015 West';
//Encode the url string.
Enc = http_url_encoder_new();
rc2 = http_url_encoder_addvar( Enc:
'body':
%addr(data) + 2:
%len(data));
bigString = http_url_encoder_getstr(Enc);
urlValues = 'type=queue&' + bigString;
//Post the request.
rc = http_url_post_raw(url + urlValues:
%addr(data):
%len(%trimr(data)):
1:
%paddr('INCOMING'));
if rc <> 1;
msg = http_error;
dsply msg;
//return;
else;
if retlen > 1;
callp http_xlate(retlen: retdata: TO_EBCDIC);
endif;
endif;
//Free the memory allocated to the encoded URL.
http_url_encoder_free(Enc);
*inlr = *on;
return;
/end-free
P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P* this procedure will receive the raw data received from UPS
P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P Incoming B
D Incoming PI 10I 0
D descriptor 10I 0 value
D data 8192A options(*varsize)
D datalen 10I 0 value
C* Make sure we don't overflow the string:
c eval retlen = (nextpos + datalen) - 1
c if retlen > %size(retdata)
c eval datalen=datalen-(retlen-%size(retdata))
c endif
C* If there is nothing to write, return THAT...
c if datalen < 1
c return 0
c endif
C* Here we add any data sent to the end of our 'retdata' string:
c eval %subst(retdata: nextpos) =
c %subst(data:1:datalen)
c eval nextpos = nextpos + datalen
c* We always return the amount of data that we wrote. Note
C* that if http-api sees that we didn't write as much data as
C* it sent us, it'll abort the process with an error message.
c return datalen
P E
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------