Convert  file url to http url

Hi, is there a way to convert file url (file:/opt/test/test.pdf) to http url? I have tried so hard and still stuck on it. Please give help. Thanks in advance!

Hi,
if you are using strings
String s;
s.replaceFirst("file:", "http:");
http://galileo.spaceports.com/~ibidris/

Similar Messages

  • Accessing BSP File Download using HTTPS URL

    Hi,
    I'm struggling with a problem of downloading a file from a https url. I wrote a BSP App for downloading a file from a unix server.. It works fine when I use a http URL with port 8080 and does not work when I use https.!!
    Example:
    https://comms.gmsanet.co.za/supplier [ download does not work ]
    http://comms.gmsanet.co.za:8080/supplier [ download works ]
    When I try to download using https.. it does not pull the file name and path
    see code  below and suggest me if anything to be chnaged.
    In the Form Initialization method:
    event handler fr data retrieval
    DATA: i_file        type string,
          s_fields      TYPE tihttpnvp,
          s_fields_line TYPE ihttpnvp,
          multipart_form type ref to if_http_entity,
          file_upload    type xstring,
          lv_backend     type string,
          success        type string,
          entity         type ref to if_http_entity,
          file           type xstring,
          content_type   type string,
          content_filename type string,
          content_length type string,
          content_disposition type string,
          num_multiparts type i,
          i              type i value 1,
          doEcho         type string value 'X',
          value          type string,
          filename       type ZFILETAB-fileinfo,
          ext1           type string,
          ext2           type string,
          dsn            type string,
          bptype         like sy-uname,
          itab           TYPE ZFILETAB,
          itab_line      TYPE ZFILETABLINE,
          file_ext       type ZFILETABLINE,
          fileinfo       type c,
          zcount         type i.
        filename = '/NewMessge.doc'.
        content_filename = filename.
    Check the extension and assign the content type
        split filename at '.' into ext1 ext2.
        case ext2.
          when 'zip'.
            content_type = 'application/x-zip-compressed'.
          when 'doc'.
            content_type = 'application/msword'.
          when 'txt'.
            content_type = 'text/plain'.
          when 'ppt' or 'pps'.
            content_type = 'application/vnd.ms-powerpoint'.
          when 'xls' or 'exe'.
            content_type = 'application/octet-stream'.
          when 'gif'.
            content_type = 'image/gif'.
          when 'jpg' or 'jpeg'.
            content_type = 'image/pjpeg'.
          when 'htm' or 'html'.
            content_type = 'text/html'.
        endcase.
        dsn = filename.
        OPEN DATASET dsn FOR INPUT IN BINARY MODE.
        IF sy-subrc NE 0.
          zmessage = 'Error opening file'.
          navigation->set_parameter( name = 'zmessage' value = zmessage ).
          navigation->goto_page( 'downloaderror.htm' ).
          exit.
        ENDIF.
        DO.
          READ DATASET dsn INTO <b>file</b>.
          EXIT.
        ENDDO.
        CLOSE DATASET dsn.
    set response data to be the file content
      runtime->server->response->set_data( <b>file</b> ).
      runtime->server->response->set_header_field(
                                    name  = 'Content-Type'
                                    value = content_type ).
      concatenate 'attachment; filename=' filename into content_disposition.
      runtime->server->response->set_header_field(
                                    name = 'Content-Disposition'
                                    value = content_disposition ).
    set the file size in the response
      content_length = xstrlen( file ).
      runtime->server->response->set_header_field(
                                name  = 'Content-Length'
                                value = content_length ).
      runtime->server->response->delete_header_field(
                                name = 'Cache-Control' ).
      runtime->server->response->delete_header_field(
                                name = 'Expires' ).
      navigation->response_complete( ).
    Thanks
    Ajay

    Hi Brian,
    I have the same problem as Ajay Yeluguri. In http mode I can generate a download of an Excel document but when we use the portal in https it doesn't work.
    When I try to download using https it does not pull the file name and path and when I choose download I have a error message : "Internet Explorer cannot download from ..."
    I've test the point 3.2 "... including file up/download" of the BSP application IT00 and it works fine in http and https mode. My problem is not the upload but the download. And in this application the uploaded document is opened in the Internet Explorer window but I want to generate a Save as... window to download the file.
    Have you an idea what i can do to solve my problem.
    Thanks
    Yann

  • Convert file url to http url in jsp

    Hi, is there a way to convert file url (file:/opt/test/test.pdf) to http url? I have tried so hard and still stuck on it. Please give help. Thanks in advance!

    I found another solution to dispaly my pdf file on browser without storing the pdf file to application real path. My application generated PDF file and stored it to some place like /opt/report/**.pdf. Then define ContentType("application/vnd.fdf"), use java InputStream and outputStream to operater file.
    I deeply appreciate the help from everyone in this forum. I hope my solution could help someone who have the problem like me.
    Here is the code:
    response.setContentType("application/vnd.fdf");
    File f = new File(filename);
    DataInputStream dis = new DataInputStream(new FileInputStrea(filename));
    OutputStream osout = response.getOutputStream() ;
    int data=0;
    long count=f.length();
    try
    while(count !=0)
    data = dis.readByte();
    osout.write(data);
    count--;
    }catch(Exception e)
    System.out.println(e.toString());
    dis.close();
    osout.flush();
    osout.close();

  • Name of .crl and .crt file missing from HTTP URL in certificate details

    Hello Everyone,
    I am in the process of building a 2-tier Windows Server 2012 R2 PKI. The CA name of both the offline standalone root CA and enterprise subordinate CA have spaces in it (we'll call the CA name, 'Test Lab Root CA' for point of reference).
    When I submitted the certificate request for the subordinate CA to the root CA and viewed the attributes/extensions of the pending request, I noticed the HTTP URL is missing the name of the .crt and .crl file.
    The AIA extension reads URL=http://test.domainname.com/pki/.crt
    in the issued certificate details.
    The CDP extension reads URL=http://test.domainname.com/pki/.crl
    in the issued certificate details.
    The AIA and CDP location HTTP URLs are configured as http://test.domainname.com/pki/<CertificateName>.crt and  http://test.domainname.com/pki/<CRLNameSuffix><DeltaCRLAllowed>.crl, respectively on the
    root CA. 
    The LDAP URL shows the .crt and .crl file name (with %20 replacing the spaces) perfectly fine. The LDAP URL is configured using variables as well. It's just the HTTP URL that is missing the name of the file altogether. 
    I have read about the issue where spaces are not being replaced with %20 in the URL on Windows Server 2012 and a hotfix is available for that issue. But this issue seems to be slightly different and I'm running Windows Server 2012 R2. I tried installing
    the hotfix to see if it would help, but the hotfix can't install because it doesn't apply to Server 2012 R2.
    I've been trying to find a technet discussion or blog article for a week to see if anyone has seen this and what the fix is, but I'm coming up empty. I only find talks about %20 not replacing the space in the name.
    Does anyone have any insight to my particular issue? I don't want to issue the subordinate CA certificate until I know the HTTP URL populates the CRL and CRT file name correctly. I can get around this by typing out the name of the file (with spaces and not
    %20... e.g. http://test.domainname.com/pki/Test Lab Root CA.crl) in the URL via the registry and the URL displays the name of the file (with %20 in the name) when I do another certificate request and check the attributes/extensions in the
    pending request. However, I prefer to avoid manually typing out the name of the file in the registry. I'd like to use the variables if at all possible. 
    Any help/guidance would be greatly appreciated.
    Thank you.

    On Fri, 27 Mar 2015 03:42:28 +0000, Brian Komar [MVP] wrote:
    You have totally messed up the URLs.
    If you run certutil -getreg ca\CRLPublicationURLs and certutil -getreg ca\CACertPublicationURLs, you will see that you do not have correct use of variables when compared to the settings that follow:
    The URLs should be set to the following for an offline CA:
    certutil -setreg CA\CRLPublicationURLs "1:%WINDIR%\system32\CertSrv\CertEnroll\%%3%%8%%9.crl\n2:http://test.domainname.com/pki/%%3%%8%%9.crl"
    *certutil -setreg CA\CACertPublicationURLs  "1:%WINDIR%\system32\CertSrv\CertEnroll\%%1_%%3%%4.crt\n2:http://*test.domainname.com*/pki/%%1_%%3%%4.crt"*
    For an issuing CA, they should be set to:
    The URLs should be set to the following for an offline CA:*certutil -setreg CA\CRLPublicationURLs "65:%WINDIR%\system32\CertSrv\CertEnroll\%%3%%8%%9.crl\n6:http://test.domainname.com/pki/%%3%%8%%9.crl"*
    *certutil -setreg CA\CACertPublicationURLs  "1:%WINDIR%\system32\CertSrv\CertEnroll\%%1_%%3%%4.crt\n2:http://**test.domainname.com**/pki/%%1_%%3%%4.crt"*
    Just a clarification here, if you're running the above certutil commands at
    the command prompt you only need single % characters in the command line.
    The double % characters are only required if the commands are being run in
    a batch file.
    Paul Adare - FIM CM MVP

  • Print PDF from http URL

    I have a project wherein a piece of it will require me to retrieve a PDF file from a http URL (i.e.
    http://www.somewebsite.com/test.pdf) and print the PDF.  I've been looking for examples of how to do this but I'm not finding any. Is the only way to do this download the PDF to disk and then send to a
    printer? Speaking of printing, I need to send the PDF to an IP address which I've not done before either. If someone could point me to a good example of that, I'd appreciate it.
    Thank you.

    Since I had access to ABCPDF8, I ended up using it to print the PDF.  ABCPDF comes with example projects that helped me figure out what I needed to get the PDF to print.  For anyone who also has access to
    ABCPDF and needs to use it to print a PDF, I've pasted my code below.  The code is a cut-down version of the ABCPDF example as I did not need a lot of the functionality the example had. 
    Thanks again to all who responded to my post.
    ABCPDF8 code:
                private static WebSupergoo.ABCpdf8.Doc mDoc = null;
                private static System.Drawing.Printing.PrintDocument mPrint = null;
                private static int mPage = 0;
                private static int mPageSaved = 0;
                private static int mCopiesNumber;
                private static string pdfFile;
                private static string pdfPrinterName;
                private static string pdfPrinterTray;
                public enum Method
                    AdobeReader,
                    ABCPDF8
                /// <summary>
                /// </summary>
                /// <param name="pdfFilePath"></param>
                /// <param name="printerName"></param>
                /// <param name="printMethod"></param>
                public static void DoPrint(string pdfFilePath, string printerName, string printerTray, Method printMethod)
                    if (System.IO.Path.GetExtension(pdfFilePath).Trim().ToUpper() != ".PDF")
                        throw new System.ApplicationException(String.Format("File '{0}' is not a PDF!", pdfFilePath));
                    pdfFile = pdfFilePath;
                    pdfPrinterName = printerName;
                    pdfPrinterTray = printerTray;
                    switch (printMethod)
                        case Method.AdobeReader:
                            PrintViaAdobeReader();
                            break;
                        case Method.ABCPDF8:
                            PrintViaABCPDF8();
                            break;
                        default:
                            break;
               private static void PrintViaABCPDF8()
                    mDoc = new WebSupergoo.ABCpdf8.Doc();
                    //read in the PDF
                    mDoc.Read(pdfFile);
                    //crete new print document
                    mPrint = new System.Drawing.Printing.PrintDocument();
                    mPrint.DocumentName = System.IO.Path.GetFileName(pdfFile);
                    mPrint.PrinterSettings.PrinterName = pdfPrinterName;
                    mPrint.PrinterSettings.FromPage = 1;
                    mPrint.PrinterSettings.ToPage = mDoc.PageCount;
                    mPrint.PrinterSettings.MinimumPage = 1;
                    mPrint.PrinterSettings.MaximumPage = mDoc.PageCount;
                    mPrint.QueryPageSettings += (sndr, args) =>
                        if (!String.IsNullOrWhiteSpace(pdfPrinterTray))
                            for (int i = 0; i < mPrint.PrinterSettings.PaperSources.Count; i++)
                                if (mPrint.PrinterSettings.PaperSources[i].SourceName.ToLower().Trim() == pdfPrinterTray.ToLower())
                                    args.PageSettings.PaperSource = mPrint.PrinterSettings.PaperSources[i];
                                    break;
                    mPrint.BeginPrint += new System.Drawing.Printing.PrintEventHandler(DoBeginPrint);
                    mPrint.EndPrint += new System.Drawing.Printing.PrintEventHandler(DoEndPrint);
                    mPrint.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(DoPrintPage);
                    mPrint.Print();
                    mDoc.Clear();
                    mDoc.Dispose();
                /// <summary>
                /// Start printing via ABCPDF8
                /// </summary>
                /// <param name="sender"></param>
                /// <param name="e"></param>
                private static void DoBeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
                    mPage = mPrint.PrinterSettings.FromPage;
                    mPageSaved = mDoc.PageNumber;
                    mCopiesNumber = 1;
                /// <summary>
                /// Print page using ABCPDF8
                /// </summary>
                /// <param name="sender"></param>
                /// <param name="e"></param>
                private static void DoPrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
                    mDoc.PageNumber = mPage;
                    if (mCopiesNumber++ >= mPrint.PrinterSettings.Copies)
                        mPage++;
                        mCopiesNumber = 1;
                    e.HasMorePages = mPage <= mPrint.PrinterSettings.ToPage;
                    using (System.Drawing.Graphics g = e.Graphics)
                        if (mDoc.PageCount == 0) return;
                        if (mDoc.Page == 0) return;
                        WebSupergoo.ABCpdf8.XRect cropBox = mDoc.CropBox;
                        double srcWidth = (cropBox.Width / 72) * 100;
                        double srcHeight = (cropBox.Height / 72) * 100;
                        double pageWidth = e.PageBounds.Width;
                        double pageHeight = e.PageBounds.Height;
                        double marginX = e.PageSettings.HardMarginX;
                        double marginY = e.PageSettings.HardMarginY;
                        double dstWidth = pageWidth - (marginX * 2);
                        double dstHeight = pageHeight - (marginY * 2);
                        const bool autoRotate = true;
                        int rotate = 0;
                        if (autoRotate && srcWidth != srcHeight && dstWidth != dstHeight
                            && (srcWidth > srcHeight) != (dstWidth > dstHeight))
                            double temp = pageWidth;
                            pageWidth = pageHeight;
                            pageHeight = temp;
                            temp = marginX;
                            marginX = marginY;
                            marginY = temp;
                            temp = dstWidth;
                            dstWidth = dstHeight;
                            dstHeight = temp;
                            rotate = GetPageRotation(mDoc) % 360;
                            if (rotate <= -180)
                                rotate += 360;
                            else if (rotate > 180)
                                rotate -= 360;
                            rotate = rotate > 0 ? 90 : -90; // default to -90
                            // Use -90 because we want the staple to be at a top corner
                            // of the page.  Assuming a rotation of "rotate" (0 or 180 degrees)
                            // produces upright contents, a rotation of -90 or 90 degrees
                            // (respectively) produces outputs whose top is at the
                            // left edge of the portrait page.  The staple at the top-left
                            // corner of the portrait page will be at the top-right corner of the
                            // contents.
                        else
                            rotate = GetPageRotation(mDoc) % 360;
                            if (rotate != 180 && rotate != -180)
                                rotate = 0;
                        // if source bigger than destination then scale
                        if ((srcWidth > dstWidth) || (srcHeight > dstHeight))
                            double sx = dstWidth / srcWidth;
                            double sy = dstHeight / srcHeight;
                            double s = Math.Min(sx, sy);
                            srcWidth *= s;
                            srcHeight *= s;
                        // now center
                        double x = (pageWidth - srcWidth) / 2;
                        double y = (pageHeight - srcHeight) / 2;
                        // save state
                        double saveDotsPerInch = mDoc.Rendering.DotsPerInch;
                        mDoc.Rendering.AutoRotate = false;
                        System.Drawing.RectangleF theRect = new System.Drawing.RectangleF((float)x, (float)y, (float)srcWidth, (float)srcHeight);
                        int theRez = e.PageSettings.PrinterResolution.X;
                        if (e.PageSettings.Color) // color is generally CMYK so to translate from dpi to ppi we divide by four
                            theRez /= 4;
                        if (theRez <= 0) // Invalid printer resolution - use the default value
                            theRez = 72;
                        // draw content
                        mDoc.Rect.SetRect(cropBox);
                        System.Drawing.Drawing2D.Matrix oldTransform = null;
                        if (rotate != 0)
                            oldTransform = g.Transform;
                            switch (rotate)
                                case 90:
                                    using (System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix(0,
    1, -1, 0,
                                        (float)(2 * y + srcHeight), 0))
                                        g.MultiplyTransform(matrix);
                                    break;
                                case -90:
                                    using (System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix(0,
    -1, 1, 0,
                                        0, (float)(2 * x + srcWidth)))
                                        g.MultiplyTransform(matrix);
                                    break;
                                case 180:
                                case -180:
                                    using (System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix(-1,
    0, 0, -1,
                                        (float)(2 * x + srcWidth), (float)(2 * y +
    srcHeight)))
                                        g.MultiplyTransform(matrix);
                                    break;
                        g.SetClip(theRect);
                        if (!mDoc.Encryption.CanPrintHi)
                            mDoc.Rendering.DotsPerInch = 72;
                            using (System.Drawing.Bitmap bm = mDoc.Rendering.GetBitmap())
                                g.DrawImage(bm, theRect);
                        else
                            mDoc.Rendering.DotsPerInch = theRez;
                            mDoc.Rendering.ColorSpace = WebSupergoo.ABCpdf8.XRendering.ColorSpaceType.Rgb;
                            mDoc.Rendering.BitsPerChannel = 8;
                            byte[] theData = mDoc.Rendering.GetData(".emf");
                            System.IO.MemoryStream theStream = new System.IO.MemoryStream(theData);
                            using (System.Drawing.Imaging.Metafile theEMF = new System.Drawing.Imaging.Metafile(theStream))
                                g.DrawImage(theEMF, theRect);
                        if (oldTransform != null)
                            g.Transform = oldTransform;
                            oldTransform.Dispose();
                        // restore state
                        mDoc.Rendering.DotsPerInch = saveDotsPerInch;
                        mDoc.Rendering.AutoRotate = true;
                /// <summary>
                /// End printing ABCPDF8
                /// </summary>
                /// <param name="sender"></param>
                /// <param name="e"></param>
                private static void DoEndPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
                    mDoc.PageNumber = mPageSaved;
                /// <summary>
                /// Current page number
                /// </summary>
                public static int PageNumber
                    get
                        if (mDoc == null)
                            return 0;
                        else
                            return mDoc.PageNumber;
                    set
                        if (mDoc != null && value <= mDoc.PageCount && value != mDoc.PageNumber)
                            mDoc.PageNumber = value;
                /// <summary>
                /// </summary>
                /// <param name="theDoc"></param>
                /// <returns></returns>
                private static int GetPageRotation(WebSupergoo.ABCpdf8.Doc theDoc)
                    return (theDoc != null) ? theDoc.GetInfoInt(theDoc.Page, "Rotate") : 0;

  • How to download video files using http urls through OSB

    Hi all,
    I am working on a requirement where I need to download the video using http url of that video through OSB. Is it possible to convert the video files hosted in a server into base64 code using OSB ? Kindly help me on this.
    Thanks
    Edited by: 887737 on Jul 25, 2012 3:26 AM

    Hi,
    I believe you can get the video file using file transport and then convert it into base64 using a java call out...
    This may help...
    https://blogs.oracle.com/ateamsoab2b/entry/an_example_of_how_to
    Cheers,
    Vlad

  • How can i convert a url from https to http?

    Hi,
    SSL is enabled in WLS 9.2 and its wrkng fine. And iam able to access login page in secure(https)mode. After this page i need to convert the url from https mode to http. For enabling https i added some code in web.xml. For switchinng https to http i dn't knw anythng.
    Pls gve me suggetion.
    Thanks in advance.

    Export it from iPhoto. This process will make a QuickTime movie of it. That will play on an PC that has QuickTime installed - and that's a free download for PC, and comes with iTunes for PC
    Regards
    TD

  • How to read XML file kept on NON-SAP server using the Http URL ?

    Dear Experts,
    I am working on CRM2007 web UI. I need to read a XML file placed on a shared server location by a third party program. Then process that XML file into CRM and create a quotation using the data extracted from the file.
    All i have with me is the http URL that points to the location of the file.
    I am supposed to read the file , create quotation and at later point of time i would be asked to update the quotation and then generated new XML representing updated quotation and replace the XML file on shared server location with this new updated XML file.
    I know how to extract data from XML file into ABAP but i have no clue as to how to access the file on some other server using the http url i have and how to read it ?
    I searched on the forum and i found the codes for reading XML file that is located either on client machine OR on the Application server wheareas my file is on some other than sap application server.
    Please help me as its an urgent issue .
    Points will be rewarded for sure.
    Please help.
    Thanks in advance,
    Suchita.
    p.s. : the http url to the file location is like -->
    http://SomeServerDomain/SomeDirectory/file.xml

    hi,
    interesting task.
    to request the file by a http call you need to create an if_http_client object.
    More info is [here|http://help.sap.com/saphelp_nwmobile71/helpdata/en/e5/4d350bc11411d4ad310000e83539c3/frameset.htm]
    to parse the file you either have to work with the ixml packages ([info|http://help.sap.com/saphelp_nwmobile71/helpdata/en/47/b5413acdb62f70e10000000a114084/content.htm]) or you use an XSLT transformation ([info|http://help.sap.com/saphelp_nwmobile71/helpdata/en/a8/824c3c66177414e10000000a114084/content.htm]).
    uploading the final file isn't so easy. if you only have http, you should write a server script to allow uploading of the new file and copying it into the place of the old file. but you definitely need the script.
    now it's your take. depending on how experienced you are in ABAP and networking this might turn out to be easy or pretty complicated.
    have fun,
    anton

  • Send xml file from sap to third party url through https

    Hi,
    I have a requirement to send the xml file from ecc to a 3rd party url through HTTPS. How can we achieve this using ABAP.
    Client doesn't have XI enviroment. The client has provided the 3rd party url where the file needs to be uploaded.
    Please help ! <removed by moderator>
    Thanks in advance.
    Regards,
    Chitra.K
    Edited by: Thomas Zloch on Sep 12, 2011 12:58 PM

    Hi Chitra,
    I had similar requirement and here is what I did: -
    REPORT  Z_HTTP_POST_TEST_AMEY.
    DATA: L_URL               TYPE                   STRING          ,
          L_PARAMS_STRING     TYPE                   STRING          ,
          L_HTTP_CLIENT       TYPE REF TO            IF_HTTP_CLIENT  ,
          L_RESULT            TYPE                   STRING          ,
          L_STATUS_TEXT       TYPE                   STRING          ,
          L_HTTP_STATUS_CODE  TYPE                   I               ,
          L_HTTP_LENGTH       TYPE                   I               ,
          L_PARAMS_XSTRING    TYPE                   XSTRING         ,
          L_XSTRING           TYPE                   XSTRING         ,
          L_IS_XML_TABLE      TYPE STANDARD TABLE OF SMUM_XMLTB      ,
          L_IS_RETURN         TYPE STANDARD TABLE OF BAPIRET2        ,
          L_OUT_TAB           TYPE STANDARD TABLE OF TBL1024
    MOVE 'https://<hostname>/xxx/yyy/zzz' TO L_URL.
    MOVE '<XML as string>' TO L_PARAMS_STRING.
    *STEP-1 : CREATE HTTP CLIENT
    CALL METHOD CL_HTTP_CLIENT=>CREATE_BY_URL
        EXPORTING
          URL                = L_URL
        IMPORTING
          CLIENT             = L_HTTP_CLIENT
        EXCEPTIONS
          ARGUMENT_NOT_FOUND = 1
          PLUGIN_NOT_ACTIVE  = 2
          INTERNAL_ERROR     = 3
          OTHERS             = 4 .
    "STEP-2 :  AUTHENTICATE HTTP CLIENT
    CALL METHOD L_HTTP_CLIENT->AUTHENTICATE
      EXPORTING
        USERNAME             = 'testUser'
        PASSWORD             = 'testPassword'.
    "STEP-3 :  SET HTTP HEADERS
    CALL METHOD L_HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
          EXPORTING NAME  = 'Accept'
                    VALUE = 'text/xml'.
    CALL METHOD L_HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
        EXPORTING NAME  = '~request_method'
                   VALUE = 'POST' .
    CALL METHOD L_HTTP_CLIENT->REQUEST->SET_CONTENT_TYPE
        EXPORTING CONTENT_TYPE  = 'text/xml' .
    "SETTING REQUEST DATA FOR 'POST' METHOD
    IF L_PARAMS_STRING IS NOT INITIAL.
       CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
         EXPORTING
             TEXT   = L_PARAMS_STRING
         IMPORTING
               BUFFER = L_PARAMS_XSTRING
         EXCEPTIONS
            FAILED = 1
            OTHERS = 2.
    CALL METHOD L_HTTP_CLIENT->REQUEST->SET_DATA
        EXPORTING DATA  = L_PARAMS_XSTRING  .
    ENDIF.
    "STEP-4 :  SEND HTTP REQUEST
      CALL METHOD L_HTTP_CLIENT->SEND
        EXCEPTIONS
          HTTP_COMMUNICATION_FAILURE = 1
          HTTP_INVALID_STATE         = 2.
    "STEP-5 :  GET HTTP RESPONSE
        CALL METHOD L_HTTP_CLIENT->RECEIVE
          EXCEPTIONS
            HTTP_COMMUNICATION_FAILURE = 1
            HTTP_INVALID_STATE         = 2
            HTTP_PROCESSING_FAILED     = 3.
    "STEP-6 : Read HTTP RETURN CODE
    CALL METHOD L_HTTP_CLIENT->RESPONSE->GET_STATUS
        IMPORTING
          CODE = L_HTTP_STATUS_CODE
          REASON = L_STATUS_TEXT  .
    WRITE: / 'HTTP_STATUS_CODE = ',
              L_HTTP_STATUS_CODE,
             / 'STATUS_TEXT = ',
             L_STATUS_TEXT .
    "STEP-7 :  READ RESPONSE DATA
    CALL METHOD L_HTTP_CLIENT->RESPONSE->GET_CDATA
            RECEIVING DATA = L_RESULT .
    "STEP-8 : CLOSE CONNECTION
    CALL METHOD L_HTTP_CLIENT->CLOSE
      EXCEPTIONS
        HTTP_INVALID_STATE = 1
        OTHERS             = 2   .
    "STEP-9 : PRINT OUTPUT TO FILE
    CLEAR : L_XSTRING, L_OUT_TAB[].
    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
        EXPORTING
          TEXT   = L_RESULT
        IMPORTING
          BUFFER = L_XSTRING
        EXCEPTIONS
          FAILED = 1
          OTHERS = 2.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        BUFFER                = L_XSTRING
      TABLES
        BINARY_TAB            = L_OUT_TAB .
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
       FILENAME                        = 'C:AMEYHTTP_POST_OUTPUT.xml'
      TABLES
        DATA_TAB                        = L_OUT_TAB .
    Also, following is the detailed link for use of HTTP_CLIENT class: -
    http://help.sap.com/saphelp_nw70ehp1/helpdata/EN/1f/93163f9959a808e10000000a114084/content.htm
    Also, in below link, you can ignore XI specific part and observe how its sending XML to external URL:-
    (I know it describes call to SAP XI server's URL, but it can be used to call any URL)
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/ae388f45-0901-0010-0f99-a76d785e3ccc
    In addition to all above, following configs to be present at ABAP application server: -
    1. The hostname used to URL should be present in SAP ABAP application server's 'hosts' file.
    2. Security certificate (if available) for URL to be called must be installed in SAP ABAP application server.
    Let me know if you achieve any progress with it...

  • Http URL starts with file://

    Hi.
    I need to access the file content which is placed in the local system.
    The format of the url is:
    file://<Server Name>/<FolderName>/FileName
    example: file://pwdf1234/sample/abc,jpg
    Is there any specific criteria if the url starts with file:// or
    Should I configure in Visual administrator if the url starts with file://
    Could you please let me know.
    Regards
    Bala

    Hi Raj.
    Thanks for your reply.
    No, Im not using Link To URL
    It (the url which starts with file://) is a hyperlink.
    If you click from webdynpro UI it should navigate to the actual content.
    If it is a http url(for ex: http://www.google.com), it works but if it is a url which starts with file://
    does'nt seems to work.
    Regards
    Bala
    Edited by: Balachandar P on Dec 26, 2007 5:58 AM

  • Can any body help me in reading from HTTPS URL

    I need to read an HTTPS URL and store the response within a table .
    How will I manage to do it from within a servlet using URLConnection and openStream as it does'nt work .
    How will JSSE help in this regard .
    Since I also need to give the userid and password to get into the file and read the file
    https://anyhost.com/readthisfile.html
    somnath
    Web Developer

    Hi,
    The Java Secure Socket Extension (JSSE) library from Sun Microsystems lets you access a secure Web server from behind a firewall via
    proxy tunneling. To do this, the JSSE application needs to set the https.ProxyHost and https.ProxyPort system properties. The
    tunneling code in JSSE checks for "HTTP 1.0" in the proxy's response. If your proxy, like many, returns "HTTP 1.1", you will get an
    IOException. In this case, you need to implement your own HTTPS tunneling protocol.
    In this article, I will show you how to create a secure socket that tunnels through the firewall, and pass it to the HTTPS stream handler to
    open HTTPS URLs using the URLConnection class.
    Open the http tunnel socket to the proxy
    The first step to creating your secure socket is to open the tunneling socket to the proxy port. The code needed to do this proxy
    handshaking can be found in the sample code SSLClientSocketWithTunneling.java that comes with the JSSE distribution. First, a normal socket is created that connects to
    the proxy port on the proxy host (line 65). After the socket is created, it is passed to the doTunnelHandshake() method where the proxy's tunneling protocol is called:
    54 SSLSocketFactory factory =
    55 (SSLSocketFactory)SSLSocketFactory.getDefault();
    56
    57 /*
    58 * Set up a socket to do tunneling through the proxy.
    59 * Start it off as a regular socket, then layer SSL
    60 * over the top of it.
    61 */
    62 tunnelHost = System.getProperty("https.proxyHost");
    63 tunnelPort = Integer.getInteger("https.proxyPort").intValue();
    64
    65 Socket tunnel = new Socket(tunnelHost, tunnelPort);
    66 doTunnelHandshake(tunnel, host, port);
    In doTunnelHandshake(), an http "CONNECT" command is sent to the proxy, with the secure site's hostname and port number as the parameters (line 161). In the original
    tunneling code on line 206 in JSSE, it then checks for "HTTP/1.0 200" in the proxy's reply. If your organization's proxy replies with "HTTP 1.1", an IOException will be
    thrown. To get around this, the code here checks for the reply "200 Connection Established", which indicates that tunneling is successful (line 207). You can modify the
    code to check for the expected corresponding response from your proxy:
    139 private void doTunnelHandshake(Socket tunnel, String host, int port)
    140 throws IOException
    141 {
    142 OutputStream out = tunnel.getOutputStream();
    143 String msg = "CONNECT " + host + ":" + port + " HTTP/1.0\n"
    144 + "User-Agent: "
    145 + sun.net.www.protocol.http.HttpURLConnection.userAgent
    146 + "\r\n\r\n";
    147 byte b[];
    148 try {
    149 /*
    150 * We really do want ASCII7 -- the http protocol doesn't change
    151 * with locale.
    152 */
    153 b = msg.getBytes("ASCII7");
    154 } catch (UnsupportedEncodingException ignored) {
    155 /*
    156 * If ASCII7 isn't there, something serious is wrong, but
    157 * Paranoia Is Good (tm)
    158 */
    159 b = msg.getBytes();
    160 }
    161 out.write(b);
    162 out.flush();
    163
    164 /*
    165 * We need to store the reply so we can create a detailed
    166 * error message to the user.
    167 */
    168 byte reply[] = new byte[200];
    169 int replyLen = 0;
    170 int newlinesSeen = 0;
    171 boolean headerDone = false; /* Done on first newline */
    172
    173 InputStream in = tunnel.getInputStream();
    174 boolean error = false;
    175
    176 while (newlinesSeen < 2) {
    177 int i = in.read();
    178 if (i < 0) {
    179 throw new IOException("Unexpected EOF from proxy");
    180 }
    181 if (i == '\n') {
    182 headerDone = true;
    183 ++newlinesSeen;
    184 } else if (i != '\r') {
    185 newlinesSeen = 0;
    186 if (!headerDone && replyLen < reply.length) {
    187 reply[replyLen++] = (byte) i;
    188 }
    189 }
    190 }
    191
    192 /*
    193 * Converting the byte array to a string is slightly wasteful
    194 * in the case where the connection was successful, but it's
    195 * insignificant compared to the network overhead.
    196 */
    197 String replyStr;
    198 try {
    199 replyStr = new String(reply, 0, replyLen, "ASCII7");
    200 } catch (UnsupportedEncodingException ignored) {
    201 replyStr = new String(reply, 0, replyLen);
    202 }
    203
    204 /* We check for Connection Established because our proxy returns
    205 * HTTP/1.1 instead of 1.0 */
    206 //if (!replyStr.startsWith("HTTP/1.0 200")) {
    207 if(replyStr.toLowerCase().indexOf(
    208 "200 connection established") == -1){
    209 throw new IOException("Unable to tunnel through "
    210 + tunnelHost + ":" + tunnelPort
    211 + ". Proxy returns \"" + replyStr + "\"");
    212 }
    213
    214 /* tunneling Handshake was successful! */
    215 }
    Overlay http tunnel socket with SSL socket
    After you have successfully created the tunneling socket, you overlay it with the SSL socket. Again, this is not difficult to do:
    54 SSLSocketFactory factory =
    55 (SSLSocketFactory)SSLSocketFactory.getDefault();
    56
    57 /*
    58 * Set up a socket to do tunneling through the proxy.
    59 * Start it off as a regular socket, then layer SSL
    60 * over the top of it.
    61 */
    62 tunnelHost = System.getProperty("https.proxyHost");
    63 tunnelPort = Integer.getInteger("https.proxyPort").intValue();
    64
    65 Socket tunnel = new Socket(tunnelHost, tunnelPort);
    66 doTunnelHandshake(tunnel, host, port);
    67
    68 /*
    69 * Ok, let's overlay the tunnel socket with SSL.
    70 */
    71 SSLSocket socket =
    72 (SSLSocket)factory.createSocket(tunnel, host, port, true);
    73
    74 /*
    75 * register a callback for handshaking completion event
    76 */
    77 socket.addHandshakeCompletedListener(
    78 new HandshakeCompletedListener() {
    79 public void handshakeCompleted(
    80 HandshakeCompletedEvent event) {
    81 System.out.println("Handshake finished!");
    82 System.out.println(
    83 "\t CipherSuite:" + event.getCipherSuite());
    84 System.out.println(
    85 "\t SessionId " + event.getSession());
    86 System.out.println(
    87 "\t PeerHost " + event.getSession().getPeerHost());
    88 }
    89 }
    90 );
    The code had called the SSLSocketFactory's getDefault() method earlier to get an instance of the SSLSocketFactory (line 54, repeated above). Next, it passes the
    tunneling socket that was created in the previous step to the createSocket() method of the SSLSocketFactory. The createSocket() method returns an SSLSocket that is
    connected to the destination host and port via the proxy tunnel. You can optionally add a HandshakeCompletedListener to the socket if you wish to be informed when the
    SSL handshaking is completed.
    The SSLSocket created is basically ready for use to transfer secure contents. The startHandshake() method is called to start the SSL handshaking (line 98). After which, you
    can issue the http "GET" command to retrieve the secure pages (line 105):
    91
    92 /*
    93 * send http request
    94 *
    95 * See SSLSocketClient.java for more information about why
    96 * there is a forced handshake here when using PrintWriters.
    97 */
    98 socket.startHandshake();
    99
    100 PrintWriter out = new PrintWriter(
    101 new BufferedWriter(
    102 new OutputStreamWriter(
    103 socket.getOutputStream())));
    104
    105 out.println("GET http://www.verisign.com/index.html HTTP/1.0");
    106 out.println();
    107 out.flush();
    However, issuing http commands to the tunneling SSL socket to access Webpages is not ideal because it would mean having to rewrite the whole http protocol handler from
    scratch. Instead, you should use the HTTPS URL APIs that the JSSE already includes for that purpose. To do this, you have to pass the tunneling SSL socket to the HTTPS URL
    stream handler.
    Pass SSL socket to HTTPS URL stream handler
    The JSSE library has an HttpsURLConnection class that is in the com.sun.net.ssl package, which extends the java.net.URLConnection class. An HttpsURLConnection object
    is returned by the URL object's openConnection() method when "HTTPS" is specified as the protocol. The HttpsURLConnection class has a method, setSSLSocketFactory(),
    that lets you set an SSLSocketFactory of your choice. To pass the tunneling SSL socket to the HTTPS URL stream handler, you would set the setSSLSocketFactory()
    method's parameter with a socket factory that returns the tunneling SSL socket that you created previously.
    To do this, you would wrap the code discussed previously in an SSLTunnelSocketFactory class that extends from the SSLSocketFactory class. The SSLSocketFactory is an
    abstract class. To extend it, you must implement the createSocket() method to return the tunneling SSL socket that you created earlier:
    12 public SSLTunnelSocketFactory(String proxyhost, String proxyport){
    13 tunnelHost = proxyhost;
    14 tunnelPort = Integer.parseInt(proxyport);
    15 dfactory = (SSLSocketFactory)SSLSocketFactory.getDefault();
    16 }
    44 public Socket createSocket(Socket s, String host, int port,
    45 boolean autoClose)
    46 throws IOException,UnknownHostException
    47 {
    48
    49 Socket tunnel = new Socket(tunnelHost,tunnelPort);
    50
    51 doTunnelHandshake(tunnel,host,port);
    52
    53 SSLSocket result = (SSLSocket)dfactory.createSocket(
    54 tunnel,host,port,autoClose);
    55
    56 result.addHandshakeCompletedListener(
    57 new HandshakeCompletedListener() {
    58 public void handshakeCompleted(HandshakeCompletedEvent event) {
    59 System.out.println("Handshake finished!");
    60 System.out.println(
    61 "\t CipherSuite:" + event.getCipherSuite());
    62 System.out.println(
    63 "\t SessionId " + event.getSession());
    64 System.out.println(
    65 "\t PeerHost " + event.getSession().getPeerHost());
    66 }
    67 }
    68 );
    69
    70 result.startHandshake();
    71
    72 return result;
    73 }
    Notice that the SSLTunnelSocketFactory contains a default SSLSocketFactory object. The default SSLSocketFactory object can be instantiated from a call to the static
    method getDefault() (line 15). You need this SSLSocketFactory object to overlay the tunnel socket with the SSL socket, as discussed earlier. You also call the default
    object's getDefaultCipherSuites() and getSupportedCipherSuites() methods when implementing the corresponding abstract methods of the SSLSocketFactory super
    class. For implementation details, please refer to the complete source code for the SSLTunnelSocketFactory in Resources.
    Tunnel through the proxy via URLConnection
    To tunnel through the proxy via URLConnection in your JSSE application, after you call the openConnection() method, check if the returned object is that of the
    HttpsURLConnection. If so, you instantiate your SSLTunnelSocketFactory object and set it in the setSSLSocketFactory() method (lines 22 through 25):
    10 public class URLTunnelReader {
    11 private final static String proxyHost = "proxy.sg.ibm.com";
    12 private final static String proxyPort = "80";
    13
    14 public static void main(String[] args) throws Exception {
    15 System.setProperty("java.protocol.handler.pkgs",
    16 "com.sun.net.ssl.internal.www.protocol");
    17 //System.setProperty("https.proxyHost",proxyHost);
    18 //System.setProperty("https.proxyPort",proxyPort);
    19
    20 URL verisign = new URL("https://www.verisign.com");
    21 URLConnection urlc = verisign.openConnection(); //from secure site
    22 if(urlc instanceof com.sun.net.ssl.HttpsURLConnection){
    23 ((com.sun.net.ssl.HttpsURLConnection)urlc).setSSLSocketFactory
    24 (new SSLTunnelSocketFactory(proxyHost,proxyPort));
    25 }
    26
    27 BufferedReader in = new BufferedReader(
    28 new InputStreamReader(
    29 urlc.getInputStream()));
    30
    31 String inputLine;
    32
    33 while ((inputLine = in.readLine()) != null)
    34 System.out.println(inputLine);
    35
    36 in.close();
    37 }
    38 }
    You can then access the HTTPS URLs using the APIs provided by the URLConnection class. You don't need to worry about the format of the http GET and POST commands,
    which you would if you used the SSL Socket APIs.
    The complete source code for the SSLTunnelSocketFactory and the application code that connects to a secure URL using proxy tunneling is included in Resources. To
    compile and run the application, you would need to download and install Sun's JSSE from its Website, also listed in Resources.
    Conclusion
    If your JSSE application could not tunnel through your organization's firewall, you need to implement your own tunneling socket. The sample code included with the JSSE
    distribution shows you how to open an SSL socket tunnel. This article goes one step further to show you how to pass the tunneling socket to the HTTPS URL stream handler,
    and saves you the trouble of rewriting a http handler
    I hope this will help you.
    Thanks
    Bakrudeen

  • How to do Handshake with tired party(bank) HTTPS URL from SAP PI server

    Dear Expert,
    I have developed bunch of scenarios, all are synchronous ABAP proxy to HTTP_AAE with bank on PI 7.4(dual stack). Bank web server is HTTPS enabled server. Our ABAP developments are still in progress also we have few issue in connection from ECC to PI.but that is not the focus of discussion here.
    we want to do the handshake to check the connectivity with bank on their HTTPS URL from PI. Bank has provided the privet key for SSL from their server and corresponding public key they have maintained on their server. I have imported the private key under NWA -> Certificates -> Key Storage -> TrustedCA->Import Entry->Entry Type->PKCS#12->select the SSL.p12 file->import , also I have selected the option to "Use SSL" in HTTP_AAE receiver communication channel and selected the corresponding entryin  "keystore view" and "keystore entry". All these I have done in our DEV system, and we are trying to connect our PI dev to bank Dev server.
    Questions
    Is there any specific steps to do the handshake with third party HTTPS(bank in my case) server? if not, how can we just test the HTTPS connectivity by using the SSL private installed on our PI server, without running the complete scenarios. Our PI has been installed on UNIX, and "telnet https url 443" is working, as network team has opened the HTTPS port.
    We have not enabled the SSL technically on our PI server, and we have not installed any generated certificate from our PI server. Moreover, we have not made our PI url as "https:hostname:port" as we just need to communicate with bank by using their private key. Do you guys think we should enable the SSL? if yes, please explain why.
    What is the best practice to test the connection with third party having HTTPS URL? how can I just assure HTTPS communication is working fine, before testing my actual scenarios.
    Thanks for helping always.
    Regards,
    Farhan

    Hi Farhan,
    Some part of the blog is applicable for sending HTTPS request to partners/third party (Receiver SOAP Adapter).
    If banks certificates are already in trustedCA, then,  can you check if it also imported under user PIISuser under Identity management in NWA. If above 2 steps are done then i think your are good to go. But be careful when you install certificate, it should be in proper order.
    As you already mentioned, connectivity is already established and you are able to PIng/telnet from pi server, connectivity looks ok.
    While sending request, if you are getting 401 unauthorized, below might be the reason -
    1. Certificate not installed correctly or some missing steps
    2. Partner or TP is not ready to receive it, some certificate issue in there side.
    other than 401 means you are ok (As per certificate and Connectivity) - 403 and 500 errors are next stops.
    403 - error because of encoding method.
    500 - data issue.
    Regards
    Aashish Sinha

  • URGENT - Posting a XML file to a listener URL

    Hi all,
    I have a situation like this: A servlet Client should post a XML file
    to a listener URL, and the listener responds back with a XML file
    after the processing the posted XML file.
    1. Before posting, the servlet client should establish a session with
    the server on which the listener URL is sitting and the Server will
    return a cookie with the authentication credentials to the servlet
    client.
    2. That cookie should be added to the HTTPResponse and then the
    posting of the file should happen.
    The first part is happening okay ..and i could add that cookie to the
    HTTPresponse.
    Now, did anyone successfully post a XML file to a listener URL like this from a servlet?
    I tried using URLConnection, but my cookie got lost and i got back a 401 error. The key there is i should use the same HTTPrequest and HTTPresponse objects, as the cokie needs to be retained!
    Any example code please!!
    thanks a lot
    Rox

    Thanks for your response, but i dont think using authenticator would work. To tell you exactly what is happening there, the url to which the sevlet posts the XML file is protected by Siteminder ( a Enterprise securty platform) and all it requires is a cookie with authenticated credentials on the httprequest/httpresponse objects which are trying to post to that URL. If it find the cookie with the credentials, then the requestor will not be challenged for credentials.
    Here is what i am doing:
    String urlString = "http://webservicesURL.com/ws";
    Cookie SMSESSION = setSMSession();
              if(SMSESSION != null)
                   response.addCookie(SMSESSION);     
              System.out.println("\n..Cookie confirmation..\n"+SMSESSION.getName()+" : "+SMSESSION.getValue());
    URL u = new URL(urlString);
              URLConnection conn = u.openConnection();
              conn.setDoOutput(true);
              conn.setDoInput(true);
              conn.setRequestProperty(SMSESSION.getName(),SMSESSION.getValue());
              OutputStream out = conn.getOutputStream();
    BufferedReader in = new BufferedReader(new FileReader(file));
              while((s = in.readLine())!= null)
                   xml_line = xml_line+s;
              writer.println("The XML file is ..\n");
              writer.println(xml_line);
              writer.println("\n\n\n");
              out.write(xml_line.getBytes());
              InputStream ins = conn.getInputStream();
    when i execute the servlet, i get a tomcat error 401 on the last line above.
    So the new URLConnection that is being opened, is not carying the credentials with it, or the siteminder is unable to read the credentails from the URLConnection. But i am positive that it can read the credentials from the cookie from the HttpResponse object.
    Do you have any more ideas, please?
    thanks

  • Safari 5.0.5 (6533.21.1) - Lost ability to browse "https" urls, "http" fine

    Bizarre occurrence in Safari for me that I was hoping someone may have come across before:
    Tonight for some reason it will not accept any https url whatsoever - it produces the following error:
    can't open the page  <https://url> The error is: “The operation couldn't be completed. Operation not permitted” (NSPOSIXErrorDomain:1) Please choose Safari > Report Bugs to Apple, note the error number, and describe what you did before you saw this message
    I've not installed anything recently or made any config changes.  All I do is stay up-to-date with the software updates from Apple.
    I've tried moving the app to the Trash, rebooting and then re-installing but with no luck
    I tried restoring a previous version of Safari (5.0.4) from early April Time Machine version but still had the same problem.  Wondering if there are files outwith the Safari App that may be the cause and not the app itself.
    I have checked that my firewall and content filtering allow access - (this is the unchanged config I mention above) - and they do and am accessing this discussion site (ironically https so Safari couldn't get to it after my initial Google search) from Firefox.
    I've nothing against Firefox as a browser but I was happy enough with Safari and would like to keep using it.
    In trawling the web I couldn't see anything that directly matched what I was experiencing.
    If anyone has any hints or tips that might help I'd be really grateful.
    Thanks
    Steve

    Mac OS X (10.5.2)  <---   your profile.
    Which Mac OS X are you running?
    If you haven't tried, reinstall Safari.
    http://support.apple.com/kb/DL1070
    Then repair disk permissions.
    Launch Disk Utility. (Applications/Utilities) Select MacintoshHD in the panel on the left, select the FirstAid tab. Click: Repair Disk Permissions. When it's finished from the Menu Bar, Quit Disk Utility and restart your Mac. If you see a long list of "messages" in the permissions window, it's ok. That can be ignored. As long as you see, "Permissions Repair Complete" when it's finished... you're done. Quit Disk Utility and restart your Mac.  If you see any warnings re: SUID messages, they can be safely ignored, information here: http://support.apple.com/kb/TS1448?viewlocale=en_US

  • Reading XML file from a given URL

    Hi, I want to read an XML file - such as an RSS weather feed and format it to match the style of my site (im using Java servlets). I am able to get a HttpURLConnection, but how do I then read from it? if I use the .getInputStream() method on runtime I get the error
    "java.net.UnknownServiceException: protocol doesn't support input
         java.net.URLConnection.getInputStream(URLConnection.java:779)"
    can anyone enlighten me?

    xi4xi4xi4 wrote:
    here's my code
    URL url = new URL("http://feeds.bbc.co.uk/weather/feeds/rss/obs/world/0008.xml");
    HttpURLConnection con = new HttpURLConnection(url) {
    @Override
    public void disconnect() {
    throw new UnsupportedOperationException("Not supported yet.");
    @Override
    public boolean usingProxy() {
    throw new UnsupportedOperationException("Not supported yet.");
    @Override
    public void connect() throws IOException {
    throw new UnsupportedOperationException("Not supported yet.");
    out.println(con.getInputStream().toString());
    Also, if you actually want an object of type HttpURLConnection for some reason, then you do this:
    HttpURLConnection con = (HttpURLConnection) url.openConnection();conn will be some subclass of HttpURLConnection that implements all its abstract methods. openConnection() sorts out what subclass it needs to create. Here is a complete example:
    import java.net.*;
    import java.io.*;
    public class Test
      public static void main(String args[])
        URL url = null;
        try
           url = new URL("http://feeds.bbc.co.uk/weather/feeds/rss/obs/world/0008.xml");
        catch(MalformedURLException e)
          System.out.println("Error: url not in proper format.");
          return;
        HttpURLConnection conn = null;
        try
          conn = (HttpURLConnection)url.openConnection();
        catch(IOException e)
          System.out.println("Error: couldn't open connection.");
          return;
        BufferedReader in = null;
        try
          in = new BufferedReader(
                new InputStreamReader(
                  conn.getInputStream() ));
        catch(IOException e)
          System.out.println("Error: couldn't open stream.");
          e.printStackTrace();
          return;
        String line = null;
        try
          while( (line = in.readLine()) != null )
            System.out.println(line);
        catch(IOException e)
          System.out.println("Error while reading the file.");
    }

Maybe you are looking for

  • Yet another problem getting a .jar file working on Mountain Lion

    The program I need to run is used for generating sounds. Its a simple java program, set up in a Windows .msi container: http://innertotality.com/?q=node/9 I currently have the most up to date Java build from Oracle, according to their online test: v7

  • Transfer from external hard drive to Apple TV

    I'm not the sharpest computer user, but I need to know how to transfer movies I've put on my external hard drive to save space on my Mac mini to Apple TV. Is this possible without loading them on the mini first?

  • Leaf Digital Back files

    After adopting Aperture and learning how to use it in my workflow for my Canon RAW files, I find that it does not support the files from the Leaf Digital backs. Considering the number of file types that Aperture does support, I find this a glaring om

  • How much does it cost to unlock iphone 4s

    Hey guys im planning to buy a iphone 4s locked version as the unlocked version is costly how much does it take to unlock it

  • Material Master by Plant

    Dear friends, I have one situation that I have to activate the accounting view for UNBW only to 4 plants. Do you know If I could do that ? I mean after activate the view in OMS2 let available only to 4 plants.? if yes how could I do that ? best regar