## ## exchange.pl -- demo CGI program which just responds to a soap call ## use SOAP::Transport::HTTP; my %currency=( 'EUR',1, 'BEF',40.3399, 'DEM',1.95583, 'ESP',166.386, 'FRF',6.55957, 'GRD',340.750, 'IEP',0.787564, 'ITL',1936.27, 'LUF',40.3399, 'NLG',2.20371, 'ATS',13.7603, 'PTE',200.482, 'FIM',5.94573); # Deploy Services as 'ExchangeRates' # (SOAP Wrapper around class 'ExchangeRates') SOAP::Transport::HTTP::CGI -> dispatch_to('ExchangeRates') -> handle; package ExchangeRates; # Method getRate(currencyID); sub getRate { my ($class, $currencyID) = @_; if ($currency{$currencyID} eq "") { # SOAP Fault die_with_fault(); } return "$currency{$currencyID}"; } # constructor for object sub new { # allow class and instance methods my $self = shift; my $class = ref($self) || $self; return bless{_currencyID => shift} => $class || die "Problem while creating object" ; } sub die_with_fault { die SOAP::Fault -> faultcode('Client.unknownCurrency') -> faultstring('You specified an unknown Currency') -> faultdetail(bless {code => 1} => 'BadError') }