function _decodeFault($msg) { $errResponse = new EbatNs_ResponseError(); $p = xml_parser_create(); xml_parse_into_struct($p, $msg, $lstValues, $index); xml_parser_free($p); foreach ($lstValues as $value) { if ($value['type'] == 'complete') { switch ($value['tag']) { case 'FAULTSTRING': $errResponse->raise('soap-fault: ' . utf8_decode($value['value']), 90000 + 2); break; case 'ERRORCODE': $code = $value['value']; break; case 'SEVERITY': $severity = $value['value']; break; case 'DETAILEDMESSAGE': $errResponse->raise($value['value'], $code, $severity); break; } } } $this->_reduceElement($errResponse); return $errResponse; }
public function executeBatchOperation() { // not using a batch-operation if (!$this->useCurlBatch) { return null; } $this->_startTp('executeBatchOperation'); // lets execute the batch-operation $running = null; do { curl_multi_exec($this->mh, $running); } while ($running > 0); foreach ($this->chMultiHandles as $id => $ch) { $responseRaw = curl_multi_getcontent($ch); if (!$responseRaw) { $currentResult = new EbatNs_ResponseError(); $currentResult->raise('curl_error ' . curl_errno($ch) . ' ' . curl_error($ch), 80000 + 1, EBAT_SEVERITY_ERROR); $this->responseData[$id] = $currentResult; } else { $responseBody = null; if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $responseRaw, $match)) { $responseBody = $match[2]; $headerLines = preg_split("/\r?\n/", $match[1]); foreach ($headerLines as $line) { if (strpos($line, ':') === false) { $responseHeaders[0] = $line; continue; } list($key, $value) = explode(':', $line); $responseHeaders[strtolower($key)] = trim($value); } } if ($responseBody) { $this->logXml($responseBody, 'Response'); } else { $this->logXml($responseRaw, 'ResponseRaw'); } $this->responseData[$id] = $this->decodeMessage($this->resultMethods[$id], $responseBody, EBATNS_PARSEMODE_CALL); } curl_multi_remove_handle($this->mh, $ch); } curl_multi_close($this->mh); $this->chMultiHandles = array(); $this->resultMethods = array(); $this->useCurlBatch = false; $this->_stopTp('executeBatchOperation'); $this->_logTp(); print_r($this->_loggingOptions); // makes sense to clean this up // so use cleanBatchOperation once the result is proceeded return $this->responseData; }