Loading ...
Sorry, an error occurred while loading the content.

AW: [soaplite] getting NIL string on custom Akamai datatype

Expand Messages
  • Martin Busik
    Hi Dave, the problem is, that SOAP::Lite does not serialize ArrayOfXXX types. There are 2 ways to solve it: ... sub serialize_array { my ($self, $value, $name,
    Message 1 of 4 , Nov 26, 2009
    • 0 Attachment
      Hi Dave,

      the problem is, that SOAP::Lite does not serialize ArrayOfXXX types.

      There are 2 ways to solve it:

      1. define an own serializer:
      ---------------------
      sub serialize_array {
      my ($self, $value, $name, $type, $attr) = @_;
      return [
      $name,
      { %$attr },
      [ map { SOAP::Data->name("item")->value($_)->type("") } @$value ],
      ];
      }

      *SOAP::Serializer::as_ArrayOfInt = \&serialize_array;
      *SOAP::Serializer::as_ArrayOfString = \&serialize_array;

      $service->serializer->typelookup->{ArrayOfInt} = [99, sub { ref($_[0]) eq
      'ARRAY' }, 'as_ArrayOfInt'];
      $service->serializer->typelookup->{ArrayOfString} = [99, sub { ref($_[0]) eq
      'ARRAY' }, 'as_ArrayOfString'];

      my @cp2 = (123);
      my @columns = ("abc","def");

      my $t = $service->getTrafficSummaryForCPCode( \@cp2
      ,'2009-11-00T00:00:00','2009-11-05T00:00:00','PST8PDT',\@columns);
      -------------------------

      2. Do not use the SOAP::Lite's serialization at all, construct your request
      yourself.
      As you are using a stub, make the parameters array emtpy, i.e. delete the
      following lines:

      parameters => [
      SOAP::Data->new(name => 'cpcodes', type => 'tns1:ArrayOfInt', attr =>
      {}),
      SOAP::Data->new(name => 'start', type => 'xsd:dateTime', attr => {}),
      SOAP::Data->new(name => 'end', type => 'xsd:dateTime', attr => {}),
      SOAP::Data->new(name => 'timeZone', type => 'xsd:string', attr => {}),
      SOAP::Data->new(name => 'columns', type => 'tns1:ArrayOfString', attr
      => {}),
      ], # end parameters

      then call the service as follows:

      my $t = $service->getTrafficSummaryForCPCode(
      SOAP::Data->name('cpcodes')->type(undef)->value( \SOAP::Data->value(
      SOAP::Data->name('item')->value(123)->type(undef)
      )),

      SOAP::Data->name('start')->type('xsd:dateTime')->value('2009-11-26T00:00:00'
      ),
      ...
      );

      Cheers,
      Martin
    Your message has been successfully submitted and would be delivered to recipients shortly.