Exemplo n.º 1
0
 /**
  * Perform a RESTful DLF request.
  *
  * @param array  $path_elements URL path elements
  * @param array  $params        GET parameters (null for none)
  * @param string $method        HTTP method
  * @param string $body          HTTP body
  *
  * @return SimpleXMLElement
  */
 protected function doRestDLFRequest($path_elements, $params = null, $method = 'GET', $body = null)
 {
     $path = '';
     foreach ($path_elements as $path_element) {
         $path .= $path_element . "/";
     }
     $url = "http://{$this->host}:{$this->dlfport}/rest-dlf/" . $path;
     $url = $this->appendQueryString($url, $params);
     $result = $this->doHTTPRequest($url, $method, $body);
     $replyCode = (string) $result->{'reply-code'};
     if ($replyCode != "0000") {
         $replyText = (string) $result->{'reply-text'};
         $this->logError("DLF request failed", ['url' => $url, 'reply-code' => $replyCode, 'reply-message' => $replyText]);
         $ex = new AlephRestfulException($replyText, $replyCode);
         $ex->setXmlResponse($result);
         throw $ex;
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Perform a RESTful DLF request.
  *
  * @param array  $path_elements URL path elements
  * @param array  $params        GET parameters (null for none)
  * @param string $method        HTTP method
  * @param string $body          HTTP body (for PUT or POST HTTP method)
  *
  * @return SimpleXMLElement
  */
 public function doRestDLFRequest($path_elements, $params = null, $method = 'GET', $body = null)
 {
     $path = '';
     foreach ($path_elements as $path_element) {
         $path .= $path_element . "/";
     }
     $url = "http://{$this->host}:{$this->dlfport}/rest-dlf/" . $path;
     $headers = ["accept" => "application/xml"];
     if ($this->language) {
         $params['lang'] = $this->language;
     }
     $result = $this->doHTTPRequest($url, $params, $method, $body, $headers);
     $replyCode = (string) $result->{'reply-code'};
     if ($replyCode != "0000") {
         $replyText = (string) $result->{'reply-text'};
         $this->logger->err("DLF request failed", array('url' => $url, 'reply-code' => $replyCode, 'reply-message' => $replyText));
         $ex = new AlephRestfulException($replyText, $replyCode);
         $ex->setXmlResponse($result);
         throw $ex;
     }
     return $result;
 }