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

sending multiple hashes from client to server over SOAP

Expand Messages
  • Rohitashva Sharma
    Dear All, I am writing a web service based application where I need to send three associative arrays (hashes) from SOAP-Lite based client to SOAP-Lite based
    Message 1 of 6 , Oct 12, 2006
    • 0 Attachment
      Dear All,

      I am writing a web service based application where I need to send
      three associative arrays (hashes) from SOAP-Lite based client to
      SOAP-Lite based server. In normal case I get all the hashes mixed up
      in single array @_.

      How should I send them so that at the server end I can receive three
      differnet hashes. Please help me in this regards

      Thanks
      Sharma R
    • Sebastian Jaenicke
      On Thu, Oct 12, 2006 at 06:30:27PM +0200, Rohitashva Sharma wrote: [..] ... How does the server side expect the data? ... - remote_method( %hash1, %hash2,
      Message 2 of 6 , Oct 12, 2006
      • 0 Attachment
        On Thu, Oct 12, 2006 at 06:30:27PM +0200, Rohitashva Sharma wrote:
        [..]
        > I am writing a web service based application where I need to send
        > three associative arrays (hashes) from SOAP-Lite based client to
        > SOAP-Lite based server. In normal case I get all the hashes mixed up
        > in single array @_.

        How does the server side expect the data?

        Ideas:

        ---------------------------------------------
        ->remote_method( %hash1, %hash2, %hash3)
        ---------------------------------------------
        ->remote_method( \%hash1, \%hash2, \%hash3)
        ---------------------------------------------
        my %hash = ( hash1 => \%hash1,
        hash2 => \%hash2,
        hash3 => \%hash3);

        ->remote_method(\%hash);
        ---------------------------------------------

        - Sebastian

        --
        Progress (n.): The process through which Usenet has evolved from
        smart people in front of dumb terminals to dumb people in front
        of smart terminals.
        -- obs@...
      • Rohitashva Sharma
        Hi Sebastian, Thanks for your reply.. At server side I want these three hashes back in the same way i have at client. I am trying out your suggestions. thanks
        Message 3 of 6 , Oct 12, 2006
        • 0 Attachment
          Hi Sebastian,

          Thanks for your reply..

          At server side I want these three hashes back in the same way i have at client. I am trying out your suggestions.

          thanks and regards
          Sharma R

          On 10/12/06, Sebastian Jaenicke <sjaenick+SOAPLITE@...-bielefeld.de> wrote:

          On Thu, Oct 12, 2006 at 06:30:27PM +0200, Rohitashva Sharma wrote:
          [..]
          > I am writing a web service based application where I need to send
          > three associative arrays (hashes) from SOAP-Lite based client to
          > SOAP-Lite based server. In normal case I get all the hashes mixed up
          > in single array @_.

          How does the server side expect the data?

          Ideas:

          ---------------------------------------------
          ->remote_method( %hash1, %hash2, %hash3)
          ---------------------------------------------
          ->remote_method( \%hash1, \%hash2, \%hash3)
          ---------------------------------------------
          my %hash = ( hash1 => \%hash1,
          hash2 => \%hash2,
          hash3 => \%hash3);

          ->remote_method(\%hash);
          ---------------------------------------------

          - Sebastian

          --
          Progress (n.): The process through which Usenet has evolved from
          smart people in front of dumb terminals to dumb people in front
          of smart terminals.
          -- obs@...


        • Rohitashva Sharma
          Hi Sebastian, I tried the suggestion given by you. Here is the part of code CLIENT SIDE: use SOAP::Lite; my $x = shift; my $soap_handle; my %hash1 = ( Rohit
          Message 4 of 6 , Oct 12, 2006
          • 0 Attachment
            Hi Sebastian,

            I tried the suggestion given by you. Here is the part of code

            CLIENT SIDE:

            use SOAP::Lite;

            my $x = shift;
            my $soap_handle;

            my %hash1 = (
                    "Rohit"   =>  31,
                    "Poney"   =>  05
                    );
            my %hash2 = (
                    "RRohit"   =>  31,
                    "RPoney"   =>  05
                    );

            my %hash = ( hashh1 => \%hash1,
                         hashh2 => \%hash2
                       );

            $soap_handle = SOAP::Lite
              ->uri("http://localhost/Notd")
              ->proxy("http://localhost/cgi-bin/notd_test.cgi ");

            eval '$soap_response = $soap_handle->handle_hash(%hash);';

            print $soap_response->result;
            print "\n";

            SERVER SIDE:

            sub handle_hash {
              my $me = shift;
              my %hash = @_;
              open DATA, ">/tmp/data";
                foreach my $x (keys %hash){
                    foreach my $y (keys %$x){
                       print DATA $y . "\t" . $$x{$y} . "\n";
                    }
                }
              close DATA;
              return ('1');
            }

            When I run client file /tmp/data is created but there is nothing in the file. Please suggest what is that I am missing.

            thanks and regards
            Sharma R

            On 10/12/06, Sebastian Jaenicke <sjaenick+SOAPLITE@...-bielefeld.de> wrote:

            On Thu, Oct 12, 2006 at 06:30:27PM +0200, Rohitashva Sharma wrote:
            [..]
            > I am writing a web service based application where I need to send
            > three associative arrays (hashes) from SOAP-Lite based client to
            > SOAP-Lite based server. In normal case I get all the hashes mixed up
            > in single array @_.

            How does the server side expect the data?

            Ideas:

            ---------------------------------------------
            ->remote_method( %hash1, %hash2, %hash3)
            ---------------------------------------------
            ->remote_method( \%hash1, \%hash2, \%hash3)
            ---------------------------------------------
            my %hash = ( hash1 => \%hash1,
            hash2 => \%hash2,
            hash3 => \%hash3);

            ->remote_method(\%hash);
            ---------------------------------------------

            - Sebastian

            --
            Progress (n.): The process through which Usenet has evolved from
            smart people in front of dumb terminals to dumb people in front
            of smart terminals.
            -- obs@...


          • Sebastian Jaenicke
            On Thu, Oct 12, 2006 at 09:04:52PM +0200, Rohitashva Sharma wrote: [..] ... [..] ... Use - handle_hash( %hash); # note the here, which results in
            Message 5 of 6 , Oct 12, 2006
            • 0 Attachment
              On Thu, Oct 12, 2006 at 09:04:52PM +0200, Rohitashva Sharma wrote:
              [..]
              > CLIENT SIDE:
              [..]
              > eval '$soap_response = $soap_handle->handle_hash(%hash);';

              Use

              ->handle_hash(\%hash); # note the '\'

              here, which results in

              <handle_hash xmlns="http://localhost/Notd">
              <c-gensym3>
              <hashh2>
              <RRohit xsi:type="xsd:int">31</RRohit>
              <RPoney xsi:type="xsd:int">5</RPoney>
              </hashh2>
              <hashh1>
              <Rohit xsi:type="xsd:int">31</Rohit>
              <Poney xsi:type="xsd:int">5</Poney>
              </hashh1>
              </c-gensym3>
              </handle_hash>

              > SERVER SIDE:

              sub handle_hash {
              my ($self, $hash_ref) = @_;
              my %hash = %$hash_ref;
              open (DATA, ">>/tmp/data");
              foreach my $key (keys %hash) {
              print DATA "HASH: $key\n";
              my %entry = %{$hash{$key}};
              foreach my $k (keys %entry) {
              print DATA " $k -> $entry{$k}\n";
              }
              }
              close(DATA);
              return 1;
              }

              Works for me:

              $ cat /tmp/data
              HASH: hashh2
              RRohit -> 31
              RPoney -> 5
              HASH: hashh1
              Rohit -> 31
              Poney -> 5


              - Sebastian
              -
              Progress (n.): The process through which Usenet has evolved from
              smart people in front of dumb terminals to dumb people in front
              of smart terminals.
              -- obs@...
            • Rohitashva Sharma
              Hi Sebastian, Thanks a lot... regards Sharma On 10/12/06, Sebastian Jaenicke
              Message 6 of 6 , Oct 13, 2006
              • 0 Attachment
                Hi Sebastian,

                Thanks a lot...

                regards
                Sharma

                On 10/12/06, Sebastian Jaenicke
                <sjaenick+SOAPLITE@...-bielefeld.de> wrote:
                > On Thu, Oct 12, 2006 at 09:04:52PM +0200, Rohitashva Sharma wrote:
                > [..]
                > > CLIENT SIDE:
                > [..]
                > > eval '$soap_response = $soap_handle->handle_hash(%hash);';
                >
                > Use
                >
                > ->handle_hash(\%hash); # note the '\'
                >
                > here, which results in
                >
                > <handle_hash xmlns="http://localhost/Notd">
                > <c-gensym3>
                > <hashh2>
                > <RRohit xsi:type="xsd:int">31</RRohit>
                > <RPoney xsi:type="xsd:int">5</RPoney>
                > </hashh2>
                > <hashh1>
                > <Rohit xsi:type="xsd:int">31</Rohit>
                > <Poney xsi:type="xsd:int">5</Poney>
                > </hashh1>
                > </c-gensym3>
                > </handle_hash>
                >
                > > SERVER SIDE:
                >
                > sub handle_hash {
                > my ($self, $hash_ref) = @_;
                > my %hash = %$hash_ref;
                > open (DATA, ">>/tmp/data");
                > foreach my $key (keys %hash) {
                > print DATA "HASH: $key\n";
                > my %entry = %{$hash{$key}};
                > foreach my $k (keys %entry) {
                > print DATA " $k -> $entry{$k}\n";
                > }
                > }
                > close(DATA);
                > return 1;
                > }
                >
                > Works for me:
                >
                > $ cat /tmp/data
                > HASH: hashh2
                > RRohit -> 31
                > RPoney -> 5
                > HASH: hashh1
                > Rohit -> 31
                > Poney -> 5
                >
                >
                > - Sebastian
                > -
                > Progress (n.): The process through which Usenet has evolved from
                > smart people in front of dumb terminals to dumb people in front
                > of smart terminals.
                > -- obs@...
                >
              Your message has been successfully submitted and would be delivered to recipients shortly.