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

[no subject]



Hi,
I've a problem using http_url_post() function.

The Web Server expect an xml document in URL parameter 'data'.

I coded my RPG source as following

H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('HTTPAPI')                  
                                                                 
D/copy qrpgcopy,httpapi_h                                        
                                                                 
D cmd             pr                  extpgm('QCMDEXC')          
D  command                     200A   const                      
D  length                       15P 5 const                      
                                                                 
D enc             s                   like(HTTP_URL_ENCODER)     
D pointer         s               *                              
D size            s             10I 0                            
D xml             s           1024a   varying                    
                                                                 
D RESPONSE        c                   const('/tmp/response.xml') 
D TRACE           c                   const('/tmp/trace.txt')    
D CRLF            c                   const(x'0D25')             
D HYP             c                   const(x'7D')               
D URL             c                   const(in this point I wrote server's URL 
as a constant)               
 * it's like this: http://ipAddress:port/axis2/WebService
D OK              c                   const(1)                   

 /free                                     
                                           
  xml = // in this point I composed my xml document as a string, 
        // without any separator between xml tags
        // or CRLF at end of lines.

 http_debug(*ON:TRACE);                                                 
                                                                        
 enc = http_url_encoder_new();                                          
 http_url_encoder_addvar(enc:'data' : %addr(xml)+2 : %len(%trimr(xml)));
 http_url_encoder_getptr(enc : pointer : size);                         
                                                                        
 if http_url_post(URL:         
                  pointer:                                        
                  size:                                           
                  RESPONSE) = OK;                                 
    cmd('DSPF ' + HYP + RESPONSE + HYP : 200);                          
 endif;                                                                 
                                                                        
 *inlr = *on;                                                           
 return;                                                                
                                                                        
/end-free                                                               


Well, when I tried to send the document I received an xml response with an 
error message.
It looked like 'data' parameter was missing or something causing 
nullPointerException.

Reading the debug trace i found data I expect to be sent.
I found 'data=' followed by my xml document in encoded version.
I tried to send it directly from the browser (copying in the URL bar my url, '?
data=' and ecndoded xml)
It ran correctly and I received the response I expected.

Then I wrote this html form.

<form action="in this point I copied server's URL" method=post>
<fieldset>
<legend>Simulator</legend>
<br>
<br>
<br/>
Document<br/>
<textarea rows="5" cols="132" name="data">
in this point I copied my xml document in text format (I mean not encoded)
</textarea><br/>
<input type="submit" value="Enter">
</fieldset>
</form>

I sent my xml document copying it into the textarea and pressing Enter. 
It ran correctly again.

I think that the way I used HTTPAPI procedures in not correct.
Can anyone help me?

Thanks

Eugenio

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------