/** * Send an NCIP request. * * @param string $xml XML request document * * @return object SimpleXMLElement parsed from response * @access private */ private function _sendRequest($xml) { // Make the NCIP request: $client = new Proxy_Request(null, array('useBrackets' => false)); $client->setMethod(HTTP_REQUEST_METHOD_POST); $client->setURL($this->_config['Catalog']['url']); $client->addHeader('Content-type', 'application/xml; "charset=utf-8"'); $client->setBody($xml); $result = $client->sendRequest(); if (PEAR::isError($result)) { PEAR::raiseError($result); } // Process the NCIP response: $response = $client->getResponseBody(); $result = @simplexml_load_string($response); if (is_a($result, 'SimpleXMLElement')) { $result->registerXPathNamespace('ns1', 'http://www.niso.org/2008/ncip'); return $result; } else { PEAR::raiseError(new PEAR_Error("Problem parsing XML")); } }
/** * Send a request to the SIRSI side API script and returns the response. * * @param array $params Associative array of query parameters to send. * * @return string */ protected function querySirsi($params) { // make sure null parameters are sent as empty strings instead or else the // driver.pl may choke on null parameter values foreach ($params as $key => $value) { if ($value == null) { $params[$key] = ''; } } $url = $this->url; if (empty($url)) { $url = $this->host; if ($this->port) { $url = "http://" . $url . ":" . $this->port . "/" . $this->search_prog; } else { $url = "http://" . $url . "/" . $this->search_prog; } } $httpClient = new Proxy_Request(); // use HTTP POST so parameters like user id and PIN are NOT logged by web // servers $httpClient->setMethod(HTTP_REQUEST_METHOD_POST); $httpClient->setURL($url); $httpClient->setBody(http_build_query($params)); $result = $httpClient->sendRequest(); if (!PEAR::isError($result)) { // Even if we get a response, make sure it's a 'good' one. if ($httpClient->getResponseCode() != 200) { PEAR::raiseError("Error response code received from {$url}"); } } else { PEAR::raiseError($result); } // get the response data $response = $httpClient->getResponseBody(); return rtrim($response); }