/** * Login * * @param string $username * @param string $password * @param string $organisation * @todo should this function create a new SOAP clust clienst? * @throw SoapFault */ public function logon($username, $password, $organisation) { $return = false; $parameters = array('user' => $username, 'password' => $password, 'organisation' => $organisation); $logonResponse = $this->soapLoginClient->logon($parameters); if ($logonResponse->LogonResult == LogonResult::OK) { // Read the SOAP client last response $response = $this->soapLoginClient->__getLastResponse(); /* //echo htmlentities($response); echo '<pre>'; var_dump($this->soapLoginClient->__getTypes()); echo '</pre>'; echo '<pre>'; var_dump($logonResponse); echo '</pre>'; */ // Create an SimpleXML object so we can easy access XML elements $envelope = simplexml_load_string($response, null, null, self::XML_NAMESPACE_SOAP_ENVELOPE); // Get the Twinfield header element from SOAP evenlope header $header = $envelope->Header->children(Twinfield::XML_NAMESPACE); // Save the clust and session ID data $this->cluster = $logonResponse->cluster; $this->sessionId = $header->Header->SessionID; // Create an SOAP input header for further SOAP request $this->soapInputHeader = new \SoapHeader(Twinfield::XML_NAMESPACE, 'Header', array('SessionID' => $this->sessionId)); // Create a new SOAP client that connects to the cluster $wsdlClusterUrl = sprintf(self::SOAP_WSDL_CLUSTER_URI, $this->cluster); $this->soapClusterClient = new \SoapClient($wsdlClusterUrl); $return = true; } return $return; }
/** * 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; }
/** * Gets the soap client with the headers attached * * Will automaticly login if haven't already on this instance * * @since 0.0.1 * * @access public * @return \SoapClient */ public function getClient() { if (!$this->processed) { $this->process(); } // Makes a new client, and assigns the header to it $client = new SoapClient(sprintf($this->clusterWSDL, $this->cluster)); $client->__setSoapHeaders($this->getHeader()); return $client; }