error 500 calling rpc.pl

Leonardo Certuche <[email protected]>
Newsgroups gmane.comp.otrs.devel
Message-ID <[email protected]>
Hello there!

We're currently developing an extension to the OTRS API that will allow us
to create/modify/link OTRS configuration items using calls made from
third-party applications. In order to avoid starting from scratch we decided
to first try to adopt the current API to our needs, attached are the two
files involved:

rpc.pl has some useful SOAP methods that we'd like to imitate in order to
have available new methods related to the Kernel::System::GeneralCatalog
class, but when we add the new line to instance that object:

$CommonObject{GeneralCatalogObject} =
Kernel::System::GeneralCatalog->new(%CommonObject);

We get error 500.

We're currently consuming the services exposed by default on rpc.pl and they
work flawlessly. It's only when the mentioned line is added that error 500
occurs.

What changes should we make to Kernel::System::GeneralCatalog in order to
use it as a SOAP service?

Thanks in advance for your help,

Leonardo Certuche
www.itconsultores.com.co
Medellín, Colombia

---------------------------------------------------------------------
OTRS mailing list: dev - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/dev
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/dev
rpc.pl (application/x-perl, 4.2 KB)
#!/usr/bin/perl -w
# --
# bin/cgi-bin/rpc.pl - soap handle
# Copyright (C) 2001-2009 OTRS AG, http://otrs.org/
# --
# $Id: rpc.pl,v 1.14 2009/06/29 21:25:56 martin Exp $
# --
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU AFFERO General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# or see http://www.gnu.org/licenses/agpl.txt.
# --

use strict;
use warnings;

# use ../../ as lib location
use FindBin qw($Bin);
use lib "$Bin/../..";
use lib "$Bin/../../Kernel/cpan-lib";

use SOAP::Transport::HTTP; 
use Kernel::Config; 
use Kernel::System::Encode;
use Kernel::System::Log;
use Kernel::System::DB;
use Kernel::System::PID;
use Kernel::System::Main;
use Kernel::System::Time;
use Kernel::System::User;
use Kernel::System::Group;
use Kernel::System::Queue; 
use Kernel::System::CustomerUser;
use Kernel::System::Ticket;
use Kernel::System::LinkObject;
use Kernel::System::GeneralCatalog;

use vars qw($VERSION);
$VERSION = qw($Revision: 1.14 $) [1];

SOAP::Transport::HTTP::CGI->dispatch_to('Core')->handle;

package Core;

sub new {
    my $Self = shift;

    my $Class = ref($Self) || $Self;
    bless {} => $Class;

    return $Self;
}

sub Dispatch {
    my ( $Self, $User, $Pw, $Object, $Method, %Param ) = @_;

    $User ||= '';
    $Pw   ||= '';

    # common objects
    my %CommonObject = ();
    $CommonObject{ConfigObject} = Kernel::Config->new();
    $CommonObject{EncodeObject} = Kernel::System::Encode->new(%CommonObject);
    $CommonObject{LogObject}    = Kernel::System::Log->new(
        LogPrefix => 'OTRS-RPC',
        %CommonObject,
    );
    $CommonObject{MainObject}         = Kernel::System::Main->new(%CommonObject);
    $CommonObject{DBObject}           = Kernel::System::DB->new(%CommonObject);
    $CommonObject{PIDObject}          = Kernel::System::PID->new(%CommonObject);
    $CommonObject{TimeObject}         = Kernel::System::Time->new(%CommonObject);
    $CommonObject{UserObject}         = Kernel::System::User->new(%CommonObject);
    $CommonObject{GroupObject}        = Kernel::System::Group->new(%CommonObject);
    $CommonObject{QueueObject}        = Kernel::System::Queue->new(%CommonObject);
    $CommonObject{CustomerUserObject} = Kernel::System::CustomerUser->new(%CommonObject);
    $CommonObject{TicketObject}       = Kernel::System::Ticket->new(%CommonObject);
    $CommonObject{LinkObject}         = Kernel::System::LinkObject->new(%CommonObject);
    # this line get the 500 server error 
    $CommonObject{GeneralCatalogObject}         = Kernel::System::GeneralCatalog->new(%CommonObject);

    my $RequiredUser     = $CommonObject{ConfigObject}->Get('SOAP::User');
    my $RequiredPassword = $CommonObject{ConfigObject}->Get('SOAP::Password');

    if (
        !defined $RequiredUser
        || !length $RequiredUser
        || !defined $RequiredPassword || !length $RequiredPassword
        )
    {
        $CommonObject{LogObject}->Log(
            Priority => 'notice',
            Message  => "SOAP::User or SOAP::Password is empty, SOAP access denied!",
        );
        return;
    }

    if ( $User ne $RequiredUser || $Pw ne $RequiredPassword ) {
        $CommonObject{LogObject}->Log(
            Priority => 'notice',
            Message  => "Auth for user $User (pw $Pw) failed!",
        );
        return;
    }

    if ( !$CommonObject{$Object} ) {
        $CommonObject{LogObject}->Log(
            Priority => 'error',
            Message  => "No such Object $Object!",
        );
        return "No such Object $Object!";
    }

    return $CommonObject{$Object}->$Method(%Param);
}

1;
TestITSM.pl (application/x-perl, 1.4 KB)
#!/bin/perl -w
# --
# scripts/rpc-example.pl - soap example client
# Copyright (C) 2001-2009 OTRS AG, http://otrs.org/
# --
# $Id: rpc-example.pl,v 1.7 2009/12/22 11:19:52 mb Exp $
# --
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU AFFERO General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# or see http://www.gnu.org/licenses/agpl.txt.
# --

use strict;
use warnings;

my $Debug = 1;

# config
use SOAP::Lite( 'autodispatch', proxy => 'http://192.168.0.11/otrs/rpc.pl' );
my $User = 'some_user';
my $Pw   = 'some_pass';

my $RPC = Core->new();

my %stateList = $RPC->Dispatch( $User, $Pw, 'LinkObject', 'TypeList', UserID => 47 );

print "size of hash:  " . keys( %stateList ) . ".\n";

while ( my ($key, $value) = each(%stateList) ) {
	my $value = $stateList{$key};
	print "$key => $value\n";
}
    
print "done.\n"; 
 
exit 0;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.