我编写了一个perl脚本来访问返回复杂数据的wcf服务方法。我能够看到来自wcf服务的xml架构响应(在perl中使用dumper)。但我无法访问架构中的值:
$response1= $soap->GetAddress
(SOAP::Data->new(name=>'mailAddress',value=>[SOAP::Data->new (name=>'a:city'),
SOAP::Data->new (name=>'a:name'),SOAP::Data->new (name=>'a:streetaddress'),SOAP::Data->new
(name=>'a:zipcode')])->attr({'xmlns:a'=>$xmlns}))->result;
我正在使用它来访问服务中的方法。如何阅读$response1
的值?
$响应1:
$VAR1 = {
'city' => 'Hyd',
'streetaddress' => 'ECIL',
'name' => 'Avinash Patil',
'zipcode' => '5000012',
'state' => 'AP'
};
答案 0 :(得分:0)
尝试使用:
my @values;
my $value[0]= $soap->'Method-name'($header,$data)->valueof('//city');
my $value[1]= $soap->'Method-name'($header,$data)->valueof('//streetaddress');
my $value[2]= $soap->'Method-name'($header,$data)->valueof('//name');
my $value[3]= $soap->'Method-name'($header,$data)->valueof('//state');
答案 1 :(得分:0)
$response1=$soap->getCustomer(SOAP::Data->new(name => 'customerid', value =>$custid))->result;
print $response1->{'Email'};
print "\n";
print $response1->{'Mobile'};
print "\n";