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"?>
            <soap:Envelope 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
                <soap:Body>
                    <Dispatch xmlns="/Core">
                        <c-gensym4 xsi:type="xsd:string">soap_user</c-gensym4>
                        <c-gensym6 
xsi:type="xsd:string">soap_password</c-gensym6>
                        <c-gensym8 
xsi:type="xsd:string">TicketObject</c-gensym8>
                        <c-gensym10 
xsi:type="xsd:string">ArticleGet</c-gensym10>
                        <c-gensym12 xsi:type="xsd:string">ArticleID</c-gensym12>
                        <c-gensym14 xsi:type="xsd:int">9</c-gensym14>
                        <c-gensym16 xsi:type="xsd:string">UserID</c-gensym16>
                        <c-gensym18 xsi:type="xsd:int">1</c-gensym18>
                    </Dispatch>
                </soap:Body>
            </soap:Envelope>
            
        SOAP::Transport::HTTP::Client::send_receive: 
HTTP::Response=HASH(0x1547ed4)
        SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
        Connection: close
        Date: Wed, 19 Oct 2011 10:08:54 GMT
        Server: Apache/2.2.3 (CentOS)
        Content-Length: 11151
        Content-Type: text/xml; charset=utf-8
        Client-Date: Wed, 19 Oct 2011 10:08:55 GMT
        Client-Peer: 10.215.240.99:80
        Client-Response-Num: 1
        SOAPServer: SOAP::Lite/Perl/0.714

            <?xml version="1.0" encoding="UTF-8"?>
            <soap:Envelope 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
                <soap:Body>
                    <DispatchResponse xmlns="/Core">
                        <s-gensym861 xsi:type="xsd:string">Age</s-gensym861>
                        <s-gensym863 xsi:type="xsd:int">782743</s-gensym863>
                        <s-gensym941 
xsi:type="xsd:string">ArticleID</s-gensym941>
                        <s-gensym943 xsi:type="xsd:int">9</s-gensym943>
                    </DispatchResponse>
                </soap:Body>
            </soap:Envelope>
            
        SOAP::Deserializer::deserialize: ()
        SOAP::Parser::decode: ()
        SOAP::SOM::new: ()
        SOAP::Data::new: ()
        SOAP::Data::new: ()
        SOAP::Data::new: ()
        SOAP::Data::new: ()
        SOAP::Data::DESTROY: ()
        SOAP::Data::DESTROY: ()
        SOAP::Data::DESTROY: ()
        SOAP::Data::DESTROY: ()
        SOAP::SOM::DESTROY: ()
        SOAP::Data::DESTROY: ()
        SOAP::Data::DESTROY: ()
        SOAP::Data::DESTROY: ()
        SOAP::Data::DESTROY: ()
        SOAP::Transport::HTTP::Client::DESTROY: ()
        SOAP::Parser::DESTROY: ()
        SOAP::Transport::DESTROY: ()
        SOAP::Serializer::DESTROY: ()
        SOAP::Data::DESTROY: ()
        SOAP::Deserializer::DESTROY: ()
        SOAP::Lite::DESTROY: ()

-------------------------------------------------------
case 2: TicketObject->ArticleGet providing TicketID
    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 $ArticleIndex = $RPC->Dispatch( $User, $Pw, 'TicketObject', 
'ArticleGet', TicketID => 4, UserID => 1)
            || die "Failed to get article: $!";
        print "size of hash: ". keys (%$ArticleIndex) ."\n";
        while ( my ($key, $value) = each( %$ArticleIndex ) ){
            print "$key => $value\n";
        }

    perl output
        size of hash: 2
        Age => 1044565
        ArticleID => 2

    debug info
        SOAP::Lite::call: ()
        SOAP::Serializer::envelope: ()
        SOAP::Serializer::envelope: Dispatch soap_user soap_password 
TicketObject ArticleGet TicketID 4 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(0x10eab94)
        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: 822
        Content-Type: text/xml; charset=utf-8
        SOAPAction: "/Core#Dispatch"

            <?xml version="1.0" encoding="UTF-8"?>
            <soap:Envelope 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
                <soap:Body>
                    <Dispatch xmlns="/Core">
                        <c-gensym4 xsi:type="xsd:string">soap_user</c-gensym4>
                        <c-gensym6 
xsi:type="xsd:string">soap_password</c-gensym6>
                        <c-gensym8 
xsi:type="xsd:string">TicketObject</c-gensym8>
                        <c-gensym10 
xsi:type="xsd:string">ArticleGet</c-gensym10>
                        <c-gensym12 xsi:type="xsd:string">TicketID</c-gensym12>
                        <c-gensym14 xsi:type="xsd:int">4</c-gensym14>
                        <c-gensym16 xsi:type="xsd:string">UserID</c-gensym16>
                        <c-gensym18 xsi:type="xsd:int">1</c-gensym18>
                    </Dispatch>
                </soap:Body>
            </soap:Envelope>
            
        SOAP::Transport::HTTP::Client::send_receive: 
HTTP::Response=HASH(0x154802c)
        SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
        Connection: close
        Date: Wed, 19 Oct 2011 09:55:11 GMT
        Server: Apache/2.2.3 (CentOS)
        Content-Length: 9034
        Content-Type: text/xml; charset=utf-8
        Client-Date: Wed, 19 Oct 2011 09:55:12 GMT
        Client-Peer: 10.215.240.99:80
        Client-Response-Num: 1
        SOAPServer: SOAP::Lite/Perl/0.714

            <?xml version="1.0" encoding="UTF-8"?>
            <soap:Envelope 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
                <soap:Body>
                    <DispatchResponse xmlns="/Core">
                        <s-gensym1663>
                            <Age xsi:type="xsd:int">1044565</Age>
                            <ArticleID xsi:type="xsd:int">2</ArticleID>
                        </s-gensym1663>
                        <s-gensym1665>
                            <Age xsi:type="xsd:int">1044565</Age>
                            <ArticleID xsi:type="xsd:int">13</ArticleID>
                        </s-gensym1665>
                    </DispatchResponse>
                </soap:Body>
            </soap:Envelope>
            
        SOAP::Deserializer::deserialize: ()
        SOAP::Parser::decode: ()
        SOAP::SOM::new: ()
        SOAP::Data::new: ()
        SOAP::Data::new: ()
        SOAP::Data::DESTROY: ()
        SOAP::Data::DESTROY: ()
        SOAP::SOM::DESTROY: ()
        SOAP::Data::DESTROY: ()
        SOAP::Data::DESTROY: ()
        SOAP::Data::DESTROY: ()
        SOAP::Data::DESTROY: ()
        SOAP::Transport::HTTP::Client::DESTROY: ()
        SOAP::Parser::DESTROY: ()
        SOAP::Transport::DESTROY: ()
        SOAP::Serializer::DESTROY: ()
        SOAP::Data::DESTROY: ()
        SOAP::Deserializer::DESTROY: ()
        SOAP::Lite::DESTROY: ()

Kind regards,
Juan Clavero Almirón


---------------------------------------------------------------------
OTRS mailing list: otrs - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/otrs
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/otrs

Reply via email to