public static function Run($strClassName, $strNamespace = null) { QApplication::$EncodingType = 'UTF-8'; $objWsdlCache = new QCache('soap', QApplication::$ScriptName, 'wsdl', QApplication::$ScriptFilename); $objDiscoCache = new QCache('soap', QApplication::$ScriptName, 'disco', QApplication::$ScriptFilename); $objClassWrapperCache = new QCache('soap', QApplication::$ScriptName, 'class.php', QApplication::$ScriptFilename); // Reflect through this QSoapService $strDisco = $objDiscoCache->GetData(); if ($strDisco === false || !$strNamespace) { $objReflection = new ReflectionClass($strClassName); } // Figure Out Namespace if (!$strNamespace) { $objReflectionProperties = $objReflection->getStaticProperties(); $strNamespace = $objReflectionProperties['DefaultNamespace']; } $strNamespace = trim($strNamespace); if (QString::LastCharacter($strNamespace) == '/') { $strNamespace = substr($strNamespace, 0, strlen($strNamespace) - 1); } // Check for Cached Disco if ($strDisco === false) { // Instantiate Service and Setup new Soap Methods $objService = new $strClassName($strClassName, $strNamespace); // Setup SOAP Methods try { $objService->SetupSoapMethods($objReflection); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } // Get Disco, Wsdl and Wrapper, and cache them! $objWsdlCache->SaveData($objService->GetWsdl()); $objDiscoCache->SaveData($objService->GetDisco()); $objClassWrapperCache->SaveData($objService->GetClassWrapper()); } // Process Service Browse (e.g. if accessed via GET) if ($_SERVER['REQUEST_METHOD'] == 'GET') { if (array_key_exists('QUERY_STRING', $_SERVER)) { switch (strtolower($_SERVER['QUERY_STRING'])) { case 'disco': header('Content-Type: text/xml'); _p('<?xml version="1.0" encoding="' . QApplication::$EncodingType . '"?>', false); _p($objDiscoCache->GetData(), false); return; case 'wsdl': header('Content-Type: text/xml'); _p('<?xml version="1.0" encoding="' . QApplication::$EncodingType . '"?>', false); _p($objWsdlCache->GetData(), false); return; } } printf('<link rel="alternate" type="text/xml" href="%s?disco"/><a href="%s?disco">Web Service Discovery File</a> | <a href="%s?wsdl">Web Service Description File (WSDL)</a>', QApplication::$ScriptName, QApplication::$ScriptName, QApplication::$ScriptName); return; } // Process Service Execution (e.g. accessed via a POST) $objService = new $strClassName($strClassName, $strNamespace); // Get the Request $strRequest = file_get_contents("php://input"); // Create the Service Class Wrapper require $objClassWrapperCache->GetFilePath(); // Use PHP 5.1+'s SoapServer class to handle the actual work $objService->objSoapServer = new SoapServer($objWsdlCache->GetFilePath()); $objService->objSoapServer->setClass($strClassName . 'Wrapper', $strClassName, $strNamespace); $objService->objSoapServer->handle($strRequest); }