/**
  * Send the request to service.
  *
  * @param $identifiers
  *   Pass requested identifiers.
  * @return mixed
  *   Response object or error message.
  */
 protected function sendRequest($identifiers)
 {
     $authInfo = array('authenticationUser' => $this->username, 'authenticationGroup' => $this->group, 'authenticationPassword' => $this->password);
     $client = new SoapClient($this->wsdlUrl);
     try {
         $response = $client->moreInfo(array('authentication' => $authInfo, 'identifier' => $identifiers));
     } catch (Exception $e) {
         watchdog_exception('artesis_netarchive', $e);
     }
     return $response;
 }
 /**
  * Send request to the addi server, returning the data response.
  */
 protected function sendRequest($identifiers)
 {
     $auth_info = array('authenticationUser' => $this->username, 'authenticationGroup' => $this->group, 'authenticationPassword' => $this->password);
     // New moreinfo service.
     $client = new SoapClient($this->wsdlUrl . '/moreinfo.wsdl');
     // Record the start time, so we can calculate the difference, once
     // the addi service responds.
     $start_time = explode(' ', microtime());
     // Start on the responds object.
     $response = new stdClass();
     $response->identifierInformation = array();
     // Try to get covers 40 at the time as the service has a limit.
     try {
         $offset = 0;
         $ids = array_slice($identifiers, $offset, 40);
         while (!empty($ids)) {
             $data = $client->moreInfo(array('authentication' => $auth_info, 'identifier' => $ids));
             // Check if the request went through.
             if ($data->requestStatus->statusEnum != 'ok') {
                 throw new AdditionalInformationServiceException($response->requestStatus->statusEnum . ': ' . $response->requestStatus->errorText);
             }
             // Move result into the responce object.
             $response->requestStatus = $data->requestStatus;
             if (is_array($data->identifierInformation)) {
                 // If more than one element have been found an array is returned.
                 $response->identifierInformation = array_merge($response->identifierInformation, $data->identifierInformation);
             } else {
                 // If only one "cover" have been request, we need to wrap the data in
                 // an array.
                 $response->identifierInformation = array_merge($response->identifierInformation, array($data->identifierInformation));
             }
             // Single image... not array but object.
             $offset += 40;
             $ids = array_splice($identifiers, $offset, 40);
         }
     } catch (Exception $e) {
         // Re-throw Addi specific exception.
         throw new AdditionalInformationServiceException($e->getMessage());
     }
     $stop_time = explode(' ', microtime());
     $time = floatval($stop_time[1] + $stop_time[0] - ($start_time[1] + $start_time[0]));
     // Drupal specific code - consider moving this elsewhere.
     if (variable_get('addi_enable_logging', FALSE)) {
         watchdog('addi', 'Completed request (' . round($time, 3) . 's): Ids: %ids', array('%ids' => implode(', ', $ids)), WATCHDOG_DEBUG, 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
     }
     if (!is_array($response->identifierInformation)) {
         $response->identifierInformation = array($response->identifierInformation);
     }
     return $response;
 }
 /**
  * Send request to the addi server, returning the data response.
  */
 protected function sendRequest($identifiers)
 {
     $auth_info = array('authenticationUser' => $this->username, 'authenticationGroup' => $this->group, 'authenticationPassword' => $this->password);
     // New moreinfo service.
     $client = new SoapClient($this->wsdlUrl . '/moreinfo.wsdl');
     // Record the start time, so we can calculate the difference, once
     // the addi service responds.
     $start_time = explode(' ', microtime());
     $response = $client->moreInfo(array('authentication' => $auth_info, 'identifier' => $identifiers));
     // Calculate the request time.
     $stop_time = explode(' ', microtime());
     $time = floatval($stop_time[1] + $stop_time[0] - ($start_time[1] + $start_time[0]));
     // Drupal specific code - consider moving this elsewhere.
     if (variable_get('addi_enable_logging', FALSE)) {
         watchdog('addi', 'Completed request in @seconds seconds.', array('@seconds' => $time), WATCHDOG_DEBUG, 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
     }
     if ($response->requestStatus->statusEnum != 'ok') {
         throw new AdditionalInformationServiceException($response->requestStatus->statusEnum . ': ' . $response->requestStatus->errorText);
     }
     if (!is_array($response->identifierInformation)) {
         $response->identifierInformation = array($response->identifierInformation);
     }
     return $response;
 }