예제 #1
0
     * @param string $param2
     * @param string $param1
     * @param string $param3
     * @return string
     */
    function test($param2, $param1, $param3)
    {
        return 'test1 ' . $param1 . ' test2 ' . $param2 . ' test3 ' . $param3;
    }
    /**
     * Displays the Tiki_ComplexType data.
     *
     * @param Tiki_ComplexType $complex_param
     * @return string
     */
    function test_complex(Tiki_ComplexType $complex_param)
    {
        return $complex_param->param1 . ' =====> ' . $complex_param->param2;
    }
}
if (is_null($_GET['wsdl'])) {
    $protocol = isset($_SERVER['HTTPS']) ? 'https' : 'http';
    $server = new Zend\Soap\Server($protocol . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'] . '?wsdl');
    $server->setClass('Tiki_WebServices');
    $server->handle();
} else {
    $wsdl = new Zend\Soap\AutoDiscover();
    $wsdl->setUri($_SERVER['SCRIPT_NAME']);
    $wsdl->setClass('Tiki_WebServices');
    $wsdl->handle();
}
예제 #2
0
/***
 * SOAP example - Alejandro Martinez (almarag@gmail.com) 
 * In order to this example works, please host code on your webserver
 * and modify the endpoint Uri on script accordingly. 
 * This is the server part of example. I used Zend\Soap libraries
 * since SoapServer function on PHP doesn't support WSDL generation by itself.
 * AutoDiscover class is a very useful library for WSDL generation.
 * For client side part please refer to client.php script.  
 ***/
require_once "WebService/TestWebService.php";
$loader = (require 'vendor/autoload.php');
use BasicConcepts\SOAP\WebService\TestWebService as WebService;
// Note: You should add the return type on docblock in order to
// AutoDiscover can handle it.
/**
 * @return string
 */
function helloWorld()
{
    $webService = new WebService();
    return $webService->HelloWorld();
}
if (isset($_GET['wsdl'])) {
    $autodiscover = new Zend\Soap\AutoDiscover();
    $autodiscover->addFunction('helloWorld')->setUri('http://localhost:8080/webservicetest/server.php')->setServiceName('TestWebService');
    $autodiscover->handle();
} else {
    $server = new Zend\Soap\Server(null, array('uri' => 'http://localhost:8080/webservicetest/server.php'));
    $server->addFunction('helloWorld');
    $server->handle();
}