|
From: Jason S. <jas...@gm...> - 2008-09-14 07:02:10
|
Hey Martin,
I don't believe the only issue is with the deserializer - I believe it
is also with the _as_data() method of SOAP::SOM. Here is the current
method:
sub _as_data {
my $self = shift;
my $pointer = shift;
SOAP::Data
-> new(prefix => '', name => o_qname($pointer), name =>
o_lname($pointer), attr => o_lattr($pointer))
-> set_value(o_value($pointer));
}
First the 'name' key to new() is duplicated - seems like a bug, and
second the value is set to o_value($pointer) - which is just the
simple hash-reference given by the deserializer. This is not recursive
- so unless o_value($pointer) return a valid SOAP::Data instance this
is useless.
I suggest the following recursive fix:
sub _as_data {
my $self = shift;
my $node = shift;
my $data = SOAP::Data->name(o_qname($node))->attr(o_attr($node));
if (defined o_child($node)) {
my @children;
foreach my $child (@{ o_child($node) }) {
push(@children,$self->_as_data($child));
}
$data->set_value(\SOAP::Data->value(@children));
} else {
$data->value(o_value($node));
}
return $data;
}
This now produces a correct SOAP::Data object with all the attributes
included for the subelements.
Any feedback? jas.
On Sat, Sep 13, 2008 at 11:32 AM, Martin Kutter
<mar...@fe...> wrote:
> ... then we probably should change the deserializer to fill all
> appropriate slots: With a XML node containing XML attributes, clearly
> the attr slot should be filled.
>
> Martin
>
>
> Am Freitag, den 12.09.2008, 17:03 +0530 schrieb Jason Stewart:
>> Hey,
>>
>> I dug a bit deeper...
>>
>> Maybe what I need to understand here is why the SOAP::SOM object that
>> is generated by the deserializer has the construct that is the
>> sub-elements without attributes as the value slot.
>>
>> The struct has 7 slots:
>> 0) qname
>> 1) attr
>> 2) child
>> 3) chars
>> 4) value
>> 5) lname
>> 6) lattr
>>
>> The child slot is an accurate representation of the sub-tree with
>> attributes, but the value slot only has element data (names of
>> elements as keys, and the text of the elements as values).
>>
>> So the whole issue is that the value slot does not include attribute
>> data. So this is not a bug as a design limitation.
>>
>> I'm back at simply wanting to get at the XML payload of the Body tag.
>> And I'm wanting to set the xml payload of the body response tag
>> without a gross hack to keep it from being wrapped in a method tag by
>> the serializer.
>>
>> Cheers, jas.
>>
>
>
|