

One of PHP5's landmark new features is the inclusion of a library of SOAP functions that make it easy to interact with SOAP based web services. While these functions are very powerful, learning to use them the first time can be a little intimidating. The goal of this article is to introduce you to PHP5's basic SOAP functions and how they are used through a working example.
Web Services is an exploding technology and one that PHP is in an excellent position to leverage to offer our users an improved level of service. In this context web services will be used to refer to the technologies used for different websites to communicate with each other over the Internet.
Within the Web Services umbrella there are three commonly implemented standards for communication to take place, REST, XML-RPC and SOAP. This article will focus on SOAP, the most structured of the protocols, and also one of the trickiest to implement on your own. Luckily, you don't need to: PHP 5 ships with an excellent Soap library. With it you will be provided with an easy-to-use interface for the complex SOAP protocol. In this article I will provide you with a step-by-step series of instructions for interacting with a SOAP API that you may then replicate to use with whatever service you desire.
1. Register to use the web service you would like to interact with. Most web services require some type of registration, and will provide you with some sort of identification credentials like: username/password, developer key, or token. This example will use the Amazon web services, and you can obtain your developer key at: http://aws.amazon.com
2. Locate the .wsdl (wiz-dell) file associated with the service you would like to interact with, this URL is generally either listed quite predominantly, or is found within the “getting started” section of the documentation of the site you would like to work with. The Amazon web services wsdl file is located at: http://soap.amazon.com/schemas2/AmazonWebServices.wsdl
The built in SOAP functions work (for the purposes of this article) by interpreting the WSDL file, and providing the developer with an object oriented interface for the functions the WSDL indicates are available. When a call is made against a function within the client object, PHP goes out and makes the call against the remote server, providing the response as a result Object nicely encapsulating the entire SOAP process.
3. Within PHP create a Soap client, and make two basic function calls against that new client.

