cancel
Showing results for 
Search instead for 
Did you mean: 

VS.Net working example of Web Services in Crystal Server 2008?

Former Member
0 Kudos

I've been beating my head against the wall trying to figure this out but to no avail.

Summary: I have a Crystal Reports 2008 Report with two parameters reporting on a SQL 2005 express database in a Crystal Reports Server 2008. The report works fine when I execute it in Crystal Reports 2008 and in Crystal Reports Server 2008. When I try to access it in Crystal Reports Server 2008 from a VS 2005 project using a web service I get an parameter error. It seems to work fine if parameters are suppressed.

I've setup up 3 machines with XP SP3.

Machine 1:

Crystal Reports Server 2008 (default install with enterprise logon)

Machine 2:

Crystal Reports 2008

Machine 3

VS2005 SP1

SQL2005 Express (latest sp)

I've created a table TestTable (TestTableID int, TestTableName nvarchar(200))

I've created a stored procedure called TestGet(Select TestTableID, TestTableName From TestTable Where TestID = @intTestID)

I've created a report on Machine 2 using OLEDB to connect to Machine 3.

I've uploaded the report to the Crystal Report Server 2008 and modified the database logon so it doesn't prompt me.

The report works in Crystal Reports 2008 and Crystal Reports Server 2008.

The report has two parameters. (TestID and DummyParam1)

I've created a new web site in VS2005.

I added:

BusinessObjects.DSWS.BICatalog.dll

BusinessObjects.DSWS.BIPlatform.dll

BusinessObjects.DSWS.dll

BusinessObjects.DSWS.LiveOffice.dll

BusinessObjects.DSWS.Publish.dll

BusinessObjects.DSWS.QueryService.dll

BusinessObjects.DSWS.ReportEngine.dll

BusinessObjects.DSWS.SaveService.dll

BusinessObjects.DSWS.Session.dll

All files have a File Version of 12.0.2000.683

I'm using code from Ted Ueda (Thanks Ted) and modified it for my own use:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BusinessObjects.DSWS;
using BusinessObjects.DataSource;
using BusinessObjects.Query;
using BusinessObjects.DSWS.Session;
using BusinessObjects.DSWS.BIPlatform;
using BusinessObjects.DSWS.ReportEngine;
using BusinessObjects.DSWS.BIPlatform.Constants;


public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

        // Document path
        //string crPath = FixedPaths.InfoObjects.ROOT_FOLDER + "/302782727/302782727_sp@SI_ID";
        string crPath = "path://InfoObjects/Root Folder/WWE Reports/CR2008_OLEDB_test_SP2_nodata";
        // Enterprise Web Services URL and Login Credentials.
        //string boSessionURL = "http://tueda-bexir2s2:8080/dswsbobje/services/session";
        string boSessionURL = "http://192.168.1.146:8080/dswsbobje/services/Session";

        //string boCMSName = "TUEDA-BEXIR2S2";
        string boCMSName = "myorgani-1cf481";
                            
        string boAuthType = "secEnterprise";
        string boUsername = "Administrator";
        //string boPassword = "";
        string boPassword = "myDatabase";

        Session boSession = null;
        try
        {

            // Logon to Enterprise

            EnterpriseCredential boCredential = new EnterpriseCredential();
            boCredential.Domain = boCMSName;
            boCredential.AuthType = boAuthType;
            boCredential.Login = boUsername;
            boCredential.Password = boPassword;

            boSession = new Session(new Connection(boSessionURL));
            boSession.Login(boCredential);

            // Retrieve Document CUID

            BIPlatform biPlatform
                = BIPlatform.GetInstance(boSession, boSession.GetAssociatedServicesURL("BIPlatform")[0]);

            ResponseHolder rh = biPlatform.Get(crPath, null);

            string doc_cuid = rh.InfoObjects.InfoObject[0].CUID;

            // Retrieve ReportEngine service.

            ReportEngine reportEngine
                = ReportEngine.GetInstance(boSession, boSession.GetAssociatedServicesURL("ReportEngine")[0]);

            // Refresh document and retrieve the prompts.

            RetrieveMustFillInfo retrieveInfo = new RetrieveMustFillInfo();
            retrieveInfo.RetrievePromptsInfo = new RetrievePromptsInfo();

            DocumentInformation doc
                    = reportEngine.GetDocumentInformation(doc_cuid, null, new Action[] { new Refresh() }, null, null);
            string docRef = doc.DocumentReference;


            doc = reportEngine.GetDocumentInformation(docRef, retrieveInfo, null, null, null);
            docRef = doc.DocumentReference;

            int promptCount = doc.PromptInfo == null ? 0 : doc.PromptInfo.Length;

            FillPrompt[] fillPromptList = new FillPrompt[promptCount];

            int i = 0;
            foreach (PromptInfo promptInfo in doc.PromptInfo)
            {
                fillPromptList<i> = new FillPrompt();
                fillPromptList<i>.ID = promptInfo.ID;

                DiscretePromptValue dvalue1, dvalue2;

                dvalue1 = new DiscretePromptValue();
                dvalue1.Value = "5";
                fillPromptList<i>.Values = new PromptValue[] { dvalue1 };
                i++;
                Response.Write(promptInfo.ID + "<BR>");
            }

            FillPrompts fillPrompts = new FillPrompts();
            fillPrompts.FillPromptList = fillPromptList;

            doc = reportEngine.GetDocumentInformation(docRef, null, new Action[] { fillPrompts }, null, null);
            docRef = doc.DocumentReference;

            retrieveInfo = new RetrieveMustFillInfo();
            retrieveInfo.RetrieveDBLogonInfo = new RetrieveDBLogonInfo();

            doc = reportEngine.GetDocumentInformation(docRef, retrieveInfo, null, null, null);
            docRef = doc.DocumentReference;

            DBLogonInfo[] dbLogonInfos = doc.DBLogonInfos;

            FillDBLogon[] dbLogon = new FillDBLogon[1];
            dbLogon[0] = new FillDBLogon();
            dbLogon[0].Name = dbLogonInfos[0].Name;
            dbLogon[0].UserName = "vantech";
            dbLogon[0].Password = "vantech";


            FillDBLogons dbLogons = new FillDBLogons();
            dbLogons.FillDBLogonList = dbLogon;

            doc = reportEngine.GetDocumentInformation(docRef, null, new Action[] { dbLogons } , null, null);
            docRef = doc.DocumentReference;

            RetrieveData retrieveData = new RetrieveData();
            RetrieveView retrieveView = new RetrieveView();

            ViewSupport viewSupport = new ViewSupport();
            viewSupport.OutputFormat = OutputFormatType.HTML;
            viewSupport.ViewType = ViewType.CHARACTER;
            viewSupport.ViewMode = ViewModeType.REPORT_PAGE;

            retrieveView.ViewSupport = viewSupport;
            retrieveData.RetrieveView = retrieveView;

            doc = reportEngine.GetDocumentInformation(docRef, null, null, null, retrieveData);
            docRef = doc.DocumentReference;
            String content = ((CharacterView)doc.View).Content;

            // Close document connection.
            doc = reportEngine.GetDocumentInformation(docRef, null, new Action[] { new Close() }, null, null);

            // Output view to web browser.
            Response.Write(content);



        }
        catch (DSWSException ex)
        { Console.WriteLine(ex); }
        finally
        {

            if (boSession != null)
                boSession.Logout();

        }

    }

}

When I run it I get an error at the line:

doc = reportEngine.GetDocumentInformation(docRef, retrieveInfo, null, null, null);

With the error:

{"Failed to retrieve database logon info. Information is needed before this report can be processed. (WRE 02517)"}
    base {System.Exception}: {"Failed to retrieve database logon info. Information is needed before this report can be processed. (WRE 02517)"}
    CallStackTrace: "com.crystaldecisions.sdk.occa.report.lib.ReportSDKParameterFieldException: Information is needed before this report can be processed.---- Error code:-2147213303 Error code name:invalidParameterField\n\tat com.crystaldecisions.sdk.occa.report.lib.ReportSDKParameterFieldException.throwReportSDKParameterFieldException(Unknown Source)\n\tat com.crystaldecisions.sdk.occa.managedreports.ps.internal.f.a(Unknown Source)\n\tat com.crystaldecisions.sdk.occa.managedreports.ps.internal.f.getPromptDatabaseLogOnInfos(Unknown Source)\n\tat com.businessobjects.dsws.wsc.reportengine.Report.getDBLogonsInfo(Unknown Source)\n\tat com.businessobjects.dsws.wsc.reportengine.DocumentAgent.handleRetrieveMustFillInfo(Unknown Source)\n\tat com.businessobjects.dsws.wsc.reportengine.DocumentAgent.handleActions(Unknown Source)\n\tat com.businessobjects.dsws.wsc.reportengine.CrystalReportEngineSoapImpl.getDocumentInformation(Unknown Source)\n\tat com.businessobjects.dsws.reportengine.ReportEngineSoapImpl.getDocumentInfo
rmation(Unknown Source)\n\tat com.businessobjects.dsws.reportengine.ReportEngineSkeleton.getDocumentInformationByMTOM(Unknown Source)\n\tat com.businessobjects.dsws.reportengine.ReportEngineMessageReceiverInOut.invokeBusinessLogic(Unknown Source)\n\tat org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:42)\n\tat org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:96)\n\tat org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)\n\tat org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)\n\tat org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:709)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:802)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)\n\tat org.apache.catalina.core.ApplicationFilterChain.do
Filter(ApplicationFilterChain.java:173)\n\tat com.businessobjects.dsws.wsc.common.axis.FlashFilter.doFilter(Unknown Source)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)\n\tat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)\n\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)\n\tat org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)\n\tat org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11Base
Protocol.java:664)\n\tat org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)\n\tat org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)\n\tat org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)\n\tat java.lang.Thread.run(Thread.java:595)\n"
    CauseDetail: "Information is needed before this report can be processed."
    CauseException: "com.crystaldecisions.sdk.occa.report.lib.ReportSDKParameterFieldException"
    CauseID: null
    CauseMessage: "Information is needed before this report can be processed."
    ID: "2517"
    Message: "Failed to retrieve database logon info. Information is needed before this report can be processed. (WRE 02517)"
    Operation: "reportengine.dsws.businessobjects.com/getDocumentInformation"
    WebServiceID: ""
	

I've tried several variations of this and I don't think I'm doing anything too exotic so... does anyone have an example of this working? It seems to work if I don't put any parameters in but it dies when I do.

Any help would be hugely appreciated.

Thanks in advance,

j

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Hello, Jason;

Just to confirm what Tom has said, Crystal Reports Server XI R3.0 (12.0.0.683) is the only release at the moment.

It has no Visual Studio .NET SDK and can only be used with .NET through Web Services as you are doing. It appears that Stored Procedure parameters or Command parameters do fail.

I have it working with Business Objects Enterprise XI R3.1, the updated Web Services .dlls (12.1.2000.882) and the code you see.

Crystal Reports XI R3.1 has not been released yet.

The options are:

u2022 Create a data connection that does not need a Stored Procedure or Command parameter.

u2022 Use Crystal Reports .NET SDK directly to create your web application and not Crystal

Reports Server.

u2022 Fall back to Crystal Reports Server XI R2 (11.5)

u2022 Wait for Crystal Reports Server XI R3.1 (12.1.0.882)

I will post any new information as I find it.

Elaine

Former Member
0 Kudos

Jason,

Just to clarify, the code that Elaine posted seems to work if you have SP1 for BOE or Cyrstal Reports Server. However, if you are like me and only bought Crystal Reports Server (not BOE), then you will have to wait until the specific CRS SP1 update comes out. Unfortunately, this doesn't have an actual release date yet which makes it anyone's guess how long we would have to wait. My next step is to attempt to downgrade to CRS XI to see if I can get it working correctly with that.

Former Member
0 Kudos

Hello, Jason;

We have finished testing and have the following code working with Crystal Reports Server XI 3.1 SP 1 (File version 12.1.0.882)

There is an array of 3 action properties.

There is a "RetrieveMustFillInfo" added for the Database credentials.

Parameters must be set before the Database logon

Let me know what you find.

Elaine

========================================

Imports BusinessObjects.DSWS

Imports BusinessObjects.DSWS.BIPlatform

Imports BusinessObjects.DSWS.BIPlatform.Constants

Imports BusinessObjects.DSWS.BIPlatform.Desktop

Imports BusinessObjects.DSWS.ReportEngine

Imports BusinessObjects.DSWS.Session

Imports System

Imports System.Data

Imports System.Configuration

Imports System.Web

Imports System.Web.Security

Imports System.Web.UI

Imports System.Web.UI.WebControls

Imports System.Web.UI.WebControls.WebParts

Imports System.Web.UI.HtmlControls

Partial Class _Default

Inherits System.Web.UI.Page

' Modify the variables here to reflect the environment

' CMS-specific parameters

Private CMS_USER As String = "Administrator"

Private CMS_USER_PASSWORD As String = "cmsPassword"

Private CMS_CLUSTER_NAME As String = String.Empty

Private CMS_AUTHENTICATION As String = String.Empty

' Web Services URLs

Private WS_BASE_URL As String = "http://localhost:8080/dswsbobje/services/"

Private WS_URL_SESSION As String = WS_BASE_URL + "Session"

Private WS_URL_REPORTENGINE As String = WS_BASE_URL + "reportengine"

Private WS_URL_BIPLATFORM As String = WS_BASE_URL + "biplatform"

' Name of the report to be viewed

Private REPORT_NAME As String = "SQL_StoredProc.rpt"

'Database Logon properties

Private USER_NAME As String = "vantech"

Private USER_PASSWORD As String = "vantech"

Private bipService As BIPlatform

Private boRepEng As ReportEngine

Private wSession As Session

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

ConfigureCrystalReports()

End Sub

Private Sub ConfigureCrystalReports()

' The following sample code demonstrates how to view a report using the Web Services BIPlatform and \

' Report Engine services.

' Just running the following code will enable you to view a simple report with no additional options.

' Include the commented blocks of code to view reports with different viewing options:

' - View a report in PDF format

' - View a report with database logon information

' - View a report with discrete parameters

' Note: You may have to change some parts of the code to make the special viewing options work.

Logon()

ViewReport()

End Sub

Private Sub Logon()

Dim wSession As BusinessObjects.DSWS.Session.Session

Try

Dim boConnection As BusinessObjects.DSWS.Connection = New BusinessObjects.DSWS.Connection(WS_URL_SESSION)

' login to BusinessObjects Enterprise using web services

Console.WriteLine("Logging into web service...")

Dim credential As New EnterpriseCredential

credential.Login = CMS_USER

credential.Password = CMS_USER_PASSWORD

credential.Domain = CMS_CLUSTER_NAME

credential.AuthType = CMS_AUTHENTICATION

wSession = New BusinessObjects.DSWS.Session.Session(boConnection)

wSession.Login(credential)

Console.WriteLine("Logged into web service.")

boConnection.URL = WS_URL_BIPLATFORM

bipService = New BIPlatform(boConnection, wSession.ConnectionState)

boConnection.URL = WS_URL_REPORTENGINE

boRepEng = New ReportEngine(boConnection, wSession.ConnectionState)

Session("Platform") = bipService

Session("ReportEngine") = boRepEng

Catch ex As DSWSException

Console.Error.WriteLine(ex)

Console.Error.WriteLine(ex.CauseDetail)

Throw

End Try

End Sub

Private Sub ViewReport()

Try

Dim reportRH As ResponseHolder = bipService.Get("path://InfoObjects/Root Folder/**/" + REPORT_NAME, Nothing)

Dim infoobjects As InfoObjects = reportRH.InfoObjects

If (Nothing Is infoobjects) Then

Return

End If

Dim repID As String = infoobjects.InfoObject(0).CUID

'****NOTE: This is the first RetrieveMustFillInfo used for the parameter information

Dim boMustFill As RetrieveMustFillInfo = New RetrieveMustFillInfo

boMustFill.RetrievePromptsInfo = New RetrievePromptsInfo

Dim oActions(0 To 2) As Action

oActions(0) = New Refresh

Dim boDocInfo As DocumentInformation = boRepEng.GetDocumentInformation(repID, boMustFill, oActions, Nothing, Nothing)

Dim objViewSupport As ViewSupport = New ViewSupport

objViewSupport.ViewMode = ViewModeType.REPORT_PAGE

objViewSupport.ViewType = ViewType.CHARACTER

objViewSupport.OutputFormat = OutputFormatType.HTML

Dim objRetrieveCharacterView As RetrieveCharacterView = New RetrieveCharacterView

objRetrieveCharacterView.ViewSupport = objViewSupport

'Use this code instead of the above to view the report in PDF format

'***********************************************************************'

'Dim objViewSupport As ViewSupport = New ViewSupport

'objViewSupport.ViewMode = ViewModeType.DOCUMENT

'objViewSupport.ViewType = ViewType.BINARY

'objViewSupport.OutputFormat = OutputFormatType.PDF

'Dim objRetrieveBinaryView As RetrieveBinaryView = New RetrieveBinaryView

'objRetrieveBinaryView.ViewSupport = objViewSupport

'***********************************************************************'

' Include this code to view a report with discrete parameters

' Make sure the parameter code is run before the database code

'***********************************************************************'

Dim oPromptInfos() As PromptInfo = boDocInfo.PromptInfo

Dim myPrompt As PromptInfo = oPromptInfos(0)

Dim FillPrompts As New FillPrompts()

Dim fillPromptList(0) As FillPrompt

fillPromptList(0) = New FillPrompt()

fillPromptList(0).ID = myPrompt.ID

Dim dPromptValues(0) As DiscretePromptValue

dPromptValues(0) = New DiscretePromptValue()

dPromptValues(0).Value = "ANTON"

fillPromptList(0).Values = dPromptValues

FillPrompts.FillPromptList = fillPromptList

oActions(1) = FillPrompts

'***********************************************************************'

' Include this code to view a report that requires database logon information

'***********************************************************************'

'****NOTE: This is the second RetrieveMustFillInfo used for the database information

'Without this the logon in the case of Stored Procedure Parameters will not work

Dim boMustFilldb As New RetrieveMustFillInfo

boMustFilldb.RetrieveDBLogonInfo = New RetrieveDBLogonInfo()

boDocInfo = boRepEng.GetDocumentInformation(repID, boMustFilldb, oActions, Nothing, Nothing)

'get the name of the connection

Dim dbLogonInfo() As DBLogonInfo = boDocInfo.DBLogonInfos

Dim cnnName As String = dbLogonInfo(0).Name

'fill DBLogon properties

Dim oFillDBLogons As New FillDBLogons

Dim oFillDBLogon(0) As FillDBLogon

oFillDBLogon(0) = New FillDBLogon()

oFillDBLogon(0).UserName = USER_NAME

oFillDBLogon(0).Password = USER_PASSWORD

'setting the connection is important to identify whether

'you're setting the connection for the main report or subreports

oFillDBLogon(0).Name = cnnName

oFillDBLogons.FillDBLogonList = oFillDBLogon

oActions(2) = oFillDBLogons

'***********************************************************************

Dim boCallOpt(0 To 0) As CallbackOption

Dim boImgMan As ImageManagement = New ImageManagement

boImgMan.CallbackScript = "getImage.aspx"

boImgMan.ImageManagementHolder = "imageName"

boImgMan.DocumentReferenceHolder = "docRef"

boCallOpt(0) = boImgMan

Dim retBOData As RetrieveData = New RetrieveData

objRetrieveCharacterView.CallbackOption = boCallOpt

retBOData.RetrieveView = objRetrieveCharacterView

boDocInfo = boRepEng.GetDocumentInformation(boDocInfo.DocumentReference, Nothing, oActions, Nothing, retBOData)

Dim myBOView As CharacterView = boDocInfo.View

Dim docContents As String = myBOView.Content

Response.Write(docContents)

'Use this code instead of the above to view the report in PDF format

'***********************************************************************'

'Dim strToken As String = boDocInfo.DocumentReference

'Dim myBOView As BinaryView = boDocInfo.View

'Dim docContents = myBOView.Content

'Response.Clear()

'Response.AddHeader("content-disposition", "inlinefilename=" + REPORT_NAME + ".pdf")

'Response.ContentType = "application/pdf"

'Response.BinaryWrite(docContents)

'Response.End()

'***********************************************************************'

Catch ex As DSWSException

Console.Error.WriteLine(ex)

Console.Error.WriteLine(ex.CauseDetail)

Throw

Finally

If Not wSession Is Nothing Then

wSession.Logout()

End If

Console.Write("Press the [ENTER] key to terminate program.")

End Try

End Sub

End Class

========================================

Former Member
0 Kudos

Extraordinary! I have taken almost a day to find this. That's the only code that will help in case of parameters and DBLogonInfo!

Former Member
0 Kudos

This issue is being looked at in another thread:

[Click here|;

Former Member
0 Kudos

Elaine, Jason,

Did you resolve this problem? I've got the exact same issue.

I'm using the latest Crystal Reports 2008 (sp1) and Crystal Reports Server 2008.

(Jason, sorry ... I also replied to another post of yours seeking information on this.)

Any pointers to a solution is appreciated ...

Thanks,

GR

Former Member
0 Kudos

Hello, Jason;

Web Services require the order you have set. There was a known issue with the order being set but it has been resolved. Do you have any updates with Crystal Reports Server 2008 and Crystal Reports 2008?

As a test, if you run a report that has no parameters and logs on to the same database, does it succeed?

I am going to look into this further.

Elaine

Former Member
0 Kudos

Hello, Jason;

Test passing the logon to the database before you pass the parameters to the report. It may be an issue of what order the Web Services are looking for that information.

Elaine