/**
  * Execute request against the data well.
  *
  * @param TingClientRequest $request
  *
  * @return mixed|string
  * @throws Exception
  * @throws TingClientException
  */
 public function execute(TingClientRequest $request)
 {
     //Prepare the parameters for the SOAP request
     $soapParameters = $request->getParameters();
     // Separate the action from other parameters
     $soapAction = $soapParameters['action'];
     unset($soapParameters['action']);
     // We use JSON as the default outputType.
     if (!isset($soapParameters['outputType'])) {
         $soapParameters['outputType'] = 'json';
     }
     try {
         try {
             $startTime = explode(' ', microtime());
             // Add option to send CURL parameters with the request. This can be used
             // to send requests through a SOCKS5 ssh proxy.
             $curl_options = array();
             if (function_exists('variable_get')) {
                 $curl_options = variable_get('curl_options');
             }
             $client = new NanoSOAPClient($request->getWsdlUrl(), array('curl' => $curl_options));
             $response = $client->call($soapAction, $soapParameters);
             $stopTime = explode(' ', microtime());
             $time = floatval($stopTime[1] + $stopTime[0] - ($startTime[1] + $startTime[0]));
             $this->logger->log('Completed SOAP request ' . $soapAction . ' ' . $request->getWsdlUrl() . ' (' . round($time, 3) . 's). Request body: ' . $client->requestBodyString . ' Response: ' . $response);
             // If using JSON and DKABM, we help parse it.
             if ($soapParameters['outputType'] == 'json') {
                 return json_decode($response);
             } else {
                 return $response;
             }
         } catch (NanoSOAPcURLException $e) {
             //Convert NanoSOAP exceptions to TingClientExceptions as callers
             //should not deal with protocol details
             throw new TingClientException($e->getMessage(), $e->getCode());
         }
     } catch (TingClientException $e) {
         $this->logger->log('Error handling SOAP request ' . $soapAction . ' ' . $request->getWsdlUrl() . ': ' . $e->getMessage());
         throw $e;
     }
 }
Example #2
0
 function execute(TingClientRequest $request)
 {
     return $request->execute($this->requestAdapter);
 }