title: Why I am getting Class "SoapClient' not found in..etc"
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6760716/wamp-stack-php-fatal-error-class-soapclient-not-found">WAMP Stack PHP “Fatal error: Class ‘SoapClient’ not found”</a>  </p>
  </blockquote>
  
  
  
  <p>I downloaded a library from this site <a href="https://github.com/Exeu/Amazon-ECS-PHP-Library/downloads" rel="nofollow noreferrer">library</a> and when I tried to use it's examples it says : "Fatal error: Class 'SoapClient' not found in C:\wamp\www\Amazon-ECS\Exeu-Amazon-ECS-PHP-Library-9030053\lib\AmazonECS.class.php on line 231" How should I able to fix this?</p>
  
  <pre><code>    &lt;?php
  /**
   * Amazon ECS Class
   * http://www.amazon.com
   * =====================
   *
   * This class fetchs productinformation via the Product Advertising API by Amazon (formerly ECS).
   * It supports three basic operations: ItemSearch, ItemLookup and BrowseNodeLookup.
   * These operations could be expanded with extra prarmeters to specialize the query.
   *
   * Requirement is the PHP extension SOAP.
   *
   * @package      AmazonECS
   * @license      http://www.gnu.org/licenses/gpl.txt GPL
   * @version      1.3.4-DEV
   * @author       Exeu &lt;exeu65@googlemail.com&gt;
   * @contributor  Julien Chaumond &lt;chaumond@gmail.com&gt;
   * @link         http://github.com/Exeu/Amazon-ECS-PHP-Library/wiki Wiki
   * @link         http://github.com/Exeu/Amazon-ECS-PHP-Library Source
   */
  class AmazonECS
  {
    const RETURN_TYPE_ARRAY  = 1;
    const RETURN_TYPE_OBJECT = 2;
  
    /**
     * Baseconfigurationstorage
     *
     * @var array
     */
    private $requestConfig = array(
      'requestDelay' =&gt; false
    );
  
    /**
     * Responseconfigurationstorage
     *
     * @var array
     */
    private $responseConfig = array(
      'returnType'          =&gt; self::RETURN_TYPE_OBJECT,
      'responseGroup'       =&gt; 'Small',
      'optionalParameters'  =&gt; array()
    );
  
    /**
     * All possible locations
     *
     * @var array
     */
    private $possibleLocations = array('de', 'com', 'co.uk', 'ca', 'fr', 'co.jp', 'it', 'cn', 'es');
  
    /**
     * The WSDL File
     *
     * @var string
     */
    protected $webserviceWsdl = 'http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl';
  
    /**
     * The SOAP Endpoint
     *
     * @var string
     */
    protected $webserviceEndpoint = 'https://webservices.amazon.%%COUNTRY%%/onca/soap?Service=AWSECommerceService';
  
    /**
     * @param string $accessKey
     * @param string $secretKey
     * @param string $country
     * @param string $associateTag
     */
    public function __construct($accessKey, $secretKey, $country, $associateTag)
    {
      if (empty($accessKey) || empty($secretKey))
      {
        throw new Exception('No Access Key or Secret Key has been set');
      }
  
      $this-&gt;requestConfig['accessKey']     = $accessKey;
      $this-&gt;requestConfig['secretKey']     = $secretKey;
      $this-&gt;associateTag($associateTag);
      $this-&gt;country($country);
    }
  
    /**
     * execute search
     *
     * @param string $pattern
     *
     * @return array|object return type depends on setting
     *
     * @see returnType()
     */
    public function search($pattern, $nodeId = null)
    {
      if (false === isset($this-&gt;requestConfig['category']))
      {
        throw new Exception('No Category given: Please set it up before');
      }
  
      $browseNode = array();
      if (null !== $nodeId &amp;&amp; true === $this-&gt;validateNodeId($nodeId))
      {
        $browseNode = array('BrowseNode' =&gt; $nodeId);
      }
  
      $params = $this-&gt;buildRequestParams('ItemSearch', array_merge(
        array(
          'Keywords' =&gt; $pattern,
          'SearchIndex' =&gt; $this-&gt;requestConfig['category']
        ),
        $browseNode
      ));
  
      return $this-&gt;returnData(
        $this-&gt;performSoapRequest("ItemSearch", $params)
      );
    }
  
    /**
     * execute ItemLookup request
     *
     * @param string $asin
     *
     * @return array|object return type depends on setting
     *
     * @see returnType()
     */
    public function lookup($asin)
    {
      $params = $this-&gt;buildRequestParams('ItemLookup', array(
        'ItemId' =&gt; $asin,
      ));
  
      return $this-&gt;returnData(
        $this-&gt;performSoapRequest("ItemLookup", $params)
      );
    }
  
    /**
     * Implementation of BrowseNodeLookup
     * This allows to fetch information about nodes (children anchestors, etc.)
     *
     * @param integer $nodeId
     */
    public function browseNodeLookup($nodeId)
    {
      $this-&gt;validateNodeId($nodeId);
  
      $params = $this-&gt;buildRequestParams('BrowseNodeLookup', array(
        'BrowseNodeId' =&gt; $nodeId
      ));
  
      return $this-&gt;returnData(
        $this-&gt;performSoapRequest("BrowseNodeLookup", $params)
      );
    }
  
    /**
     * Implementation of SimilarityLookup
     * This allows to fetch information about product related to the parameter product
     *
     * @param string $asin
     */
    public function similarityLookup($asin)
    {
      $params = $this-&gt;buildRequestParams('SimilarityLookup', array(
        'ItemId' =&gt; $asin
      ));
  
      return $this-&gt;returnData(
        $this-&gt;performSoapRequest("SimilarityLookup", $params)
      );
    }
  
    /**
     * Builds the request parameters
     *
     * @param string $function
     * @param array  $params
     *
     * @return array
     */
    protected function buildRequestParams($function, array $params)
    {
      $associateTag = array();
  
      if(false === empty($this-&gt;requestConfig['associateTag']))
      {
        $associateTag = array('AssociateTag' =&gt; $this-&gt;requestConfig['associateTag']);
      }
  
      return array_merge(
        $associateTag,
        array(
          'AWSAccessKeyId' =&gt; $this-&gt;requestConfig['accessKey'],
          'Request' =&gt; array_merge(
            array('Operation' =&gt; $function),
            $params,
            $this-&gt;responseConfig['optionalParameters'],
            array('ResponseGroup' =&gt; $this-&gt;prepareResponseGroup())
      )));
    }
  
    /**
     * Prepares the responsegroups and returns them as array
     *
     * @return array|prepared responsegroups
     */
    protected function prepareResponseGroup()
    {
      if (false === strstr($this-&gt;responseConfig['responseGroup'], ','))
        return $this-&gt;responseConfig['responseGroup'];
  
      return explode(',', $this-&gt;responseConfig['responseGroup']);
    }
  
    /**
     * @param string $function Name of the function which should be called
     * @param array $params Requestparameters 'ParameterName' =&gt; 'ParameterValue'
     *
     * @return array The response as an array with stdClass objects
     */
    protected function performSoapRequest($function, $params)
    {
      if (true ===  $this-&gt;requestConfig['requestDelay']) {
        sleep(1);
      }
  
      $soapClient = new SoapClient(
        $this-&gt;webserviceWsdl,
        array('exceptions' =&gt; 1)
      );
  
      $soapClient-&gt;__setLocation(str_replace(
        '%%COUNTRY%%',
        $this-&gt;responseConfig['country'],
        $this-&gt;webserviceEndpoint
      ));
  
      $soapClient-&gt;__setSoapHeaders($this-&gt;buildSoapHeader($function));
  
      return $soapClient-&gt;__soapCall($function, array($params));
    }
  
    /**
     * Provides some necessary soap headers
     *
     * @param string $function
     *
     * @return array Each element is a concrete SoapHeader object
     */
    protected function buildSoapHeader($function)
    {
      $timeStamp = $this-&gt;getTimestamp();
      $signature = $this-&gt;buildSignature($function . $timeStamp);
  
      return array(
        new SoapHeader(
          'http://security.amazonaws.com/doc/2007-01-01/',
          'AWSAccessKeyId',
          $this-&gt;requestConfig['accessKey']
        ),
        new SoapHeader(
          'http://security.amazonaws.com/doc/2007-01-01/',
          'Timestamp',
          $timeStamp
        ),
        new SoapHeader(
          'http://security.amazonaws.com/doc/2007-01-01/',
          'Signature',
          $signature
        )
      );
    }
  
    /**
     * provides current gm date
     *
     * primary needed for the signature
     *
     * @return string
     */
    final protected function getTimestamp()
    {
      return gmdate("Y-m-d\TH:i:s\Z");
    }
  
    /**
     * provides the signature
     *
     * @return string
     */
    final protected function buildSignature($request)
    {
      return base64_encode(hash_hmac("sha256", $request, $this-&gt;requestConfig['secretKey'], true));
    }
  
    /**
     * Basic validation of the nodeId
     *
     * @param integer $nodeId
     *
     * @return boolean
     */
    final protected function validateNodeId($nodeId)
    {
      if (false === is_numeric($nodeId) || $nodeId &lt;= 0)
      {
        throw new InvalidArgumentException(sprintf('Node has to be a positive Integer.'));
      }
  
      return true;
    }
  
    /**
     * Returns the response either as Array or Array/Object
     *
     * @param object $object
     *
     * @return mixed
     */
    protected function returnData($object)
    {
      switch ($this-&gt;responseConfig['returnType'])
      {
        case self::RETURN_TYPE_OBJECT:
          return $object;
        break;
  
        case self::RETURN_TYPE_ARRAY:
          return $this-&gt;objectToArray($object);
        break;
  
        default:
          throw new InvalidArgumentException(sprintf(
            "Unknwon return type %s", $this-&gt;responseConfig['returnType']
          ));
        break;
      }
    }
  
    /**
     * Transforms the responseobject to an array
     *
     * @param object $object
     *
     * @return array An arrayrepresentation of the given object
     */
    protected function objectToArray($object)
    {
      $out = array();
      foreach ($object as $key =&gt; $value)
      {
        switch (true)
        {
          case is_object($value):
            $out[$key] = $this-&gt;objectToArray($value);
          break;
  
          case is_array($value):
            $out[$key] = $this-&gt;objectToArray($value);
          break;
  
          default:
            $out[$key] = $value;
          break;
        }
      }
  
      return $out;
    }
  
    /**
     * set or get optional parameters
     *
     * if the argument params is null it will reutrn the current parameters,
     * otherwise it will set the params and return itself.
     *
     * @param array $params the optional parameters
     *
     * @return array|AmazonECS depends on params argument
     */
    public function optionalParameters($params = null)
    {
      if (null === $params)
      {
        return $this-&gt;responseConfig['optionalParameters'];
      }
  
      if (false === is_array($params))
      {
        throw new InvalidArgumentException(sprintf(
          "%s is no valid parameter: Use an array with Key =&gt; Value Pairs", $params
        ));
      }
  
      $this-&gt;responseConfig['optionalParameters'] = $params;
  
      return $this;
    }
  
    /**
     * Set or get the country
     *
     * if the country argument is null it will return the current
     * country, otherwise it will set the country and return itself.
     *
     * @param string|null $country
     *
     * @return string|AmazonECS depends on country argument
     */
    public function country($country = null)
    {
      if (null === $country)
      {
        return $this-&gt;responseConfig['country'];
      }
  
      if (false === in_array(strtolower($country), $this-&gt;possibleLocations))
      {
        throw new InvalidArgumentException(sprintf(
          "Invalid Country-Code: %s! Possible Country-Codes: %s",
          $country,
          implode(', ', $this-&gt;possibleLocations)
        ));
      }
  
      $this-&gt;responseConfig['country'] = strtolower($country);
  
      return $this;
    }
  
    /**
     * Setting/Getting the amazon category
     *
     * @param string $category
     *
     * @return string|AmazonECS depends on category argument
     */
    public function category($category = null)
    {
      if (null === $category)
      {
        return isset($this-&gt;requestConfig['category']) ? $this-&gt;requestConfig['category'] : null;
      }
  
      $this-&gt;requestConfig['category'] = $category;
  
      return $this;
    }
  
    /**
     * Setting/Getting the responsegroup
     *
     * @param string $responseGroup Comma separated groups
     *
     * @return string|AmazonECS depends on responseGroup argument
     */
    public function responseGroup($responseGroup = null)
    {
      if (null === $responseGroup)
      {
        return $this-&gt;responseConfig['responseGroup'];
      }
  
      $this-&gt;responseConfig['responseGroup'] = $responseGroup;
  
      return $this;
    }
  
    /**
     * Setting/Getting the returntype
     * It can be an object or an array
     *
     * @param integer $type Use the constants RETURN_TYPE_ARRAY or RETURN_TYPE_OBJECT
     *
     * @return integer|AmazonECS depends on type argument
     */
    public function returnType($type = null)
    {
      if (null === $type)
      {
        return $this-&gt;responseConfig['returnType'];
      }
  
      $this-&gt;responseConfig['returnType'] = $type;
  
      return $this;
    }
  
    /**
     * Setter/Getter of the AssociateTag.
     * This could be used for late bindings of this attribute
     *
     * @param string $associateTag
     *
     * @return string|AmazonECS depends on associateTag argument
     */
    public function associateTag($associateTag = null)
    {
      if (null === $associateTag)
      {
        return $this-&gt;requestConfig['associateTag'];
      }
  
      $this-&gt;requestConfig['associateTag'] = $associateTag;
  
      return $this;
    }
  
    /**
     * @deprecated use returnType() instead
     */
    public function setReturnType($type)
    {
      return $this-&gt;returnType($type);
    }
  
    /**
     * Setting the resultpage to a specified value.
     * Allows to browse resultsets which have more than one page.
     *
     * @param integer $page
     *
     * @return AmazonECS
     */
    public function page($page)
    {
      if (false === is_numeric($page) || $page &lt;= 0)
      {
        throw new InvalidArgumentException(sprintf(
          '%s is an invalid page value. It has to be numeric and positive',
          $page
        ));
      }
  
      $this-&gt;responseConfig['optionalParameters'] = array_merge(
        $this-&gt;responseConfig['optionalParameters'],
        array("ItemPage" =&gt; $page)
      );
  
      return $this;
    }
  
    /**
     * Enables or disables the request delay.
     * If it is enabled (true) every request is delayed one second to get rid of the api request limit.
     *
     * Reasons for this you can read on this site:
     * https://affiliate-program.amazon.com/gp/advertising/api/detail/faq.html
     *
     * By default the requestdelay is disabled
     *
     * @param boolean $enable true = enabled, false = disabled
     *
     * @return boolean|AmazonECS depends on enable argument
     */
    public function requestDelay($enable = null)
    {
      if (false === is_null($enable) &amp;&amp; true === is_bool($enable))
      {
        $this-&gt;requestConfig['requestDelay'] = $enable;
  
        return $this;
      }
  
      return $this-&gt;requestConfig['requestDelay'];
    }
  }
  </code></pre>