SetHandler perl-script PerlHandler Apache::SOAP PerlSetVar dispatch_to "/usr/local/apache/lib/soap" #### package Factory; use strict; use DBI; my $dbh = DBI->connect( qw(DBI:vendor:database:host user pass), { RaiseError => 1} ); sub instantiate { my ($self,$package,$id) = @_; my $sth = $dbh->selectall_arrayref(' select title,artist,year from songs where id = ? ',undef,$id)->[0]; my $obj = eval { $package->new($id,@$sth) }; return $@ ? undef : $obj; } package My::User; use strict; sub new { my ($class,$id,$title,$artist,$year) = @_; my $self = { id => $id, title => $title, artist => $artist, year => $year, }; return bless $self,$class; } # this will be discussed later ... sub foo { 'foo' } 1; #### use strict; use SOAP::Lite; use Data::Dumper; my $soap = SOAP::Lite ->uri("http://127.0.0.1/Factory") ->proxy("http://127.0.0.1/mod_soap"); my $object = $soap->instantiate('My::User','5')->result; print Dumper $object; #### $VAR1 = bless( { 'artist' => 'Van Halen', 'title' => 'You Really Got Me', 'id' => '5', 'year' => '1978' }, 'My::User' ); #### my $object = $soap->instantiate('My::User','5')->result; print $object->foo(); # yields: Can't locate object method "foo" via package "My::User" at ./instantiate.pl line 23.