Exemplo n.º 1
0
 /**
  * sendMessage method defined by NP wsdl
  * called by external providers to send transaction messages to internal
  * the call to internal will be forward by forking
  * 
  * @param		Array $params
  * @return		array "NP_ACK" or string
  */
 public function sendMessage($params)
 {
     Application_Model_General::virtualSleep();
     $reqModel = new Application_Model_Request($params);
     //prepares data for sending internal the message
     $ack = $reqModel->Execute();
     // log all received calls if request log enabled
     if (Application_Model_General::getSettings('EnableRequestLog')) {
         Application_Model_General::logRequestResponse($params, $ack, $reqModel->getRequest()->getHeaderField('REQUEST_ID'), '[Input] ');
     }
     if ($ack === FALSE || strpos(strtolower($ack), "ack") === FALSE) {
         $ack = "Ack00";
     }
     return array('NP_ACK' => array('ACK_CODE' => $ack, 'ACK_DATE' => Application_Model_General::getDateTimeIso()));
 }
Exemplo n.º 2
0
 /**
  * send http request to internal RPC and return response string.
  * 
  * @return string
  */
 public function SendRequestToInternal(Np_Method $request)
 {
     Application_Model_General::virtualSleep();
     // used to write to log to be in order
     $data = $this->createPostData($request);
     $url = Application_Model_General::getSettings('UrlToInternalResponse');
     $auth = Application_Model_General::getSettings('InternalAuth');
     $method = self::getMethodName($this->params['MSG_TYPE']);
     if ($this->protocal == 'http') {
         $client = new Zend_Http_Client();
         $client->setUri($url);
         $client->setParameterGet('method', $method);
         if (is_numeric($timeout = Application_Model_General::getSettings('InternalAuth'))) {
             $client->setConfig(array('timeout' => $timeout));
         }
         $client->setParameterPost($data);
         if (isset($auth['user'])) {
             $user = (string) $auth['user'];
             if (isset($auth['password'])) {
                 $password = (string) $auth['password'];
                 $client->setAuth($user, $password);
             }
             $client->setAuth($user);
         }
         $logContentRequest = "Send to internal " . PHP_EOL . print_R(array_merge(array('method' => $method), $data), 1) . PHP_EOL;
         Application_Model_General::logRequest($logContentRequest, $data['reqId']);
         $client->setMethod(Zend_Http_Client::POST);
         $response = $client->request();
         $ret = $response->getBody();
         $logContentResponse = "Response from internal " . PHP_EOL . $ret . PHP_EOL . PHP_EOL . PHP_EOL;
         Application_Model_General::logRequest($logContentResponse, $data['reqId']);
     } elseif ($this->protocal == 'soap') {
         $client = new Zend_Soap_Client();
         $client->setUri($url);
         $ret = call_user_func_array(array($client, $method), $data);
     }
     return $ret;
 }