Ejemplo n.º 1
0
 private function getSoapClient()
 {
     ini_set('max_execution_time', 3600);
     date_default_timezone_set("CET");
     $settings = SoapSetting::getDefaultSetting($this->ID);
     $this->ID = $settings->ID;
     if ($version) {
         $settings->version = $version;
     }
     $soapClient = new \SoapClient($settings->connection_uri . "version" . $settings->version . "/?xml", array('trace' => 1));
     $soapHeader = $settings->soap_header;
     $lastToken = $settings->last_token;
     if (!$soapHeader || date("z", $lastToken) != date("z", time())) {
         $authentification = $soapClient->GetAuthentificationToken(array('Username' => $settings->username, 'Userpass' => $settings->password));
         if (isset($authentification->Token)) {
             $headerbody = new \stdClass();
             $headerbody->UserID = $authentification->UserID;
             $headerbody->Token = $authentification->Token;
             $headerbody->Username = $settings->username;
             $serializedHeader = serialize($headerbody);
             $settings->soap_header = $serializedHeader;
             $settings->last_token = time();
             $settings->save();
         }
     }
     $soapHeader = $settings->soap_header;
     $headerbody = unserialize($soapHeader);
     $header = new \SOAPHeader('Authentification', 'verifyingToken', $headerbody, false);
     $this->instance = $soapClient->__setSoapHeaders($header);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = SoapSetting::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['ID' => $this->ID, 'version' => $this->version, 'enabled' => $this->enabled]);
     $query->andFilterWhere(['like', 'connection_uri', $this->connection_uri])->andFilterWhere(['like', 'username', $this->username]);
     return $dataProvider;
 }