Retrieve data/files fro HTTP POST request in On-Demand process

Hello,
I would like to integrate https://github.com/blueimp/jQuery-File-Upload to my APEX 4.2 application inside XE11g. I would like to use this kind of jQuery component, multiple file upload, use Drag & Drop, image resize, size limit, filter extensions etc...
This jQuery component and also others javascript uploaders sends data files to some defined URL. Developer need to build some servlet, php script or something on server side that will read files from HTTP request and stores it somewhere.
Do you know how to do it in APEX? How can I read data from HTTP POST request in PL/SQL? Now I can only call my On-Demand application process from javascript, but I am not able to read any data from HTTP POST in it.
Can I do it in APEX, or using MOD_PLSQL?
I would like to implement this:
1) some javascript uploader will call some URL of my application and sends HTTP POST with data files
2) I will read data files from HTTP POST and store them into database
3) I will create some HTTP response for javascript uploader
Thank you for some tips

I know about that existing plugin " Item Plugin - Multiple File Upload"
But I doesn't work in IE and has only basic features. Licence for commercial use is also needed. I would like to use some existing jQuery plugin. There are many of these plugins with nice features. And only one problem is that I need to create some server side process/servlet/script.. that can recieve HTTP request, get files from it and stores them into DB.

Similar Messages

  • HTTP POST Request with XML file in

    Hi @ all,
    I would like to send an HTTP Request with an XML File in the body to an SAP System
    I have the target URL and the a XML File.
    Now the question is. Is it possible to use something like the HTTP_POST FuBa to send an url post request with an xml file?
    If yes can anybody give me a hint?
    I have a php script which exactly do this coding. But to integrate it all in one system it is necessary to transform it into ABAP and call it there.
    // compose url and request and call send function
    function test($productID, $categoryID) {
         // create url
         $PIhost = "XXX.wdf.sap.corp";
         $PIport = "50080";
         $PIurl = "/sap/xi/adapter_plain";
         $PIurl .= "?sap-client=800";
         $PIurl .= "&service=XXX";
         $PIurl .= "&namespace=XXX";
         $PIurl .= "&interface=Frontend_Interface";
         $PIurl .= "&qos=EO";
         $PIurl .= "&sap-user=XXX";
         $PIurl .= "&sap-password=XXX";
         // create xml
         $request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
         $request .="<n1:FrontendInbound_MessageType xmlns:n1=\"http://crmpiebay.com\">\n";
         $request .= "\t<FrontendInbound>\n";
         $request .= "\t\t<ProductName/>\n";
         $request .= "\t\t<ProductCategory>".$categoryID."</ProductCategory>\n";
         $request .= "\t\t<ProductID>".$productID."</ProductID>\n";
         $request .= "\t\t<MessageID/>\n";
         $request .= "\t</FrontendInbound>\n";
         $request .= "</n1:FrontendInbound_MessageType>";
         // send http request
         postToHost($PIhost, $PIport, $PIurl, $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"]."/".$_SERVER["PHP_SELF"], $request);
    // send post request to PI server
    function postToHost($host, $port, $path, $referer, $data_to_send) {
      $fp = fsockopen($host, $port);
      if($fp) {
           $res="";
           fputs($fp, "POST $path HTTP/1.1\r\n");
           fputs($fp, "Host: $host\r\n");
           fputs($fp, "Referer: $referer\r\n");
           fputs($fp, "Content-type: text/plain\r\n");
           fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n");
           fputs($fp, "Connection: close\r\n\r\n");
           fputs($fp, $data_to_send);
           while(!feof($fp)) {
               $res .= fgets($fp, 128);
           fclose($fp);
           return $res;
    Would be great if anybody could give me a hint how to solve such a HTTP Post request with XML body data.
    Thanks in advance.
    Chris
    Edited by: Christian Kuehne on Feb 26, 2009 4:32 PM

    hi friend could you please share your solution regarding this query if u got it already?

  • Get file from HTTP POST (upload image)

    Hello,
    I would like to integrate http://www.plupload.com flash component to my APEX 4.1 website. I need it because I want to resize image and transform image before upload on client side, upload multiple files etc..
    But I don't know how to read image binary data from POST method.
    When I hit "Start upload" button on plupload component it makes some transformations and creates POST method like this:
    ------pluploadboundary1334433145869
    Content-Disposition: form-data; name="name"
    p16qp6jm3nhan1ca46me1ocr3tu1.jpg
    ------pluploadboundary1334433145869
    Content-Disposition: form-data; name="chunks"
    1
    ------pluploadboundary1334433145869
    Content-Disposition: form-data; name="chunk" 0
    ------pluploadboundary1334433145869
    Content-Disposition: form-data; name="file"; filename="centerd.jpg"
    Content-Type: image/jpeg
    ÿØÿà�JFIF������ÿÛ�„�
    image content
       now I would like to read content of this HTTP POST and read sended image and store it to DB.
    Question is... how can I read file sended with HTTP POST in APEX pl/sql process or pl/sql procedure?
    Thank you...
    Edited by: cardel on Apr 14, 2012 11:17 PM

    Hi,
    here are my two cents ...
    this will be a bit difficult. When you use the standard APEX File upload it is not PL/SQL handling the POST request. The request is handled by the webserver - depending on the variant you are using it is either mod_plsql, the C code of the Embedded Gateway or the APEX Listener. The webserver is also doint the insert into APEX' file repository. So I see two options:
    It might be possible to configure your plugin (don't know about it) the behave the same as a standard browser upload. Then for APEX there would be no difference - mod_plsql should handle the files accordingly.
    If you want to handle the POST request yourself, as said, you can't do this in PL/SQL. It would be possible to write a Java servlet doing this and deploy that servlet on the same container as the APEX Listener (when using Apache with mod_plsql you would need an additional Java server for that) ....
    Hope this helps ...
    Best regards
    -Carsten

  • Query regarding sending XML over HTTP Post request

    Hello,
    I am trying to send XML data from a server to client via HTTP Post request
    And vice versa � receive the data by a client
    Assume that the xml data looks something like
    <?xml+version="1.0"?>
    So my post query will look like
    http://<IP Address>:<port>/
    POST /MessageReceiver.jsp HTTP/1.0
    Host: www.SomeHost.net
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 38
    %3C%3Fxml%2Bversion%3D%221.0%22%3F%3E+
    This information will be received by the client and converted back to xml data.
    My query is - is there some library/open-source stuff that
    does the process of transcoding the entity's non-ASCII characters
    at the server side
    and decoding the URL back to human-readable form at the client side?
    i.e. I need a simple mechanism to convert
    <?xml+version="1.0"?>
    to
    %3C%3Fxml%2Bversion%3D%221.0%22%3F%3E+
    at the server side, while sending data
    and do the opposite at the client side to get the xml back.
    Also could some one confirm if JTidy is a right tool to check if the xml is well-formed?
    Or is there any other standard tool that checks for well-formed properties of xml?
    regards,
    Deepak.

    java.net.URLEncoder / URLDecoder?
    Also could some one confirm if JTidy is a right tool to check if the xml is well-formed?No, it's for parsing HTML. An XML parser is checking for well-formedness in any case.

  • Transmit file in HTTP POST

    Hello,
    Sorry I am french my english is not very good !
    I have an JAVA applet and I would transmit a file of my applet to an ASP web page with HTTP POST. I try with HTTPClient but I don't success. If you have solution for transmit file in HTTP POST ?
    Thanks
    [My PortFolio|http://florent.lagoda.free.fr]

    Crossposted and already answered: [http://forums.sun.com/thread.jspa?threadID=5347746].
    In the future, do not crosspost without mentioning about the crosspost. It is considered very rude to crosspost at forums. Others may spend lot of time and effort in helping you and they may got very angry when they discovered that you already got help and answer at aonther topic which you didn't mention about at all.
    Edited by: BalusC on 14-nov-2008 9:28 (wrong link)

  • Extract Portal User Name From HTTP POST Request (WSRP SOAP)

    How can we extract the user name from the HTTP POST Request (*WSRP SOAP*) from the Portal to the Portlet Provider (Producer)?
    We are load balancing between the Portal (10.1.14.2) and the providers (OC4J 10.1.3.3) and would like to extract the user name within the load balancer so we can create session affinity based on it.
    BTW, we already tried using TCP Flow but were unable to see the user name.

    From the documentation, it seems that you need to use
    HttpURLConnection.setRequestMethod("POST"); // "GET" is the defaultalthough I have seen examples on the web without it.
    Try!
    Edit: Also the single quotes around userid and password may be a problem.
    Use the previous poster suggestion, but do not include the single quotes.
    Edited by: baftos on Aug 6, 2008 4:27 PM

  • Problem Retrieving DATA files from Zen To

    Has anybody else had this problem?
    I moved a bunch of data files to my zen touch. My computer hardri've
    failed and now I want to copy the data back.
    BUT when I try to do it, I get an error message that I can't remove
    the data files.
    I called tech support once and they had me "clean" the hardri've --
    didn't work. Then he recommended JBHTTP. I downloaded that
    (free) and it does work, but I can't remove the files <EM>within the file</EM>
    <EM>structure</EM> -- and only one at a time.
    This is better than nothing, but it will take a long time to remove
    all 3000+ files.
    I found a recommendation for NotMad on the web, but the free
    version will not do data transfers, and I don't want to pay for it
    if it isn't going to work.
    Has anyone had any similar problems? Any solutions? Any
    suggestions?
    Please help. I need it. :angry:
    <FONT face="Comic Sans MS" color=#336600 size=4>JT

    I believe via Xtreamer, in the trial version of Notmad, you can also download data files. But it sounds like the same process as JBHTTP i.e. slow and one-by-one.
    I've seen before that new drivers and firmware update can fix this. I've also seen that new drivers have broken data retrieval, and reverting back to the install CD drivers have fixed it. It's worth trying.
    It's a good idea to check data retrieval on a device once you've copied some files over, just to test. Also never trust important files (audio or data) to an MP3 player as the sole source.

  • Where does firefox cache the form parameters to be used in the reload event of a page that was the resposne of a HTTP POST request?

    Suppose there is form in a web page and it submits data in HTTP POST method. After submitting the form, if I reload the page [either by the refresh button or back button; whichever applicable], firefox asks permission to resend the form data by saying "To display this page, Firefox must send information that will repeat any action...". Now if the user clicks on the resend, firefox resubmits the form data.
    So where does firefox store this from data for such future resending/resubmission?
    Is it possible to retrieve/manipulate those stored form data?

    I thought I'd tried that, as tried lots of other things like encoding URL, but obviously not as this works.
    Thanks for the quick reply.
    We also have an issue with the people results not being able to be refined by Department or Job Title now we have connected the SP2010 farm to use the service applications from a SP2013 farm.
    Any ideas on this?  I've started a new thread as its unrelated though:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/c89d5463-4531-4a28-9586-1f690c7b580d/can-you-refine-people-search-results-using-a-sharepoint-2013-search-service-application-connected-in?forum=sharepointsearch

  • Uploading big files via http post to XDB table

    Hello,
    I ve created a web form for to upload files as blobs to the database using XML DB, DBPS_EPG package and preconfigured DAD.
    The issue is that small files (~10kb) are being uploaded ok, but file which is 100K during http post returns connection reset from the server side.
    To my opinion there might be some max file size parameter for oracle server to accept during oracle listener tcp connection (as apach has maxrequestlimit).
    Is there any workaround for to load large files to the XDB table via webform?
    Here is a piece of code:
    CREATE USER web IDENTIFIED BY web_upload;
    ALTER USER web DEFAULT TABLESPACE XML_DATA;
    ALTER USER web QUOTA UNLIMITED ON XML_DATA;
    ALTER USER web TEMPORARY TABLESPACE TEMP;
    GRANT CONNECT, ALTER SESSION TO web;
    GRANT CREATE TABLE, CREATE PROCEDURE TO web;
    ALTER SESSION SET CURRENT_SCHEMA = XDB;
    BEGIN DBMS_EPG.CREATE_DAD('WEB', '/upload/*'); END;
    BEGIN
        DBMS_EPG.SET_DAD_ATTRIBUTE('WEB', 'database-username', 'WEB');
        DBMS_EPG.SET_DAD_ATTRIBUTE('WEB', 'document-table-name', 'uploads');
        DBMS_EPG.SET_DAD_ATTRIBUTE('WEB', 'nls-language', '.al32utf8');
        DBMS_EPG.SET_DAD_ATTRIBUTE('WEB', 'default-page', 'upload');
        COMMIT;
    END; 
    ALTER SESSION SET CURRENT_SCHEMA = SYS;
    CREATE TABLE web.uploads (
        name VARCHAR2(256) NOT NULL
            CONSTRAINT pk_uploads PRIMARY KEY,
        mime_type VARCHAR2(128),
        doc_size NUMBER,
        dad_charset VARCHAR2(128),
        last_updated DATE,
        content_type VARCHAR2(128) DEFAULT 'BLOB',
        blob_content BLOB
    CREATE OR REPLACE PROCEDURE web.upload
    AS
      url VARCHAR2(256) := 'http://demo.test.com:9090/upload/uploaded';
    BEGIN
        HTP.P('<html>');
        HTP.P('<head>');
        HTP.P('  <title>Upload</title>');
        HTP.P('</head>');
        HTP.P('<body>');
        HTP.P('  <h1>Upload</h1>');
        HTP.P('  <form method="post"');
        HTP.P('      action="' || url || '"');
        HTP.P('      enctype="multipart/form-data">');
        HTP.P('    <p><input type="file" name="binaryfile" /></p>');
        HTP.P('    <p><input type="file" name="binaryfile" /></p>');
        HTP.P('    <p><button type="submit">Upload</button></p>');
        HTP.P('  </form>');
        HTP.P('</body>');
        HTP.P('</html>');
    END;
    CREATE OR REPLACE PROCEDURE web.uploaded (
        binaryfile OWA.VC_ARR
    AS
    BEGIN
        HTP.P('<html>');
        HTP.P('<head>');
        HTP.P('  <title>Uploaded</title>');
        HTP.P('</head>');
        HTP.P('<body>');
        HTP.P('  <h1>Uploaded</h1>');
        FOR i IN 1 .. binaryfile.COUNT LOOP
            IF binaryfile(i) IS NOT NULL THEN
                HTP.P('  <p>File: ' || binaryfile(i) || '</p>');
            END IF;
        END LOOP;
        HTP.P('</body>');
        HTP.P('</html>');
    END;
    /帖子经 anatoly编辑过

    Welcome to Apple Discussions!
    Much of what is available on Bittorrent is not legal, beta, or improperly labelled versions. If you want public domain software, see my FAQ*:
    http://www.macmaps.com/macosxnative.html#NATIVE
    for search engines of legitimate public domain sites.
    http://www.rbrowser.com/ has a light mode that supports binary without SSH security.
    http://rsug.itd.umich.edu/software/fugu/ has ssh secure FTP.
    Both I find are quick and a lot more reliable than Fetch. I know Fetch used to be the staple FTP program, but it grew too big for my use.
    - * Links to my pages may give me compensation.

  • Query regarding encoding/decoding of XML over HTTP Post request

    Hello,
    I am working on a project where I need to put SMS inside XML and
    eventually transfer this XML via HTTP post from/to server/client.
    Assuming the SMS to be 7-bit text the XML may look something like
    <?xml+version="1.0"?>
    <SMS
    TESTMESSAGE
    </SMS>
    This XML when encoded in a HTML post may look something like
    http://<IP Address>:<port>/
    POST /MessageReceiver.jsp HTTP/1.0
    Host: www.SomeHost.net
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 90
    xmlMsg=%3C%3Fxml+version%3D%221.0%22%3F%3E%0D%0A%3CSMS%0D%0A%09TESTMESSAGE0D%0A%3C%2FSMS%3E
    This xml is UTF-8 (7-bit ASCII) by default since no encoding format has been specified.
    My question - how will the encoding of xml change to - when 8 bit binary data
    is transferred via xml.
    for e.g.
    <?xml+version="1.0"?>
    <SMS
    <!!!!!BINARY DATA!!!!!>
    </SMS>
    for such a file how/what shld the encoding be set to.
    Further my spec-states the following.
    "The content of the XML must respect the encoding. Thus a SMS
    containing typically french characters must use ISO-8859-1 encoding"
    "This code needs to work with both UTF-8 and UTF-16 standards (ASCII and Unicode). Because of this the parsing code should work internally with UTF-16 and translate up/down to/from UTF-8 (ASCII) only when dealing with the basic HTTP."
    could anyone clarify this for me.

    The first thing you need to do is clear up some fundamental misconceptions about character encodings. UTF-8 is not the same thing as "7-bit ASCII", and UTF-16 is not the same as "Unicode". Anyway, you're making this a lot more difficult than it needs to be. Just use UTF-8 to encode and decode all messages; it can handle all the characters from any language you're likely to run into.

  • HTTP POST Request? How? Please Help!

    Hi maybe this is a simple question. But I was able to do a GET Request from an applet to an ASP page just fine but I am having problems with the POST Request. How do you do a HTTP POST and put the parameter on the post data?
    This is what I am doing:
    url = new URL(queryParam);
    connection = (HttpURLConnection)url.openConnection();
    connection.setDoOutput(true);
    connection.setRequestMethod("POST");
    // IS THIS CORRECT WAY TO ADD PARAMETER TO POST
    connection.setRequestProperty("name","javaguy");
    BufferedReader in = new BufferedReader( new InputStreamReader( connection.getInputStream()));
    String inputLine;
    while ((inputLine = in.readLine()) != null)
    System.out.println(inputLine);
    in.close();

    The setRequestProperty() method is used to add HTTP headers to the request. The way you pass "post" parameters is to send them as the body of the message in "application/x-www-form-urlencoded" form. In other words, create a string of URLEncoded "name=value" pairs delimited by '&', just like you would see in the URL when making a GET request through the browser:
    String paramStr = "name=javaguy&occupation=web+developer" ;
    byte[] paramBuf = paramStr.getBytes("ISO-8859-1") ;
    url = new URL(queryParam);
    connection = (HttpURLConnection)url.openConnection();
    connection.setDoOutput(true);
    connection.setRequestMethod("POST");
    // THIS CORRECT WAY TO ADD PARAMETER TO POST
    connection.setRequestProperty("Content-Length", Integer.toString(paramBuf.length)) ;
    OutputStream out = connection.getOutputStream() ;
    out.write(paramBuf) ;
    out.flush() ;
    out.close() ;
    BufferedReader in = new BufferedReader( new InputStreamReader( connection.getInputStream()));
    String inputLine;
    while ((inputLine = in.readLine()) != null)
        System.out.println(inputLine);
    in.close();Good luck!

  • How can i upload file using ajax post request and jsp

    Hi
    this is my code files
    addPhoto.jsp
    <html>
    <head>
    <title>Add Photo</title>
    <script>
    var optionNo = 0;
    var i=1;
    var val=0;
    var file = 0;
    var exten = new Array(".jpg",".jpeg",".gif");
    function addValues()
         for(var i=0;i<5;i++)
              optionNo += 1;
              oNewOption = new Option();
              oNewOption.text = optionNo;
              oNewOption.value = optionNo;
              addSelect.add(oNewOption);
    function addBoxes()
         var str = "";
         var j=0;
         val = document.getElementById('addSelect').value;
         for(j=1; j<= val; j++)
              str = str + '<font size=3>file:' + j + '</font>';
              str = str + '<input type="file" id=filepath'+ j +' name=file'+ j + ' onchange="uploadFile(hidden'+ j + '.value)"><div id="result'+ j +'"></div>
              str = str + '<input type="hidden" name="hidden' + j + '" value=' + j +'>';
         document.getElementById('addPhoto').innerHTML = str;
    function uploadFile(value)
    var str = "filepath" + value;
    file = value;
    var param = document.getElementById(str).value;
    var parameter = "filepath=" + param;
    alert(parameter.length);
    if(checkValidity(param))
    var url = "uploadFile.jsp";
    if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    req.open("POST", url, true);
    req.setRequestHeader("Content-type", "multipart/form-data");
    //req.setRequestHeader("Content-length", parameter.length);
    req.setRequestHeader("Connection", "close");
    req.onreadystatechange = callback;
    req.send(null);
         else
              document.getElementById("result" + file).innerHTML = "upload .jpeg,.jpg,.gif Files Only";
    function callback() {
    if (req.readyState == 4) {
    updatepage(req.responseText);
    function updatepage(str){
         document.getElementById("result" + file).innerHTML = str;
    function checkValidity(str)
         var i=0;
         var j=0;
         var str1 = str.substring(str.lastIndexOf("."),str.length);
         alert(str1);
         for(i=0;i<exten.length;i++)
         if(str1.search(exten) != -1)
              j++;
              break;
         if(j>0)
              return true;
         else
              return false;
    </script>
    </head>
    <body onload="addValues()">
    <h5>Add Photo(s)</h5>
    <select id="addSelect" name="addSelect" onchange="addBoxes()">
    <option id="select" selected>Select</option>
    </select>
    <div id="addPhoto"></div>
    </body>
    </html>
    uploadFile.jsp
    <%@page import="java.io.*"%>
    <%
    /*try
    String contentType = request.getContentType();
         System.out.println(request.getMethod());
         System.out.println("Content type is :: " +contentType); 
         if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0))
              DataInputStream in = new DataInputStream(request.getInputStream());
              DataInputStream in1 = in;
              int formDataLength = request.getContentLength();
    System.out.println(formDataLength);
              byte dataBytes[] = new byte[formDataLength];
              int byteRead = 0;
              int totalBytesRead = 0;
              while (totalBytesRead < formDataLength)
                   byteRead = in1.read(dataBytes, totalBytesRead, formDataLength);
                   totalBytesRead += byteRead;
              out.println("<br>totalBytesRead : " + totalBytesRead + " : formDataLength = " + formDataLength);
         } catch(Exception e) {
              e.printStackTrace();
         try
         String filePath = request.getParameter("filepath");
         System.out.println(filePath);
         File f= new File(filePath);
         String path = f.getName();
         String contentType = request.getContentType();
         System.out.println(contentType);
         //InputStream in = new FileInputStream(filePath);
         DataInputStream in = new DataInputStream(request.getInputStream());
         int formDataLength = request.getContentLength();
         System.out.println(formDataLength);
    byte[] buf = new byte[1024];
    OutputStream out1 = new FileOutputStream("c:/docs/" + path);
    int len;
    while ((len = in.read(buf)) > 0) {
    out1.write(buf, 0, len);
    in.close();
    out1.close();
         out.write("File Uploaded SucssesFully");
    catch(Exception e)
         e.printStackTrace();
         out.write("error while Writing File");
    %>
    the above code in request.getContentType() i am getting 0. I am not passing the content length. for the same application with out using Ajax i am
    getting the size of file... it is very very urgent for me.. pls help me out on this...
    Any one having the code on this pls mail me the code...
    my mail id ... [email protected]
    Regards
    Ashok Kumar

    Sure, you can upload a file, using a form input element of type file. You pick this up with a servlet, though you need a special request wrapper to sort out the multi-part request you get back that way (there's a suitable package on jakarta.apache.org/commons)
    The servlet decrypts the file and can pass the results to a JSP for display.
    Don't try to do the complicated stuff in a JSP, it all gets incredibly messy, and that's not what JSPs are for.

  • Content-length in HTTP Post request

    Hi all,
    I have a problem with a Http request. I send data in a POST to a servlet, but the KVM doesn't set the Content-Length correctly. How can I do ?
    The code :
    conn = (HttpConnection) Connector.open(m_strServer);
    conn.setRequestMethod(HttpConnection.POST);
    conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    String requestData = "from=" + m_strOriginator + "&to=" + m_strDestinator + "&message=" + m_strMessage;
    out = conn.openDataOutputStream();
    out.write(requestData.getBytes());
    out.flush();
    in = conn.openDataInputStream();
    if (conn.getResponseCode() == 200)
         response = true;the request sended :
    POST /my_directory/test.xml HTTP/1.1
    Content-Type: application/x-www-form-urlencoded
    Transfer-Encoding: chunked
    Host: my_pc
    15
    from=8&to=9&message=J
    0
    I think that the KVM doesn't put "Content-Length:" before "15".
    Perhaps it's a bug.
    St�phane

    Maby u try to force it with:
    conn.setRequestProperty ( "Content-Length" ,
                   Integer.toString (requestData.getBytes()));
    for me it does also not work...but u never know
    lemme know if it works
    Fabian

  • How to insert document into xmltype column through an http post request with perl

    Oracle 11.2.0.3
    Windows server 2008r2
    Apache tomcat 7.0
    Oracle APEX 4.2.1
    Oracle APEX Listener 2.0
    I would like to insert a XML document into the database through an APEX restful web service. The POST into the web service in done with PERL. The following code will insert an empty record in a table with column of XMLType type.
    Perl Code
    use strict;
    use warnings;
    use LWP::UserAgent;
    use HTTP:Headers;
    my $headers = HTTP::Headers->new();
    my $url = "http://host:port:apex/<application_workspace>/<restfull service module>/<uri template>/
    my $sendthis = ('<?xml version="1.0" enconding="utf-8"?>
    <students>
    <row>
           <name>Mark</name>
          <age>30</age>
    </row>
    <./students>';)
    $headers -> header('Content-Type' => 'text/xml; charset=utf-8');
    my $request = HTTP:Request->new('POST', $url, $headers, $sendthis);
    $request-> protocol('HTTP/1.1');
    my $browser = LWP::UserAgent->new();
    my $response = $browser->request($request);
    my $gotthis= $response->content();
    my $the_file_data = $response->content();
    APEX restful service
    Method: POST
    Source type: PL/SQL
    MIME Types allowed: blank
    require secure access: none
    source:
    {declare
    doc varchar2(32000);
    begin
    insert into table <column name>
    values(doc);
    commit;
    end;
    Table code
    { create table <tablename>
    (column name XMLType>);
    The above code will insert an empty column into the table.
    Any ideas why?

    It's a really bad idea to assemble XML using strings and string concatenation in SQL or PL/SQL. First there is a 4K limit in SQL, and 32K limit in PL/SQL, which means you end up constructing the XML in chunks, adding uneccessary complications. 2nd you cannot confirm the XML is valid or well formed using external tools.
    IMHO it makes much more sense to keep the XML content seperated from the SQL / PL/SQL code
    When the XML can be stored a File System accessable from the database, The files can be loaded into the database using mechansims like BFILE.
    In cases where the XML must be staged on a remote file system, the files can be loaded into the database using FTP or HTTP and in cases where this is not an option, SQLLDR.
    -Mark

  • How to make a HTTP Post request to a remote server ?

    Hi Guys,
    I'm new to java technology. I've a small problem with my code. All i need is to send a request to the remote server whose control is not at all in my hands with the POST method, which includes few of the parameters along with one of them is a xml formatted variable. The result of this request is an xml generated out which i want to fetch in my jsp code. I've tried it with the HTTPUrlConnection method and code for the same is below :
    <%
    try {
    String xmlString = "<FARES><AGENCY_ID>TFI</AGENCY_ID><DEP_CITY>NYC</DEP_CITY><ARR_CITY>LON</ARR_CITY><DEP_DATE>12</DEP_DATE><DEP_MONTH>DEC</DEP_MONTH><OWRT>RT</OWRT></FARES>";
    URL url = new URL("http://www.lowestairprice.com/Canada/mars.asp?WCI=Start&WCE=XMLFARES&reqMsg=Yes&");
    HttpURLConnection con = (HttpURLConnection)url.openConnection();
    con.setInstanceFollowRedirects(true);
    con.setFollowRedirects(true);
    con.setRequestMethod("POST");
    con.setDoOutput(true);
    out.println("Testing...");
    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(con.getOutputStream()));
    bw.write("xmltekst=" + xmlString);
    bw.flush();
    bw.close();
    BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String line = br.readLine();
    String result ="";
    while (line !=null) {
    result += line;
    line = br.readLine();
    br.close();
    out.println("Resultat: " + result);
    } catch(Exception exc) {
    exc.printStackTrace();
    out.println(exc);
    %>
    But when i run this on browser it gives me the following error.
    java.net.MalformedURLException: unknown protocol: https
    Now the response they provide is thrown back with the https protocol instead of the http. How can i fetch their response in my jsp code and store it in a local variable.
    If anybody can help me out in this, i would be thankful for the same.
    Thanking You,
    Rgds,
    Gaurav
    (Software Engineer)
    Ultra Infotech.

    Have you tried to use HttpsURLConnection instead ?

Maybe you are looking for