class BroadsoftXMLWS !!!128009.php!!! getInstance(inout wsdl : string = null, inout user : string = null, inout passwd : string = null, inout log : LogMessages = null) : BroadsoftXMLWS if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c($wsdl); self::$user = $user; self::$passwd = $passwd; self::$log = $log; } return self::$instance; !!!128137.php!!! closeInstance() self::$instance->logout(); self::$instance->__destruct(); !!!128265.php!!! __construct(inout wsdl : string) $this->wsdl = $wsdl; $this->conectar(); !!!128393.php!!! prepareDOM() $this->dom = new DOMDocument("1.0"); $this->root = new DOMElement("processOCIMessage"); $this->dom->appendChild($this->root); $this->root->setAttribute("SOAP-ENV:encodingStyle", "http://schemas.xmlsoap.org/soap/encoding/"); $this->root->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); !!!128521.php!!! addXML(inout datosXML : string) $eleme_arg0 = new DOMElement("in0", htmlspecialchars($datosXML)); $this->root->appendChild($eleme_arg0); $eleme_arg0->setAttribute("xsi:type", "soapenc:string"); $eleme_arg0->setAttribute("xmlns:soapenc", "http://schemas.xmlsoap.org/soap/encoding/"); !!!128649.php!!! getXML() : string return ($this->dom->saveXML($this->root)); !!!128777.php!!! conectar() try { $this->soap_client = new SoapClient($this->wsdl, array('soap_version' => SOAP_1_1, 'trace' => true, "exceptions" => true, "connection_timeout" => "3", "user_agent" => "PHP Provisioning")); } catch (SoapFault $fault) { throw new ProvisioningException("Fallo al conectar al Web Service de Broadsoft", ProvisioningException::EXP_UNABLE_CONNECT_SOAP_SERVER, $fault); } $this->prepareDOM(); !!!128905.php!!! login() $this->conectar(); $this->prepareDOM(); $base = new BroadsoftXMLBase(); $cmdAuthRequest = new BroadsoftXMLCommandAuthenticationRequest(); $base->addCommand($cmdAuthRequest->getCommand()); $cmdAuthRequest->setUser(self::$user); $cmdAuthRequest->setCommand(); $this->ssid = $base->getsessionId(); $this->addXML($base->getXML()); $reintentos = 0; $ejecuto = false; while ($reintentos < $this->cant_retry) { $reintentos++; try { $this->soap_client->processOCIMessage(new SoapVar(utf8_encode($this->getXML()), XSD_ANYXML)); $reintentos = $this->cant_retry; $ejecuto = true; } catch (SoapFault $fault) { $fdetail = (isset($fault->detail)) ? $fault->detail->string : ""; sleep($this->time_retry); self::$log->AddLog(LogMessages::LOG_ERROR, LogMessages::SYS_BS, 7, "WS: INTENTO CONECTAR NUEVAMENTE: [" . $fault->faultcode . "] mensaje: [" . $fault->faultstring . "] detail: [" . $fdetail . "]"); $this->conectar(); } } $respuesta = new BroadsoftXMLAuthenticationRequestResponse($this->soap_client->__getLastResponse(), $this->soap_client->__getLastResponseHeaders()); $this->jssid = $respuesta->getJSESSIONID(); $bs_rt1 = new BroadsoftXMLBase($this->ssid); $bs_rt2 = new BroadsoftXMLCommandLoginRequest(); unset($this->dom); unset($this->root); $this->prepareDOM(); $bs_rt1->addCommand($bs_rt2->getCommand()); $bs_rt2->setData(BroadsoftXMLWS::USER_WS, BroadsoftXMLWS::PASSWORD_WS, $respuesta->getnonce()); $bs_rt2->setCommand(); $this->addXML($bs_rt1->getXML()); $this->soap_client->__setCookie($this->jssid); $this->soap_client->processOCIMessage(new SoapVar(utf8_encode($this->getXML()), XSD_ANYXML)); $this->lastRequest = $this->soap_client->__getLastRequest(); $this->lastResponse = $this->soap_client->__getLastResponse(); $this->lastRequestHeaders = $this->soap_client->__getLastRequestHeaders(); $this->lastResponseHeaders = $this->soap_client->__getLastResponseHeaders(); !!!129033.php!!! logout() $base = new BroadsoftXMLBase($this->ssid); $cmdLogOut = new BroadsoftXMLCommandLogoutRequest(); unset($this->dom); unset($this->root); $this->prepareDOM(); $base->addCommand($cmdLogOut->getCommand()); $cmdLogOut->setUser(self::$user); $cmdLogOut->setCommand(); $this->addXML($base->getXML()); try { $this->soap_client->processOCIMessage(new SoapVar(utf8_encode($this->getXML()), XSD_ANYXML)); } catch (SoapFault $fault) { throw new ProvisioningException("Fallo al ejecutar processOCIMessage con el comando de logout del Web Service de Broadsoft", ProvisioningException::EXP_UNABLE_EXECUTE_FUNCTION, $fault); } !!!129161.php!!! _prepareForExecute(inout commands : ) $this->login(); unset($this->dom); unset($this->root); $this->prepareDOM(); $xd = new BroadsoftXMLBase($this->ssid); $aComandos = $commands->getCommands(); if (count($aComandos) > 0) { foreach ($aComandos as $identificador => $aCmd) { $xd->addCommand($aCmd["Command"]->getCommand()); $aCmd["Command"]->setCommand(); } } $this->addXML($xd->getXML()); $this->soap_client->__setCookie($this->jssid); !!!129289.php!!! execute(inout commands : BroadsoftXMLCommands) : bool $this->commands = $commands; $reintentos = 0; $ejecuto = false; while ($reintentos < $this->cant_retry) { $reintentos++; try { $this->_prepareForExecute($commands); try { $this->lastRequest = ""; $this->lastResponse = ""; $this->soap_client->processOCIMessage(new SoapVar($this->getXML(), XSD_ANYXML)); $reintentos = $this->cant_retry; $ejecuto = true; $this->lastRequest = $this->soap_client->__getLastRequest(); $this->lastResponse = $this->soap_client->__getLastResponse(); $this->lastRequestHeaders = $this->soap_client->__getLastRequestHeaders(); $this->lastResponseHeaders = $this->soap_client->__getLastResponseHeaders(); $this->logout(); unset($this->soap_client); } catch (SoapFault $fault) { $fdetail = (isset($fault->detail)) ? $fault->detail->string : ""; self::$log->AddLog(LogMessages::LOG_ERROR, LogMessages::SYS_BS, 7, "WS: Error al ejecutar algun comando - codigo: [" . $fault->faultcode . "] mensaje: [" . $fault->faultstring . "] detail: [" . $fdetail . "]"); sleep($this->time_retry); } } catch (ProvisioningException $pe) { self::$log->AddLog(LogMessages::LOG_ERROR, LogMessages::SYS_BS, 7, "WS: Error al ejecutar algun comando - codigo: [" . $pe->getCode() . "] mensaje: [" . $pe->getMessage() . "]"); sleep($this->time_retry); } } if (!$ejecuto) self::$log->AddLog(LogMessages::LOG_ERROR, LogMessages::SYS_BS, 7, "BroadsoftXMLWS->execute: Se llegó al límite de reintentos y no se ejecutó/ejecutaron el/los comando/s."); return ($ejecuto); !!!129417.php!!! getLastResponse() : string return($this->lastResponse); !!!129545.php!!! getLastResponseHeaders() : string return($this->lastResponseHeaders); !!!129673.php!!! getLastRequestHeaders() : string return($this->lastRequestHeaders); !!!129801.php!!! getLastRequest() : string return($this->lastRequest); !!!129929.php!!! getResultados() : array $aComandos = $this->commands->getCommands(); reset($aComandos); $respuestaXML = new DOMDocument("1.0"); $respuestaXML->loadXML($this->getLastResponse()); $res = array(); $processOCIMessageReturn = $respuestaXML->getElementsByTagName("processOCIMessageReturn"); if ($processOCIMessageReturn->length > 0) { $xmlBS = $processOCIMessageReturn->item(0)->nodeValue; $respuestaXMLBS = new DOMDocument("1.0", "ISO-8859-1"); $respuestaXMLBS->loadXML(str_replace("xmlns=\"C\"", "xmlns=\"\"", $xmlBS)); $respuestaComandos = $respuestaXMLBS->getElementsByTagName("command"); for ($i = 0; $i < $respuestaComandos->length; $i++) { $comandito = each($aComandos); $item = $respuestaComandos->item($i); $resComando = $item->getAttributeNode("xsi:type")->value; $cmdErrores = 0; switch ($resComando) { case "c:SuccessResponse"; break; case "c:ErrorResponse"; $hijos = $item->childNodes; $cmdErrores++; $amsgs = array(); for ($j = 0; $j < $hijos->length; $j++) { if (($hijos->item($j)->nodeName == "summary") || ($hijos->item($j)->nodeName == "detail")) { $amsgs[] = $hijos->item($j)->nodeValue; } } $msgError = implode("|", $amsgs); break; } if ($cmdErrores > 0) { $res[$comandito["key"]] = $comandito["value"]["Description"] . ": " . $msgError; } else { $res[$comandito["key"]] = 1; } } } else { $Fault = $respuestaXML->getElementsByTagName("Fault"); if ($Fault->length > 0) { $hijosDeFault = $Fault->item(0)->childNodes; $cFaultCode = ""; $cFaultString = ""; $cDetailString = ""; for ($i = 0; $i < $hijosDeFault->length; $i++) { switch ($hijosDeFault->item($i)->nodeName) { case "faultcode": $cFaultCode = $hijosDeFault->item($i)->nodeValue; break; case "faultstring": $cFaultString = $hijosDeFault->item($i)->nodeValue; break; case "detail": $hijosDeDetail = $hijosDeFault->item($i)->childNodes; for ($j = 0; $j < $hijosDeDetail->length; $j++) { switch ($hijosDeDetail->item($j)->nodeName) { case "string": $cDetailString = $hijosDeDetail->item($j)->nodeValue; break; } } break; } } $res = "SoapFault: faultcode[" . $cFaultCode . "] faultstring [" . $cFaultString . "] detail[" . $cDetailString . "]"; } else { $res = "Error-> No hubo una respuesta success, failure o fault"; } } return ($res);