################################################################ ## BeVocal Sample Code # ## (C) Copyright BeVocal, Inc. 2003, All rights reserved. # ## # ## This Sample Code is provided for your reference purposes, # ## and carries no warranty whatsoever. Use of this code is # ## restricted to use in connection with the BeVocal Cafe # ## developer's program. # ## # ## BeVocal disclaims and excludes any and all warranties of # ## merchantability, title and fitness for a particular # ## purpose. BeVocal does not warrant that the software will # ## satisfy your requirements, or that the software is without # ## defect or error. You are using the software at your own # ## risk. # ## # ## This sample accesses the Location Information Service. # ## ################################################################ # NOTE: Uncomment this next line, to debug the SOAP request/response. # use SOAP::Lite +trace => 'debug'; use SOAP::Lite; # getUSZipCodeFromPhone(phone) # # input: phone number (string) # output: the ZIP code associated with that phone number (string) # errors: if there is a SOAP fault, or a transport error, # the perl process will die with an error message. sub getUSZipCodeFromPhone { my ($phone)= @_; # Setup a pointer to the Location Service my $locationService = SOAP::Lite ->proxy('http://cafe.services.bevocal.com/LocationInfoService_v1/services/LocationInfoService_v1') ->uri('http://www.bevocal.com/soap/services/') ->on_fault( sub { my($locationService, $res) = @_; die ref $res ? $res->faultstring : $locationService->transport->status, "\n"; }); # To call this service, we need an Access Key, passed in via the SOAP header. my $head = SOAP::Header->name( platformServicesSessionID => '===insert your 128-bit key here==='); # Call the Location Service. # If there's a problem, print out fault or transport info and die. my $res1 = $locationService->getUSZipCodeFromPhone( $head, SOAP::Data->type('string')->name(phone => $phone)); return $res1->result(); } print "The ZIP code for phone number 650-641-1437 is ", getUSZipCodeFromPhone('6506411437'), ".";