2012-04-12 107 views
0

我正在从perl脚本访问托管在IIS中的Web服务。我有一个方法返回一个字符串数组。我无法阅读服务的回应。通过使用Dumper我打印了由服务返回的响应,在那里我可以看到数组值,但我无法访问数组值。如何访问从Web服务方法返回的thr数组值。在Perl

调用方法:
在PERL中访问Web服务

my $method2 = SOAP::Data->name('getCustInfo')->attr({xmlns => 'http://tempuri.org/'}); 
my @param=(SOAP::Data->name(custId=>$custid)); 
my $response1= $soap->call($method2=>@param); 
print $response1; 

print Dumper $response1; 

@result11=$response1->result; 
print Dumper $response1; 
$i=-1; 
foreach my $result(@result11) 
{ 
    ++$i; 
    print $result[$i]; 
} 


我使用的访问方法,而我试图打印,但它不能正常工作的给上面的代码:HASH(0x3a84518)$ VAR1 =民主基金;
是什么问题。

感谢,
阿维纳什

+0

请包括Dumper输出。 – user1126070 2012-04-12 11:31:27

+0

@ user1126070,他做到了。它是'$ VAR1 = undef'。 – Axeman 2012-04-12 12:02:55

回答

0

知道响应检查调用是否之前发生的。

使用严格; 使用警告;

use SOAP::Lite +trace=>"debug"; # it debugs whether the connection is set or not 

my ($soap,$proxy,$uri); 

eval { 
    $soap = new SOAP::Lite 
      proxy=>$proxy, 
      uri=>$uri; 
}; 

    if ([email protected]){ 
    print " Service Down\n"; 
    } 

对于SOAP调用,它需要代理和URI亲切有那些在EVAL以检查它们是否可以访问。

+1

注意读者:不要使用间接方法调用('new SOAP :: Lite')。直接调用('SOAP :: Lite-> new(...)')现在几乎普遍受欢迎。 – Axeman 2012-04-12 12:50:27