3 Replies Latest reply: Aug 30, 2013 1:39 PM by VipinPillai RSS

    SocketTimeoutException:Read timed out error-check in file through RIDC API

    970802
      Hi,

      I am trying to check in a file into the WebCenter Content Manager using the RIDC APIs.
      The document that I am referring to for the same is http://docs.oracle.com/cd/E23943_01/doc.1111/e10807/c23_ridc.htm

      I am using the following commands to upload the file:

      idcClient = (IdcClient) manager.createClient("http://ap9046pc.us.oracle.com:16200/cs/idcplg");
      userContext = new IdcContext(user,password);
      DataBinder inputBinder = idcClient.createBinder();

      inputBinder.putLocal("IdcService", service);
      inputBinder.putLocal("dDocTitle", f.getConSrvTitle().trim());
      inputBinder.putLocal("dDocName", "test-checkin");
      inputBinder.putLocal("dSecurityGroup", dSecurityGroup);
      inputBinder.putLocal("dDocType", f.getConSrvType().trim());
      inputBinder.putLocal("dDocAccount", dDocAccount);
      inputBinder.putLocal("xComments", f.getConSrvDescription().trim());

      TransferFile tFile = new TransferFile(is, f.getSrcPhysicalFileName().trim(), getContentLength(is));
      inputBinder.addFile(fileType, tFile);
      ServiceResponse response = idcClient.sendRequest(userContext, inputBinder);

      where 'is' is the inputStream which has the file data that needs to be uploaded.

      When I execute the code I am getting the following error:
      'Error 1: java.net.SocketTimeoutException: Read timed out'

      I have tried to increase the socket timeout upto 5 mins using the 'idcClient.getConfig ().setSocketTimeout (300000)' command but it does not work still I am getting the same error.

      Also, when the inputStream is NULL the file is created but when the InputStream has some value there is Socket Timeout error.

      How should I try to resolve this issue??
        • 1. Re: SocketTimeoutException:Read timed out error-check in file through RIDC API
          Srinath Menon-Oracle
          Hi ,


          Can you try using the following code and see if this is failing as well :

          import java.io.*;
          import oracle.stellent.ridc.*;
          import oracle.stellent.ridc.model.*;
          import oracle.stellent.ridc.protocol.*;
          import oracle.stellent.ridc.protocol.intradoc.*;
          import oracle.stellent.ridc.common.log.*;
          import oracle.stellent.ridc.model.serialize.*;
          import oracle.stellent.ridc.protocol.http.*;
          import java.util.List;


          public class TestRIDCCheckin {

          /**
          * @param args
          */
          public static void main(String[] args) {
          // Create a new IdcClientManager
          IdcClientManager manager = new IdcClientManager ();

          try{



          IdcClient idcClient = manager.createClient ("idc://<ucm hostname>:<intradocserverport>");

          //for using the web connection - start
          // IdcClient idcClient = manager.createClient("http://hostname:16200/cs/idcplg");
          // IdcContext userContext = new IdcContext("weblogic", "<password>");
          //for using web connection - end

          // Create new context using the 'sysadmin' user
          IdcContext userContext = new IdcContext ("weblogic");

          // Create an HdaBinderSerializer; this is not necessary, but it allows us to serialize the request and response data binders
          HdaBinderSerializer serializer = new HdaBinderSerializer ("UTF-8", idcClient.getDataFactory ());

          // Databinder for checkin request
          DataBinder dataBinder = idcClient.createBinder();
          dataBinder.putLocal("IdcService", "CHECKIN_NEW");
          dataBinder.putLocal("dDocName","<content id of choice>"); //If this is set to Auto-generate then no need to set this parameter
          dataBinder.putLocal("dDocAuthor","weblogic");
          dataBinder.putLocal("dDocTitle", "<Title as required>");
          dataBinder.putLocal("dDocType", "Document");

          //If needed set account , otherwise not necessary
          dataBinder.putLocal("dDocAccount", "");
          dataBinder.putLocal("dSecurityGroup", "Public");

          // dataBinder.putLocal("xCollectionID" ,"<collection id for folder to be checked in>"); - Incase folder is involved
          dataBinder.addFile("primaryFile", new File("<location for the file to be checked-in>"));
          dataBinder.putLocal("doFileCopy", "1");


          // Write the data binder for the request to stdout
          serializer.serializeBinder (System.out, dataBinder);
          // Send the request to Content Server
          ServiceResponse response = idcClient.sendRequest(userContext,dataBinder);
          // Get the data binder for the response from Content Server
          DataBinder responseData = response.getResponseAsBinder();
          // Write the response data binder to stdout
          serializer.serializeBinder (System.out, responseData);


          } catch (IdcClientException ice){
          ice.printStackTrace();
          } catch (IOException ioe){
          ioe.printStackTrace();
          }
          }

          }

          Try this code and check the results .

          Thanks
          Srinath
          • 2. Re: SocketTimeoutException:Read timed out error-check in file through RIDC API
            970802
            Thanks for your input.

            I tried the code provided by you, it worked fine when I try to upload a file like a text file.
            Then I tried to change the code in order to get the InputStream populated by the BLOB object stored in one of the tables.
            The changed code was like:

            package oracle.apps.fnd.atg.datamapmig;

            import java.io.*;

            import java.sql.DriverManager;
            import java.sql.PreparedStatement;
            import java.sql.ResultSet;

            import java.sql.SQLException;

            import oracle.stellent.ridc.*;
            import oracle.stellent.ridc.model.*;
            import oracle.stellent.ridc.protocol.*;
            import oracle.stellent.ridc.protocol.intradoc.*;
            import oracle.stellent.ridc.common.log.*;
            import oracle.stellent.ridc.model.serialize.*;
            import oracle.stellent.ridc.protocol.http.*;

            import java.util.List;
            import java.sql.Connection;
            import java.sql.DriverManager;
            import java.sql.PreparedStatement;
            import java.sql.ResultSet;
            import java.sql.SQLException;


            public class TestRIDCCheckin {

            /**
            * @param args
            */

            public static long getContentLength(InputStream is)
            {
            long bytesRead = 0;
            byte[] buffer = new byte[1024];
            int i = 0;
            try
            {
            while( (i = is.read(buffer)) > 0)

            {
            bytesRead += i;
            }
            System.out.println("Length is "+bytesRead);
            }
            catch(IOException e)
            {
            System.out.println(e.getLocalizedMessage());
            }
            return bytesRead;
            }
            public static void main(String[] args) {

            String dbHost = "<hostname>";
            String dbPort = "<Port>";
            String dbSid = "<SID>";
            String dbUsername = "<Username>";
            String dbPassword = "<Password>";
            String dbUrl = null;
            InputStream iStream = null;
            java.sql.Connection dbCon = null;
            PreparedStatement ps1 = null;
            ResultSet rs1 = null;
            final String query1 = "SELECT FILE_DATA " +
            "FROM FND_LOBS " +
            "WHERE FILE_ID = ?";

            try
            {
            dbUrl = "jdbc:oracle:thin:@".concat(dbHost)
            .concat(":").concat(dbPort)
            .concat(":").concat(dbSid);
            DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
            dbCon = DriverManager.getConnection(dbUrl,dbUsername,dbPassword);
            ps1 = dbCon.prepareStatement(query1);

            System.out.println("\nConnected to Database " + dbSid + " as " + dbUsername + ".");
            }
            catch (SQLException e1)
            {
            System.out.println(e1.getLocalizedMessage());
            }


            try
            {
            ps1.setInt(1, 1628794);
            rs1 = ps1.executeQuery();
            while(rs1.next())
            {
            //Converting to Input Stream
            iStream = rs1.getBinaryStream("FILE_DATA");
            }
            }
            catch (SQLException e3)
            {
            System.out.println(e3.getLocalizedMessage());
            }

            // Create a new IdcClientManager
            IdcClientManager manager = new IdcClientManager();

            try {
            //IdcClient idcClient = manager.createClient ("idc://<ucm hostname>:<intradocserverport>");

            //for using the web connection - start
            IdcClient idcClient =
            manager.createClient("http://<ucm hostname>:16200/cs/idcplg");
            IdcContext userContext = new IdcContext("weblogic", "<password>");
            //for using web connection - end

            // Create new context using the 'sysadmin' user
            //IdcContext userContext = new IdcContext ("weblogic");

            // Create an HdaBinderSerializer; this is not necessary, but it allows us to serialize the request and response data binders
            HdaBinderSerializer serializer =
            new HdaBinderSerializer("UTF-8", idcClient.getDataFactory());

            // Databinder for checkin request
            DataBinder dataBinder = idcClient.createBinder();
            dataBinder.putLocal("IdcService", "CHECKIN_NEW");
            dataBinder.putLocal("dDocName",
            "TestRIDC-1"); //If this is set to Auto-generate then no need to set this parameter
            dataBinder.putLocal("dDocAuthor", "weblogic");
            dataBinder.putLocal("dDocTitle", "TestRIDC-1");
            dataBinder.putLocal("dDocType", "Document");
            //If needed set account , otherwise not necessary
            dataBinder.putLocal("dDocAccount", "");
            dataBinder.putLocal("dSecurityGroup", "Public");
            if(iStream==null) {
            System.out.println("IS is null");
            }
            else {
            System.out.println("IS is not Null");
            }
            // dataBinder.putLocal("xCollectionID" ,"<collection id for folder to be checked in>"); - Incase folder is involved

            //Code changed adding InputStream into the dataBinder as a file
            dataBinder.addFile("primaryFile",new TransferFile(iStream,"Test",getContentLength(iStream));

            dataBinder.putLocal("doFileCopy", "1");
            // Write the data binder for the request to stdout
            serializer.serializeBinder(System.out, dataBinder);
            // Send the request to Content Server
            ServiceResponse response =
            idcClient.sendRequest(userContext, dataBinder);
            // Get the data binder for the response from Content Server
            DataBinder responseData = response.getResponseAsBinder();
            // Write the response data binder to stdout
            serializer.serializeBinder(System.out, responseData);
            } catch (IdcClientException ice) {
            ice.printStackTrace();
            } catch (IOException ioe) {
            ioe.printStackTrace();
            }
            }

            }


            The data got into the iStream is a BLOB object.

            The same error is coming up even then.

            The problem got resolved when I remove the call to getContentLength(inputStream) function and hard code the length.
            Actually the moment I use the inputStream.read() function 'while( (i = is.read(buffer)) > 0)' the inputStream gets Null because of which the error was coming up.

            I am not able to understand why this is happening but when I removed the call to the function then the file got uploaded.
            • 3. Re: SocketTimeoutException:Read timed out error-check in file through RIDC API
              VipinPillai

              I have the similar issue, do anyone got this working - InputStream object in a TransferFile method?

               

              The simple TransferFile method given in Srinath's post, works fine if we test uplaod a doc, in the application server host machine. But when try access the application url from a remote machine, the file path not found exception occurs. Hence I think we have to go for InputStream to TransferFile.

               

              Experts, please comment.