Failed to invoke SOAP::Lite object with two parameters
am 21.06.2005 22:59:10 von ArthurHi 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;
my $protein = Protein->newProtein_With_ID_And_Name(1,"Insulin");
print $protein->getName;
print $protein->getID;
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};
}