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

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

Expand Messages
  • Aleksandar Jelenak
    ... It is shorter to write: my @cp2 = (33333); ... The start date is not valid: 2009-11-00. You probably meant 2009-11-01. Maybe this is the real culprit?
    Message 1 of 4 , Nov 20, 2009
    • 0 Attachment
      > my @cp2;
      > $cp2[0] = '33333';

      It is shorter to write:

      my @cp2 = (33333);

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

      The start date is not valid: 2009-11-00. You probably meant
      2009-11-01. Maybe this is the real culprit?

      -Aleksandar
    • davemangot
      ... You are correct, but even after fixing the date (which had been correct in previous versions) SOAP::Lite still does not pass in my array to the server. my
      Message 2 of 4 , Nov 23, 2009
      • 0 Attachment
        --- In soaplite@yahoogroups.com, Aleksandar Jelenak <aleksandar.jelenak@...> wrote:
        >
        > > my @cp2;
        > > $cp2[0] = '33333';
        >
        > It is shorter to write:
        >
        > my @cp2 = (33333);
        >
        > > my $returnResult = $service->getTrafficSummaryForCPCode(\@cp2,'2009-11-00T00:00:00','2009-11-05T00:00:00','PST8PDT',\@columns);
        >
        > The start date is not valid: 2009-11-00. You probably meant
        > 2009-11-01. Maybe this is the real culprit?
        >
        > -Aleksandar
        >

        You are correct, but even after fixing the date (which had been correct in previous versions) SOAP::Lite still does not pass in my array to the server.

        my @cp2 = (33333);
        my $returnResult = $service->getTrafficSummaryForCPCode(\@cp2,'2009-11-01T00:00:00','2009-11-05T00:00:00','PST8PDT',\@columns); # WS Call

        <soap:Body><akasiteDeldt:getTrafficSummaryForCPCode><cpcodes xsi:nil="true" xsi:type="akasiteDeldt:ArrayOfInt" /><start xsi:type="xsd:dateTime">2009-11-01T00:00:00</start><end xsi:type="xsd:dateTime">2009-11-05T00:00:00</end><timeZone xsi:type="xsd:string">PST8PDT</timeZone><columns xsi:nil="true" xsi:type="akasiteDeldt:ArrayOfString" /></akasiteDeldt:getTrafficSummaryForCPCode></soap:Body>


        Is there any more debugging I can turn on to find out why it won't properly format my data structure?


        -Dave
      • 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 3 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.