public static function autorun()
    {
        /* @var $classes string[] */
        $classes = array_reverse( get_declared_classes() );

        foreach( $classes as $class )
        {
            $type = new \ReflectionClass( $class );
            $abstract = $type->isAbstract();

            if( is_subclass_of( $class, MRPCJsonWebService::class ) === false || $abstract === true )
            {
                continue;
            }

            /* @var $webService MRPCJsonWebService */
            $webService = new $class();

            // If the definitions are requested
            if( $_SERVER['QUERY_STRING'] == 'definition' )
            {
                $definition = new MRPCJsonWebServiceDefinition( $class );

                $webService->getHttpResponse()->setContentType( ContentType::TEXT_HTML );
                $webService->getHttpResponse()->setOutput( (string)$definition );
            }
            // Normal web service execution
            else
            {
                $webService->getHttpResponse()->setContentType( ContentType::APPLICATION_JSON );

                try
                {
                    $webService->execute( $class );
                    $webService->getResponse()->setId( $webService->getRequest()->getId() );
                } catch( MRPCJsonServerException $ex )
                {
                    $error = new MRPCJsonError();
                    $error->setCode( -1 );
                    $error->setMessage( $ex->getMessage() );

                    $webService->response = new MRPCJsonResponse();
                    $webService->response->setError( $error );
                }

                $webService->getHttpResponse()->setOutput( $webService->getResponse()->toJSON() );
            }

            return $webService;
        }

        return null;
    }
public static function autorun()
    {
        /* @var $classes string[] */
        $classes = array_reverse( get_declared_classes() );

        foreach( $classes as $class )
        {
            $type = new \ReflectionClass( $class );
            $abstract = $type->isAbstract();

            if( is_subclass_of( $class, MRPCJsonWebService::class ) === false || $abstract === true )
            {
                continue;
            }

            /* @var $webService MRPCJsonWebService */
            $webService = new $class();

            // If the definitions are requested
            if( $_SERVER['QUERY_STRING'] == 'definition' )
            {
                $definition = new MRPCJsonWebServiceDefinition( $class );

                $webService->getHttpResponse()->setContentType( ContentType::TEXT_HTML );
                $webService->getHttpResponse()->setOutput( (string)$definition );
            }
            // Normal web service execution
            else
            {
                $webService->getHttpResponse()->setContentType( ContentType::APPLICATION_JSON );

                try
                {
                    $webService->execute( $class );
                    $webService->getResponse()->setId( $webService->getRequest()->getId() );
                } catch( MRPCJsonServerException $ex )
                {
                    $error = new MRPCJsonError();
                    $error->setCode( -1 );
                    $error->setMessage( $ex->getMessage() );

                    $webService->response = new MRPCJsonResponse();
                    $webService->response->setError( $error );
                }

                $webService->getHttpResponse()->setOutput( $webService->getResponse()->toJSON() );
            }

            return $webService;
        }

        return null;
    }
public static function autorun ( ) { /* @var $classes string[] */ $ classes = array_reverse ( get_declared_classes ( ) ) ; foreach ( $ classes as $ class ) { $ type = new \ ReflectionClass ( $ class ) ; $ abstract = $ type -> isAbstract ( ) ; if ( is_subclass_of ( $ class , MRPCJsonWebService :: class ) === false || $ abstract === true ) { continue ; } /* @var $webService MRPCJsonWebService */ $ webService = new $ class ( ) ; // If the definitions are requested if ( $ _SERVER [ 'QUERY_STRING' ] == 'definition' ) { $ definition = new MRPCJsonWebServiceDefinition ( $ class ) ; $ webService -> getHttpResponse ( ) -> setContentType ( ContentType :: TEXT_HTML ) ; $ webService -> getHttpResponse ( ) -> setOutput ( ( string ) $ definition ) ; } // Normal web service execution else { $ webService -> getHttpResponse ( ) -> setContentType ( ContentType :: APPLICATION_JSON ) ; try { $ webService -> execute ( $ class ) ; $ webService -> getResponse ( ) -> setId ( $ webService -> getRequest ( ) -> getId ( ) ) ; } catch ( MRPCJsonServerException $ ex ) { $ error = new MRPCJsonError ( ) ; $ error -> setCode ( - 1 ) ; $ error -> setMessage ( $ ex -> getMessage ( ) ) ; $ webService -> response = new MRPCJsonResponse ( ) ; $ webService -> response -> setError ( $ error ) ; } $ webService -> getHttpResponse ( ) -> setOutput ( $ webService -> getResponse ( ) -> toJSON ( ) ) ; } return $ webService ; } return null ; }
Run the instance of the web service.
Run the instance of the web service .