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

4056Re: [soaplite] Cumulative SOAP::Data->attr access?

Expand Messages
  • Duncan Cameron
    Oct 20, 2004
    • 0 Attachment
      On 2004-10-20 at 05:46:22 Byrne Reese wrote:

      >This is easily accomplished using SOAP::Lite 0.65 Beta 1 - currently
      >available for download.
      >
      >The code below demonstrates how to use SOAP::Serializer's new
      >register_ns() method, which adds a new global namespace. This makes it
      >easier to construct complex types, as well as provide a slew of
      >namespaces that may or may not by used.
      >
      > my $soap = SOAP::Lite
      > ->uri($uri)
      > ->readable(1)
      > ->proxy($proxyUrl);
      >
      > $soap->serializer->register_ns("urn:Foo",'foo');
      > $soap->serializer->register_ns("urn:Bar",'bar');
      >
      > print $soap->c2f(SOAP::Data->name('temperature' => 100));
      >
      >amigo_boy2000 wrote:
      >
      >> I am trying to do add optional attributes if the user invoking my
      >> script specified their values. For example:
      >>
      >> ----------------------------------------------------------
      >> $method = SOAP::Data->name('find_business')
      >> ->attr({xmlns => 'urn:something', generic => '2.0'});
      >>
      >> if (defined($maxRows)) {
      >> $method->attr({maxRows => $maxRows});
      >> }
      >> ----------------------------------------------------------
      >>
      >> This seems to destroy the attributes set on the first call. Is there
      >> any way to cumulatively add (build) optional attributes if the values
      >> were passed to my script? The only way I know how to do it is this
      >> way:
      >>
      >> ${${$method}{_attr}}{'maxRows'} = '99';
      >>
      >> But, this seems like a bad way to access an object's data.

      I think Byrne missed slightly missed the original poster's point.
      You might be able to accumulate all the attributes and then add them in
      one go

      my %attr;
      $attr{xmlns} = 'urn:something';
      $attr{generic} = '2.0';

      $attr{maxRows} = $maxRows if defined $maxRows;

      $method = SOAP::Data->name('find_business')
      ->attr(\%attr);

      Regards
      Duncan
    • Show all 4 messages in this topic