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

Cannot call instance methods using SOAP::Lite created instance

Expand Messages
  • arthur_christoph
    I am just posting this as a new subject in case someone has a comment about it: I found the solution: my $protein =
    Message 1 of 1 , Jun 24, 2005
    • 0 Attachment
      I am just posting this as a new subject in case someone has a comment
      about it:

      I found the solution:
      my $protein = $soap->newProtein_With_ID_And_Name(1,"Insulin")->result;
      print $protein->{protid};
      print $protein->{protname};

      so my conclusion in soaplite, an instance method cannot for called for
      example try these instead:
      print $protein->getID;

      It will says something like this:
      Can't locate object method "getID" via package "Protein"

      --- In soaplite@yahoogroups.com, "arthur_christoph"
      <arthur_christoph@y...> wrote:
      > Hi all:
      > I tried to instantiate an object through soap::lite but failed when it
      > involves two attributes in other words more than one element in the
      > hash. Can anyone help me to figure what could have been the cause?
      > I have attached the client and server codes below.
      >
      > Thank you!
      > Arthur
      >
      > #!C:\Perl\bin\perl -w
      > use strict;
      > use SOAP::Lite;
      >
      > --Client Side
      > my $soap = SOAP::Lite
      > -> uri('http://localhost:8080/Protein')
      > -> proxy('http://localhost:8080/cgi-bin/SeedServer.cgi');
      > #my $protein = $soap->newProtein_With_Name("Insulin")->result;
      > #print $soap->getName($protein)->result;
      > my $protein =
      $soap->newProtein_With_ID_And_Name(1,"Insulin")->result;
      > print $soap->getName($protein)->result;
      > #The error message: Element 'protname' can't be allowed in valid XML
      > message. Died
      > --
      >
      > --Server Side
      > #!C:\Perl\bin\perl -w
      > use strict;
      > use SOAP::Transport::HTTP;
      >
      > use SOAP::Transport::HTTP;
      >
      > SOAP::Transport::HTTP::CGI
      > -> dispatch_to('Protein')
      > -> handle;
      >
      > package Protein;
      >
      > sub newProtein_With_Name{
      > #my $class = shift;
      > my $self = shift;
      > my $class = ref($self) || $self;
      > #my $protid = shift;
      > my $protname = shift;
      > #my $self = bless {ID => $id, Name => $name}, $class;
      > my $ref = {protname => $protname};
      > print $protname;
      > bless $ref, $class; #returns an instance of $self-a reference to an
      > anonymous hash
      > return $ref; #optional
      > }
      >
      > sub newProtein_With_ID_And_Name{
      > #my $class = shift;
      > my $self = shift;
      > my $class = ref($self) || $self;
      > my $protid = shift;
      > my $protname = shift;
      > my $ref = {protid => $protid, protname => $protname};
      > bless $ref, $class; #returns an instance of $self-a reference to an
      > anonymous hash
      > return $ref;
      > }
      >
      > sub getName{
      > my $self = shift;
      > $self->{protname};
      > }
      >
      > sub getID{
      > my $self = shift;
      > $self->{protid};
      > }
    Your message has been successfully submitted and would be delivered to recipients shortly.