[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Post vs Post_raw



We are new to the HTTP API utility and, after a few trial and errors, I'm in need of some support...I apologize in advance for the length of this e-mail, but I want to give you as much info as I can.
 
Here is our current situation.
 
My client has the requirement to post iSeries data to a java servlet (the servlet is brand new).  The java servlet, running on the parent company's web server, requires 5 "nested parameters":
-  message (the data), a required parameters 
and
- four optional "parameters" defining the destination.
The servlet then sends the message on to the parent company's destination database.  The servlet has a GUI so that we can test it. When the submit button is pressed, it does a post fo send the data. We tested the java servlet with the GUI by entering 'iSeriesTest' in the required message "parameter", leaving the other parameters blank, and it wrote the test message to the parent company's database. 
 
The client did not use iSeries HTTP before, so we had some iSeries HTTP configuration issues, which Scott K. helped us resolve - thanks :-) 
 
To test iSeries connectivity with the internet, we created a RPG program similar to EXAMPLE1 with a http_url_get function, pointing it to an internal Web server.  That test was successful, the program wrote the text from the file on the internal web server to an IFS file.
 
Since our data java servlet's function is similar to EXAMPLE2 (sending data to servlet), we created a http_url_post RPG program, pointing it to the parent company web server java servlet and passing the required parameter, here is the guts of the logic:
C                   eval      data='' +        
C                                           CRLF                     
C                   Eval      rc = http_url_post(                      
C                             'HTTP://10.254.20.184/' +             
C                             'DataToDw/DataToDwServlet':          
C                             %addr(Data):%Len(%trimr(data)):          
C                             '/tmp/testdoc.! txt')&nb sp;      
 
The URL for the java servlet with the GUI (that was tested)  and the one in the program are the same (same case), in other words if I type in the URL on the browser I get the GUI. The program hung up, producing no job log messages, and it put a HTTP 500 error (generic internal error) in the testdoc.txt IFS file.
 
We then thought that the http_url_post_raw function might give us some more info, so using EXAMPLE5 we created a program that uses that function, here is the logic guts of that (the incoming procedure is equal to the EXAMPLE5 procedure):
C                   eval      data='' +             
C                                             CRLF                     
C                   Eval      rc = http_url_post_raw(                  
C                             'HTTP://10.254.20.184/' +             
C                             'DataToDw/DataToDwServlet':          
C                             %addr(Data):%Len(%trimr(data)):          
C                             1:%pAddr('INCOMING'))      
 this time the program finished but we got a job log display message of
DSPLY CommTCP_read: time-out!  
We checked the GUI, and found that that the web server was hung up. After rebooting the web server the GUI worked so we reran both the http_url_post and the http_url_post_raw programs.  The http_url_post test gave us the same results - it hangs and puts a HTTP 500 error in the IFS.  The http_url_post_raw program ran again, but this time with a different job log message:
 DSPLY  recvdoc: saveproc: Not all data was written!        
We did debug on the program to see what 'retdata' variable was, and here are the results:
 > EVAL retdata                                                                
   RETDATA =                                                                   
             ....5...10...15...20...25...30...35...40...45...50...55...60      
        1   'á                                                           '     
       61   '       
I see that the "Not all data was written!" error message comes from the HTTPAP4 member and appears to be triggered when data received back from the web server is less than what was sent. 
 
OK, now the questions:
1) Since the post programs are our first try connecting to the parent company's web server and we got a timeout error when the web server was hung, can we rule out connectivity problems?
 
1) Do you know why the http_url_post program hangs while the http_url_post_raw program did not?  It seems that the post (no raw) is expecting a document that the web server isn't giving it?
 
2) For this project, we don't need to process the data received back from the server, so would you suggest we use the http_url_post or the http_url_post_raw function?
 
3) Why does the HTTP API utility check for the length of the data returned from the web server?  Is this HTTP 'under the covers' best practice?  My first thought, when I saw this code, was "how does the utility know that it will get any data back from the server, let alone that it will be longer in length?"  If successful, the java servlet returns the message (data) back (we see this in the GUI).  Is the "Not all data written!" error caused by the servlet sending because the RPG program is sending 'msg=iSeriesTest' and the servlet is sending something back something smaller?
 
4) What suggestions do you have to resolve this issue? I was thinking about commenting out the length checking logic from the HTTPAPIR4 member but don't know if that would cause other HTTP errors, so wanted to check with you first.
 
Thanks as always for any support!