0

We have a client code which is written in perl, and it is trying to connect to a WebService to make an API call.

  1. This API call is written in java, and it returns a 2-Dimemsion String Array.
  2. Here is the code on Client side:
    eval {
            $service = SOAP::Lite->service("some WS link here");
    };
    if ($exception = $@) {
            print("Failed to connect to WS: $exception");
            return 0;
    }

    my $status;
    eval {
            $status = $service->getStatus();
    };
    if ($exception = $@) {
            print("$exception");
            return 0;
    }

My question is how to extract the actual data from this "$status" value. When I was to print this "$status" value, I can only see this:

     DB> p $status
     stringArrayArray=HASH(0x126e2ac0)
     DB>

1 Answer 1

1

That means your modules has returned a hash reference. You can see what's in it with e.g. Data::Dumper

Or:

foreach my $key ( keys %$status ) { 
   print "$key => ", $status -> {$key}, "\n"; 
}

See: perlref

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the tips. But if I was using Data::Dumper, this is what I get: $VAR1 = bless( { 'item' => { 'item' => undef } }, 'stringArrayArray' ); which totally lost me.
Your api is returning junk then. That's the root of your problem - you have a nested hash that you could access as: $service -> {item} -> {item} but it is undefined.
Thanks for the help. There is a tiny issue on the web-service side. And after I had it fixed, here is full set of data from dumper, "$VAR1 = { 'item' => { 'item' => '0' } }; ". But there is still no actual data in the package. I guess my question is can client ( in perl ) really gets the full set of response from ws ?
Yes, of course. You don't have to use soap lite, you can manually process the response with LWP and a parser. This should at least give a hint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.