/** * Initialize the soap client with the local information. * * @throws InvalidCredentialException If given credentials are invalid * @throws SoapCallException If Magento is not accessible. * @throws \SoapFault */ protected function connect() { try { $this->session = $this->client->login($this->clientParameters->getSoapUsername(), $this->clientParameters->getSoapApiKey()); } catch (\SoapFault $e) { if (static::MAGENTO_BAD_CREDENTIALS === $e->faultcode) { throw new InvalidCredentialException(sprintf('Error on Magento SOAP credentials to "%s": "%s".' . 'You should check your login and Magento API key.', $this->clientParameters->getSoapUrl(), $e->getMessage()), $e->getCode(), $e); } elseif (static::MAGENTO_CLIENT_NOT_CALLABLE === $e->faultcode) { $lastResponse = $this->client->__getLastResponse(); echo "DEBUG: Last SOAP response: " . $lastResponse . "\n"; if (strlen($lastResponse) <= 200) { $truncatedLastResponse = htmlentities($lastResponse); } else { $truncatedLastResponse = substr(htmlentities($lastResponse), 0, 100) . nl2br("\n...\n") . substr(htmlentities($lastResponse), -100); } throw new SoapCallException(sprintf('Error on Magento client to "%s": "%s".' . 'Something is probably wrong in the last SOAP response:' . nl2br("\n") . '"%s"', $this->clientParameters->getSoapUrl(), $e->getMessage(), $truncatedLastResponse), $e->getCode(), $e); } else { throw $e; } } }