
Hello,
I’m trying to understand how to make RPC requests to OTRS. By now, I’ve been able to make RPC requests with simple answers (such as CustomerUserObject->CustomerName or TicketObject->TicketCreate) but I’m stuck trying to get complex data (such as TicketObject->ArticleGet).
I’ve initialized SOAP::Lite with “trace => 'all'”, so I can get debug info.
I have two cases. In the first case, I try to get TicketObject->ArticleGet providing ArticleID and UserID. In this case, XML response has the information about the article, but my perl var only has the first component. When I declare the var as an array, it only has one element and it contains the same first component.
In the second case, I try to get TicketObject->ArticleGet providing TicketID and UserID. In this case, XML response has the information about the ticket and its 2 articles, but my perl var only has the info about the first article.
Can anyone show me how to correctly get this info using RPC? I guess my perl is wrong, but I don’t see where...
Next you can see my perl code and the XML response for each case. perl output and debug info has been stripped of redundant lines that are not relevant to the problem
case 1: TicketObject->ArticleGet providing ArticleID
perl code
use SOAP::Lite( 'autodispatch', proxy => 'http://my_host/otrs/rpc.pl' , trace => 'all');
my $User = 'soap_user';
my $Pw = 'soap_password';
my $RPC = Core->new();
my %Article = $RPC->Dispatch( $User, $Pw, 'TicketObject', 'ArticleGet', ArticleID => $_[0], UserID => 1)
|| die "Failed to get article: $!";
print "size of hash: ". keys (%Article) ."\n";
while ( my ($key, $value) = each( %Article ) ){
print "$key => \n";
print "\t$value\n";
}
perl output
size of hash: 1
Age =>
debug info
SOAP::Lite::call: ()
SOAP::Serializer::envelope: ()
SOAP::Serializer::envelope: new
SOAP::Data::new: ()
SOAP::Data::new: ()
SOAP::Data::new: ()
SOAP::Data::new: ()
SOAP::Transport::HTTP::Client::send_receive: HTTP::Request=HASH(0x10ecf1c)
SOAP::Transport::HTTP::Client::send_receive: POST http://soticprotrs02v.ssib.es/otrs/rpc.pl HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
SOAP::Lite::call: ()
SOAP::Serializer::envelope: ()
SOAP::Serializer::envelope: Dispatch soap_user soap_password TicketObject ArticleGet ArticleID 9 UserID 1
SOAP::Data::new: ()
SOAP::Data::new: ()
SOAP::Data::DESTROY: ()
SOAP::Data::DESTROY: ()
SOAP::Data::DESTROY: ()
SOAP::Data::DESTROY: ()
SOAP::Data::new: ()
SOAP::Data::new: ()
SOAP::Data::new: ()
SOAP::Transport::HTTP::Client::send_receive: HTTP::Request=HASH(0x10ea654)
SOAP::Transport::HTTP::Client::send_receive: POST http://soticprotrs02v.ssib.es/otrs/rpc.pl HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 823
Content-Type: text/xml; charset=utf-8
SOAPAction: "/Core#Dispatch"
<?xml version="1.0" encoding="UTF-8"?>

Hi,
-----Original Message----- From: otrs-bounces@otrs.org [mailto:otrs-bounces@otrs.org] On Behalf Of Juan Manuel Clavero Almirón Sent: Wednesday, October 19, 2011 12:22 PM To: User questions and discussions about OTRS. Subject: [otrs] Problems with RPC response
I have two cases. In the first case, I try to get TicketObject->ArticleGet providing ArticleID and UserID. In this case, XML response has the information about the article, but my perl var only has the first component. When I declare the var as an array, it only has one element and it contains the same first component.
I remember running through this stuff a while ago, I couldn't get the exact cause, it might be a perl bug (or some feature I don't understand). The key is, don't use '||', use 'or' for the die part. A bit of testing I've done back then: ====== #!/usr/bin/perl use Data::Dumper; sub foo{ my %a = qw(a b c d e f); return %a; } my %good = foo() or die $!; my %bad = foo() || die $!; my @almost = {foo()} || die $!; print "The good:\n" . Dumper \%good; print "The bad:\n" . Dumper \%bad; print "And the wannabe:\n" . Dumper \@almost; [kroozo@pirx ~]$ ./test.pl The good: $VAR1 = { 'e' => 'f', 'c' => 'd', 'a' => 'b' }; The bad: $VAR1 = { '3/8' => undef }; And the wannabe: $VAR1 = [ { 'e' => 'f', 'c' => 'd', 'a' => 'b' } ]; ======= Hope this helps, Cheers, tamas
participants (2)
-
Juan Manuel Clavero Almirón
-
Tamás Becz