Skip to Content
0
Former Member
May 29, 2008 at 10:08 AM

Problem pushing XML as DataSource to report

149 Views

Post Author: biiz

CA Forum: JAVA

Hello!

I have a report which uses xml and xsd as datasource. I have now the requirement to dynamically set the xml-data into the report.

I do this via reportClientDocument.getDatabaseController().setDataSource(xml_ds, "ObjectSpace", "") but I receive following exception although data in xml_ds is not null:

Error occured: com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException: The data source object cannot be null.---- Error code:-2147024809 Error code name:failed

The ReportClientDocument is retrieved from Crystal Report Server XI R2 .

In crystalras log I have found following error-msg: ErrorLog 2008 5 29 10:56:40.784 1992 828 (\servers\ras\dtsagent\cdtsagent.cpp:3177): CDTSagent::doOneRequest reqId=272: CSResultException thrown. ErrorSrc:"Analysis Server" FileName:"\servers\ras\dtsagent\reporthandler.cpp" LineNum:16948 ErrorCode:-2147024809 ErrorMsg:"The data source object cannot be null." DetailedErrorMsg:""

Can you please help me?

Regards,

Gerald Spitzer

Here is my code:

CrystalEnterprise objCE = new CrystalEnterprise(); ISessionMgr objCESessionMgr = objCE.getSessionMgr(); objCESession = objCESessionMgr.logon("Administrator", "", this.getServletContext().getInitParameter("RAS"), "secEnterprise"); objTokenMgr = objCESession.getLogonTokenMgr(); cstrLogonToken = objTokenMgr.createLogonToken("", 60, 500);

IInfoStore objInfoStore = (IInfoStore) objCESession.getService("InfoStore");

java.lang.String cstrStatement;

cstrStatement = ""; cstrStatement = cstrStatement + "SELECT SI_ID, SI_NAME"; cstrStatement = cstrStatement + " FROM CI_INFOOBJECTS"; cstrStatement = cstrStatement + " WHERE SI_NAME = '" + reportName + "'"; cstrStatement = cstrStatement + " AND SI_INSTANCE = 0";

IInfoObjects objInfoObjects = objInfoStore.query(cstrStatement);

if (objInfoObjects.getResultSize() > 0) {

IInfoObject objInfoObject = (IInfoObject) objInfoObjects.get(0);

IReportAppFactory objRASFactory = (IReportAppFactory) objCESession.getService("", "RASReportFactory"); ReportClientDocument objReport = (ReportClientDocument) objRASFactory.openDocument(objInfoObject,0,java.util.Locale.ENGLISH);

FileInputStream fin = new FileInputStream("C:
fragebogen_dokument_ohneADesc.xsd"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte&#91;&#93; bytes = new byte&#91;1024&#93;; for(;;) { int count = fin.read(bytes); if(count < 0) break; baos.write(bytes, 0, count); } final byte&#91;&#93; xsdBytes = baos.toByteArray(); fin.close(); fin = new FileInputStream("C:
fragebogen_dokument_ohneADesc.xml"); baos = new ByteArrayOutputStream(); bytes = new byte&#91;1024&#93;; for(;;) { int count = fin.read(bytes); if(count < 0) break; baos.write(bytes, 0, count); } final byte&#91;&#93; xmlBytes = baos.toByteArray(); fin.close();

IXMLDataSet xml_ds = new IXMLDataSet() { private IByteArray xmlData = null; public void setXMLData(IByteArray xmlData) { this.xmlData = xmlData; } public IByteArray getXMLData() { return this.xmlData; } private IByteArray xmlSchema = null; public void setXMLSchema(IByteArray xmlSchema){ this.xmlSchema = xmlSchema; } public IByteArray getXMLSchema() { return this.xmlSchema; } };

xml_ds.setXMLData(new IByteArray() { public void fromString(String arrayValue){} public String toString() { return ""; } public byte&#91;&#93; getBytes() { return xmlBytes; } });

xml_ds.setXMLSchema(new IByteArray() { public void fromString(String arrayValue){} public String toString() { return ""; } public byte&#91;&#93; getBytes() { return xsdBytes; } });

System.out.println("####bytes.length" + xml_ds.getXMLData().getBytes().length);

objReport.getDatabaseController().setDataSource(xml_ds, "ObjectSpace", "");