Hi

It's Mark's class workshop today :)

I want to wrap up a SOAP service handle (returned from a call to a wsdl 
file) in a class (ultimately so I can make it a singleton and only call it 
once but we'll leave that for the purposes of this example).

So if I have something like this (calling a random public SOAP service)

use strict;
use warnings;
use SOAP::Lite;
use Data::Dumper;
my $service = 
SOAP::Lite->service('http://ws.cisa.ca/WehireWS/JobsWs.asmx?WSDL');
my $result = $service->GetAll;
print Dumper($result);

It works fine and I get

$VAR1 = {
          'JobDetail' => {
                         'PostingDate' => '1/30/2006',
                         'Location' => 'British Columbia',
                         'Url' => 
'http://www.wehire.ca/view.php?job_id=1408',
                         'Category' => 'Construction',
                         'Company' => 'XS West Construction Group',
                         'Title' => 'Equipment Operator'
                       }
        };

However if I try to abstract it into my own class eg

#############

package Soap;
use strict;
use warnings;
use SOAP::Lite;

sub new {

 my $class = shift;

 my $self = 
SOAP::Lite->service('http://ws.cisa.ca/WehireWS/JobsWs.asmx?WSDL');

 bless ($self, $class);

 return $self;

}

1;

################

use strict;
use warnings;
use Soap;
use Data::Dumper;
my $service = Soap->new;
my $result = $service->GetAll;
print Dumper($result);

#################

I get

Can't locate object method "GetAll" via package "Soap" at soap2.pl line 6.

I don't expect anyone to read the SOAP::Lite documentation for me but I am 
wondering whether there is anything fundamentally flawed in my approach?

Thanks
Mark 

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to