use strict;
use API::Translator;
use SOAP::Transport::HTTP;
SOAP::Transport::HTTP::CGI
-> dispatch_to('API::Translator')
-> handle;
####
use strict;
print "Content-type: text/html\n\n";
my $client = SOAP::Lite->new(
uri => 'http://www.example.com/API/Translator/',
proxy => [
'http://sandbox.example.net/api/',
credentials => [
'sandbox.example.net:80', # hostname:port
'EXAMPLE', # realm
'user' => 'password' # username => password
]
]
);
my %address = (
'line1' => '1234 Main Street',
'line2' => 'Apartment X',
'city' => 'Richmond',
'state' => 'Virginia',
'zip' => '23220'
);
# Regardless of how or what I pass, I still get the same error:
my $result = $client->normalize(SOAP::Data->name('address')->value(\%address));
#my $result = $client->normalize(\%address);
#my $result = $client->normalize('HEY!');
unless ($result->fault) {
print $result->result();
} else {
print join ', ',
$result->faultcode,
$result->faultstring;
}
####
use MooseX::Declare;
class API::Translator {
use strict;
use warnings;
has 'normalizer' => ( is =>'rw', isa => 'Address::Normalizer');
# This method throws an error regardless of what I pass it. The error is thrown on the line that defines the method itself, so it doesn't matter what code is inside the method. We never get that far.
method normalize($address) {
require Address::Normalizer;
# Initialize the services needed to normalize addresses.
$self->normalizer( Address::Normalizer->new->connect('127.0.0.1', '56789') );
$self->normalizer->normalize($address);
return $self->normalizer->response();
}
# This function from the SOAP::Lite documentation. This returns data without error.
sub f2c {
my ($class, $f) = @_;
return 5/9*($f-32);
}
}
####
soap:Server, Validation failed for 'MooseX::Types::Structured::Tuple[MooseX::Types::Structured::Tuple[Object,Defined],MooseX::Types::Structured::Dict[]]' failed with value [ [ "API::Translator", HASH(0x92c11fc) ], { } ], Internal Validation Error is: Validation failed for 'MooseX::Types::Structured::Tuple[Object,Defined]' failed with value [ "API::Translator", { city: "Richmond", line1: "1234 Main Street", line2: "Apartment X", state: "Virginia", zip: 23220 } ] at [...]/MooseX/Method/Signatures/Meta/Method.pm line 443 MooseX::Method::Signatures::Meta::Method::validate('MooseX::Method::Signatures::Meta::Method=HASH(0x8f0e660)', 'ARRAY(0x8e603b4)') called at [...]/MooseX/Method/Signatures/Meta/Method.pm line 145 API::Translator::normalize('API::Translator', 'HASH(0x92c11fc)') called at [...]/SOAP/Lite.pm line 2797 eval {...} called at [...]/SOAP/Lite.pm line 2782 eval {...} called at [...]/SOAP/Lite.pm line 2748 SOAP::Server::handle('SOAP::Transport::HTTP::CGI=HASH(0x91a5170)', '
####
method f2c ($f) {
return 5/9*($f-32);
}