Today i faced issue testing GET_FILE from Generic Soap Port so i tried using RIDC and working fine.
So just though of putting here the sample code
:
package ucm;
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;
/*
* This is a class used to test the basic functionality
* of retrieving a file from Content Server.
*/
public class TestRIDCGetFile {
public static void main(String[] args) {
// Create a new IdcClientManager
IdcClientManager manager = new IdcClientManager();
try {
// Create a new IdcClient Connection using idc protocol (i.e. socket connection to Content Server)
IdcClient idcClient = manager.createClient("idc://localhost:4444");
// Create new context using the 'sysadmin' user
IdcContext userContext = new IdcContext("sysadmin");
// 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());
//IdcContext userContext = new IdcContext("weblogic", "Welcome1");
HdaBinderSerializer serializer = new HdaBinderSerializer ("UTF-8", idcClient.getDataFactory ());
// Databinder for checkin request
DataBinder dataBinder = idcClient.createBinder();
dataBinder.putLocal("IdcService", "GET_FILE");
dataBinder.putLocal("dID", "664");
dataBinder.putLocal("dDocName", "TRANING000660");
dataBinder.putLocal("allowInterrupt", "1");
serializer.serializeBinder(System.out, dataBinder);
// Create an output stream to output the file received
FileOutputStream fos = new FileOutputStream("test.txt");
// Send the request to Content Server
ServiceResponse response =
idcClient.sendRequest(userContext, dataBinder);
// Create an input stream from the response
InputStream fis = response.getResponseStream();
// Read the data in 1KB chunks and write it to the file
byte[] readData = new byte[1024];
int i = fis.read(readData);
while (i != -1) {
fos.write(readData, 0, i);
i = fis.read(readData);
}
// Close the socket connection
response.close();
// Don't leave the streams open
fos.close();
fis.close();
} catch (IdcClientException ice) {
ice.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
Thanks
So just though of putting here the sample code
:
package ucm;
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;
/*
* This is a class used to test the basic functionality
* of retrieving a file from Content Server.
*/
public class TestRIDCGetFile {
public static void main(String[] args) {
// Create a new IdcClientManager
IdcClientManager manager = new IdcClientManager();
try {
// Create a new IdcClient Connection using idc protocol (i.e. socket connection to Content Server)
IdcClient idcClient = manager.createClient("idc://localhost:4444");
// Create new context using the 'sysadmin' user
IdcContext userContext = new IdcContext("sysadmin");
// 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());
//IdcContext userContext = new IdcContext("weblogic", "Welcome1");
HdaBinderSerializer serializer = new HdaBinderSerializer ("UTF-8", idcClient.getDataFactory ());
// Databinder for checkin request
DataBinder dataBinder = idcClient.createBinder();
dataBinder.putLocal("IdcService", "GET_FILE");
dataBinder.putLocal("dID", "664");
dataBinder.putLocal("dDocName", "TRANING000660");
dataBinder.putLocal("allowInterrupt", "1");
serializer.serializeBinder(System.out, dataBinder);
// Create an output stream to output the file received
FileOutputStream fos = new FileOutputStream("test.txt");
// Send the request to Content Server
ServiceResponse response =
idcClient.sendRequest(userContext, dataBinder);
// Create an input stream from the response
InputStream fis = response.getResponseStream();
// Read the data in 1KB chunks and write it to the file
byte[] readData = new byte[1024];
int i = fis.read(readData);
while (i != -1) {
fos.write(readData, 0, i);
i = fis.read(readData);
}
// Close the socket connection
response.close();
// Don't leave the streams open
fos.close();
fis.close();
} catch (IdcClientException ice) {
ice.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
Thanks
Hey,
ReplyDeleteHow to get the zip file using this?