Java HTTP Post Raw Data

Hi All,
I'm looking to make an HTTP post request given the raw data that I have. I've spent a while looking for the solution, made a handful of attempts and I'm looking for a little bit of help. The PHP code for what I'm looking to do looks like this:
<?
$url="http://localhost:3009";
$postdata="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<hi></hi>";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
$result = curl_exec($ch);
curl_close($ch);
echo($result);
?>
My attempt was this:
     private String setXmlPostHeader(Document doc, PostMethod postMethod) throws java.io.IOException, java.io.UnsupportedEncodingException, javax.xml.transform.TransformerException
          ByteArrayOutputStream xmlBytes = new ByteArrayOutputStream();
          XML.serialize( doc, xmlBytes );
          final byte[] ba = xmlBytes.toByteArray();
          String data = new String(ba, "utf-8");
          InputStreamRequestEntity re = new InputStreamRequestEntity(new ByteArrayInputStream(ba));
          postMethod.setRequestEntity(re);
          postMethod.setRequestHeader("Content-type", MediaType.XML.toString() + "; charset=UTF-8");
          return data;
And then executing the postMethod, but this simply is a post containing no data. Does anyone see anything wrong that I'm doing? Is there an easy way to set the raw http post data in java like there is in php? Thanks.
-Ken

Look at the PostMethod documentation. You need to set the multipart request.

Similar Messages

  • How to handle HTTP-POST encrypted data for ECC Using proxy or RFC

    I have a scenario HTTP-POST ->PI->ECC.sender is HTTP Post  send encrypted data i need to handle the data and stored in to SAP ECC  with out decrypt using PI .what should i take for receiver  can i use inbound proxy or RFC  and how can handle the encrypted data  for decrypt.
    Regards
    Ravi

    1. my sender is HTTP POST . what should i configure in sender communication channel in SAP PI .like SOAP or HTTP .What are the parameters i need to pass .
    >>>
    If you are on PI 7.3 and above, configure the HTTP AAE adapter - Configuring the Java HTTP Adapter on the Sender Channel - Advanced Adapter Engine - SAP Library
    2.while using inbound proxy for encrypted data  i need  store the data in to table , the same proxy can i call  another outbound  service for decrypt  same data.
    >>>>
    Yes you can always a proxy within a proxy.

  • How to interact with google search engine using java HTTP POST

    I am trying to develop an desktop app that acts as an online radio tuner. I want to use google as an index site for actually searching for radio stations online. So I was wandering if it is possible for me to use java to actually interface with the google search engine servers. For example, I have built a gui that allows you to enter search text. This gui will connect to the web. I would like it to connect to the Google site and post the query to the google web servers. Then i would like to began to parse the response( html page) that i get back from the google servers. Like using google without actually typing in the text field on the google site. Can anyone tell me if it is possible to do this with java. If so, what would be the best way to go about doing this. Thanks.

    Thanks for the response. It was actually alot easier to do than I anticipated. All I had to do was create a URL object initialized with the google url(search text embedded in the url - http://www.google.com/search?q=" + searchText + "&hl=en&ie=UTF-8&oe=UTF8).
    Looks like this:
    String google = http://www.google.com/search?q=" + searchText + "&hl=en&ie=UTF-8&oe=UTF8;
    URL url = new URL(google);  // creating Google Url object
    URLConnection connection = url.openConnection();
           connection.setDoOutput(true);
           connection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" );  // fooling google servers into thinking the request is coming from a real browser
           BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));The content returned by the google server can be accessed calling the BufferedReader class methods.

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

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

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

  • Render html form & send forms's input values as params via HTTP POST

    Hello,
    I'm using appache commons http client to send HTTP post queries to a given url and receive HTTP response then process it.
    one of the requirements of my Application is the following: one of these HTTP Post requests is supposed to return an HTML form with different html types (text filed, text area etc..) that i will need to display in my swing application. one important requirement is that i can't know in advance what the html form field types will be.. it depends on a given parameters that my application send as part of HTTP Post method (using apache http client).
    I Longly searched for a simple solution to this problem . There are many solutions but each one has it's limitations :
    1-i can render the html form inside a JEditorPane .but how can I collect the user entered data inside JEditorPane ? i'm not sure this swing component offers the capability to detect its html contents and more it will be difficult to know what are the values entered by user inside html form rendered by JEditorPane.
    2-are there any Java Embedded browsers that offer some API to enable me detect the html form fields ,capture the data entered by user inside the html form ?
    3-the solution i currently opted for is : parse html & convert html form to swing dialog. currently this solution i use works well but the cost of implementing it is high : it involves difficult parsing logic. this makes me worried .I'm not sure if i'm now using the right & easiest solution.
    I need some advice on What is the simplest and clean solution to render a html form & yet be able to collect user entered inputs & send the user input values as params via java HTTP POST request ?

    dragzul wrote:
    In my opinion, your actual solution is what you need to do. You're trying to "merge" two different kinds of view. Actually, the "easiest" way may be: if you have your data to display, you decide to show it on html or swing.Yes i believe that my current solution may be the unique one for my special requirements. when doing research about this problem i found a multitude of java libraries to convert xml to swing (ex: www.swixml.org) .However i was surprised there are no java libraries to convert HTML forms to swing dialogs -as far as i know-. this is a bit strange. The Limitation is that the developers of the server API are not Java guys and are reluctant to use an xml format that i can easily convert to swing . probably they have their own reasons as they might be using the HTML Response for some other server side work. So I was obliged to deal with an HTML stream that i need to display in my client application and process its data. in my opinion the only way to do this is by developing a HTML form to swing converter package. that's what i did now. i was only worried if i'm complicating things and if there are some easier solutions to this issue.
    thanks

  • HTTP Post in HTTP adapter

    Hi,
    We are developing one interface in which sender Torex system sends message in "HTTP Post" format.
    In this sender application wants the url in following format.
    http://server:port/sap/xi/adapter_plain?service=<xxx>&namespace=<xxx>&interface=<xxx>&sap-user=<xxx>&sap-password=<xxx>&qos=BE&ProductID=000000000000000216&uid=500014&deviceID=0725&StoreID=0004
    In above "HTTP Post" format data has been sent in url without body of message.
    I know the option in below blog.
    https://weblogs.sdn.sap.com/pub/wlg/13639
    But is there any other solution for this?
    xml payload for above message is as below.
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:interface xmlns:ns0="namespace">
       <ProductID>000000000000000216</ProductID>
       <UID/>
       <DeviceID/>
       <StoreID>0004</StoreID>
    </ns0:ExternalStockLocator_Retail_REQ>
    Thanks
    Edited by: darshana-PI on Feb 10, 2012 9:37 PM

    Hello,
    http://server:port/sap/xi/adapter_plain?service=<xxx>&namespace=<xxx>&interface=<xxx>&sap-user=<xxx>&sap-password=<xxx>&qos=BE&ProductID=000000000000000216&uid=500014&deviceID=0725&StoreID=0004
    In above "HTTP Post" format data has been sent in url without body of message.
    Please remember that when creating a sender/receiver using the Plain HTTP Adapter, the following are automatically filled out
    Transport Protocol: HTTP 1.0, Message Protocol: XI Payload in HTTP Body. The transport protocol means that only HTTP 1.0 is supported and that for it to work, an HTTP Body is required.
    Hope this helps,
    Mark

  • Http post to a url from a WebDynpro (Java) application

    Hi,
    I want to send http post parameters to a url from a WebDynpro (Java) component. I need to do this to send OCI catalog data back to SAP SRM.
    I found this thread:
    HTTP Post
    which suggests to use the the Suspend plug for this purpose.
    <quote>
    Sending POST parameters with Web Dynpro Suspend Plugs
    1) Define a an additional Suspend Plug parameter (besides 'Url' of type String) with name 'postParams' and of type Map
    </quote>
    After adding the postParams parameter of type java.util.Map to the Suspend-plug the WebDynpro gives the following error during build:
    Outbound plug (of type 'Suspend') 'suspend_plug' may have at most two parameters: 'url' of type 'string' and 'postParams' of type 'Map'.
    I use SAP NetWeaver Developer Studio version 7.0.16.
    Does someone know a solution? I would highly appreciate it.
    Thanks in advance.
    Eric

    Hi,
    Please have a look at this thread,
    Pass Table as Input to Adaptive RFC
    Regards,
    Saravanan K

  • How to send te XML data using HTTPS post call & receiving response in ML

    ur present design does the HTTP post for XML data using PL/SQL stored procedure call to a Java program embedded in Oracle database as Oracle Java Stored procedure. The limitation with this is that we are able to do HTTP post; but with HTTPS post; we are not able to achieve because of certificates are not installed on Oracle database.
    we fiond that the certificates need to be installed on Oracle apps server; not on database server. As we have to go ultimately with HTTPS post in Production environment; we are planning to shift this part of program(sending XML through HTTPS post call & receiving response in middle layer-Apps server in this case).
    how i can do this plz give some solution

    If you can make the source app to an HTTP Post to the Oracle XML DB repository, and POST contains a schema based XML document you can use a trigger on the default table to validate the XML that is posted. The return message would need to be managed using a database trigger. You could raise an HTTP error which the source App would trap....

  • Submit Form data by Http Post

    hi,
    i created a pdf form in livecycle designer with certain fields and want to submit the data filled in the form to a java servlet in HTTP POST Manner...
    can any1 please tell how to capture the posted data from pdf to java servlet??
    i am looking for code in java which will capture the HTTP POST data ...
    moreover, if in the servlet , is it valid to write request.getParameter("FirstName") where FirstName being a field in the PDF??
    please help ASAP....thanx in advance

    Toby,
    Look at <CFHTTP>
    http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_g-h_09.html#3989287
    Ken Ford
    Adobe Community Expert Dreamweaver/ColdFusion
    Adobe Certified Expert - Dreamweaver CS3
    Adobe Certified Expert - ColdFusion 8
    Fordwebs, LLC
    http://www.fordwebs.com
    http://www.cfnoob.com
    "toby007" <[email protected]> wrote in
    message
    news:ge5inl$21v$[email protected]..
    > Hi there
    >
    > I need to check whether the following is possible and I
    have to find out
    > ASAP.
    >
    > I have to find out if I can pass data to another
    application on a differet
    > server,
    >
    > Basically I have been told so far that the only way that
    I can pass
    > information is by a HTTP post.
    >
    > Previously I have done something similar by posting a
    form to a URL. This
    > time I have a string which contains the information.
    >
    > How can I post a string so it can be used by the
    application which is o
    > the
    > other server.
    >
    > Thanks in advance.
    >
    >
    >
    > Toby
    >

  • Http Post to XI Test Tool in Java?

    I have been able to use the HTML test tool shared on SDN for my scenarios to date, but I have been <u>also</u> trying to write an http post program in java.  For some reason the post never makes it to XI.  Does anyone have a sample they will share or notice any problems with this code?
    Thanks.
    import java.net.*;
    import java.io.*;
    public class Reply {
      private static String myUrl = "http://sr3a80px:8000/sap/xi/adapter_plain?service=PAN_HOTKEY&namespace=http://graybar.com/sandbox/hotkeyoutbound&interface=PANRequestAbstractInterfaceAsync&party=Panduit";
      public static void main(String[] args) {
        try {
        URL u = new URL(myUrl);
        URLConnection uCon = u.openConnection();
        HttpURLConnection connection = (HttpURLConnection) uCon;
        connection.setDoOutput(true);
        connection.setRequestMethod("POST");
        OutputStream out = connection.getOutputStream();
        OutputStreamWriter wout = new OutputStreamWriter(out, "UTF-8");
        wout.write("<?xml version=\"1.0\"?>\r\n");
        wout.write("<ns0:hotkeyOut_PAN_MessageType           
          xmlns:ns0=\"http://abc.com/hotkeyoutbound\">\r\n");
        wout.write("<RequestAvailability>\r\n");
        wout.write("<Date>20050919</Date>\r\n");
        ...(rest of my xml)...
        wout.flush();
        out.close();
        catch (IOException e) {
         System.err.println(e);
         e.printStackTrace();
      } // end of main
    } // end of class

    cleaning up old ticket...never got this working, but tested another way

  • How to HTTP POST data to SAP Business Connector

    Hello,
    I would like to transfer data from a client with HTTP POST to SAP Business Connector. SAP BC acts as server. In SAP BC I created a Java service containing the code:
    IDataCursor idatacursor = pipeline.getCursor();
    idatacursor.first("node");
    Object obj1 = idatacursor.getValue();
    System.out.println(obj1.toString()); //for test
    But how can I access the data that was sent with HTTP POST in my service?
    Thank you
    Piotr Dudzik

    Hi,
    quite easy:
    StringBuffer buffer = new StringBuffer();
    String resultString = null;
    String xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
            "<biztalk_1 xmlns=\"urn:biztalk-org:biztalk:biztalk_1\">"+
            "<header>"+
            "<delivery>"+
            "<to>"+
    "<address>urn:sap-com:logical-system:XXX</address>"+
            "</to>"+
            "<from>"+
    "<address>urn:sap-com:logical-system:YYY</address>"+
            "</from>"+
            "</delivery>"+
            "</header>"+
            "<body>"+
            "<doc:Z_RFC_CALL_NAME> xmlns:doc=\"urn:sap-com:document:sap:rfc:functions\" xmlns=\"\">"+
            ... [PARAMETERS]
            "</doc:Z_RFC_CALL_NAME>"+
            "</body>"+
            "</biztalk_1>";
            try {
                URL url = new URL(SCHEMA, this.host, Integer.parseInt(PORT), FILE);
                HttpURLConnection connection = (HttpURLConnection)url.openConnection();
                initConnection(connection);
                OutputStream out = connection.getOutputStream();
                out.write(xmlString.getBytes());
                out.close();
                InputStream reader = connection.getInputStream();
                char ch;
                while((ch = (char)reader.read()) != -1 && ch != 0xFFFF)
                    buffer.append(ch);
                resultString = buffer.toString();
                if (this.getXMLEntry(resultString, "E_STATUS").equals("E")) { // ERROR
                    System.out.println("errormessage: "+this.getXMLEntry(resultString, "E_EMSG"));
                } else {
                    // ok, is supose this is an S (success), parse the stuff
                reader.close();
            catch (Exception e){
                e.printStackTrace();
                System.out.println(e);

  • Is it possible to run Go URL SQL and return raw data using Java?

    Hi All,
    I just got GO URL SQL working in HTML, when i type the following URL on to the address bar.
    https://odsau.oraclecorp.com/analytics/saw.dll?Go&SQL=select+"MFG Serial Number"."Job Name","MFG Serial Number".Item+from+"Supply Chain Management"
    It prints out a table with all the data that query from the database in a HTML page. However, I want to be able to manipulate these data in a JAVA script.
    Is there a similar function i can use in Java script and return raw data so i can store them into a variable for data manipulation?
    Or is there a work around that someone has already done ?
    Thanks
    John Lau

    You can excute SQL statemetns throught JDBC, but that doesn't have a facility to read those statements from a file. You'd have to write code to read the file and create and execute statements through JDBC. That should be pretty straightforward though.
    It's conceivable that there's a third party library out there that does it, if you know what to look for.
    If you're not familiar with JDBC, check out http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/

  • Kerberos Ticket via Java to BW to access BW Querys with HTTP POST

    Hi and thanks for reading,
    im Working with 2004 and the NWDS SP10. We have a project which must show some reports from the HR system via backend and some BW Reports done with Web Application Designer 3.5.
    The user of the project application is able to select personnel numbers or org units in a tree UI element. At design time we do not know hwo many of each he might select (could be a couple of hundreds or even more).
    A URL isn't long enough to support our needs (255 characters border)
    A consultant said that we should use HTTP Post with a Form. He gave me an example like this
    <HTML>
    <BODY>
    <form name="querySelektion" action="<system name>" method="POST">
              <input type="submit" value="Formular senden" />
              <!-- Template Parameter -->
              <input name="SAP-LANGUAGE" type="hidden" value="D" />
              <input name="PAGENO" type="hidden" value="1" />
              <input name="CMD" type="hidden" value="LDOC" />
              <input name="TEMPLATE_ID" type="hidden" value="Z_TEST_AX" />
              <!-- Selektionsparameter -->
              <input name="var_name_1" type="hidden" value="H1_ORGST" /></td>
              <input name="VAR_NODE_IOBJNM_1" type="hidden" value="0ORGUNIT" />
              <input name="var_value_ext_1" type="hidden" value="50058503" />
         </form>
    </BODY>
    </HTML
    This is working beside the fact that i have to fill in my BW username and password. I translated this to Java with  the Jakarta HTTP Librarys into the following code.
    try
                HttpClient httpClient = new HttpClient();
                PostMethod post = new PostMethod("http://<system name>");
                NameValuePair[] data =
                        new NameValuePair("SAP-LANGUAGE", "D"),
                        new NameValuePair("PAGENO", "1"),
                        new NameValuePair("CMD", "LDOC"),
                        new NameValuePair("TEMPLATE_ID", "Z_TEST_AX"),
                        new NameValuePair("var_name_1", "H1_ORGST"),
                        new NameValuePair("VAR_NODE_IOBJNM_1", "0ORGUNIT"),
                        new NameValuePair("var_value_ext_1", "50058503")};
                post.setRequestBody(data);
                int iReturnCode = httpClient.executeMethod(post);
                wdContext.currentContextElement().setTextView(Integer.toString(iReturnCode ));
                post.releaseConnection();
            } catch (IOException ioe)
                wdContext.currentContextElement().setTextView(ioe.getMessage());
    All i get is an Error 401 which means "Not Authorized". The Portal (where the application is running) and the BW do both support Single Sign On and the BW System is configured in the Portal.
    I think the HTTP Post is to generic. I also think that i need to make a authorization before and post the Kereberos Ticket to the BW before.
    But how can i accomplish that? Is there a SAP HelperClass to configure or establish system connections of SSO enabled systems?
    Or is the approach with the HTTP Post in java wrong, maybe there is an easier way to do transfer a lot of personnel or orgunit numbers to the BW Query?
    Thanks in advance,
    Kai Mattern

    Since you mentioned, I now tried to modify the writeToFile method in a few ways (closing the streams, directly setting them to null...), but the "java.lang.IllegalStateException: Already connected" exception remains there
    Actually I suppose this has no effect on the originally reported cookie problem, because if I just completely remove this logwriting (+ the following URL disconnect-reconnect) from the code, the situation is the very same
    I paste my modified writeToFile method anyway, maybe you can tell what I do wrong here, and I can learn from that
        public void writeToFile ( HttpURLConnection urlConnection, String filename ) {
          try {
            BufferedReader bufferedReader = null;
            InputStreamReader inputStreamReader = null;
            // Prepare a reader to read the response from the URLConnection
            inputStreamReader = new InputStreamReader(urlConnection.getInputStream());
            bufferedReader = new BufferedReader(inputStreamReader);
            String responseLine;
            PrintStream printStream = new PrintStream(new FileOutputStream (filename));
            // Read until there is nothing left in the stream
            while ((responseLine = bufferedReader.readLine()) != null)
                printStream.println(responseLine);
            inputStreamReader.close();
            bufferedReader.close();
            inputStreamReader = null;
            bufferedReader = null;
            printStream.close();
          catch (IOException ioException) { /* Exception handling */ }
        } //writeToFile()

  • HTTP post data from the Oracle database to another web server

    Hi ,
    I have searched the forum and the net on this. And yes I have followed the links
    http://awads.net/wp/2005/11/30/http-post-from-inside-oracle/
    http://manib.wordpress.com/2007/12/03/utl_http/
    and Eddie Awad's Blog on the same topic. I was successful in calling the servlet but I keep getting errors.
    I am using Oracle 10 g and My servlet is part of a ADF BC JSF application.
    My requirement is that I have blob table in another DB and our Oracle Forms application based on another DB has to view the documents . Viewing blobs over dblinks is not possible. So Option 1 is to call a procedure passing the doc_blob_id parameter and call the web server passing the parameters.
    The errors I am getting is:
    First the parameters passed returned null. and
    2. Since my servlet directly downloads the document on the response outputStream, gives this error.
    'com.evermind.server.http.HttpIOException: An established connection was aborted by the software in your host machine'
    Any help please. I am running out of time.
    Thanks

    user10264958 wrote:
    My requirement is that I have blob table in another DB and our Oracle Forms application based on another DB has to view the documents . Viewing blobs over dblinks is not possible. Incorrect. You can use remote LOBs via a database link. However, you cannot use a local LOB variable (called a LOB <i>locator</i>) to reference a remote LOB. A LOB variable/locator is a pointer - that pointer cannot reference a LOB that resides on a remote server. So simply do not use a LOB variable locally as it cannot reference a remote LOB.
    Instead provide a remote interface that can deal with that LOB remotely, dereference that pointer on the remote system, and pass the actual contents being pointed at, to the local database.
    The following demonstrates the basic approach. How one designs and implements the actual remote interface, need to be decided taking existing requirements into consideration. I simply used a very basic wrapper function.
    SQL> --// we create a database link to our own database as it is easier for demonstration purposes
    SQL> create database link remote_db connect to scott identified by tiger using
      2  '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SID=dev)(SERVER=dedicated)))';
    Database link created.
    SQL> --// we create a table with a CLOB that we will access via this db link
    SQL> create table xml_files( file_id number, xml_file clob );
    Table created.
    SQL> insert into xml_files values( 1, '<root><text>What do you want, universe?</text></root>' );
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> --// a local select against the table works fine
    SQL> select x.*, length(xml_file) as "SIZE" from xml_files x;
       FILE_ID XML_FILE                                                                                SIZE
             1 <root><text>What do you want, universe?</text></root>                                    53
    SQL> --// a remote select against the table fails as we cannot use remote pointers/locators
    SQL> select * from xml_files@remote_db x;
    ERROR:
    ORA-22992: cannot use LOB locators selected from remote tables
    no rows selected
    SQL> //-- we create an interface on the remote db to deal with the pointer for us
    SQL> create or replace function ReturnXMLFile( fileID number, offset integer, amount integer ) return varchar2 is
      2          buffer  varchar2(32767);
      3  begin
      4          select
      5                  DBMS_LOB.SubStr( x.xml_file, amount, offset )
      6                          into
      7                  buffer
      8          from    xml_files x
      9          where   x.file_id = fileID;
    10 
    11          return( buffer );
    12  end;
    13  /
    Function created.
    SQL> --// we now can access the contents of the remote LOB (only in 4000 char chunks using this example)
    SQL> select
      2          file_id,
      3          ReturnXMLFile@remote_db( x.file_id, 1, 4000 ) as "Chunk_1"
      4  from       xml_files@remote_db x;
       FILE_ID Chunk_1
             1 <root><text>What do you want, universe?</text></root>
    SQL> --// we can also copy the entire remote LOB across into a local LOB and use the local one
    SQL> declare
      2          c               clob;
      3          pos             integer;
      4          iterations      integer;
      5          buf             varchar2(20);   --// small buffer for demonstration purposes only
      6  begin
      7          DBMS_LOB.CreateTemporary( c, true );
      8 
      9          pos := 1;
    10          iterations := 1;
    11          loop
    12                  buf := ReturnXMLFile@remote_db( 1, pos, 20 );
    13                  exit when buf is null;
    14                  pos := pos + length(buf);
    15                  iterations := iterations + 1;
    16                  DBMS_LOB.WriteAppend( c, length(buf), buf );
    17          end loop;
    18 
    19          DBMS_OUTPUT.put_line( 'Copied '||length(c)||' byte(s) from remote LOB' );
    20          DBMS_OUTPUT.put_line( 'Read Iterations: '||iterations );
    21          DBMS_OUTPUT.put_line( 'LOB contents (1-4000):'|| DBMS_LOB.SubStr(c,4000,1) );
    22 
    23          DBMS_LOB.FreeTemporary( c );
    24  end;
    25  /
    Copied 53 byte(s) from remote LOB
    Read Iterations: 4
    LOB contents (1-4000):<root><text>What do you want, universe?</text></root>
    PL/SQL procedure successfully completed.
    SQL> The concern is the size of the LOB. It does not always make sense to access the entire LOB in the database. What if that LOB is a 100GB in size? Irrespective of how you do it, selecting that LOB column from that table will require a 100GB of data to be transferred from the database to your client.
    So you need to decide WHY you want the LOB on the client (which will be the local PL/SQL code in case of dealing with a LOB on a remote database)? Do you need the entire LOB? Do you need a specific piece from it? Do you need the database to first parse that LOB into a more structured data struct and then pass specific information from that struct to you? Etc.
    The bottom line however is that you can use remote LOBs. Simply that you cannot use a local pointer variable to point and dereference a remote LOB.

  • Using RAW in Jave Bean to store data in Oracle 8i database

    I have a question about using RAW in java program to read write data in Oracle database. Is there any sample with key information for me to refer to? Your help will be appreciated.
    Jane

    I have a question about using RAW in java program to read write data in Oracle database. Is there any sample with key information for me to refer to? Your help will be appreciated.
    Jane Jane,
    here is a code snippet provided by our QA team
    hope it helps
    Kuassi
    1. Create the table:
    "CREATE TABLE rawtable (key VARCHAR2(30), rawcol RAW(2000), longrawcol
    LONG RAW, moredata VARCHAR2(100))"
    2. Write the data:
    byte x[] = {1,2,3,4,5};
    byte y[]= {6,7,8,9,10};
    PreparedStatement pstmtR =
    conn.prepareStatement("INSERT INTO rawtable (key, rawcol,
    longrawcol, moredata) VALUES (?, ?)");
    pstmtR.setString(1, "rawcol data");
    pstmtR.setBytes(2, x);
    pstmtR.setNull(3, Types.LONGVARBINARY);
    pstmtR.setString(4, "Here's some more data!");
    pstmtR.execute();
    pstmtR.setString(1, "longrawcol data");
    pstmtR.setNull(2, Types.BINARY);
    pstmtR.setBytes(3, y);
    pstmtR.setString(4, "Here's some more data!");
    pstmtR.execute();
    pstmtR.setRAW(1, RAW_obj) can be used to insert the RAW data.
    You can also use setBinaryStream to insert RAW data:
    CallableStatement cstmt =
    conn.prepareCall ("begin insert into rawtab values (?,?); end;");
    cstmt.setBinaryStream (1, (java.io.InputStream) new
    ByteArrayInputStream(rawbuf), rawbuf.length);
    cstmt.setBinaryStream (2, (java.io.InputStream) new
    ByteArrayInputStream(lrawbuf), lrawbuf.length);
    3. Read the data:
    InputStream is = null;
    byte rawbuf [];
    byte lrawbuf [];
    ResultSet rset = stmt.executeQuery("SELECT rawcol, longrawcol FROM
    rawtable");
    // You can retrieve the data with the following methods
    rawbuf = rset.getBytes(1);
    lrawbuf = rset.getBytes(2);
    RAW raw1 = rset.getRAW(1);
    is = rset.getBinaryStream(column);
    is = rset.getAsciiStream(column);
    is = rset.getUnicodeStream(column);
    When using CallableStatement:
    ((OracleCallableStatement)cstmt).registerOutParameter(1,
    OracleTypes.RAW);

Maybe you are looking for

  • [solved] Issue with conky and Kde 4

    I have a small issue with conky and KDE 4.2. I start conky with a script which I stored under ~/.kde/Autostart. The script is simple and looks like this.. conky -c ~/.conkyrc_kde4 This works fine. But when I restart the first KDE and check with ps, I

  • Iphone 5 taking screen shots by only pressing on/off button

    I know it's supposed to take screen shots if you hold down the home button and the on/off button together, but my phone is taking a screen shot every time I turn it off (i.e., without pressing the home button).  Anyone seen this issue?

  • How to use moving maximum in query desighner

    Hi All, i am new to BI, please help. I have a requirement to find the maximum and minimum posting date for an article. For this i would need to use the moving maximum feature of the query. where to find this function and how to use it. please reply t

  • Internal Error 2318

    Hi All, I hope I can find an answer for the problem I have with updating/installing Java 7 (JRE) update 67 32 bit on Windows 8.1 x64 bit system. The 64 bit Java 7 update 67 installs fine. In the past there were no issues with updating JRE 32 bit to n

  • The video tab in ipod is locked- cannot load dvd (.mp4 files) files to ipod

    I converted the dvd files to .mp4 files (Using cusoft). The files were loaded in the itune (by using add files to library). I can play the dvd in the itune on my pc but cannot transfer the dvd files to the ipod because: The dvd tab in the ipod is loc