[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AW: AW: question about example 2
Larry,
I do not know where the 3 blanks and the xOD25 (CRLF) come from. The only idea I have is that it could have been added by your "incoming" procedure, provided that is does not come from the server. From my point of view there is no other code in HTTPAPI, that adds any data to the received message.
Last but not least I noticed, that you use http_xlate() to convert the received message. Please have in mind, that the received message is "POST" data and not "protocol" data. The potential problem that I see is that http_xlate() uses the "ToASCII" and "ToEBCDIC" iconv() handles. But these handles are created with the protocol CCSIDs, that are passed to http_setCCSIDs():
http_setCCSIDs(pePostRem: pePostLoc: peProtRem: peProtLoc)
Post data conversion:
from_ccsid = pePostRem
to_ccsid = pePostLoc
pToEBCDIC = iconv_open(dsTo: dsFrom)
from_ccsid = pePostLoc
to_ccsid = pePostRem
pToASCII = iconv_open(dsTo: dsFrom)
Protocol data conversion:
from_ccsid = wwProtRem
to_ccsid = wwProtLoc
toEBCDIC = iconv_open(dsTo: dsFrom)
from_ccsid = wwProtLoc
to_ccsid = wwProtRem
toASCII = iconv_open(dsTo: dsFrom)
There is no problem, as long as you do not call http_setCCSIDs(), because the default values are the same for both conversions (job ccsid versus 819). It is always the following statement that is called to set the default values:
HTTP_SetCCSIDs( HTTP_ASCII: HTTP_EBCDIC )
But for example if you use HTTP_SetCCSIDs() to set the CCSID of the post data to 1208 (utf-8), then http_xlate() does not work any longer to convert your post data, because it still uses 819 for the protocol data.
The only procedure that use the iconv() handles for POST data is http_xlatedyn(). The disadvantage of it is, that it allocates memory and that you need to deallocate that memory by hand. Therefore it might be a good idea to wrap http_xlatedyn() with a procedure that does the following steps:
a) call http_xlatedyn() to convert the data
b) copy the translated data to the input buffer. So it is actually an IO buffer as it is with http_xlate().
c) free the memory that had been allocated by http_xlatedyn()
The disadvantage of that approach is that the IO buffer could be too small to hold the result when converting EBCDIC to UTF-8.
Just my 2 cents.
Regards,
Thomas.
-----Ursprüngliche Nachricht-----
Von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] Im Auftrag von Larry Kleinman
Gesendet: Donnerstag, 9. April 2015 22:37
An: HTTPAPI and FTPAPI Projects
Cc: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
Betreff: Re: AW: question about example 2
Scott - just wanted to let you know that I got this all working, but have
one last question. The value that I get in retdata is correct, except it
starts with 3 blanks and then a hex 0D25 (a CRLF). I am pretty sure that
this is not coming from the PHP script that my RPG program calls. Is it
possible that it is somehow being inserted by the RPG code? Here is
(what I think is) the relevant RPG and PHP code
eval rc=http_url_post_raw(
'http://10.100.100.10:24444' +
'/ebiz/customer/SendUpdateStage.php' :
mypointer: dataSize:
1:
%paddr('INCOMING'):
HTTP_TIMEOUT:
HTTP_USERAGENT:
'application/x-www-form-urlencoded' )
if rc <> 1
eval msg = http_error
dsply msg
return
endif
* convert the data we just received to EBCDIC
if retlen > 1
callp http_xlate(retlen: retdata: TO_EBCDIC)
endif
curl_setopt($ch, CURLOPT_URL, "https://the url i post data to");
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_USERPWD, "xxxx:yyyyy"); curl_setopt($ch, CURLOPT_POSTFIELDS, $parmlist); curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: application/json'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
// $output contains the output string
$output = curl_exec($ch);
// Send the HTTP response code back to RPG program
$info = curl_getinfo($ch);
echo $info['http_code'];
Larry Kleinman
Kleinman Associates, Inc.
212-949-6469
From: Scott Klement <sk@xxxxxxxxxxxxxxxx>
To: HTTPAPI and FTPAPI Projects <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>,
Date: 03/24/2015 11:36 PM
Subject: Re: AW: question about example 2
Sent by: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
That's why *OMIT doesn't work. It'd work if you use a recent release.
On 3/24/2015 8:07 PM, Larry Kleinman wrote:
> yes. that;s where i got most of the code that I am using
> Larry Kleinman
> Kleinman Associates, Inc.
> 212-949-6469
> From: Scott Klement <sk@xxxxxxxxxxxxxxxx>
> To: HTTPAPI and FTPAPI Projects
<ftpapi@xxxxxxxxxxxxxxxxxxxxxx>,
> Date: 03/24/2015 08:50 PM
> Subject: Re: AW: question about example 2
> Sent by: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> __________________________________________________________________
>
> Are you running an old version of HTTPAPI?
> On 3/24/2015 7:30 PM, Larry Kleinman wrote:
> > Scott - I got it to work. I added the parms that you
suggested
> but got
> > a "pointer not set for location referenced" message. Then I
> change
> > the 7th parm from *OMIT to HTTP_USERAGENT (like in EXAMPLE2)
and
> it
> > worked. I don't know why, but I bet you do. When you get a
> chance,
> > can you explain?
> > Thanks
> > and thank you, Mike, for your help as well!
> > Larry Kleinman
> > Kleinman Associates, Inc.
> > 212-949-6469
> > From: Scott Klement <sk@xxxxxxxxxxxxxxxx>
> > To: HTTPAPI and FTPAPI Projects
> <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>,
> > Date: 03/24/2015 07:16 PM
> > Subject: Re: AW: question about example 2
> > Sent by: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > ________________ _________________________
> _________________________
> >
> > Larry,
> > You aren't providing the content-type. Most installations
have
> the
> > default for content-type set to XML since that's the most
common
> use of
> > HTTPAPI... But, since you are simulating an HTML form, the
> > content-type should be application/x-www-form-urlencoded (this
is
> off
> > the top of my head, hopefully I'm remembering it right.) PHP
> may be
> > ignoring your data because you're telling it that the data is
XML
> and
> > it
> > doesn't understand that type of data?? The content-type can
be
> passed
> > in the 8th parameter to http_url_post_raw().
> > You are coding in fixed format calcs (shudder), so I guess
you'd
> want
> > to
> > code it like this (keeping the rest of the code the way you
had
> it in
> > the SEU printout you provided...)
> > c eval rc = http_url_post_raw(
> > c 'http://192.168.98.3/mitchells' +
> > c '/CreateCreditTest.php':
> > c : mypointer
> > C : dataSize
> > c : 1
> > C : %paddr('INCOMING')
> > C : HTTP_TIMEOUT
> > C : *OMIT
> > C :
> > 'application/x-www-form-urlencoded' )
> > Does that help? If not, we'll need a debug file like Mike
> said... but
> > we could skip that step if that's all the issue is.
> > -SK
> > On 3/24/2015 1:33 PM, Larry Kleinman wrote:
> > > Mike - I'm getting lost. I think I did what you
suggested,
> but
> > no data
> > > is POSTing to the PHP script. I've acttached the code
> that I'm
> > using.
> > > Do you see what I'm doing wrong?
> > > Larry Kleinman
> > > Kleinman Associates, Inc.
> > > 212-949-6469
> > > From: Mike Krebs <mkrebs@xxxxxxxxxxxxxxxxxx>
> > > To: HTTPAPI and FTPAPI Projects
> > <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>,
> > > Date: 03/24/2015 12:22 PM
> > > Subject: RE: AW: question about example 2
> > > Sent by: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > >
> > ___________________________________________
> _______________________
> > >
> > > So, that is pretty straight forward. Just substitute
your
> > variables
> > > (RequestID, Reference, etc) for the from, subject and
> Comment in
> > > EXAMPLE2.
> > > You will have myPointer to the webform data when you are
> > finished. Send
> > > that to http_url_post_raw in place of %addr(data). Send
> dataSize
> > in
> > > place of %len(%trimr(data)). The rest you can use
EXAMPLE5
> for.
> > > -----Original Message-----
> > > From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > > [[1][1][1]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx]
On
> Behalf Of
> > Larry
> > > Kleinman
> > > Sent: Tuesday, March 24, 2015 10:57 AM
> > > To: HTTPAPI and FTPAPI Projects
> > > Subject: RE: AW: question about example 2
> > > The URL is a private one, which you will not be able to
> access.
> > It is
> > > only a PHP script with lines like
> > > $RequestID = $_POST["RequestID"]
> > > $Reference = $_POST["Reference"]
> > > so I want the RPG program to POST a value for RequestD
and
> for
> > > Reference
> > > The script also does some simple ECHOs, and I want to
get
> that
> > back in
> > > retdata
> > > Larry Kleinman
> > > Kleinman Associates, Inc.
> > > 212-949-6469
> > > From: Mike Krebs <mkrebs@xxxxxxxxxxxxxxxxxx>
> > > To: HTTPAPI and FTPAPI Projects
> > <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>,
> > > Date: 03/24/2015 11:42 AM
> > > Subject: RE: AW: question about example 2
> > > Sent by: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > > Did you send us the url you are trying to post to? Using
> the
> > webForm
> > > stuff
> > > it is pretty easy to create the right variable but
reading
> the
> > html and
> > > getting them right is not always easy. A URL would make
it
> easier
> > to
> > > help
> > > you.
> > > -----Original Message-----
> > > From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [
> > > [2][2][2]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx]
On
> Behalf Of
> > Larry
> > > Kleinman
> > > Sent: Tuesday, March 24, 2015 9:58 AM
> > > To: HTTPAPI and FTPAPI Projects
> > > Subject: Re: AW: question about example 2
> > > Hi Thomas - I've attached the source for EXAMPLE5.
> > > I can't figure out how to use it to POST data to the web
> form,
> > and I
> > > suspect that it involves using some of the code in
> EXAMPLE2,
> > which I've
> > > also attached. I guess I am trying to combine the two
of
> them
> > into
> > > something which will POST several fields to a web form
> (like
> > EXAMPLE 2
> > > does with fromAddr, subject, and message) , and put what
> was
> > returned
> > > by
> > > the web site into data that I can manipulate (like
EXAMPLE
> 5 foes
> > with
> > > retdata)
> > > Larry Kleinman
> > > Kleinman Associates, Inc.
> > > 212-949-6469
> > > From: Thomas Raddatz <thomas.raddatz@xxxxxx>
> > > To: "'HTTPAPI and FTPAPI Projects'"
> > > <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>,
> > > Date: 03/24/2015 08:46 AM
> > > Subject: AW: question about example 2
> > > Sent by: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > > Larry,
> > > It was great if you could send the source to me, since I
do
> not
> > have an
> > > archive of 1.23. The oldest archive I have is 1.25.
> > > Thomas.
> > > -----Ursprüngliche Nachricht-----
> > > Von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [
> > > [3][3][3]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx]
Im
> Auftrag
> > von Larry
> > > Kleinman
> > > Gesendet: Dienstag, 24. März 2015 13:28
> > > An: HTTPAPI and FTPAPI Projects
> > > Cc: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > > Betreff: Re: question about example 2
> > > Yep, I am using the same version. Thomas, do you need
me
> to
> > send you
> > > the
> > > source, or can you find it in an archive of version 1.23
> > > Larry Kleinman
> > > Kleinman Associates, Inc.
> > > 212-949-6469
> > > From: Thomas Bishop <tbishop2@xxxxxxxxxx>
> > > To: "ftpapi@xxxxxxxxxxxxxxxxxxxxxx"
> > > <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>,
> > > Date: 03/24/2015 08:08 AM
> > > Subject: Re: question about example 2
> > > Sent by: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > > My copy of EXAMPLE5 also uses "raw". Version 1.23
> > > Comment at top of EXAMPLE5 source code states:
> > > * This performs the same example as EXAMPLE4, except
that
> it
> > > * uses the "raw" versio of http_url_post(). The
advantage
> is
> > > * that data is received directly into a variable in the
> program
> > > * instead of writing it to the IFS.
> > > Source code contains the following:
> > > c eval rc=http_url_post _raw(
> > > c
> 'https://wwwcie.ups.com/ups.app' +
> > > c '/xml/Track':
> > > c %addr(data):
> %len(%trimr(data)):
> > > c 1: %paddr('INCOMING'))
> > > c if rc <> 1
> > > c eval msg = http_error
> > > c dsply msg
> > > c return
> > > c endif
> > > The information transmitted is intended only for the
person
> or
> > entity
> > > to
> > > which it is addressed and may contain CONFIDENTIAL
> material. If
> > you
> > > receive this material/information in error, please
contact
> the
> > sender
> > > and
> > > delete or destroy the material/information.
> > >
> >
> -----------------------------------------------------------------------
> > > This is the FTPAPI mailing list. To unsubscribe, please
go
> to:
> > >
> [4][4][4]http://www.scottklement.com/mailman/listinfo/ftpapi
> > >
> >
> -----------------------------------------------------------------------
> > > --
> > > IMPORTANT NOTICE:
> > > This email is confidential, may be legally privileged,
and
> is for
> > the
> > > intended recipient only. Access, disclosure, copying,
> > distribution, or
> > > reliance on any of it by anyone else is prohibited and
may
> be a
> > > criminal
> > > offence. Please delete if obtained in error and email
> > confirmation to
> > > the
> > > sender.
> > >
> >
> -----------------------------------------------------------------------
> > > This is the FTPAPI mailing list. To unsubscribe, please
go
> to:
> > >
> [5][5][5]http://www.scottklement.com/mailman/listinfo/ftpapi
> > >
> >
> -----------------------------------------------------------------------
> > >
> >
> -----------------------------------------------------------------------
> > > This is the FTPAPI mailing list. To unsubscribe, please
go
> to:
> > >
> [6][6][6]http://www.scottklement.com/mailman/listinfo/ftpapi
> > >
> >
> -----------------------------------------------------------------------
> > >
> >
> -----------------------------------------------------------------------
> > > This is the FTPAPI mailing list. To unsubscribe, please
go
> to:
> > >
> [7][7][7]http://www.scottklement.com/mailman/listinfo/ftpapi
> > >
> >
> -----------------------------------------------------------------------
> > >
> > > References
> > >
> > > 1. [8][8]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > > 2. [9][9]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > > 3. [10][10]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > > 4.
> [11][11]http://www.scottklement.com/mailman/listinfo/ftpapi
> > > 5.
> [12][12]http://www.scottklement.com/mailman/listinfo/ftpapi
> > > 6.
> [13][13]http://www.scottklement.com/mailman/listinfo/ftpapi
> > > 7.
> [14][14]http://www.scottklement.com/mailman/listinfo/ftpapi
> > >
> > >
> > >
> > >
> >
> -----------------------------------------------------------------------
> > > This is the FTPAPI mailing list. To unsubscribe, please go
to:
> > > [15][15]http://www.scottklement.com/mailman/listinfo/ftpapi
> > >
> >
> -----------------------------------------------------------------------
> >
> -----------------------------------------------------------------------
> > This is the FTPAPI mailing list. To unsubscribe, please go
to:
> > [16][16]http://www.scottklement.com/mailman/listinfo/ftpapi
> >
> -----------------------------------------------------------------------
> >
> > References
> >
> > 1. [17]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > 2. [18]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > 3. [19]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > 4. [20]http://www.scottklement.com/mailman/listinfo/ftpapi
> > 5. [21]http://www.scottklement.com/mailman/listinfo/ftpapi
> > 6. [22]http://www.scottklement.com/mailman/listinfo/ftpapi
> > 7. [23]http://www.scottklement.com/mailman/listinfo/ftpapi
> > 8. [24]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > 9. [25]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > 10. [26]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> > 11. [27]http://www.scottklement.com/mailman/listinfo/ftpapi
> > 12. [28]http://www.scottklement.com/mailman/listinfo/ftpapi
> > 13. [29]http://www.scottklement.com/mailman/listinfo/ftpapi
> > 14. [30]http://www.scottklement.com/mailman/listinfo/ftpapi
> > 15. [31]http://www.scottklement.com/mailman/listinfo/ftpapi
> > 16. [32]http://www.scottklement.com/mailman/listinfo/ftpapi
> >
> >
> >
> >
> -----------------------------------------------------------------------
> > This is the FTPAPI mailing list. To unsubscribe, please go to:
> > [33]http://www.scottklement.com/mailman/listinfo/ftpapi
> >
> -----------------------------------------------------------------------
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list. To unsubscribe, please go to:
> [34]http://www.scottklement.com/mailman/listinfo/ftpapi
> -----------------------------------------------------------------------
>
> References
>
> 1. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> 2. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> 3. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> 4. http://www.scottklement.com/mailman/listinfo/ftpapi
> 5. http://www.scottklement.com/mailman/listinfo/ftpapi
> 6. http://www.scottklement.com/mailman/listinfo/ftpapi
> 7. http://www.scottklement.com/mailman/listinfo/ftpapi
> 8. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> 9. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> 10. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> 11. http://www.scottklement.com/mailman/listinfo/ftpapi
> 12. http://www.scottklement.com/mailman/listinfo/ftpapi
> 13. http://www.scottklement.com/mailman/listinfo/ftpapi
> 14. http://www.scottklement.com/mailman/listinfo/ftpapi
> 15. http://www.scottklement.com/mailman/listinfo/ftpapi
> 16. http://www.scottklement.com/mailman/listinfo/ftpapi
> 17. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> 18. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> 19. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> 20. http://www.scottklement.com/mailman/listinfo/ftpapi
> 21. http://www.scottklement.com/mailman/listinfo/ftpapi
> 22. http://www.scottklement.com/mailman/listinfo/ftpapi
> 23. http://www.scottklement.com/mailman/listinfo/ftpapi
> 24. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> 25. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> 26. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> 27. http://www.scottklement.com/mailman/listinfo/ftpapi
> 28. http://www.scottklement.com/mailman/listinfo/ftpapi
> 29. http://www.scottklement.com/mailman/listinfo/ftpapi
> 30. http://www.scottklement.com/mailman/listinfo/ftpapi
> 31. http://www.scottklement.com/mailman/listinfo/ftpapi
> 32. http://www.scottklement.com/mailman/listinfo/ftpapi
> 33. http://www.scottklement.com/mailman/listinfo/ftpapi
> 34. http://www.scottklement.com/mailman/listinfo/ftpapi
>
>
>
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list. To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> -----------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
--
IMPORTANT NOTICE:
This email is confidential, may be legally privileged, and is for the intended recipient only. Access, disclosure, copying, distribution, or reliance on any of it by anyone else is prohibited and may be a criminal offence. Please delete if obtained in error and email confirmation to the sender.
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------