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

Re: Problem with POST on a REST web service



Federico,

From the SoapUI screen shot, it looks like you are sending your data in a query-string parameter named 'xml'. But, in HTTPAPI, you are not using query string parameters at all, you are sending the XML in the body of the document.

Based on what others have said, there may also be a problem with the XML document and/or the text encoding. But none of that is going to matter if the web service is expecting the data to be in a query string parameter and you're sending it in the document body!

-SK

On 9/28/2015 3:22 AM, federico.forsi@xxxxxxxxxxx wrote:
    Good morning, i am using libhttp to exchange data with my iseries V7R1
    to another server using web services.The Iseries is the consumero of
    ws, the web services is a REST web service and i have no problem to GET
    data on my Iseries V7R1 using the procedure "http_url_get".
    The problems start when i try to POST an XML file. I make the request
    from Iseries using the procedure "http_url_post_stmf". The web services
    answer that there are no data in post variable.
    I try to make the same operation using the windows program SoapUI 5.2.0
     with the following parameters :
    [cid:_1_0C6829400C682594002DFFFDC1257ECE]  I select method = POST
    the request value is the XML file in this format
    <raccolta><doc_id>2015-OFF-0006784</doc_id><totale_righe>1</totale_righ
    e><note></note><riga num
    riga="1"><cod_art>92730</cod_art><qta>12</qta></riga></raccolta>
    i check the box Post quey/string
    and it work, the answer from the ws is that the data was recived and
    correctly updated.
    <return>
       <riga num_riga="1">
          <message>Importazione riga completata correttamente.</message>
       </riga>
    </return>
    My code on RPGLE is the following
    url= 'http://portale.ferritalia.it/personal/ws/offerte_in.php';
    rc = http_url_post_stmf(%trimr(url)
                           :%trim(expofile)
                           : '/tmp/http_result.txt'
                           : HTTP_TIMEOUT
                           : HTTP_USERAGENT
                           : ContentType );
    where expofile is the /tmp/example.xml that contain the xml code used
    on SoapUI.
    This is the debug output
    HTTPAPI Ver 1.29 released 2015-02-23
    NTLM Ver 1.4.0 released 2014-12-22
    OS/400 Ver V7R1M0
    http_url_post_stmf(): entered
    getting post file size...
    opening file to be sent...
    opening file to be received
    http_persist_open(): entered
    http_long_ParseURL(): entered
    DNS resolver retrans: 2
    DNS resolver retry  : 2
    DNS resolver options: x'00000136'
    DNS default domain: FRANZINI.IT
    DNS server found: 8.8.8.8
    DNS server found: 192.168.0.199
    DNS server found: 192.168.0.203
    Nagle's algorithm (TCP_NODELAY) disabled.
    http_persist_post(): entered
    http_persist_req(POST) entered.
    http_long_ParseURL(): entered
    http_long_ParseURL(): entered
    do_oper(POST): entered
    There are 0 cookies in the cache
    POST /personal/ws/offerte_in.php HTTP/1.1
    Host: portale.ferritalia.it
    User-Agent: http-api/1.29
    Content-Length: 167
    sendraw(): entered
    <raccolta><doc_id>2015-OFF-0006784</doc_id><totale_righe>1</totale_righ
    e><note></note><riga num
    riga="1"><cod_art>92730</cod_art><qta>12</qta></riga></raccolta>
    recvresp(): entered
    HTTP/1.1 200 OK
    Content-Type: text/xml
    Server: Microsoft-IIS/7.5
    X-Powered-By: PHP/5.4.15
    Date: Mon, 28 Sep 2015 07:56:44 GMT
    Content-Length: 87
    SetError() £13: HTTP/1.1 200 OK
    recvresp(): end with 200
    recvdoc parms: identity 87
    header_load_cookies() entered
    recvdoc(): entered
    SetError() £0:
    <?xml version="1.0"?>
    <return><message>Errore l'offerta non esiste.</message></return>
    http_close(): entered
    How can i replay the same request made with program SoapUi using
    LIBHTTP to be able to POST data with the WS ?
    Thank you very much for help !
    Best regards  Federico



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