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

Cumulative SOAP::Data->attr access?

Expand Messages
  • amigo_boy2000
    I am trying to do add optional attributes if the user invoking my ... $method = SOAP::Data- name( find_business ) - attr({xmlns = urn:something , generic =
    Message 1 of 4 , Apr 8 10:30 AM
    • 0 Attachment
      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.

      Thanks,
      Mark
    • Duncan Cameron
      ... It is slightly clumsy but this should do what you want $method- attr({%{$method- attr}, maxRows = $maxRows}); Regards Duncan
      Message 2 of 4 , Apr 8 3:08 PM
      • 0 Attachment
        At 17:30:56 on 08-04-2004 amigo_boy2000 <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.
        It is slightly clumsy but this should do what you want

        $method->attr({%{$method->attr}, maxRows => $maxRows});

        Regards
        Duncan
      • Byrne Reese
        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
        Message 3 of 4 , Oct 19, 2004
        • 0 Attachment
          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.

          Thanks,
          Mark



        • Duncan Cameron
          ... 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;
          Message 4 of 4 , 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
          Your message has been successfully submitted and would be delivered to recipients shortly.