Prev | Current Page 777 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

COM WEB SERVICES 674
echo '
';
print_r($result);
echo '
';
}
catch (SoapFault $fault)
{
trigger_error('SOAP Fault: (faultcode: ' . $fault->faultcode . ', ' .
'faultstring: ' . $fault->faultstring . ')', E_USER_ERROR);
}
?>
The whole SOAP request code is enclosed in a try block. If the SOAP request fails, it throws
an exception of the SoapFault type, which we transform into an error using the trigger_error()
function. Read more on the SOAP exception at http://www.php.net/manual/en/function.is-soapfault.
php.
The result of the SOAP request is an object containing the requested data. If you load
test_soap.php in your browser (don??™t forget to put your access key ID in it), it should display
the data in a text format that??™s not easy to read by the human eye.
The code starts by creating a SOAP client object to the Amazon.com SOAP web service:
// Initialize SOAP client object
$client = new SoapClient(
'http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl');
The referenced Web Services Definition Language (WSDL) file describes all the functions
and their parameters??™ types that Amazon.com SOAP server understands. The previously created
Amazon.com SOAP client object knows about all these functions, and you can call them now
using something like this:
$result = $client->ItemSearch($request);
Alternatively, you can make the same call, and implicitly obtain the same results, by using
the __soapCall() function (http://www.


Pages:
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789
Hotel spa bilety lotnicze Noclegi Władysławowo koszule korporacyjne Apartamenty nad morzem