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

SOAP::Lite not returning expected results

Expand Messages
  • Ovid
    Crossposted to http://www.perlmonks.org/index.pl?displaytype=display;node_id=398955 I used the program stubmaker.pl that s distributed with SOAP::Lite to
    Message 1 of 3 , Oct 13, 2004
    • 0 Attachment
      Crossposted to
      http://www.perlmonks.org/index.pl?displaytype=display;node_id=398955

      I used the program stubmaker.pl that's distributed with SOAP::Lite to
      create an SOAP client and I can't seem to retrieve the data correctly.
      The relative snippet of code is this:

      my $som = $self
      ->endpoint($method{endpoint})
      ->uri($method{uri})
      ->on_action( sub { qq/"$method{soapaction}"/ } )
      ->call($method => map { @templates ?
      shift(@templates)->value($_) : $_ } @_);
      return $som unless UNIVERSAL::isa($som => 'SOAP::SOM');
      return wantarray
      ? $som->paramsall
      : $som->result;

      I used Data::Dumper on the SOAP::SOM ($som) object that was returned
      and buried deep in the data structure is the data that I need.
      $self->call is returning a SOAP::SOM object and I'm calling it in list
      context, so it's the $som->paramsall method which is failing. It
      returns the following data structure:

      @movies = (
      {
      'Movies' => {
      'Movie' => ''
      }
      }
      );

      The XML returned by the SOAP call resembles the following (with many
      thousands of movies cut out and this is actually returned on one line.)

      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
      <GetMoviesResponse xmlns="http://www.dtmovies.com/websvcs/">
      <GetMoviesResult>
      <Movies xmlns="">
      <Movie Title="10 Things I Hate About You" FilmID="474" />
      <Movie Title="102 Dalmatians" FilmID="912" />
      <Movie Title="13 Going on 30" FilmID="1496" />
      <Movie Title="15 Minutes" FilmID="966" />
      </Movies>
      </GetMoviesResult>
      </GetMoviesResponse>
      </soap:Body>
      </soap:Envelope>

      Do you see anything wrong with the above? Would providing a snippet of
      the (long) data structure in $som be useful? Should I just run my head
      through a meat grinder instead? Inquiring minds want to know.

      I'm using SOAP::Lite version 0.60.

      Cheers,
      Ovid

      =====
      Silence is Evil http://users.easystreet.com/ovid/philosophy/decency.html
      Ovid http://www.perlmonks.org/index.pl?node_id=17000
      Web Programming with Perl http://users.easystreet.com/ovid/cgi_course/
    • jpeyser
      Ovid, You have two choices. Modify the stub code to always return a SOAP::SOM object. return $som; Or evaluate the string and work with the hash. eval($som);
      Message 2 of 3 , Oct 13, 2004
      • 0 Attachment
        Ovid,

        You have two choices.

        Modify the stub code to always return a SOAP::SOM object.

        return $som;

        Or evaluate the string and work with the hash.

        eval($som);

        print $movies[0]...

        Jonathan

        --- In soaplite@yahoogroups.com, Ovid <publiustemp-soaplite@y...> wrote:
        > Crossposted to
        > http://www.perlmonks.org/index.pl?displaytype=display;node_id=398955
        >
        > I used the program stubmaker.pl that's distributed with SOAP::Lite to
        > create an SOAP client and I can't seem to retrieve the data correctly.
        > The relative snippet of code is this:
        >
        > my $som = $self
        > ->endpoint($method{endpoint})
        > ->uri($method{uri})
        > ->on_action( sub { qq/"$method{soapaction}"/ } )
        > ->call($method => map { @templates ?
        > shift(@templates)->value($_) : $_ } @_);
        > return $som unless UNIVERSAL::isa($som => 'SOAP::SOM');
        > return wantarray
        > ? $som->paramsall
        > : $som->result;
        >
        > I used Data::Dumper on the SOAP::SOM ($som) object that was returned
        > and buried deep in the data structure is the data that I need.
        > $self->call is returning a SOAP::SOM object and I'm calling it in list
        > context, so it's the $som->paramsall method which is failing. It
        > returns the following data structure:
        >
        > @movies = (
        > {
        > 'Movies' => {
        > 'Movie' => ''
        > }
        > }
        > );
        >
        > The XML returned by the SOAP call resembles the following (with many
        > thousands of movies cut out and this is actually returned on one line.)
        >
        > <?xml version="1.0" encoding="utf-8"?>
        > <soap:Envelope
        > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
        > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        > xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        > <soap:Body>
        > <GetMoviesResponse xmlns="http://www.dtmovies.com/websvcs/">
        > <GetMoviesResult>
        > <Movies xmlns="">
        > <Movie Title="10 Things I Hate About You" FilmID="474" />
        > <Movie Title="102 Dalmatians" FilmID="912" />
        > <Movie Title="13 Going on 30" FilmID="1496" />
        > <Movie Title="15 Minutes" FilmID="966" />
        > </Movies>
        > </GetMoviesResult>
        > </GetMoviesResponse>
        > </soap:Body>
        > </soap:Envelope>
        >
        > Do you see anything wrong with the above? Would providing a snippet of
        > the (long) data structure in $som be useful? Should I just run my head
        > through a meat grinder instead? Inquiring minds want to know.
        >
        > I'm using SOAP::Lite version 0.60.
        >
        > Cheers,
        > Ovid
        >
        > =====
        > Silence is Evil
        http://users.easystreet.com/ovid/philosophy/decency.html
        > Ovid
        http://www.perlmonks.org/index.pl?node_id=17000
        > Web Programming with Perl http://users.easystreet.com/ovid/cgi_course/
      • jpeyser
        Correction. The second option should be eval(Dumper($som)); ... line.) ... http://users.easystreet.com/ovid/cgi_course/
        Message 3 of 3 , Oct 13, 2004
        • 0 Attachment
          Correction.

          The second option should be

          eval(Dumper($som));

          --- In soaplite@yahoogroups.com, "jpeyser" <jpeyser@p...> wrote:
          >
          > Ovid,
          >
          > You have two choices.
          >
          > Modify the stub code to always return a SOAP::SOM object.
          >
          > return $som;
          >
          > Or evaluate the string and work with the hash.
          >
          > eval($som);
          >
          > print $movies[0]...
          >
          > Jonathan
          >
          > --- In soaplite@yahoogroups.com, Ovid <publiustemp-soaplite@y...> wrote:
          > > Crossposted to
          > > http://www.perlmonks.org/index.pl?displaytype=display;node_id=398955
          > >
          > > I used the program stubmaker.pl that's distributed with SOAP::Lite to
          > > create an SOAP client and I can't seem to retrieve the data correctly.
          > > The relative snippet of code is this:
          > >
          > > my $som = $self
          > > ->endpoint($method{endpoint})
          > > ->uri($method{uri})
          > > ->on_action( sub { qq/"$method{soapaction}"/ } )
          > > ->call($method => map { @templates ?
          > > shift(@templates)->value($_) : $_ } @_);
          > > return $som unless UNIVERSAL::isa($som => 'SOAP::SOM');
          > > return wantarray
          > > ? $som->paramsall
          > > : $som->result;
          > >
          > > I used Data::Dumper on the SOAP::SOM ($som) object that was returned
          > > and buried deep in the data structure is the data that I need.
          > > $self->call is returning a SOAP::SOM object and I'm calling it in list
          > > context, so it's the $som->paramsall method which is failing. It
          > > returns the following data structure:
          > >
          > > @movies = (
          > > {
          > > 'Movies' => {
          > > 'Movie' => ''
          > > }
          > > }
          > > );
          > >
          > > The XML returned by the SOAP call resembles the following (with many
          > > thousands of movies cut out and this is actually returned on one
          line.)
          > >
          > > <?xml version="1.0" encoding="utf-8"?>
          > > <soap:Envelope
          > > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
          > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          > > xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          > > <soap:Body>
          > > <GetMoviesResponse xmlns="http://www.dtmovies.com/websvcs/">
          > > <GetMoviesResult>
          > > <Movies xmlns="">
          > > <Movie Title="10 Things I Hate About You" FilmID="474" />
          > > <Movie Title="102 Dalmatians" FilmID="912" />
          > > <Movie Title="13 Going on 30" FilmID="1496" />
          > > <Movie Title="15 Minutes" FilmID="966" />
          > > </Movies>
          > > </GetMoviesResult>
          > > </GetMoviesResponse>
          > > </soap:Body>
          > > </soap:Envelope>
          > >
          > > Do you see anything wrong with the above? Would providing a snippet of
          > > the (long) data structure in $som be useful? Should I just run my head
          > > through a meat grinder instead? Inquiring minds want to know.
          > >
          > > I'm using SOAP::Lite version 0.60.
          > >
          > > Cheers,
          > > Ovid
          > >
          > > =====
          > > Silence is Evil
          > http://users.easystreet.com/ovid/philosophy/decency.html
          > > Ovid
          > http://www.perlmonks.org/index.pl?node_id=17000
          > > Web Programming with Perl
          http://users.easystreet.com/ovid/cgi_course/
        Your message has been successfully submitted and would be delivered to recipients shortly.