Next | SOAP::Lite Client Experiences | 14 |
I had to add some logic to the SOAP::Lite serializer, to correctly assign the data types to the values.
sub SOAP::Serializer::as_int { my $self = shift; my($value, $name, $type, $attr) = @_; return [$name, {'xsi:type' => 'xsd:boolean', %$attr}, 'true'] if ($name =~ /^(has|affects)/ && $value == 1); return [$name, {'xsi:type' => 'xsd:boolean', %$attr}, 'false'] if ($name =~ /^(has|affects)/ && $value == 0); for (qw(eventaddorder showorder testconfigtype)) { return [$name, {'xsi:type' => 'xsd:short', %$attr}, $value] if $name eq $_; } for (qw(recordid cookie)) { return [$name, {'xsi:type' => 'xsd:long', %$attr}, $value] if $name eq $_; } return [$name, {'xsi:type' => 'xsd:int', %$attr}, $value]; } $soap->typelookup->{dateTime} = [15, sub {$_[0] =~ /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d-\d\d:\d\d$/ }, 'as_dateTime']; sub SOAP::Serializer::as_dateTime { my $self = shift; my($value, $name, $type, $attr) = @_; return [$name, {'xsi:type' => 'xsd:dateTime', %$attr}, $value]; }
An improvement to SOAP::Lite would be to save the data types, which are part of the XML messages it gets from the server.
Copyright © 2004 David Baird |