diff --git a/Payment/PayPal/SOAP.php b/Payment/PayPal/SOAP.php index 11118c2..f939899 100644 --- a/Payment/PayPal/SOAP.php +++ b/Payment/PayPal/SOAP.php @@ -359,14 +359,20 @@ public function __construct(array $options) */ public function call($requestName, $arguments = array()) { - try { - $client = $this->getSoapClient(); + $client = $this->getSoapClient(); + + // Use a unique client. If an exception is thrown, state will be + // preserved if subsequent requests are made. + $client = clone $client; + $headers = $this->getSoapHeaders(); + + try { $response = $client->__soapCall( $requestName, array($arguments), null, - $this->getSoapHeader() + $headers ); if (isset($response->Errors)) { @@ -409,8 +415,6 @@ public function call($requestName, $arguments = array()) ); } } - - return $response; } catch (SoapFault $e) { $message = $e->getMessage(); @@ -439,8 +443,10 @@ public function call($requestName, $arguments = array()) // Unknown SOAP exception, pass it along. throw new Payment_PayPal_SOAP_FaultException('PayPal SOAP Error: ' . - $e->getMessage(), $e->getCode(), $e); + $e->getMessage(), $e->getCode(), $e, $client); } + + return $response; } // }}} diff --git a/Payment/PayPal/SOAP/Exceptions.php b/Payment/PayPal/SOAP/Exceptions.php index 32fcf80..bc6a678 100644 --- a/Payment/PayPal/SOAP/Exceptions.php +++ b/Payment/PayPal/SOAP/Exceptions.php @@ -273,20 +273,31 @@ class Payment_PayPal_SOAP_FaultException extends */ private $_soapFault = null; + /** + * The SOAP client that caused the exception + * + * @var SoapClient + * @see Payment_PayPal_SOAP_FaultException::getSoapClient() + */ + private $_soapClient = null; + // }}} // {{{ public function __construct() /** * Creates a new PayPal SOAP fault exception * - * @param string $message the exception message. - * @param integer $code the exception code. - * @param SoapFault $soapFault the original SoapFault. + * @param string $message the exception message. + * @param integer $code the exception code. + * @param SoapFault $soapFault the original SoapFault. + * @param SoapClient $soapClient the SOAP client that caused the fault. */ - public function __construct($message, $code, SoapFault $soapFault) + public function __construct($message, $code, SoapFault $soapFault, + SoapClient $soapClient) { parent::__construct($message, $code); - $this->_soapFault = $soapFault; + $this->_soapFault = $soapFault; + $this->_soapClient = $soapClient; } // }}} @@ -303,6 +314,19 @@ public function getSoapFault() return $this->_soapFault; } + // }}} + // {{{ getSoapClient() + + /** + * Gets the original SOAP client that caused the exception + * + * @return SoapClient the SOAP client that caused the exception. + */ + public function getSoapClient() + { + return $this->_soapClient; + } + // }}} }