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

Re: Help on http_url_post() procedure



Eugenio,

Please understand that all web services are different.  We are not 
familiar with your web service, and do not know how the data is supposed 
to be sent -- therefore it's very difficult to answer your question.

You say that you copy/paste it into a browser, adding ?data= and 
pressing enter, and that works.   Hmmm... well, the browser is doing a 
GET request, and you're asking HTTPAPI to do a POST request.  Perhaps 
that's the problem??  Maybe this web service is expecting a GET request?!

Also, you are not setting the content-type of the data for your POST 
request.  For a GET request, there's no content-type... but for a POST, 
you might have to set the content-type correctly.  As it stands, you're 
taking the default, which would be wrong for a URL encoded HTML form 
(which is what you appear to be sending.)   What does your web service 
expect for a content-type?



edlp1950@xxxxxxxxx wrote:
> 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(here I wrote server's URL
> as a constant)              
> * it's like this: http://ipAddress:port/axis2/WebService
> D OK              c                   const(1)                  
> 
> /free                                    
>                                           
>   xml = // here 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 looks 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">
> here 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 opening xml page and pressing Enter.
> It ran correctly again.
> 
> I think that the way I used HTTPAPI procedures is 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
> -----------------------------------------------------------------------
> 

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