[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: https with userid and password
Sender: "Stoicescu, Adriana" <astoicescu@xxxxxxxxxx>
Scott,
I have tested the program , got error 500 and http_url_p (?) ended in error.
How can I free the space allocated with http_url_encoder_new and addvar? My
session is still active.
Here it is a joblog printout, maybe you can give me a clue about what
happened in http_url_p (?).
Length or start position is out of range for the string operation.
Function check. RNX0100 unmonitored by HTTPAPIR4 at statement 0000004161,
instruction X'0000'.
The call to HTTP_URL_P ended in error (C G D F).
Thanks
Adriana
-----Original Message-----
From: owner-ftpapi@xxxxxxxxxxxxx [mailto:owner-ftpapi@xxxxxxxxxxxxx] On
Behalf Of Scott Klement
Sent: Friday, December 30, 2005 4:22 PM
To: 'ftpapi@xxxxxxxxxxxxx'
Subject: RE: https with userid and password
Sender: Scott Klement <sk@xxxxxxxxxxxxxxxx>
Since you might make many requests and encode each one, to use HTTPAPI's
encoding routines, you must first "create an encoder". This creates
temporary space in memory that HTTPAPI will use to store info while it's
encoding data.
D Enc s like(HTTP_URL_ENCODER)
.
.
Enc = http_url_encoder_new();
Once you've created the encoder, you can add variables to it with their
values. It'll encode them properly so that the server won't choke on
them. It'll store the result in that temporary space in memory that I
mentioned above.
http_url_encoder_addvar(enc: 'xml': p_data: dataLen);
Once you've added all of the variables that you need to the encoder (in
this situation, there's just one... the xml variable) you can use the
contents of the encoder to construct a URL.
url = 'https://apps2.tradegate2000.com/import/whatever' +
+ '?' + http_url_encoder_getstr(Enc);
This'll result in a URL like 'https://. . ./whatever?xml=datadatadata'
Then you pass that URL to the http_url_post() or http_url_get() routines.
Here's a more complete example:
H DFTACTGRP(*NO) BNDDIR('LIBHTTP/HTTPAPI')
/copy libhttp/qrpglesrc,httpapi_h
D rc s 10I 0
D Enc s like(HTTP_URL_ENCODER)
D xml s 5000A varying
D url s 32767A varying
/free
xml = '<?xml version="1.0">'
+ '<testXml>'
+ ' <Dummy>Scott Klement</Dummy>'
+ ' <OtherXml>BlahBlah</OtherXml>'
+ '</testXml>';
Enc = http_url_encoder_new();
http_url_encoder_addvar(Enc: 'xml': %addr(xml)+2: %len(Xml));
url = 'https://apps2.tradegate2000.com/import' +
http_url_encoder_getstr(Enc);
rc = http_url_get(url . . .
- or -
rc = http_url_post(url . . .
http_url_encoder_free(enc);
if rc <> 1;
errmsg = http_error();
// show errmsg to user!
endif;
*inlr = *on;
/end-free
Due the fact that HTTPAPI didn't have much internal space for strings to
send to the server in version 1.12 and earlier, I recommend that you use
version 1.13 for this sort of logic. However, even so, you're limited to
around 32k (actually, it's a bit less because of the space that the other
HTTP headers use).
For anything longer than that, you really don't want to use data in the
URL. You want to use actual POST data for a document longer than that...
indeed many web browsers and web servers will choke on URL data that's
longer than 8k. (POST data has no practical limit on how large it can
be.)
I have no clue why you'd want to use variables like this on a POST
request, other than that the developer who wrote the web service didn't
really understand what he was doing. Sending the data as the body of the
POST request is a much more robust solution!!
---
Scott Klement http://www.scottklement.com
On Fri, 30 Dec 2005, Stoicescu, Adriana wrote:
>
> In fact 'xml' is the only parameter of their program and they are asking
me
> to pass it with a GET syntax although it is a POST. They want the variable
> to be named xml. How can I do this?
> This I cannot understand.
> Adriana
>
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------
-------------------------------------------------------------------------------------
Email Confidentiality Notice and Disclaimer
This email message contains information which may be confidential and
or legally privileged. Unless you are the intended recipient (or have
been authorised to receive on behalf of the intended recipient), you
may not use, copy or disclose to anyone the message or any information
contained in the message or from any attachments that were sent with
this email. If you have received this email message in error, please
advise the sender by email, and delete the message.
All business and transactions of whatsoever nature be it as agent or
as principal with any party whatsoever shall solely be conducted in
accordance with our Standard Trading Conditions. These conditions have
clauses that may limit our liability. A copy of our Standard Terms is
available on request. When an air waybill or bill of lading or any
other international consignment note is issued, the conditions that
apply for such a document will be in addition to our Standard Trading
Conditions, and for the relative air or sea or other mode of transport
leg / movement only, they will be paramount.
-------------------------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------