HomePHP Page 2 - Using Amazon Web Services With PHP And SOAP (part 1)
Remote Control - PHP
It's the coolest store on the Web - and now, its databases are accessible to you. Welcome to Amazon Web Services, an XML-based API that allows you to quickly build an online store that leverages off Amazon.com's massive databases. Find out more, inside.
Before we get into the code, though, you need to have a clear understanding of how Amazon Web Services, aka AWS, works. This involves getting up close and personal with a complicated little critter known as SOAP, the Simple Object Access Protocol.
According to the primer available on the W3C's site (http://www.w3.org/2002/ws/), SOAP is a "lightweight protocol for exchange of information in a decentralized, distributed environment. It is an XML based protocol at the core of which is an envelope that defines a framework for describing what is in a message and how to process it and a transport binding framework for exchanging messages using an underlying protocol."
If you're anything like me, that probably made very little sense to you. So here's the Reader's Digest version, which is far more cogent: "SOAP is a simple XML based protocol to let applications exchange information over HTTP." (http://www.w3schools.com/soap/soap_intro.asp)
SOAP is a client-server paradigm which builds on existing Internet technologies to simplify the task of invoking procedures and accessing objects across a network. It uses XML to encode procedure invocations (and decode procedure responses) into a package suitable for transmission across a network, and HTTP to actually perform the transmission.
At one end of the connection, a SOAP server receives SOAP requests containing procedure calls, decodes them, invokes the function and packages the response into a SOAP packet suitable for retransmission back to the requesting client. The client can then decode the response and use the results of the procedure invocation in whatever manner it chooses. The entire process is fairly streamlined and, because of its reliance on existing standards, relatively easy to understand and use.
Here's a quick example of what a SOAP request for the procedure getFlavourOfTheDay() might look like:
I'm not going to get into the details of how SOAP works in
this article, preferring instead to focus on how SOAP can be exploited in the context of PHP and AWS. If you're new to SOAP, the information above should be sufficient to explain the basic concepts and ensure that you can follow the material that comes next; however, if you're interested in learning more about SOAP (or if you just have trouble falling asleep at night), you should read the W3C's specifications on the protocol - links will be included at the end of this article.