Sign In/My Account | View Cart  

advertisement

AddThis Social Bookmark Button

Article:
  HTTP Communication from Within the Oracle Database
Subject:   Good article, but no POST examples
Date:   2003-10-12 22:30:02
From:   anonymous2
This article mentions that 9i supports the POST method, and that this is the method that would typically be used, but does not give any examples. I cannot find any examples of using the POST method to send an XML document using utl_http - every article I have read uses the same code examples using the GET method, and then goes on to mention that you could alternatively use the POST method, but not HOW to parameterise the data when using POST.


Does anyone know where there is some example code for this?


Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • Good article, but no POST examples
    2003-11-05 12:10:29  anonymous2 [View]

    It's actually quite simple:

    PROCEDURE POST_Test (o_replytext out VARCHAR2
    ,o_return_code out INTEGER
    ,i_messagetext in VARCHAR2
    ,i_urltext in VARCHAR2
    ,i_timeout in INTEGER DEFAULT 60)
    IS
    sslreq UTL_HTTP.req; /* Secure connection request */
    rsp UTL_HTTP.resp; /* Secure response */
    replymessage VARCHAR2(32767); /* reply message (local) */
    replyline VARCHAR2(32767); /* piece of reply message read from secure site. */
    BEGIN
    /* Set up wallet information for secure connection capability */
    /* remove this line if you don't have wallet installed and are not using https */
    -- UTL_HTTP.SET_WALLET('file:DirectoryPath','put password here');
    /* Initiate request to secure site, set parameters */
    sslreq := UTL_HTTP.BEGIN_REQUEST(i_urltext,'POST','HTTP/1.0');
    UTL_HTTP.SET_HEADER(sslreq,'Content-Type','text/xml');
    UTL_HTTP.SET_HEADER(sslreq,'Content-Length',to_char(length(i_messagetext)));
    UTL_HTTP.SET_TRANSFER_TIMEOUT(i_timeout);
    /* Write information over secure connection */
    UTL_HTTP.WRITE_TEXT(sslreq,i_messagetext);
    /* Initialize Response */
    rsp:=UTL_HTTP.GET_RESPONSE(sslreq);
    replymessage := '';
    /* Retrieve response */
    BEGIN
    LOOP
    UTL_HTTP.READ_LINE(rsp,replyline,TRUE);
    replymessage := replymessage || replyline;
    END LOOP;
    UTL_HTTP.END_RESPONSE(rsp);
    EXCEPTION
    WHEN UTL_HTTP.END_OF_BODY THEN
    UTL_HTTP.END_RESPONSE(rsp);
    END;
    /* Set output information */
    o_replytext := replymessage;
    o_return_code := 0;
    EXCEPTION
    WHEN OTHERS THEN
    o_return_code := SQLCODE;
    o_replytext := SQLERRM;
    END POST_Test;

    Post for HTTP 1.1 is suppose to be supported, but it doesn't work. There is a bug in utl_http that Oracle knows about, and has yet to fix.
    • Good article, but no POST examples
      2006-04-20 09:17:18  jafri100 [View]

      It is helpful. Can we use persistance cookie as part of POST and how?

      Thanks