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

possible fix for generate_stub()

Expand Messages
  • swiersdorf
    Hi all, I m fairly new to soaplite and am hoping someone can point me in the right direction. I ve been trying to access Google s AdSense API
    Message 1 of 1 , Aug 23, 2006
    • 0 Attachment
      Hi all, I'm fairly new to soaplite and am hoping someone can point me
      in the right direction. I've been trying to access Google's AdSense
      API (createAdSenseAccount) using soaplite and have noticed that while
      0.60 works, 0.65 and later (including 0.69) do not.

      0.69's _call() method (generated inside generate_stub()) has a chunk
      like this:

      my $result = $self->serializer->$method($param, $template->name,
      $template->type, $template->attr);
      push(@parameters, $template->value($result->[2]));

      which seems to work fine for "basic" types, such as 'xsd:string' or
      'xsd:boolean'. But for types such as 'impl:EntityType' or
      'impl:SyndicationService_Type', the serializer() returns undef (the
      result of a missed lookup in @EXPORT).

      Because it returns undef, none of the values for these missing types
      show up in the resulting SOAP call (fragment--notice the blank
      synServiceTypes value):

      <synServiceTypes xsi:nil="true"
      xsi:type="impl:SyndicationService_Type" />
      <hasAcceptedTCs xsi:type="xsd:boolean">true</hasAcceptedTCs>

      If I change the $result code above to something like this:

      if( my $result = $self->serializer->$method($param,
      $template->name, $template->type, $template->attr) ) {
      push(@parameters, $template->value($result->[2]));
      }
      else {
      push(@parameters, $template->value($param));
      }

      the call to Google actually works, but with a SOAP call (fragment)
      that looks like this:

      <synServiceTypes>ContentAds</synServiceTypes>
      <hasAcceptedTCs xsi:type="xsd:boolean">true</hasAcceptedTCs>

      So the synServiceTypes value is present, but none of the element
      attributes that we had before.

      Fwiw, I'm calling the API like this:

      my $namespace = "http://www.google.com/api/adsense/v2";
      my $wsdl_url =
      "http://www.google.com/api/adsense/staging/AccountService?WSDL";
      my $client = SOAP::Lite->new;
      my $accountService = $client->service($wsdl_url);
      my $synServiceData = $accountService->createAdSenseAccount(...);

      (this code is from an example given by Google itself).

      The parameters in the relevant method in the generated stub looks like
      this:

      parameters => [
      SOAP::Data->new(name => 'loginEmail', type => 'xsd:string', attr
      => {}),
      SOAP::Data->new(name => 'entityType', type => 'impl:EntityType',
      attr => {}),
      SOAP::Data->new(name => 'websiteUrl', type => 'xsd:string', attr
      => {}),
      SOAP::Data->new(name => 'websiteLocale', type => 'xsd:string',
      attr => {}),
      SOAP::Data->new(name => 'usersPreferredLocale', type =>
      'xsd:string', attr => {}),
      SOAP::Data->new(name => 'emailPromotionPreferences', type =>
      'xsd:boolean', attr => {}),
      SOAP::Data->new(name => 'synServiceTypes', type =>
      'impl:SyndicationService_Type', attr => {}),
      SOAP::Data->new(name => 'hasAcceptedTCs', type => 'xsd:boolean',
      attr => {}),
      ], # end parameters

      I'm hoping for one of the following outcomes:

      1) someone can correct how I'm using SOAP::Lite so I don't get a miss
      when I'm looking up the variables in the serializer (which I'm
      assuming would fix everything)

      2) someone can correct the "patch" (as it were) so that the attributes
      are also put back in the element.

      Scott
    Your message has been successfully submitted and would be delivered to recipients shortly.