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

getting NIL string on custom Akamai datatype

Expand Messages
  • davemangot
    Hi, I m kinda at wits end so hopefully this will make some sense. I m trying to get a report from Akamai using their SOAP interface. I downloaded their WSDL
    Message 1 of 4 , Nov 20, 2009
    • 0 Attachment
      Hi,

      I'm kinda at wits end so hopefully this will make some sense. I'm trying to get a report from Akamai using their SOAP interface.

      I downloaded their WSDL file and used stubmaker.pl to generate the Perl module. I'm using SOAP::Lite version 0.710.10.

      Here is the call I make from my client:
      my @cp2;
      $cp2[0] = '33333';
      my $returnResult = $service->getTrafficSummaryForCPCode(\@cp2,'2009-11-00T00:00:00','2009-11-05T00:00:00','PST8PDT',\@columns);

      Which is a call to:
      getTrafficSummaryForCPCode => {
      endpoint => 'https://control.akamai.com/nmrws/services/SiteAcceleratorReportService',
      soapaction => '',
      namespace => 'https://control.akamai.com/SiteAcceleratorReportService.xsd',
      parameters => [
      SOAP::Data->new(name => 'cpcodes', type => 'akasiteDeldt: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 => 'akasiteDeldt:ArrayOfString', attr => {}),
      ], # end parameters
      }, # end getTrafficSummaryForCPCode


      The problem is when I run this, all the fields that are straight up xsd types (dateTime and string) work fine, but the akasiteDeldt types just show up as blank.

      <soap:Body><akasiteDeldt:getTrafficSummaryForCPCode><cpcodes xsi:nil="true" xsi:type="akasiteDeldt:ArrayOfInt" /><start xsi:type="xsd:dateTime">2009-11-00T00: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>

      However, for example, the first field is supposed to look like:
      <cpcodes xsi:type="akasiteDeldt:ArrayOfInt" soapenc:arrayType="xsd:int[]"><item>33244</item><item>33234</item></cpcodes>

      If I change the type from akasiteDeldt:ArrayOfInt to xsd:string and pass in a string, then it gets sent correctly (which of course breaks on the receiving (server) end).

      I'm guessing SOAP::Lite must not like the datastructure I'm passing in and therefore will not format the fields correctly.

      This is how ArrayOfInt is defined in the WSDL:

      <complexType name="ArrayOfInt">
      <complexContent>
      <restriction base="soapenc:Array">
      <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:int[]"/>
      </restriction>
      </complexContent>
      </complexType>


      I've tried passing in arrays, arrays of arrays, hashes of arrays, references to arrays, hashes, etc. Still no luck.

      How can I nail down what getTrafficSummaryForCPCode is expecting for a data structure or why SOAP::Lite is not populating my field correctly?

      Any help would be greatly appreciated. I've run this as far with Akamai support as I can.

      Cheers,

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