public function output($doc = true, $wsdl = false, $phpclient = false)
 {
     require_once PROJECT_PATH . '/lib/php-wsdl-2.3/class.phpwsdl.php';
     $soap = \PhpWsdl::CreateInstance('API', null, null, array(PROJECT_PATH . '/lib/soapapi/v1/soapapihandler.class.php'), null, null, null, false, false);
     // Don't start the SOAP server right now
     // Disable caching for demonstration
     ini_set('soap.wsdl_cache_enabled', 0);
     // Disable caching in PHP
     \PhpWsdl::$CacheTime = 0;
     // Disable caching in PhpWsdl
     if ($wsdl) {
         $soap->ForceOutputWsdl = true;
     } else {
         if ($phpclient) {
             $soap->ForceOutputPhp = true;
         } else {
             $this->ForceOutputHtml = true;
         }
     }
     //$soap->Optimize = false;
     $soap->RunServer();
 }
示例#2
0
// If you want to mix class and global methods, you need to use the proxy.
// Include the demonstration classes
require_once 'class.soapdemo.php';
require_once 'class.complextypedemo.php';
// Initialize the PhpWsdl class
require_once 'class.phpwsdl.php';
PhpWsdlMethod::$DefaultException = 'SoapFault';
// This will set SoapFault as exception type for all methods
PhpWsdl::$UseProxyWsdl = true;
// Comment this line out to get rid of "Missing parameter" exceptions and to use the method "AnotherDemoMethod" exported by the class "SecondClass"
$soap = PhpWsdl::CreateInstance(null, null, './cache', array('class.soapdemo.php', 'class.complextypedemo.php', __FILE__), null, null, null, false, false);
// Don't start the SOAP server right now
// Disable caching for demonstration
ini_set('soap.wsdl_cache_enabled', 0);
// Disable caching in PHP
PhpWsdl::$CacheTime = 0;
// Disable caching in PhpWsdl
// Run the SOAP server
if ($soap->IsWsdlRequested()) {
    $soap->Optimize = false;
}
// Don't optimize WSDL to send it human readable to the browser
$soap->RunServer(null, array('SoapDemo', new SoapDemo()));
/**
 * This is how to define a global method for WSDL
 * 
 * @return string Response
 * @pw_set global=1 -> Tell PhpWsdl to serve this as global method (outside of a class)
 */
function GlobalMethodDemo()
{
 /**
  * Enable caching
  * 
  * @param string $folder The cache folder or NULL to use a system temporary directory (default: NULL)
  * @param int $timeout The caching timeout in seconds or NULL to use the previous value or the default (3600) (default: NULL)
  */
 public static function EnableCache($folder = null, $timeout = null)
 {
     if (is_null($folder)) {
         if (self::IsCacheFolderWriteAble('./cache')) {
             $folder = './cache';
         } else {
             if (self::IsCacheFolderWriteAble(dirname(__FILE__) . '/cache')) {
                 $folder = dirname(__FILE__) . '/cache';
             } else {
                 if (self::IsCacheFolderWriteAble(sys_get_temp_dir())) {
                     $folder = sys_get_temp_dir();
                 } else {
                     self::Debug('Could not find a cache folder');
                 }
             }
         }
     }
     if (is_null($timeout)) {
         $timeout = self::$CacheTime != 0 ? self::$CacheTime : 3600;
     }
     self::Debug('Enable cache in folder "' . (is_null($folder) ? '(none)' : $folder) . '" with timeout ' . $timeout . ' seconds');
     self::$CacheFolder = $folder;
     self::$CacheTime = $timeout;
 }