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

Re: [soaplite] Re:

Expand Messages
  • Mark Cance
    Thanks for the advice, the snippet you sent me and the article have helped loads. My only problem is that the array $service_accounts is built within a loop;
    Message 1 of 5 , Jul 3, 2003
    • 0 Attachment
      Re: [soaplite] Re: <item> Thanks for the advice, the snippet you sent me and the article have helped loads. My only problem is that the array $service_accounts is built within a loop;

      for (my $i=0; $i < $NumberOfAccounts; ++$i){
          #some account creation code

          #add Account to array
          $services_accounts = [ SOAP::Data->name(Account =>
              \SOAP::Data->value(
                  SOAP::Data->name(UserId => $services_userid.';'.$services_passwd),
                  )
              )];
      }  
      return SOAP::Data->name("AccountList")->attr({'Length' => $NumberOfAccounts})->type("xsd:ArrayOfAccounts" =>$services_accounts);

      The above case works, but obviously the a tree AccountList only contains one Account – the last created. And that’s my problem I need to append accounts to the AccountList tree on the fly, and so far I’ve had no luck, aside from defining $services_accounts as an array and serializing it after the loop which produces the unwanted <item> tag :(

      Best,
      Mark.



      On 2/7/03 17:07, "jpeyser" <jpeyser@...> wrote:

      Mark,

         Here is one way to do it.

      my $service_accounts = [ SOAP::Data->name(account =>
        \SOAP::Data->value(
               SOAP::Data->name(UserId => 'ABC'),
               SOAP::Data->name(UserId => 'ABC'),
            )
        )];

      return SOAP::Data->name("AccountList" => $service_accounts)->type
      ("xsd:ArrayOfAccounts");

      See following article by byrne reese
      http://soapenv.org/article.pl?sid=02/02/11/1740229&mode=thread

      Jonathan

      --- In soaplite@yahoogroups.com, "mscance" <mark@f...> wrote:
      > Hi,
      >
      > I'm returning an array like so;
      > return SOAP::Data->name("AccountList")->type("xsd:ArrayOfAccounts"
      =>
      > \@services_accounts);
      >
      > Where @services_accounts is an array of hashes of the format;
      > UserId => ABC
      >
      > My code all works and i get the following returned;
      > <AccountList SOAP-ENC:arrayType="namesp2:SOAPStruct[5]"
      > xsi:type="xsd:ArrayOfAccounts">
      > <item xsi:type="namesp2:SOAPStruct">
      > <UserId xsi:type="xsd:string">ABC</UserId>
      > </item>
      > </AccountList>
      >
      > My problem is that I want the return to be;
      > <AccountList SOAP-ENC:arrayType="namesp2:SOAPStruct[5]"
      > xsi:type="xsd:ArrayOfAccounts">
      > <account xsi:type="xsd:User">
      > <UserId xsi:type="xsd:string">ABC</UserId>
      > </account>
      > </AccountList>
      >
      > Anyone have any ideas on how I could change the <item> to something
      > more meaningful and declare the type without hacking
      SOAP::Serializer??
      >
      > Also the SOAP-ENC:arrayType="namesp2:SOAPStruct[5]" worries me its
      the
      > size of the array but the namespace looks weird...
      >
      > As always any help really appreciated,
      > Best
      > Mark.


      Yahoo! Groups Sponsor
       
       
      ADVERTISEMENT
      <http://rd.yahoo.com/M=251812.3170658.4537139.1261774/D=egroupweb/S=1705701014:HM/A=1652963/R=0/SIG=11tvulr8i/*http://www.netflix.com/Default?mqso=60178275&partid=3170658>  

      To unsubscribe from this group, send an email to:
      soaplite-unsubscribe@yahoogroups.com



      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .

    • Eric Amick
      ... I m probably missing something obvious or suggesting something you ve already tried, but what happens with this code? @services_accounts = (); for (my
      Message 2 of 5 , Jul 3, 2003
      • 0 Attachment
        > Thanks for the advice, the snippet you sent me and the article
        > have helped
        > loads. My only problem is that the array $service_accounts is
        > built within a
        > loop;
        >
        > for (my $i=0; $i < $NumberOfAccounts; ++$i){
        > #some account creation code
        >
        > #add Account to array
        > $services_accounts = [ SOAP::Data->name(Account =>
        > \SOAP::Data->value(
        > SOAP::Data->name(UserId =>
        > $services_userid.';'.$services_passwd),
        > )
        > )];
        > }
        > return SOAP::Data->name("AccountList")->attr({'Length' =>
        > $NumberOfAccounts})->type("xsd:ArrayOfAccounts" =>$services_accounts);

        I'm probably missing something obvious or suggesting something you've
        already tried, but what happens with this code?

        @services_accounts = ();
        for (my $i=0; $i < $NumberOfAccounts; ++$i){
        #some account creation code

        #add Account to array
        push @services_accounts, SOAP::Data->name(Account =>
        \SOAP::Data->value(
        SOAP::Data->name(UserId =>
        $services_userid.';'.$services_passwd),
        )
        );
        }
        return SOAP::Data->name("AccountList")->attr({'Length' =>
        $NumberOfAccounts})->type("xsd:ArrayOfAccounts" =>
        \@services_accounts);

        Eric Amick
        Columbia, MD
      • Mark Cance
        I was sure that was the first method I tried.... But I must of had the syntax slightly wrong, tried it again using your snippet and it works :) Thanks for the
        Message 3 of 5 , Jul 4, 2003
        • 0 Attachment
          Re: [soaplite] Re: Re: <item> I was sure that was the first method I tried.... But I must of had the syntax slightly wrong, tried it again using your snippet and it works :)

          Thanks for the help!

          Best,
          Mark.


          On 3/7/03 14:12, "Eric Amick" <eric-amick@...> wrote:

          > Thanks for the advice, the snippet you sent me and the article
          > have helped
          > loads. My only problem is that the array $service_accounts is
          > built within a
          > loop;
          >
          > for (my $i=0; $i < $NumberOfAccounts; ++$i){
          >    #some account creation code
          >
          >    #add Account to array
          >    $services_accounts = [ SOAP::Data->name(Account =>
          >        \SOAP::Data->value(
          >            SOAP::Data->name(UserId =>
          > $services_userid.';'.$services_passwd),
          >            )
          >        )];
          > }  
          > return SOAP::Data->name("AccountList")->attr({'Length' =>
          > $NumberOfAccounts})->type("xsd:ArrayOfAccounts" =>$services_accounts);

          I'm probably missing something obvious or suggesting something you've
          already tried, but what happens with this code?

          @services_accounts = ();
          for (my $i=0; $i < $NumberOfAccounts; ++$i){
              #some account creation code

              #add Account to array
              push @services_accounts, SOAP::Data->name(Account =>
                  \SOAP::Data->value(
                      SOAP::Data->name(UserId =>
          $services_userid.';'.$services_passwd),
                      )
                  );
          }  
          return SOAP::Data->name("AccountList")->attr({'Length' =>
          $NumberOfAccounts})->type("xsd:ArrayOfAccounts" =>
          \@services_accounts);

          Eric Amick
          Columbia, MD



          Yahoo! Groups Sponsor
           
           
          ADVERTISEMENT
          <http://rd.yahoo.com/M=244522.3512152.4794593.1261774/D=egroupweb/S=1705701014:HM/A=1595053/R=0/SIG=1245der9k/*http://ashnin.com/clk/muryutaitakenattogyo?YH=3512152&yhad=1595053>  

          To unsubscribe from this group, send an email to:
          soaplite-unsubscribe@yahoogroups.com



          Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .

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