Jump to content

Help needed in configuring PHP to call SQL Server Reports


Recommended Posts

Hello 
I am using SQL Server 2008 and Xampp server for PHP. I am trying to call SQL Server reports from PHP and I am using the code from https://ssrsphp.codeplex.com/discussions/577518#

 

I can call the URL which connects to the Reports server from PHP but when I try to click the dropdown and run the reports I get an error. 

Fatal error: Class 'PReportException' not found in E:\PHP_SRS\ssrsphp\Factory\SSRSTypeFactory.php on line 75 


Can someone please tell me how to fix this error ? 

Thanks

The developer should fix this.

 

Taking a wild guess that they are calling the class PReportException when should be calling SSRSReportException

 

I looked fast through the source code.

 

sample hello world

require_once 'SSRSReport.php';

 

catch(SSRSReportException $serviceExcprion)
{
    echo  $serviceExcprion->GetErrorMessage();
}

 

 

SSRSReport/bin/SSRSReport.php

require_once 'SSRSReportException.php';

 

class SSRSReportException extends Exception
{

 

 

 

But in \Factory\SSRSTypeFactory.php all throughout code is this

 

throw new PReportException(

 

 

Try using this SSRSTypeFactory.php file

<?php
/**
  *
  * Copyright (c) 2009, Persistent Systems Limited
  *
  * Redistribution and use, with or without modification, are permitted
  *  provided that the following  conditions are met:
  *   - Redistributions of source code must retain the above copyright notice,
  *     this list of conditions and the following disclaimer.
  *   - Neither the name of Persistent Systems Limited nor the names of its contributors
  *     may be used to endorse or promote products derived from this software
  *     without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

/**
  *
  * class SSRSTypeFactory
  */
class SSRSTypeFactory
{
    /**
     *
     * @var array
     */
    private static $SSRSTypes = array();
    
    /**
     *
     * @var array
     */
    private static $SSRSEnums = array();

    /**
     * To register a SSRS type with factory
     * @param string $ssrsType
     */
    public static function RegsiterType($ssrsType)
    {
        $class = new ReflectionClass($ssrsType);
        if (! $class->implementsInterface('ISSRSBaseType'))
        {
            throw new SSRSReportException("",
                "Only classes which implements 'ISSRSBaseType' " .
                "can be registered with SSRSTypeFactory");
        }       

        self::$SSRSTypes[$ssrsType] = $ssrsType; 
    }

    /**
     * To register an ssrs enum with factory
     * @param string $ssrsEnum
     */
    public static function RegisterEnum($ssrsEnum)
    {
        self::$SSRSEnums[$ssrsEnum] = $ssrsEnum;
    }

    public static function CreateSSRSObject($ssrsType, $stdObject)
    {
        if (!array_key_exists($ssrsType, self::$SSRSTypes))
        {
            throw new SSRSReportException("",
                                       "Requested SSRS Type $ssrsType is not Registered!");
        }

        $class = new ReflectionClass($ssrsType);
        $object = $class->newInstance();
        $object->FromStdObject($stdObject);
        return $object;
    }

    /**
     * To get the generic type of a type (basic or ssrs)
     * @param string $type
     * @return string
     */
    public static function GetType($type)
    {
        $retType = 'unknown';

        if($type == 'bool' || $type == 'int' ||
           $type == 'DateTime' || $type == 'string' ||
           $type == 'double')
       {
            $retType = 'basic';
       }
       else if(array_key_exists($type, self::$SSRSTypes) ||
               array_key_exists($type, self::$SSRSEnums)
       )
       {
            $retType = 'ssrs';
       }
       return $retType;
    }
}
?>

Edited by QuickOldCar
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.