Downloading file via HTTP

Hi,
is it possible or exist some adapter or service, which can
process(or download) file placed on HTTP server?
Thanks
Martin

Chtira,
I've done it in JDeveloper with HttpServlet class and not in BPEL. I've overridden the doGet and doPost methods.
doGet looks something like this:
  public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
    throws ServletException, IOException
    response.setContentType(CONTENT_TYPE);
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head><title>Communication</title></head>");
    out.println("<body>");
    out.println("<p>GET method is not supported. Please use POST method for XML messages.</p>");
    out.println("</body></html>");
    out.close();
  }doPost method is a bit more complicated. Basically I'll call my BPEL processes with the XML messages I receive but I'm still struggling with XML validation against a schema in this servlet class.
When you have the class you have to put something like
  <servlet>
    <servlet-name>HttpServletPost</servlet-name>
    <servlet-class><your package>.HttpServletClass</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
     <servlet-name>HttpServletPost</servlet-name>
     <url-pattern>/Communication/*</url-pattern>
  </servlet-mapping> in your web.xml file.
Hope this helps you somehow.
BB

Similar Messages

  • Problem downloading a file via http

    Hi
    I'm just getting started with WLS (sp5) and am having a problem downloading
    a file via http. The document is stored in the main html docs directory and
    whenever I link to it or try to download it directly (eg:
    http://<host>:<port>/myfile.doc) I get the following error in a message box:
    Your current security settings do not allow this file to be downloaded.
    Can anyone point me in the right direction as to where I grant permissions
    to do this - I've tried using the weblogic.security.URLAclFile and adding
    the directory as a weblogic.io.fileSystem (a desperation move, I know).
    Thanks in advance,
    Peter Villiers

    PLEASE IGNORE THIS POST
    The problem was caused by someone (me though I honestly don't remember doing
    it), setting the content security level to high in my web browser which
    stopped this type of download.
    Peter

  • Uploading Very Large Files via HTTP

    I am developing some classes that must upload files to a web server via HTTP and multipart/form-data. I am using Apache's Tomcat FileUpload library contained within the commons-fileupload-1.0.jar file on the server side. My code fails on large files or large quantities of small files because of the memory restriction of the VM. For example when uploading a 429 MB file I get this exception:
    java.lang.OutOfMemoryError
    Exception in thread "main"I have never been successful in uploading, regardless of the server-side component, more than ~30 MB.
    In a production environment I cannot alter the clients VM memory setting, so I must code my client classes to handle such cases.
    How can this be done in Java? This is the method that reads in a selected file and immediately writes it upon the output stream to the web resource as referenced by bufferedOutputStream:
    private void write(File file) throws IOException {
      byte[] buffer = new byte[bufferSize];
      BufferedInputStream fileInputStream = new BufferedInputStream(new FileInputStream(file));
      // read in the file
      if (file.isFile()) {
        System.out.print("----- " + file.getName() + " -----");
        while (fileInputStream.available() > 0) {
          if (fileInputStream.available() >= 0 &&
              fileInputStream.available() < bufferSize) {
            buffer = new byte[fileInputStream.available()];
          fileInputStream.read(buffer, 0, buffer.length);
          bufferedOutputStream.write(buffer);
          bufferedOutputStream.flush();
        // close the files input stream
        try {
          fileInputStream.close();
        } catch (IOException ignored) {
          fileInputStream = null;
      else {
        // do nothing for now
    }The problem is, the entire file, and any subsequent files being read in, are all being packed onto the output stream and don't begin actually moving until close() is called. Eventually the VM gives way.
    I require my client code to behave no different than the typcial web browser when uploading or downloading a file via HTTP. I know of several commercial applets that can do this, why can't I? Can someone please educate me or at least point me to a useful resource?
    Thank you,
    Henryiv

    Are you guys suggesting that the failures I'm
    experiencing in my client code is a direct result of
    the web resource's (servlet) caching of my request
    (files)? Because the exception that I am catching is
    on the client machine and is not generated by the web
    server.
    trumpetinc, your last statement intrigues me. It
    sounds as if you are suggesting having the client code
    and the servlet code open sockets and talk directly
    with one another. I don't think out customers would
    like that too much.Answering your first question:
    Your original post made it sound like the server is running out of memory. Is the out of memory error happening in your client code???
    If so, then the code you provided is a bit confusing - you don't tell us where you are getting the bufferedOutputStream - I guess I'll just assume that it is a properly configured member variable.
    OK - so now, on to what is actually causing your problem:
    You are sending the stream in a very odd way. I highly suspect that your call to
    buffer = new byte[fileInputStream.available()];is resulting in a massive buffer (fileInputStream.available() probably just returns the size of the file).
    This is what is causing your out of memory problem.
    The proper way to send a stream is as follows:
         static public void sendStream(InputStream is, OutputStream os, int bufsize)
                     throws IOException {
              byte[] buf = new byte[bufsize];
              int n;
              while ((n = is.read(buf)) > 0) {
                   os.write(buf, 0, n);
         static public void sendStream(InputStream is, OutputStream os)
                     throws IOException {
              sendStream(is, os, 2048);
         }the simple implementation with the hard coded 2048 buffer size is fine for almost any situation.
    Note that in your code, you are allocating a new buffer every time through your loop. The purpose of a buffer is to have a block of memory allocated that you then move data into and out of.
    Answering your second question:
    No - actually, I'm suggesting that you use an HTTPUrlConnection to connect to your servlet directly - no need for special sockets or ports, or even custom protocols.
    Just emulate what your browser does, but do it in the applet instead.
    There's nothing that says that you can't send a large payload to an http servlet without multi-part mime encoding it. It's just that is what browsers do when uploading a file using a standard HTML form tag.
    I can't see that a customer would have anything to say on the matter at all - you are using standard ports and standard communication protocols... Unless you are not in control of the server side implementation, and they've already dictated that you will mime-encode the upload. If that is the case, and they are really supporting uploads of huge files like this, then their architect should be encouraged to think of a more efficient upload mechanism (like the one I describe) that does NOT mime encode the file contents.
    - K

  • Cannot download file over https behind firewall ?

    I have a program to download files :
    public class TestServlet
         public static void main(String args[]){
        Authenticator.setDefault(new AuthImpl());
         if (args.length!=2){
          System.out.println("Proper Usage: java -Dhttp.proxyHost=172.21.32.166 -Dhttp.proxyPort=80 TestServlet RemoteFileURL LocalFileName");
           System.out.println("Usage Example:java -Dhttp.proxyHost=199.67.138.83 -Dhttp.proxyPort=8080 TestServlet https://url.com/csv/file.zip file.zip");
          System.exit(0);
         DataOutputStream out=null;
         FileOutputStream fOut=null;
         try
          trustAllHttpsCertificates();
          String urlStr = args[0];
              HostnameVerifier hv = new HostnameVerifier() {
                   public boolean verify(String urlHostName, SSLSession session) {
                        System.out.println("Warning: URL Host: "+urlHostName+" vs. "+session.getPeerHost());
                        return true;
             HttpsURLConnection.setDefaultHostnameVerifier(hv);
              System.out.println("\nConnecting to Website . . . "+urlStr);
              URL url = new URL(urlStr == null ? "https://url/Downloads/WC.csv" : urlStr);
              System.out.println("\nConnecting . . . . ");
              BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
              System.out.println(". . . Connected");
              System.out.print("\nDownloading the file . . . ");
              int buff;
              fOut=new FileOutputStream(args[1]);
              System.out.print(" . .");
              out=new DataOutputStream(fOut);
              System.out.print(" . .");
              while ((buff = in.read()) != -1) {
                fOut.write(buff);
              in.close();
            System.out.println(" . . . Done \n");
          catch (Exception e) {
                e.printStackTrace();
           finally {
              try{
                   fOut.flush();
                   fOut.close();
                   System.exit(0);
               catch(Exception e){
                   e.printStackTrace();
        HostnameVerifier hv = new HostnameVerifier()
            public boolean verify(String urlHostName, SSLSession session) {
                //System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
                return true;
        private static void trustAllHttpsCertificates() throws Exception
             //  Create a trust manager that does not validate certificate chains:
            javax.net.ssl.TrustManager[] trustAllCerts =  new javax.net.ssl.TrustManager[1];
            javax.net.ssl.TrustManager tm = new miTM();
            trustAllCerts[0] = tm;
              javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL");
            sc.init(null, trustAllCerts, null);
            javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
        public static class miTM implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {
            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                return null;
            public boolean isServerTrusted(java.security.cert.X509Certificate[] certs) {
                return true;
            public boolean isClientTrusted(java.security.cert.X509Certificate[] certs) {
                return true;
            public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
                    throws java.security.cert.CertificateException {
                return;
            public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
                    throws java.security.cert.CertificateException {
                return;
       public static class AuthImpl extends Authenticator {
       protected PasswordAuthentication getPasswordAuthentication() {
          String username = new String("guest");
    String password = new String ("guest");
           return new PasswordAuthentication(username, password.toCharArray());
    }This program works fine for downloading files, over both http and https from my home. When I run this on my desktop in the office it can download files over http, but cannot download https files.
    When I try to download files over https, I get the foll. exception:
    java.net.UnknownHostException: www.site.com
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:153)
    at java.net.Socket.connect(Socket.java:452)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(DashoA12275)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(DashoA12275)
    at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(DashoA12275)
    at sun.net.www.protocol.https.HttpsClient.doConnect(DashoA12275)
    There are 2 differences here, one being that my office desktop sits behind a firewall and there is a proxy in between.
    In the office I run the program as :
    java -Dhttp.proxyHost -Dhttp.proxyPort TestServlet URL [filename]
    eg.:
    java -Dhttp.proxyHost=235.67.138.84 -Dhttp.proxyPort=8080 TestServlet https://site.com/portal/Downloads/file.csv file.csv
    This url requires authentication, the userid and pwd are hardcoded in the code.
    Now, my problem is I cannot understand why this error would come. Is it because of the firewall or because of the proxy ?
    Why is it that I can download over http successfully from my office desktop? If the problem is with the firewall or proxy, then even http protocol urls should give the same problem.
    Please help.
    Vinay
    Message was edited by:
    vinay_dsouza
    Message was edited by:
    vinay_dsouza

    If you are using HTTPS you should be setting
    https.proxyHost
    https.proxyPortnot the http.* ones.

  • Download file via terminal

    I want to download a http file via terminal, whats the command?

    curl -O http://path-to-file
    or
    curl -O ftp://path-to-file
    etc.
    FYI, That's the letter Oh, not the number Zero

  • How to send a pdf file via http call

    Hi Experts,
    Please try to think on how you would send a file like a pdf file via the http call. You might need to convert the pdf in a character string which can be sent via http. The character string then might need to  get converted back into a pdf and saved in a file. Read through the Archive Link API guide to see how they send the body of a file.
    Please it is urgent......
    Thanks
    Basu

    so you want to push the PDF file over http to external system.
    where is pdf file stored.
    for examle if its in the clients desktop, you can use gui_upload to upload to internal tabble (type BIN) then use FM SCMS_BINARY_TO_XSTRING to conver the binary table to type string.
    then use cl_http_client class to push the file to the destination.

  • Download file via jsp

    dear all,
    to download a *.txt-file via jsp i use following code:
    java.io.File file = new java.io.File("C:\\FileName.txt");
    response.setHeader("Content-Disposition", "attachment;filename=\""+file.getName()+"\";");
    response.setContentType("APPLICATION/OCTET-STREAM");
    response.setContentLength((int) file.length());
    if(file.isFile()){
         java.io.FileInputStream fis = new java.io.FileInputStream(file);
         java.io.BufferedOutputStream bos = new java.io.BufferedOutputStream(response.getOutputStream());
         byte b[] = new byte[(int)file.length()];
         int read = 0;
         while((read = fis.read(b)) != -1){
              bos.write(b,0,read);
         bos.flush();
         fis.close();
         bos.close();
    } the problem is:
    the file will be displayed in the browser IE6 (inline), but i want to open a save-dialog!
    any ideas?!
    thanks for help. andy

    up to now i tried another browser (mozilla firebird) and several settings about the contenttype like:
    - application/x-download
    - application/x-msdownload
    - application/x-octet-stream
    - application/octet-stream
    - application/download
    ... and the file-name like:
    *.zip
    *.txt
    *.exe
    but the browser shows the content of the file always inline (even *.zip and *.exe files!!).
    anyway, thank you for help.
    andy

  • How the external system will talk to ECXpert 3.5 for transfering files via HTTP SSl?

    We are using ECxpert3.5 on Solaris box. One of our Trading Partner want to communicate through HTTP-SSL and we are doing XML/EDI mapping. Could you guide us what steps we need to take care to implement this.
    How the external system will talk to ECXpert for transferring files. (We need the syntax for the URL). How ECXpert will receive XML file through HTTP-SSL protocol from External System and file submittion.
    Please send is there any other document which explain about. Thanks in advance for your help. [email protected] or [email protected]

    Hi Steve,
    You can bring the GRC framework to a state equivalent to a raw install by following options:
    Option 1.) You should have a base-line backup before GRC installation. If so then apply that base-lin backup and deploy GRC components. If there is no base-lin backup, then
    Option 2.) Uninstall and re-install J2EE and then follow up with rest of the installation process. If you don't want to go through re-install process, then
    **Correction to Option 3**
    Option3.) SAP is in process of creating a SAP Note for Delete script, Instead of delivering Delete Script script via OSS message.  Will update you as soon as the Note gets released.
    Please refere to Note # 1416728 to Manage your deletion in RAR 5.3 SP10.
    Hope this helps.
    Best Regards,
    Sirish Gullapalli.

  • Download file via Browser window

    Hello,
    I have a question about downloading a file. How can i Download the file via the browser ? I did get it working to download with flex but also get
    "Error: Error #2176" this error with flash 10 which is not good :-/
    Is there a way to download a file via the browser . i.e : with firefox download window , etc.
    I have seen weborb doing it while i was downloading the weborb application, and i wanted to know if anyone has any idea or sample on how to get this done.
    Help is appreciated .
    Thanks.

    You could write a Javascript function in the HTML page that accepts a URL string as its parameter. This function get then open a new window with this url. You could invoke this function it via the ExternalInterface API in Flex. I believe that would invoke the Firefox Download Manager.

  • Downloading files over HTTPS

    how can i upload files over https
    can you give me some links to web sites that explain this
    thank u

    Hi..
    Have you got the information yet ?
    I need more information for uploading file in https.
    Thanks in advance

  • Cannot download files via Bluetooth since upgrading to Yosemite

    I cannot download files, E.G. photos and spreadsheets, from my Windows phone to my MacBook Pro Retina since upgrading to OS 10.10 Yosemite.
    I can send files from the MacBook Pro to the Windows phone.
    Tried resetting PRAM, no luck
    Tried unpairing and repairing all devices, no luck
    Tried dumping "bluetooth.plist", no luck
    Tried cold start & Resart after each, no luck
    Devices are paired. Bluetooth Sharing is on.
    Help!

    PROBLEM SOLVED:
    Go to "System Preferences" - "Sharing" - "Bluetooth Sharing" - "Folder for selected items:", and select a folder."
    No folder is selected.
    Prior to the upgrade the Folder had been set to "Downloads", so I reset it to "Downloads" and it now works.
    Praise the Lord!!

  • Downloading files from http

    I want to download the Boot Camp program from terminal.... i was wondering what commands are involved in doing that... i already have the Boot Camp Address... just need the commands... i remember doing a tutorial on CVS that had me download and extract something.. but i don't remember how i did that.... so... any help would be greatly appreciated.

    There are a number of ways of downloading via the command line. One of the commnest is via curl:
    <pre class=command>curl -o /path/to/save/file http://server.net/path/to/remote</pre>
    Where /path/to/save/file is where you want to save the file when it's downloaded.

  • 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.

  • Header variable: Content Disposition for downloading file over HTTP?

    Hi All,
    I have a general content server question...Is there anyway to pass a parameter or set a setting on the content server to send the file with the header variable content-disposition set so that when a user selects a file within a browser, it doesn't open in place but asks the user whether they want to open or save the document?
    Note - I'm actually using this with ArchiveLink and displaying the link in the Portal but this forum seems the closest I can get to asking this question.
    Regards,
    Matt

    Thanks Athol.
    Although there's quite a bit of configuration options there for displaying files, there doesn't appear to be anything that let's you manipulate the HTTP header variables to set content-disposition.
    Any other ideas?
    Cheers,
    Matt
    ps. If you want to artificially see the behaviour I'm after, within IIS, you can predefine this header variable for the contentserver.dll but this makes every HTTP request act like a file that wants to be downloaded, and it calls every file contentserver.<suffix>. From a user perspective, there's nothing worse than a document opening in place in your window (losing the underlying application), or within another IE window, hence why I'd like it to act like a file download.

  • Download File Via JavaScript Calls From Website

    Hello,
    I am currently trying to create a program in c# that will download the file "PracticeProfiles.xls" from this website:
    http://fingertips.phe.org.uk/profile/general-practice/data
    I need to somehow on navigation to this site pass the javascript calls "showExport();exportData();", which will start the download.
    Any help would be greatly appreciated.
    Many Thanks

    The link has a method which apparently works, however I had to modify a few things to make it compile:
    public void DownloadIEFile(Browser browser)
    HwndSource source;
    source = HwndSource.FromHwnd(WatiN.Core.Native.Windows.NativeMethods.GetWindow(browser.hWnd, 5));
    Window windowMain = source.RootVisual as Window;
    System.Windows.Automation.TreeWalker trw = new System.Windows.Automation.TreeWalker(System.Windows.Automation.Condition.TrueCondition);
    System.Windows.Automation.AutomationElement mainWindow = trw.GetParent(System.Windows.Automation.AutomationElement.FromHandle(browser.hWnd));
    source = HwndSource.FromHwnd(WatiN.Core.Native.Windows.NativeMethods.GetWindow(new WindowInteropHelper(windowMain).Handle, 5));
    Window windowDialog = source.RootVisual as Window;
    // if doesn't work try to increase sleep interval or write your own waitUntill method
    Thread.Sleep(1000);
    windowDialog.Activate();
    System.Windows.Automation.AutomationElementCollection amc = System.Windows.Automation.AutomationElement.FromHandle(new WindowInteropHelper(windowDialog).Handle).FindAll(System.Windows.Automation.TreeScope.Children, System.Windows.Automation.Condition.TrueCondition);
    foreach (System.Windows.Automation.AutomationElement element in amc)
    // You can use "Save ", "Open", ''Cancel', or "Close" to find necessary button Or write your own enum
    if (element.Current.Name.Equals("Save"))
    // if doesn't work try to increase sleep interval or write your own waitUntil method
    // WaitUntilButtonExsist(element,100);
    Thread.Sleep(1000);
    System.Windows.Automation.AutomationPattern[] pats = element.GetSupportedPatterns();
    // replace this foreach if you need 'Save as' with code bellow
    foreach (System.Windows.Automation.AutomationPattern pat in pats)
    // '10000' button click event id
    if (pat.Id == 10000)
    System.Windows.Automation.InvokePattern click = (System.Windows.Automation.InvokePattern)element.GetCurrentPattern(pat);
    click.Invoke();
    However I am getting null when I try to get the hwnd source, can't see why?
    Any Suggestions?
    Many Thanks

Maybe you are looking for