44
855
Solution Overview
// perform actual soap query
$result = $soap_proxy->BrowseNodeSearchRequest($parameters);
if(isSOAPError($result))
return false;
$this->totalResults = $result[‘TotalResults’];
foreach($result[‘Details’] as $product)
{
$this->products[] = new Product($product);
}
unset($soapclient);
unset($soap_proxy) ;
There are no extra functions to go through here;the SOAP client does everything for
you.
You begin by creating an instance of the SOAP client:
$soapclient = new soapclient(
‘http://soap.amazon.com/schemas2/AmazonWebServices.wsdl’,
‘wsdl’);
Here, you provide the client with two parameters.The first is the WSDL description of
the service,and the second parameter tells the SOAP client that this is a WSDL URL.
Alternatively,you could just provide one parameter:the endpoint of the service,which is
the direct URL of the SOAP Server.
We chose to do it this way for a good reason,which you can see right there in the
next line of code:
$soap_proxy = $soapclient->getProxy();
This line creates a class according to the information in the WSDL document.This class,
the SOAP proxy,will have methods that correspond to the methods of the Web Service.
This makes life much easier.You can interact with the Web Service as though it were a
local PHP class.
Next, you set up an array of the parameters you need to pass to the
browsenode
query:
$parameters[‘mode’]=$mode;
$parameters[‘page’]=$page;
$parameters[‘type’]=’heavy’;
$parameters[‘tag’]=$this->_assocID;
$parameters[‘devtag’]=$this->_devTag;
$parameters[‘sort’]=’+salesrank’;
$parameters[‘browse_node’] = $browseNode;
Using the
proxy
class,you can then just call the Web Service methods,passing in the
array of parameters: