本文介绍了如何解析以HASH格式的数据的SOAP响应的输出?请参阅下面的代码以获取详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#perl!
use warnings;
use strict;
use XML::Compile::SOAP;
use XML::Compile::SOAP11;
use XML::Compile::WSDL11;
use XML::Compile::Transport::SOAPHTTP;
use Data::Dumper;
##my other variables pointing to wsdl and xsd files.
my $url="http://myhost.com:9080/imws/services/ImpactManager/";
my %inargs_connect = (
"userName" => "xxxx",
"password" => "xxxxxxxxxx",
"imname" => "yyyyyyyyyyy",
"bufferType" => "abcd"
);
my $wsdl = XML::Compile::WSDL11->new;
$wsdl->addWSDL($wsdl_file);
$wsdl->compileCalls(address =>$url);
my ($answer, $trace) = $wsdl->call( 'Connect', %inargs_connect);
print ($answer);
上面的代码正在打印:哈希(0x47f8b28)
the above code is printing :HASH(0x47f8b28)
如果我使用了dumper,则会收到以下响应.print Dumper($answer);
in the last print statement if i use dumper, i get the below response.print Dumper($answer);
$VAR1 = {
'outargs' => {
'connectionId' => '1557666855346'
}
};
如何解析所需的值,例如,我需要能够轻松访问'connectionId'和'1557666855346'吗?
how to parse the required values like,i need to be able to easily access 'connectionId' and '1557666855346' ?
任何想法都欢迎.提前致谢.谢谢,考希克(Kaushik KM).
Any ideas are welcome. Thanks in advance.Thanks,Kaushik KM.
推荐答案
$answer
似乎是哈希引用,因此您可以使用常规的解引用技术来访问数据:
$answer
appears to be a hash reference, so you'd access the data using normal dereferencing techniques:
my $conn_id = $answer->{outargs}{connectionId};
print "$conn_id\n";
输出:
1557666855346
这篇关于如何解析以HASH格式的数据的SOAP响应的输出?请参阅下面的代码以获取详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!