HTTP Multipart Post

I have been given a new requirement to send a zipped file(s) to a client using HTTPS using a Multipart Post.
I have found an example...
DECLARE
  req   utl_http.req;
  resp  utl_http.resp;
  value VARCHAR2(1024);
BEGIN
  req := utl_http.begin_request('http://www.psoug.org');
  resp := utl_http.get_response(req);
  LOOP
    utl_http.read_line(resp, value, TRUE);
    dbms_output.put_line(value);
  END LOOP;
  utl_http.end_response(resp);
EXCEPTION
  WHEN utl_http.end_of_body THEN
    utl_http.end_response(resp);
END;Which obviously returns and displays the HTML content of the URL, however we need to post zipped files in the content. We have been told by someone at Oracle that we can use the UTL_HTTP package to do this but when i search for this all i find is Java.
Can anyone point me in the right direction as to where to start and any code examples would be a great help.
Thanks in advance
Graham.

I have been given a new requirement to send a zipped file(s) to a client using HTTPS using a Multipart Post.
I have found an example...
DECLARE
  req   utl_http.req;
  resp  utl_http.resp;
  value VARCHAR2(1024);
BEGIN
  req := utl_http.begin_request('http://www.psoug.org');
  resp := utl_http.get_response(req);
  LOOP
    utl_http.read_line(resp, value, TRUE);
    dbms_output.put_line(value);
  END LOOP;
  utl_http.end_response(resp);
EXCEPTION
  WHEN utl_http.end_of_body THEN
    utl_http.end_response(resp);
END;Which obviously returns and displays the HTML content of the URL, however we need to post zipped files in the content. We have been told by someone at Oracle that we can use the UTL_HTTP package to do this but when i search for this all i find is Java.
Can anyone point me in the right direction as to where to start and any code examples would be a great help.
Thanks in advance
Graham.

Similar Messages

  • HTTPS using a Multipart Post

    I have been given a new requirement to send a zipped file(s) to a client using HTTPS using a Multipart Post.
    I have found an example...
    DECLARE
      req   utl_http.req;
      resp  utl_http.resp;
      value VARCHAR2(1024);
    BEGIN
      req := utl_http.begin_request('http://www.psoug.org');
      resp := utl_http.get_response(req);
      LOOP
        utl_http.read_line(resp, value, TRUE);
        dbms_output.put_line(value);
      END LOOP;
      utl_http.end_response(resp);
    EXCEPTION
      WHEN utl_http.end_of_body THEN
        utl_http.end_response(resp);
    END;Which obviously returns and displays the HTML content of the URL, however we need to post zipped files in the content. We have been told by someone at Oracle that we can use the UTL_HTTP package to do this but when i search for this all i find is Java.
    Can anyone point me in the right direction as to where to start and any code examples would be a great help, i tried posting this in the SQL / PLSQL forum but with no success..
    Thanks in advance
    Graham.

    Hi:
    This is tricky one and I have to say that there is not a lot around about it.
    The example you have shown is for UTL_HTTP and while you are on the right track, you want HTTPS and that requires, in addition to what you, the use of the Oracle Wallet. The wallet has to be setup on your machine and referenced in your code. Additionally, you need to be quite clear about the data that is being expected by the remote system to which you are sending the POST request.
    Here is a code example that I have tried to explain a bit for you. Obviously my code is doing something quite different from what you require but the methodology will be similar:
    +++++++++++++++++++++++
    create or replace
    PROCEDURE ABS_MSG_API
    (cab IN VARCHAR2,
    booking_ref IN NUMBER)
    AS
    l_cab VARCHAR2(10);
    l_booking_ref NUMBER;
    l_uuid VARCHAR2(50);
    l_answer integer;
    req utl_http.req;
    resp utl_http.resp;
    value clob;
    listing VARCHAR2(400);
    BEGIN
    l_cab := cab;
    l_booking_ref := booking_ref;
    listing := 'https://........<site address>;
    /* next you must identify the location of your wallet */
    utl_http.set_wallet('file:C:\Documents and Settings\administrator\ORACLE\WALLETS','redy2go4it');
    utl_http.set_transfer_timeout(60);
    dbms_output.put_line(listing);
    /* next we start the request. Though a GET here, a POST is the same thing */
    req := utl_http.begin_request(listing,'GET','HTTP/1.1');
    /* in my case a username and password are passed - think of this at your POST parameters */
    utl_http.set_header(req,'Username',xxxx);
    utl_http.set_header(req,'Password',xxxxx);
    utl_http.set_header(req,'Version','99.99.99');
    /* the rest is much like your code already, with some debug capability */
    resp := utl_http.get_response(req);
    DBMS_OUTPUT.PUT_LINE('Request Method....'||req.METHOD);
    DBMS_OUTPUT.PUT_LINE('HTTP Response Status Code: ' || resp.status_code);
    DBMS_OUTPUT.PUT_LINE('HTTP Response Reason Phrase: ' || resp.reason_phrase);
    DBMS_OUTPUT.PUT_LINE('HTTP Response Version: ' || resp.http_version);
    LOOP
    utl_http.read_line(resp, value, TRUE);
    l_answer := instr(value,'uuid',1,1);
    IF l_answer > 0 THEN
    l_uuid := substr(value,l_answer+6,36);
    dbms_output.put_line('The string is.....'||l_uuid);
    END IF;
    IF l_answer > 0 THEN
    send_dt_message(l_uuid,l_cab,l_booking_ref);
    EXIT;
    END IF;
    END LOOP;
    utl_http.end_response(resp);
    EXCEPTION
    WHEN utl_http.end_of_body THEN
    utl_http.end_response(resp);
    l_answer := instr(value,'uuid',1,1);
    dbms_output.put_line('The value is......'||l_answer);
    END ABS_MSG_API;
    When you submit a POST, all of the parameters are passed as part of the header. You must determine exactly the information being expected by the remote system.
    You can find further information is you search for HTTPS on Ask Tom. There is some useful stuff there.
    I use UTL_HTTP for HTTPS requrests all the time. As I said, it is a bit tricky at first, but the key is the Oracle Wallet and then reading the UTL_HTTP documentation that comes on your DB media disc under PLSQL Packaged Procedures.
    I hope this helps.
    Bruce Clark

  • How do I set the Http Header POST URL in SAAJ?

    Hi ,
    I am a newbie in the field of web services. I was trying to create a SOAP request with Http Header POST information having a POST url like
    the following:
    POST /OMASTI.xml HTTP/1.1
    Content-Type: multipart/related; boundary="eladeladeladeladeladeladeladeladelad"; type=text/xml; start=11814460
    Content-Length: 54596
    Host: unspecified
    SOAPAction: ""
    to that effect I did the following in the SAAJ client:
    MimeHeaders md = message.getMimeHeaders();
              md.setHeader("SOAPAction" ,"\"\"");
              md.setHeader("POST" ,"/OMASTI.xml");
    However what I got was :
    POST / HTTP/1.1
    Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    SOAPAction: ""
    POST: /OMASTI.xml
    Content-Type: multipart/related; type="text/xml"; boundary="----=_Part_2_32124414.1153146262750"
    Content-Length: 3352
    Cache-Control: no-cache
    Pragma: no-cache
    User-Agent: Java/1.5.0_07
    Host: www.google.com
    Connection: keep-alive
    I have two POSTs in the header. How do I fix it? Please Help ASAP.
    Regards,
    Zeus

    Hi,
    Please forgive my ignorance. I did the same as you said. and then checked the Http request being sent out using ethreal software... it was the same as I had told earlier. Is only POST supported by the connection object? And the does the URL that comes in the Mime header as POST refer to the URL to which the request was sent? what I mean is that if the mime header says
    POST /OMASTI.xml HTTP 1.1, does it mean that the URL that was passed to the connection object was "/OMASTI.xml" ? I had given the url as http://www.google.com to test the request being sent.. I only have a sample SOAP request which shows a HTTP header with the post url as I said before. I need to create a SOAP request with the same sort of Http header and the body needs to follow a certain OMA-STI protocol. My experience in the SOAP domain is almost nil. So please enlighten me.
    Thanks in advance,
    zeus

  • POST/multipart-POST

    Hi,
    I've been looking at various APIs for sending HTTP POST functions, in particular I'm interested in the different uses between the above 2 methods. The typical line is "if you're sending a file - use multipart".
    Why, do POST methods have a certain maximum size?
    Or, what's the point when I should use POST or multipart-POST?
    Is it typical to just use multipart-POST everywhere?
    Is the trade-off just more overhead?
    Any help on this would be appreciated.

    This is really an HTTP question, not a Java question.

  • How to upload large file with http via post

    Hi guys,
    Does anybody know how to upload large file (>100 MB) use applet to servlet with http via post method? Thanks in advance.
    Regards,
    Mark.

    Hi SuckRatE
    Thanks for your reply. Could you give me some client side code to upload a large file. I use URL to connect to server. It throws out of memory exception. The part of client code is below:
    // connect to the servlet
    URL theServlet = new URL(servletLocation);
    URLConnection servletConnection = theServlet.openConnection();
    // inform the connection that we will send output and accept input
    servletConnection.setDoInput(true);
    servletConnection.setDoOutput(true);
    // Don't used a cached version of URL connection.
    servletConnection.setUseCaches (false);
    servletConnection.setDefaultUseCaches(false);
    // Specify the content type that we will send text data
    servletConnection.setRequestProperty("Content-Type",
    +"application/octet-stream");
    // send the user string to the servlet.
    OutputStream outStream = servletConnection.getOutputStream();
    FileInputStream filein = new FileInputStream(largeFile);
    //BufferedReader in = new BufferedReader(new InputStreamReader
    +(servletConnection.getInputStream()));
    //System.out.println("tempCurrent = "+in.readLine());
    byte abyte[] = new byte[2048];
    int cnt = 0;
    while((cnt = filein.read(abyte)) > 0)
    outStream.write(abyte, 0, cnt);
    filein.close();
    outStream.flush();
    outStream.close();
    Regards,
    Mark.

  • HTTP Form Post

    Hi,
    I need to emulate an HTTP form post from ALSB 2.5.
    I have the business service defined as Text for both the Request and Response message types. I have a proxy that routes to the business service and sets the Content-type to 'application/x-www-form-urlencoded'.
    But what I'm not clear on is how can I specify the form data set (name/value pairs) in the outbound HTTP request?
    Thx in advance for the guidance!

    You can do it from anywhwere in the pipeline. You can use an assign action and modify the content of $body. Don't modify the whole variable.
    If it still does not work, here is what I would do. Write a simple html file containing a submit and point to a service bus dummy proxy service. Inside the dummy service use a log action to log the content of $body so you have an idea how it should exactlty looks like.
    Gregory Haardt
    ALSB Prg. Manager
    [email protected]

  • Applicationhost.config updates for HTTP Slow Post with Azure Websites

    We are trying to update our Azure websites to not show as vulnerable to the HTTP Slow Post vulnerability. Some articles suggest fixing this by updating the applicationHost.config via IIS to update the connection timeout values. Obviously with Azure websites,
    we don't have access to IIS. Came across some options with Kudu and XDT to modify the application host file, as outlined on these two sites:
    http://azure.microsoft.com/en-us/documentation/articles/web-sites-transform-extend/#transform
    http://rtigger.com/blog/2014/03/31/number-til-modifying-you-azure-applicationhost-dot-config
    Currently am using the following as our applicationHost.xdt (I have this both in our application root, as well as in a SiteExtensions folder as I wasn't clear which one was required).
    <?xml version="1.0"?> 
    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
    <system.applicationHost>
            <sites>
                <siteDefaults>
                    <limits connectionTimeout="00:00:30"
    xdt:Transform="Insert" />
                </siteDefaults>
                <applicationDefaults applicationPool="DefaultAppPool" />
                <virtualDirectoryDefaults allowSubDirConfig="true" />
            </sites>
            <webLimits connectionTimeout="00:00:30"
    xdt:Transform="Insert" />
    </system.applicationHost>
    </configuration> 
    We also set the WEBSITE_PRIVATE_EXTENSIONS app-setting to 1 as instructed.
    When testing our site using a 3rd party tool, it appears the setting is not getting applied. Hoping someone can point out where our error may be. Alternatively, is there any way to see what the current applicationHost.config is for our website? I'm curious
    if our XDT is correctly being applied, so if we could see what the resulting file was that may also allow us to further troubleshoot.
    Thanks in advance for any advise!

    Please see
    this page, which has detailed steps on finding your applicationhost.config and finding the logs from the transformation. And please make sure that your applicationhost.xdt is in your
    d:\home\site folder (and not in your site\wwwroot).
    David

  • Xml over http form post and response example

    can some one point me to http form post/get  syntax to send and receive xml...let me know

    Use the cfhttp tag. For example, suppose the xmlDoc is already defined. Then you could post the document using
    <cfhttp url="the_url" method="post">
        <cfhttpparam type="header" name="content-type" value="text/xml">
        <cfhttpparam type="header" name="content-length" value="#len(xmlDoc)#">
        <cfhttpparam type="header" name="charset" value="utf-8">
        <cfhttpparam type="xml" name="message" value="#xmlDoc#">
    </cfhttp>

  • Read of HTTP Request POST parameters failed:Read timed out

    Hi !
    Any one seen this exception . any ideas of the cause?
    java.lang.RuntimeException: Read of HTTP Request POST parameters failed: Read timed out
    at org.apache.catalina.connector.HttpRequestBase.parseParameters(HttpRequestBase.j ava:665)
    at org.apache.catalina.connector.HttpRequestBase.getParameterValues(HttpRequestBase.java :737)
    at org.apache.catalina.connector.RequestFacade.getParameterValues(RequestFacade.java:170 )
    Thanks,

    Assuming there is nothing wrong with
    org.apache.catalina.connector.HttpRequestBase.parseParameters
    I can only think of 2 things:
    1. The timeout is set for an extremely short time in the Apache settings (server.xml&#51032;)
    2. The client application is sending the POST verry slow or incorrect. For example the
    client says that the POST is 500 long than sends 200 and leaves the connection open.
    You can try and post the following:
    request.txt:
    POST /somePath/somefile.js HTTP/1.1
    Host: localhost:44
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041217
    Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 45
    depreciatedButWontPostWithoutAName=some+valueThe client sending the request:
    import java.io.*;
    import java.net.*;
    import java.io.DataOutputStream;
    import java.applet.Applet;
    public class appTest extends Applet implements Runnable {
         public static final int HTTP_PORT = 80;
         public static final String hostName = "localhost";
         public void run() {
              try{
                   InetAddress addr = InetAddress.getByName(hostName);
                   Socket s = new Socket(addr,HTTP_PORT);
                   BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(s.getOutputStream(), "UTF8"));
                   s.setSoTimeout(2000);
                   File fileToSend = new File("request.txt");
                   FileInputStream fleHTML = new FileInputStream(fileToSend);
                   StringBuffer sbHTMFile = new StringBuffer();
                   int b = fleHTML.read();
                   while(b!=-1){
                        sbHTMFile.append((char) b);
                        b = fleHTML.read();
                   wr.write(sbHTMFile.toString());
                   wr.flush();
                   BufferedReader rd = new BufferedReader(new InputStreamReader(s.getInputStream()));
                   String line;
                   while ((line = rd.readLine()) != null) {
                        System.out.println(line);
                   wr.close();
                   rd.close();
                   } catch (Exception e) {
                        e.printStackTrace();
         public void init(){
              new Thread(this).start();
         public appTest(){
              new Thread(this).start();
         // main program
         public static void main(String argv[]) throws Exception {
              new appTest();
    }In appTest.java change HTTP_PORT to the port you need and hostName to the
    hostname you need.
    In request.txt change the /somePath/somefile.js to the location you desire.
    And change Host: localhost:44 to the hostname and post you desire.

  • HTTP Status 405 - HTTP method POST is not supported by this URL

    dear all
    can u solve my problem.am getting the *"HTTP Status 405 - HTTP method POST is not supported by this URL"* msg from the browser when i press the search button in my form.plz suggest me the solution for my fault.these are the following html,xml,class files:
    search.html*
    <html>
    <head>
    <title>Search Page</title>
    </head>
    <body>
    <p align="center"><font size="6" color="#0000FF"><b>Search Module</b></font></p>
    <p align="center"> </p>
    <center>
    <form method="POST" action="./emp">
    <table border="1" width="43%">
    <tr>
    <td width="50%">
    <p align="right">Employee Name</td>
    <td width="50%"><input type="text" name="empname" size="36"></td>
    </tr>
    <tr>
    <td width="100%" colspan="2">
    <p align="center"><input type="submit" value="Search" name="B1"></td>
    </tr>
    </table>
    </form>
    </center>
    </body>
    </html>
    web.xml*
    <web-app>
    <servlet>
    <servlet-name>jdbc</servlet-name>
    <servlet-class>searchModule</servlet-class>
    <init-param>
    <param-name>driver</param-name>
    <param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>
    </init-param>
    <init-param>
    <param-name>url</param-name>
    <param-value>jdbc:odbc:first</param-value>
    </init-param>
    <init-param>
    <param-name>user</param-name>
    <param-value>scott</param-value>
    </init-param>
    <init-param>
    <param-name>pass</param-name>
    <param-value>tiger</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>jdbc</servlet-name>
    <url-pattern>/emp</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
    <welcome-file>search.html</welcome-file>
    </welcome-file-list>
    </web-app>
    SearchModule.java*
    import java.util.*;
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class searchModule extends HttpServlet
    Connection con;
    public void init() throws ServletException
    String d=getInitParameter("driver");
    String u=getInitParameter("url");
    String us=getInitParameter("user");
    String pwd=getInitParameter("pass");
    try
    Class.forName(d);
    con=DriverManager.getConnection(u,us,pwd);
    catch(ClassNotFoundException e)
    System.out.println(e);
    catch(SQLException e)
    System.out.println("Unable to establish the connection");
    }//init
    public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
    String empname=req.getParameter("empname");
    res.setContentType("text/html");
    PrintWriter pw=res.getWriter();
    try
    pw.println("<html><body><center>");
    Statement st=con.createStatement();
    String sql="select * from employee where empname="+empname;
    ResultSet rs=st.executeQuery(sql);
    if(rs.next())
    pw.println("<h2>Employee Details</h2>");
    pw.println("<table border=1>");
    pw.println("<tr><th>Employee No.</th>");
    pw.println("<th>Employee Name</th>");
    pw.println("<th>Designation</th>");
    pw.println("<th>Department</th>");
    pw.println("<th>Salary</th>");
    pw.println("</tr><tr>");
    pw.println("<td>"+rs.getInt(1)+"</td>");
    pw.println("<td>"+empname+"</td>");
    pw.println("<td>"+rs.getString(3)+"</td>");
    pw.println("<td>"+rs.getString(4)+"</td>");
    pw.println("<td>"+rs.getInt(5)+"</td>");
    pw.println("</tr></table>");
    else
    pw.println("<h2>Employee Record Not Found</h2>");
    pw.println("</center></body></html>");
    pw.close();
    rs.close();
    st.close();
    catch(SQLException e)
    System.out.println(e);
    }//doPost
    public void destroy()
    if(con!=null)
    try
    con.close();
    catch(Exception e)
    System.out.println("Connection Closed");
    }//destroy
    }//searchModule
    in control panel i selected System DNS and created the name as first and driver as Microsoft ODBC for Oracle
    plz suggest me the solution where i committed mistake.

    <form method="*POST*" action="./emp">
    public void doGet (HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
    HTTP method POST is not supported by this URL

  • HTTPS for posting incoming Invoices

    Currently our vendors are using HTTP to post XML invoices to our XI server. But one of our vendor cannot use HTTP, they have to use HTTPS. So what should we do in our system so our vendor can post invoices to XI server by using HTTPS? do we need do extra settings in XI?
    Thanks in advance!
    Mrudula

    Hi Mrudula
    Check this thread
    HTTP Adapter with SSL/HTTPS
    cheers
    Sameer

  • HTTP Method Post not supported by this URL

    We are running WL6.0sp1 on Win2000. When we try to open a JSP page which calls
    a servlet we get a "HTTP Method Post not supported by this URL". This same setup
    (WL 6.0sp1 on Win2000) on another machine works absolutely fine running from the
    same client. Is there any setup that needs to be done in Weblogic for this? Any
    pointers on this would be appreciated.
    Rgds

    Normally when you get this error, your username/password is not correct.
    It's not a clean way of errorhandling. I have had the same issue and after a while i noticed the password i entered was not correct.

  • HTTP method POST is not supported by this URL

    Hi everyone,
    I'm having a problem in my application.
    I used the ADF Security Wizard to enable the ADF Security in my application. So, it created the pages login.html, error.html and welcome.jsp.
    The problem is when I try to sign in in my applicaton. On the page login.html I filled in the fields username and password and click on the button to post the form. But when the form is posted I get the message: "HTTP method POST is not supported by this URL".
    The form is posted to the bean j_security_check.
    Does anybody know why is it happening? What should I do to fix it?
    Thanks a lot
    Daniel
    Edited by: [email protected] on 23/02/2010 05:37

    Normally when you get this error, your username/password is not correct.
    It's not a clean way of errorhandling. I have had the same issue and after a while i noticed the password i entered was not correct.

  • 405 HTTP method POST is not supported by this URL

    When I use GET method to browse a servlet by using TOMCAT or Resin, receive the following message:
    405 HTTP method POST is not supported by this URL
    Thanks!

    Just post your question once and be patient:
    http://forum.java.sun.com/thread.jspa?threadID=573890
    %

  • Plain HTTP sending Post Requests and Multipart Uploads

    Hi,
    I have a scenaio where I need to send an normal POST request
    to the server. This request needs to have not the XML payload but
    the same data in the form of a POST request.
    Is there a way to transform the data out of the XML format into
    the plain POST format prior to sending it?
    Also, another scenario requires an file upload via HTTP (like a
    file submitted by a web-form). Is this possible with PI and how?
    Thanks for any pointers
    Best regrads

    Hi,
    If you do not send any payload in the http request you are going to get a http error.
    For your second requirement, There is no any problem, You can use any existent tool, or maybe develop you own program.
    Http client.
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417600)ID1536482550DB10501227175138097442End?blog=/pub/wlg/15296
    Regards
    Ivan

Maybe you are looking for