コード例 #1
0
ファイル: demo3.php プロジェクト: vasylignatyev/soap
//
// With the PhpWsdlProxy class I try to get around the problem, but
// complex type return values must be returned with PHPs SoapVar
// object then. Primitive return types like string, int or boolean don't
// need a special handling.
// To get rid of the NULL problem you need to ensure that the PHP
// SoapServer has no knowledge of the WSDL. To ensure this, set the
// PhpWsdl::$UseProxyWsdl property to FALSE (is FALSE per default).
//
// 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
コード例 #2
0
ファイル: demo5.php プロジェクト: Eugen1985/stalker_portal
<?php

// This is an example how to use global methods in a SOAP webservice.
//
// You can't mix class and global methods within one webservice, if you're not
// using the PhpWsdlProxy class (see demo3.php).
require_once 'class.phpwsdl.php';
ini_set('soap.wsdl_cache_enabled', 0);
// Disable caching in PHP
PhpWsdl::$CacheTime = 0;
// Disable caching in PhpWsdl
PhpWsdlMethod::$IsGlobalDefault = true;
// Serve any method as global per default
PhpWsdl::RunQuickMode();
// Run in quick mode
/**
 * This is how to define a global method for WSDL. A setting was not required since the 
 * PhpWsdlMethod::$IsGlobalDefault property was set to TRUE so every method is handled 
 * as global method per default now
 * 
 * @return string Response
 */
function GlobalMethodDemo()
{
    return utf8_encode('Response of the global method demo');
}
// If you want PhpWsdl to handle all methods as global per default, set the
// PhpWsdlMethod::$IsGlobalDefault to TRUE. Then you don't need to set the
// setting "global" to "1" for every method.