Exemplo n.º 1
0
 /**
  * Execute SOAP request using CURL
  *
  * @param string $request
  * @param string $location
  * @param string $action
  * @param int $version
  * @param int $one_way
  * @return string
  * @throws \Exception
  */
 public function __doRequest($request, $location, $action, $version, $one_way = 0)
 {
     $this->curlPlusClient->initialize($location, true);
     $this->curlPlusClient->setCurlOpt(CURLOPT_POSTFIELDS, (string) $request);
     $this->curlPlusClient->setCurlOpts($this->curlOptArray);
     // Add the header strings
     foreach ($this->defaultRequestHeaders as $headerString) {
         $this->getClient()->addRequestHeaderString($headerString);
     }
     $this->curlPlusClient->addRequestHeaderString('SOAPAction: "' . $action . '"');
     $ret = $this->curlPlusClient->execute();
     if ($this->isDebug()) {
         $this->debugQueries[] = array('headers' => $ret->getRequestHeaders(), 'body' => (string) $request);
         $this->debugResults[] = array('code' => $ret->getHttpCode(), 'headers' => $ret->getResponseHeaders(), 'response' => (string) $ret->getResponse());
     }
     if ($ret->getResponse() == false || $ret->getHttpCode() != 200) {
         throw new \Exception('DCarbone\\SoapClientPlus::__doRequest - CURL Error during call: "' . addslashes($ret->getError()) . '", "' . addslashes($ret->getResponse()) . '"');
     }
     return $ret->getResponse();
 }