我需要将对象传递给perl中的API。结构如下所示:
{"requestId": "requestid1",
"result": "result1",
"actions":
{"actionMap":
{"key1":
{"result": "POSITIVE",
"comment": "foo"},
"key2":
{"result": "POSITIVE",
"comment": "foo"}
},
"comment": "foo"}
}
Wsdl:
<xsd:complexType name="postresult">
<xsd:sequence>
<xsd:element minOccurs="0" name="requestId" type="tns:RequestId"/>
<xsd:element minOccurs="0" name="result" type="tns:result"/>
<xsd:element minOccurs="0" name="actions" type="tns:actions"/>
</xsd:sequence>
</xsd:complexType>
地图
<xsd:complexType name="ActionValue">
<xsd:sequence>
<xsd:element minOccurs="0" name="result" type="tns:ResultType"/>
<xsd:element minOccurs="0" name="comment" type="tns:Comment"/>
</xsd:sequence>
以下是我正在使用的代码
my @actionMap;
foreach my $question(@{$quesAndAns}){
my $actionValue;
$actionValue->{result} = $question->{'Answer'};
$actionValue->{comment}=$question->{'Comment'};
my %action;
$action{$question->{'Question'}} = $actionValue;
push(@actionMap,%action);
}
$invResult->{actionMap} = \@actionMap;
$invResult->{comment}= $annotationobj->{'AdditionalComments'};
$output = $sanctionsasyncObject->postInvestigatorResult(requestId => $requestId, result => $result, actions=> $invResult);
代码不起作用,我得到一个obj但它是空的,$ output-?getResult给出undef而不是true或false,API工作正常,我从其他资源确认,是否有语法错误?什么是正确的方法吗?