Demnogonis
Demnogonis

Reputation: 3222

Can't use object methods of SOAP object with SOAP::Lite

I am reading data from our Jira via SOAP and recieve an array of RemoteIssue-Objects. Now I want to iterate over these and get the status of each ticket. The documentation of RemoteIssue says that there is a getStatus()-Method. When I call it on the objects my program throws an error.

Some code:

my $soap = SOAP::Lite->uri($soap_uri)->proxy($soap_proxy);
my $login = $soap->login( $soap_user, $soap_password)->result;

if ($login) {
    # This works
    my $issues = $soap->getIssuesFromJqlSearch( $login, "project = \"$project\" AND fixVersion = \"$project_version\"", 500 );

    if ($issues) {
        foreach my $issue (@{$issues->result}) {
            my $foo = $issue->getStatus(); # This doesn't work
            print Dumper $foo;
        }
    }
}
$soap->logout();

The thrown error:

Can't locate object method "getStatus" via package "RemoteIssue" at D:\ZeuS\lib/ZeuS.pm line 81

Every other object method doesn't work either.

Does anyone know what I am doing wrong?

Upvotes: 0

Views: 871

Answers (1)

Axeman
Axeman

Reputation: 29854

From what I gather, you're under the impression that you're receiving the Java object that you would manipulate on a Java consumer.

Unless $issue->getStatus() is a SOAP call (which I don't think it is) you're not dealing with the API, you're dealing with SOAP::Lite's representation in Perl of the response in XML.

getIssuesFromJqlSearch seems to be the remote call. From that, you should get $issues as a SOAP::SOM object. Which you then properly address with the result method.

This will have whatever methods are defined for the class this object is blessed into.

To see what all this object responds to try this:

use mro ();
use Scalar::Util qw<blessed>;
...
    foreach my $issue (@{$issues->result}) {
        say '$issue ISA ('
          . join( ',', @{ mro::get_linear_isa( blessed( $issue )) } )
          . ')'
          ;
          ...
    }

$issue will only have those methods that have been defined for it on the Perl side.

  • NOTE: It is not clear from your code where ZeuS.pm comes into this thing.

Upvotes: 1

Related Questions