[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Post vs Post_raw
Sender: Scott Klement <sk@xxxxxxxxxxxxxxxx>
---
Scott Klement  http://www.scottklement.com
On Wed, 12 Jan 2005 rbelz@xxxxxxxxxxx wrote:
Here is an update on our situation and one question (see bottom):
- the java program was created to execute a post to the java servlet. 
When it ran it got back a HTTP 500 error, just like the RPG program did. 
After some trial and error, the java program worked sending the message 
to the parent company database.  One of the things that the java program 
had to do was change the "content-type" and "user-agent" HTTP property 
values. The "content-type" value was changed to 
'application/x-www-form-urlencoded' and the "user-agent" value was 
changed to 'Mozilla/4.0'.  This proved that a program post to the java 
servlet works, ergo the RPG HTTP API post should work.
Okay.  It's stupid that the servlet requires you to tell it that you're 
Mozilla, but it's easy enough to do that.
And, yes, if the data is url encoded, you definitely should be passing 
'application/x-www-form-urlencoded' as your content type.
- we saw that the "content-type" and "user-agent" values in the CONFIG_H 
source member did not match these values.
- we changed the CONFIG_H source so that the HTTP_USERAGENT and 
HTTP_CONTTYPE constants matched the java program values. We recompiled 
the HTTPAPIR4 program (as this seems to be the one that does the actual 
post) so that it will use the new values
Keep in mind that the values in CONFIG_H are the default values (the ones 
specified if you do not pass the optional parms to http_url_post_raw) and 
it's not necessary to change it in that member unless you want all of your 
programs to use those settings...
If you need this for only one application, I'd just override them on the 
call to http_url_post_raw()
- called the http_url_post_raw RPG program and got the same results - 
DSPLY recvdoc: saveproc: Not all data was written! in the joblog.
That error couldn't possibly by related to the user agent or content type. 
That error is internal, it only relates to what happens when HTTPAPI calls 
your INCOMING procedure.
- we then tried to force these HTTP property values, via the 
http_url_post_raw parameters:
  C                   Eval      rc = http_url_post_raw(
  C                             'HTTP://10.254.20.184/cs/' +
  C                             'DataToDw/DataToDwServlet':
  C                             %addr(data):
  C                             %len(%trimr(data)):
  C                             1:
  C                             %pAddr('incoming'):
  C                             10:
  C                              'Mozilla/4.0':
  C                              'application/x-www-form-urlenco' +
  C                              'ded')
and got the same job log error message.
Do you really have 'incoming' in lowercase in the %paddr() statement?  If 
so, I wouldn't think your program would compile at all...
- we are now trying to get a web sniffer on the parent company server to 
see what it is receiving from the iSeries
You can do that if you like, but it should be irrelevant to the 'recvdoc:' 
error.
Since you weren't getting an error with http_url_post(), maybe you should 
try using that instead. (setting the content-type and user-agent like you 
did, above, might solve the 500 error, but won't affect the 'recvdoc:' 
error, which has to do with your INCOMING procedure returning the wrong 
value.)
If anyone can provide any more HTTP API utility support/suggestions it 
would be most helpful, we are running out of project time and need to 
resolve this soon.
I can only think of one other thing that would help -- giving me access to 
your web server so that I can try it myself.
Question: What does the 4th parameter in the http_url_post_raw (comment 
says "peFD = FD to pass back to peProc") do? We used the value "1" since 
the example did.
It just passes that variable back to you.  If you supply a 1, then every 
time it calls the INCOMING procedure, it'll pass 1 as the first parameter. 
If you pass 142 as the peFD value, it'll pass 142 as the first parameter.
This is useful when you want to write the results to another socket, 
stream file, pipe, etc. -- you can pass it the descriptor of the file you 
want to write it to.   Or if called http_url_post_raw() 3 times in a 
program, and you want each result saved to a different variable, you might 
declare an array, and pass the array index...  but you can use that number 
for anything you want... all HTTPAPI does is pass it back to your 
procedure each time it calls it.
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------