/** * Gets the soap client with the headers attached * * Will automatically login if haven't already on this instance * * @since 0.0.1 * * @param string|null $wsdl the wsdl to use. If null, the clusterWSDL is used. * @access public * @return \SoapClient */ public function getClient($wsdl = null) { if (!$this->processed) { $this->process(); } $wsdl = is_null($wsdl) ? $this->clusterWSDL : $wsdl; $header = $this->getHeader(); // Makes a new client, and assigns the header to it $client = new SoapClient(sprintf($wsdl, $this->cluster), $this->config->getSoapClientOptions()); $client->__setSoapHeaders($header); return $client; }
/** * Will process the login. * * If successful, will set the session and cluster information * to the class * * @since 0.0.1 * * @access public * @return boolean If successful or not */ public function process() { // Process logon $response = $this->soapLoginClient->Logon($this->config->getCredentials()); // Check response is successful if ('Ok' == $response->LogonResult) { // Response from the logon request $this->loginResponse = $this->soapLoginClient->__getLastResponse(); // Make a new DOM and load the response XML $envelope = new \DOMDocument(); $envelope->loadXML($this->loginResponse); // Gets SessionID $sessionID = $envelope->getElementsByTagName('SessionID'); $this->sessionID = $sessionID->item(0)->textContent; // Gets Cluster URL $cluster = $envelope->getElementsByTagName('cluster'); $this->cluster = $cluster->item(0)->textContent; // This login object is processed! $this->processed = true; return true; } return false; }