public function call($webservice)
 {
     $webServiceContext = $this->container->get('webservice.context.' . $webservice);
     $this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request'));
     $this->serviceBinder = $webServiceContext->getServiceBinder();
     $this->soapServer = $webServiceContext->getServerFactory()->create($this->soapRequest, $this->soapResponse);
     $this->soapServer->setObject($this);
     ob_start();
     $this->soapServer->handle($this->soapRequest->getSoapMessage());
     $soapResponseContent = ob_get_clean();
     $this->soapResponse->setContent($soapResponseContent);
     return $this->soapResponse;
 }
Example #2
0
 public function processRequest(callable $callback)
 {
     $server = new \SoapServer($this->wsdl, array('classmap' => $this->classmap));
     $server->setObject($this);
     $this->callback = $callback;
     $server->handle();
     $this->callback = null;
 }
 /**
  * @Route("/server", name="server")
  */
 public function serverAction()
 {
     $server = new \SoapServer('web/public/hello.wsdl');
     $server->setObject($this->get('hello_service'));
     $response = new Response();
     $response->headers->set('Content-Type', 'text/xml; charset=ISO-8859-1');
     ob_start();
     $server->handle();
     $response->setContent(ob_get_clean());
     return $response;
 }
 public function serverAction(Request $request)
 {
     $baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
     $server = new \SoapServer($baseurl . '/APIxml.wsdl');
     $server->setObject($this->get('moocsy.api_xml'));
     $response = new Response();
     $response->headers->set('Content-Type', 'text/xml; charset=ISO-8859-1');
     ob_start();
     $server->handle();
     $response->setContent(ob_get_clean());
     return $response;
 }
Example #5
0
 /**
  * Handle the service request
  */
 protected function handleRequest()
 {
     $server = new \SoapServer(null, ['uri' => $this->getServiceUri()]);
     /** @var object $object */
     $object = GeneralUtility::makeInstance($this->serverClass);
     $server->setObject($object);
     try {
         $server->handle();
     } catch (\Exception $ex) {
         $server->fault($ex->getCode(), $ex->getMessage());
     }
 }
 /**
  * @Route("/soap/key")
  * @Template()
  */
 public function sendKeyAction()
 {
     //        $server = new \SoapServer($this->container->get('templating.helper.assets')->getUrl('cibsoap/soap/test.wsdl'));
     $server = new \SoapServer('/var/www/LicenseManager/web/bundles/cibsoap/soap/licenseSoap.wsdl');
     //        $server = new \SoapServer('C:\wamp\www\LicenseManager\web\bundles\cibsoap\soap\licenseSoapWindows.wsdl');
     $server->setObject($this->get('sendKey'));
     $response = new Response();
     $response->headers->set('Content-Type', 'text/xml; charset=utf-8');
     ob_start();
     $server->handle();
     $response->setContent(ob_get_clean());
     return $response;
 }
 /**
  * Finally returns a SoapClient instance.
  *
  * @return \BeSimple\SoapServer\SoapServer
  */
 public function build()
 {
     $this->validateOptions();
     use_soap_error_handler($this->errorReporting);
     $server = new SoapServer($this->wsdl, $this->getSoapOptions());
     if (null !== $this->persistence) {
         $server->setPersistence($this->persistence);
     }
     if (null !== $this->handlerClass) {
         $server->setClass($this->handlerClass);
     } elseif (null !== $this->handlerObject) {
         $server->setObject($this->handlerObject);
     }
     return $server;
 }
Example #8
0
 public function serverAction()
 {
     ini_set("soap.wsdl_cache", "0");
     ini_set("soap.wsdl_cache_enabled", "0");
     ini_set('soap.wsdl_cache_ttl', 0);
     $filePath = $this->getServiceProvider()->getWsdlPath();
     $soap = new \SoapServer($filePath);
     $soap->setObject($this->getServiceProvider()->getService());
     $response = new Response();
     $response->headers->set('Content-Type', 'text/xml');
     ob_start();
     $soap->handle();
     $response->setContent(ob_get_clean());
     return $response;
 }
Example #9
0
<?php

class Foo
{
    function __call($name, $args)
    {
        if ($name == "test") {
            return "Hello World";
        } else {
            return SoapFault("Server", "Function {$name} doesn't exist");
        }
    }
}
$foo = new Foo();
$server = new SoapServer(null, array('uri' => "http://testuri.org"));
$server->setObject($foo);
$HTTP_RAW_POST_DATA = <<<EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:si="http://soapinterop.org/xsd">
  <SOAP-ENV:Body>
    <ns1:test xmlns:ns1="http://testuri.org" />
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
EOF;
$server->handle($HTTP_RAW_POST_DATA);
echo "ok\n";
Example #10
0
<?php

/**
 * LinkQuick - vložení nové adresy do databáze
 * @author Vitex <*****@*****.**>
 * @copyright Vitex@hippy.cz (G) 2009,2011
 */
require_once 'includes/LQInit.php';
require_once 'classes/LQEncoder.php';
$encoder = new Encoder();
$server = new SoapServer(null, ['uri' => EasePage::phpSelf()]);
$server->setObject($encoder);
$server->handle();
/*
 function hello($someone) {
 return "Hello " . $someone . "!";
 }
 $server = new SoapServer(null, array('uri' => "urn://www.herong.home/res"));
 $server->addFunction("hello");
 $server->handle();
*/
                $file = "LeerlinginfoNietBeschikbaar";
                $foutTemp = 1;
                break;
            case "206314401":
                $file = "LeveringGeweigerd";
                $foutTemp = 1;
                break;
            default:
                $file = "LeerlingNietBekend";
                $foutTemp = 1;
        }
        $fout = $school->sessionResponse->fout;
        if ($school->sessionResponse->fout == 'GeenRelatieMetDoel') {
            $fout = 'LeveringGeweigerd';
        }
        // sessionControlResponse contains fault
        if (isset($school->sessionResponse->fout)) {
            return new SoapVar('<ns1:documentResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema"><ns1:fout>' . $fout . '</ns1:fout></ns1:documentResponse>', XSD_ANYXML);
        } else {
            if ($foutTemp == '1') {
                return new SoapVar('<ns1:documentResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema"><ns1:fout>' . $file . '</ns1:fout></ns1:documentResponse>', XSD_ANYXML);
            } else {
                return new SoapVar('<ns1:documentResponse xmlns="http://www.edustandaard.nl/oso_gegevensset/1.2/dossier" >' . $file . '</ns1:documentResponse>', XSD_ANYXML);
            }
        }
    }
}
//here the documentsRequest is received. From here all the necessary information like bsn, sessionId is passed to the function Document
$server = new SoapServer($wsdl);
$server->setObject(new PSE($wsdl, $my_cert_file3, $passphrase3, "98SS", $aanleverpunt));
$server->handle();
Example #12
0
<?php

ini_set('display_errors', 1);
require_once "MyServer.php";
$soapServer = new SoapServer("schema.wsdl");
$soapServer->setObject(new MyServer());
$soapServer->handle();
            $path->path_order = $i;
            $i++;
            $path->setPortBySTP($dst->item(0)->nodeValue);
            $path->setDomainBySTP($dst->item(0)->nodeValue);
            if (!$path->save()) {
                Yii::trace($path);
                return false;
            }
        }
        return true;
    }
    private function updateConnectionBandwidth($conn, $response)
    {
        $criteria = $response->reservation->criteria;
        Yii::trace(print_r($criteria, true));
        $p2pXml = $criteria->any;
        $p2pXml = str_replace("<nsi_p2p:p2ps>", "<p2p>", $p2pXml);
        $p2pXml = str_replace("</nsi_p2p:p2ps>", "</p2p>", $p2pXml);
        $p2pXml = '<?xml version="1.0" encoding="UTF-8"?>' . $p2pXml;
        $xml = new \DOMDocument();
        $xml->loadXML($p2pXml);
        $parser = new \DOMXpath($xml);
        $cap = $parser->query("//capacity");
        $conn->bandwidth = $cap->item(0)->nodeValue;
        return true;
    }
}
$wsdl = Url::to('@web/wsdl/ogf_nsi_connection_requester_v2_0.wsdl', true);
$requester = new \SoapServer($wsdl, array('encoding' => 'UTF-8'));
$requester->setObject(new RequesterController('req', Module::getInstance()));
$requester->handle();
Example #14
0
<?php

use Lib\Config;
// Inclusao do arquivo de bootstrap
require __DIR__ . '/bootstrap.php';
if ($_GET) {
    if (isset($_GET['modulo'])) {
        $modulo = "Model\\{$_GET['modulo']}";
        $objeto = new $modulo();
        $servidor_soap = new SoapServer(Config::get('path') . "wsdl/{$_GET['modulo']}.wsdl");
        $servidor_soap->setObject($objeto);
        $servidor_soap->handle();
    }
}
Example #15
0
        return getXml($myresponse);
    }
}
//
function echoString($inputString)
{
    return $inputString;
}
//create a new SOAP server in non - WSDL mode
$server = new SoapServer(NULL, $options);
// NG with functions and addFunction(SOAP_FUNCTIONS_ALL) you get all the php functions and everything else NG
// looks like you can addFunction or setClass, but you can't mix and match
//$server->addFunction("echoString");
//attach the API class to the SOAP Server
//$server->setClass('MyAPI','arg1 maybe a cert');
$server->setObject(new MyService());
//start the SOAP requests handler
$server->handle();
//$server->addFunction(SOAP_FUNCTIONS_ALL);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $server->handle();
} else {
    echo "This SOAP server can handle following functions:<br>";
    $functions = $server->getFunctions();
    foreach ($functions as $func) {
        echo $func . "<br>";
    }
}
//nada nothing zip zilch wtf
//$definedVars = get_defined_vars(); // return empty if from here
//error_log('ss defined variable'. displaydefinedVariables($definedVars),0);
Example #16
0
 /**
  * Handle
  *
  * @param string $calling_component_filename Filename
  * @param string $service_description        Service description
  *
  * @return mixed
  */
 public function handle($calling_component_filename, $service_description)
 {
     SCA::$logger->log('Entering');
     $class_name = SCA_Helper::guessClassName($calling_component_filename);
     $wsdl_filename = str_replace('.php', '.wsdl', $calling_component_filename);
     if (!file_exists($wsdl_filename)) {
         file_put_contents($wsdl_filename, SCA_Bindings_Soap_ServiceDescriptionGenerator::generateDocumentLiteralWrappedWsdl($service_description));
     }
     $handler = new SCA_Bindings_soap_Mapper("SoapServer");
     try {
         SCA::$logger->log("Wsdl Type = {$wsdl_filename}");
         $handler->setWSDLTypes($wsdl_filename);
     } catch (SCA_RuntimeException $wsdlerror) {
         echo $wsdlerror->exceptionString() . "\n";
     }
     if (SCA_Helper::wsdlWasGeneratedForAnScaComponent($wsdl_filename)) {
         $options = $service_description->binding_config;
         $options['typemap'] = $handler->getTypeMap();
         $server = new SoapServer($wsdl_filename, $options);
     } else {
         $server = new SoapServer($wsdl_filename, $service_description->binding_config);
     }
     $class_name = SCA_Helper::guessClassName($calling_component_filename);
     $service_wrapper = new SCA_Bindings_Soap_Wrapper($class_name, $handler);
     $server->setObject($service_wrapper);
     global $HTTP_RAW_POST_DATA;
     $server->handle($HTTP_RAW_POST_DATA);
 }
Example #17
0
 /**
  * Run the route action and return the response.
  *
  * @param Request $request
  * @return mixed
  * @throws NotFoundHttpException
  * @throws \SoapFault
  */
 protected function runController(Request $request)
 {
     list($class, $method) = explode('@', $this->action['uses']);
     $parameters = $this->resolveClassMethodDependencies($this->parametersWithoutNulls(), $class, $method);
     if (!method_exists($instance = $this->container->make($class), $method)) {
         throw new NotFoundHttpException();
     }
     try {
         $soapServer = new \SoapServer($this->getWsdlPath());
     } catch (\SoapFault $e) {
         throw new \SoapFault(500, 'The application encountered an unexpected error.');
     }
     try {
         $soapHandler = $this->container->make('MultiRouting\\Adapters\\Soap\\Request\\Handlers\\Handler', [$instance, $method, $parameters]);
         $soapServer->setObject($soapHandler);
         $soapServer->handle();
     } catch (\Exception $e) {
         $soapServer->fault($e->getCode(), $e->getMessage());
     }
 }
Example #18
0
 /**
  * Handles the web service request.
  */
 public function run()
 {
     header('Content-Type: text/xml;charset=' . $this->encoding);
     if (YII_DEBUG) {
         ini_set("soap.wsdl_cache_enabled", 0);
     }
     list(, $hash) = explode(' ', \Yii::$app->getRequest()->getHeaders()->get('authorization') . ' ');
     $auth = $hash ? base64_decode($hash) . '@' : '';
     $server = new \SoapServer(str_replace('http://', 'http://' . $auth, $this->wsdlUrl), $this->getOptions());
     try {
         if ($this->persistence !== null) {
             $server->setPersistence($this->persistence);
         }
         if (is_string($this->provider)) {
             $provider = $this->provider;
             $provider = new $provider();
         } else {
             $provider = $this->provider;
         }
         $server->setObject($provider);
         ob_start();
         $server->handle();
         $soapXml = ob_get_contents();
         ob_end_clean();
         return $soapXml;
     } catch (Exception $e) {
         if ($e->getCode() !== self::SOAP_ERROR) {
             // only log for non-PHP-error case because application's error handler already logs it
             // php <5.2 doesn't support string conversion auto-magically
             \Yii::error($e->__toString());
         }
         $message = $e->getMessage();
         if (YII_DEBUG) {
             $message .= ' (' . $e->getFile() . ':' . $e->getLine() . ")\n" . $e->getTraceAsString();
         }
         // We need to end application explicitly because of
         // http://bugs.php.net/bug.php?id=49513
         $server->fault(get_class($e), $message);
         exit(1);
     }
 }
Example #19
0
 /**
  * Handle SOAP service call.
  *
  * @param string $modelId    : underscore notation of the called model
  *                           without _service ending
  * @param string $wsdlMethod : method of the controller that will generate the WSDL
  */
 public function handle($controllId, $wsdlMethod = 'wsdl')
 {
     $inflector = new Inflector();
     $controllClass = $inflector->camelize($controllId);
     $wsdlCacheFile = CACHE . $controllClass . '.wsdl';
     // Try to create cache file if not exists
     if (!is_file($wsdlCacheFile)) {
         $this->getWSDL($controllId);
     }
     if (is_file($wsdlCacheFile)) {
         $server = new SoapServer($wsdlCacheFile);
     } else {
         $wsdlURL = Router::url('/' . $this->__settings['prefix'] . '/' . low($controllClass) . "/{$wsdlMethod}", true);
         $server = new SoapServer($wsdlURL);
     }
     $server->setObject($this->controller);
     $server->handle();
 }
Example #20
0
 /**
  * Main Soap server
  *
  * @return  string  Full URL to the webservice
  *
  * @since   1.4
  */
 public function apiSoap()
 {
     $wsdl = JUri::root() . $this->wsdlPath;
     $params = array('uri' => $wsdl, 'soap_version' => SOAP_1_2, 'cache_wsdl' => WSDL_CACHE_NONE);
     $operation = new RApiSoapOperationOperation($this->webservice);
     $server = new SoapServer($wsdl, $params);
     $server->setObject($operation);
     ob_start();
     $server->handle();
     $response = ob_get_contents();
     ob_end_clean();
     $this->soapResponse = str_replace('&', '&amp;', str_replace('&amp;', '&', $response));
 }
Example #21
0
 /**
  * Create SoapServer
  *
  * @param string $url URL of a WSDL file
  * @param array $options Options including encoding, soap_version etc
  * @return \SoapServer
  */
 public function create($url, $options)
 {
     $soapServer = new \SoapServer($url, $options);
     $soapServer->setObject($this->_soapHandler);
     return $soapServer;
 }
Example #22
0
<?php

require_once 'Ahorcado.class.php';
function autoinclude($className)
{
    $className = str_replace('\\', '/', $className) . '.php';
    require_once $className;
}
spl_autoload_register('autoinclude');
if (isset($_GET['wsdl'])) {
    header('Content-Type: application/soap+xml; charset=utf-8');
    echo file_get_contents('Ahorcado.wsdl');
} else {
    session_start();
    if (!isset($_SESSION['service'])) {
        $_SESSION['service'] = new Ahorcado();
    }
    $servidorSoap = new SoapServer('C:\\Users\\Iva\\Documents\\II-2015\\Apps\\TareaWebService\\TPRepo\\Ahorcado.wsdl');
    //poner la ruta en tu compu
    //Para evitar la excepción por defecto de SOAP PHP cuando no existe HTTP_RAW_POST_DATA,
    //se regresa explícitamente el siguiente fallo cuando no hay solicitud (v.b. desde un navegador)
    if (!@$HTTP_RAW_POST_DATA) {
        $servidorSoap->fault('SOAP-ENV:Client', 'Invalid Request');
        exit;
    }
    $servidorSoap->setObject(new Zend\Soap\Server\DocumentLiteralWrapper($_SESSION['service']));
    $servidorSoap->setPersistence(SOAP_PERSISTENCE_SESSION);
    $servidorSoap->handle();
}
Example #23
0
<?php

$wsdl = dirname(__FILE__) . '/wsdls/Tax.wsdl';
if (!is_file($wsdl)) {
    echo 'Missing wsdl file';
}
$serverSleep = 100;
$soapServer = new SoapServer($wsdl);
$soapServer->setObject(new FakeSoapServer($serverSleep));
$soapServer->handle();
class FakeSoapServer
{
    protected $sleepTime = 0;
    public function __construct($sleepTime)
    {
        $this->sleepTime = $sleepTime;
    }
    public function __call($method, $args)
    {
        if ($this->sleepTime) {
            sleep($this->sleepTime);
        }
        $fakeResponse = 'fake response';
        return $fakeResponse;
    }
}
 /**
  * Run the PHP SoapServer
  * 
  * @param string $wsdlFile The WSDL file name or NULL to let PhpWsdl decide (default: NULL)
  * @param string|object|array $class The class name to serve, the classname and class as array or NULL (default: NULL)
  * @param boolean $andExit Exit after running the server? (default: TRUE)
  * @param boolean $forceNoWsdl Force no WSDL usage? (default: FALSE);
  * @return boolean Did the server run?
  */
 public function RunServer($wsdlFile = null, $class = null, $andExit = true, $forceNoWsdl = false)
 {
     self::Debug('Run the server');
     if ($forceNoWsdl) {
         self::Debug('Forced non-WSDL mode');
     }
     if (self::CallHook('BeforeRunServerHook', array('server' => $this, 'wsdlfile' => &$wsdlFile, 'class' => &$class, 'andexit' => &$andExit, 'forcenowsdl' => &$forceNoWsdl))) {
         // WSDL requested?
         if ($this->OutputWsdlOnRequest($andExit)) {
             return false;
         }
         // PHP requested?
         if ($this->OutputPhpOnRequest($andExit)) {
             return false;
         }
         // HTML requested?
         if ($this->OutputHtmlOnRequest($andExit)) {
             return false;
         }
     }
     // Login
     $user = null;
     $password = null;
     if ($this->RequireLogin) {
         if (isset($_SERVER['PHP_AUTH_USER']) || isset($_SERVER['PHP_AUTH_PW'])) {
             $user = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null;
             $password = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null;
         }
         self::Debug('Check login ' . $user . ':' . str_repeat('*', strlen($password)));
         if (!self::CallHook('LoginHook', array('server' => $this, 'user' => &$user, 'password' => &$password))) {
             self::Debug('Login required');
             header('WWW-Authenticate: Basic realm="SOAP webservice login required"');
             header('HTTP/1.0 401 Unauthorized');
             if ($andExit) {
                 self::Debug('Exit script execution');
                 exit;
             }
             return false;
         }
     }
     // Load the proxy
     $useProxy = false;
     if (is_array($class)) {
         self::Debug('Use the proxy for ' . $class[0]);
         self::$ProxyObject = $class[1];
         self::$ProxyServer = $this;
         $class = $class[0];
         $useProxy = true;
     }
     // Ensure a webservice name
     if (is_null($class)) {
         self::Debug('No webservice name yet');
         if (!$this->DetermineConfiguration()) {
             throw new Exception('Invalid configuration');
         }
         if (!is_null($this->Name)) {
             $class = $this->Name;
         }
     } else {
         if (is_string($class)) {
             self::Debug('Using ' . $class . ' as webservice name');
             $this->Name = $class;
         }
     }
     self::Debug('Use class ' . (!is_object($class) ? $class : get_class($class)));
     // Load WSDL
     if (!$forceNoWsdl && (!$useProxy || self::$UseProxyWsdl)) {
         self::Debug('Load WSDL');
         $this->CreateWsdl(false, true);
         if (is_null($wsdlFile)) {
             $wsdlFile = $this->GetCacheFileName();
         }
         if (!is_null($wsdlFile)) {
             if (!file_exists($wsdlFile)) {
                 self::Debug('WSDL file "' . $wsdlFile . '" does not exists');
                 $wsdlFile = null;
             }
         }
     }
     // Load the files, if the webservice handler class doesn't exist
     if (!is_object($class)) {
         if (!class_exists($class) && !$this->IsOnlyGlobal()) {
             self::Debug('Try to load the webservice handler class');
             $i = -1;
             $len = sizeof($this->Files);
             while (++$i < $len) {
                 self::Debug('Load ' . $this->Files[$i]);
                 require_once $this->Files[$i];
             }
             if (!class_exists($class)) {
                 // Try class.webservice.php
                 if (file_exists('class.webservice.php')) {
                     self::Debug('Try to load class.webservice.php');
                     require_once 'class.webservice.php';
                     if (class_exists($class)) {
                         $this->Files[] = 'class.webservice.php';
                     }
                 }
                 if (!class_exists($class)) {
                     if (file_exists(dirname(__FILE__) . '/class.webservice.php')) {
                         self::Debug('Try to load ' . dirname(__FILE__) . '/class.webservice.php');
                         require_once dirname(__FILE__) . '/class.webservice.php';
                         if (class_exists($class)) {
                             $this->Files[] = dirname(__FILE__) . '/class.webservice.php';
                         }
                     }
                 }
                 if (!class_exists($class)) {
                     // A handler class or object is required when using non-global methods!
                     throw new Exception('Webservice handler class not present');
                 }
             }
         }
     }
     // Prepare the SOAP server
     $this->SoapServer = null;
     if (self::CallHook('PrepareServerHook', array('server' => $this, 'soapserver' => &$this->SoapServer, 'wsdlfile' => &$wsdlFile, 'class' => &$class, 'useproxy' => &$useProxy, 'forcenowsdl' => &$forceNoWsdl, 'andexit' => &$andExit, 'user' => &$user, 'password' => &$password))) {
         self::Debug('Prepare the SOAP server');
         // WSDL file
         $wsdlFile = $forceNoWsdl || $useProxy && !self::$UseProxyWsdl ? null : $wsdlFile;
         if (!is_null($wsdlFile)) {
             self::Debug('Using WSDL file ' . $wsdlFile);
         } else {
             self::Debug('No WSDL file');
         }
         // Server options
         $temp = array('actor' => $this->EndPoint, 'uri' => $this->NameSpace);
         $temp = array_merge($this->SoapServerOptions, $temp);
         if (self::$Debugging) {
             self::Debug('Server options: ' . print_r($temp, true));
         }
         // Create the server object
         self::Debug('Creating PHP SoapServer object');
         $this->SoapServer = new SoapServer($wsdlFile, $temp);
         // Set the handler class or object
         if ($useProxy || !is_object($class)) {
             $temp = $useProxy ? 'PhpWsdlProxy' : $class;
             if (!is_null($temp)) {
                 self::Debug('Setting server class ' . $temp);
                 $this->SoapServer->setClass($temp);
             } else {
                 self::Debug('No server class or object');
             }
         } else {
             self::Debug('Setting server object ' . get_class($class));
             $this->SoapServer->setObject($class);
         }
         // Add global methods
         $i = -1;
         $len = sizeof($this->Methods);
         while (++$i < $len) {
             if ($this->Methods[$i]->IsGlobal) {
                 self::Debug('Adding global method ' . $this->Methods[$i]->Name);
                 $this->SoapServer->addFunction($this->Methods[$i]->Name);
             }
         }
     }
     // Run the SOAP server
     if (self::CallHook('RunServerHook', array('server' => $this, 'soapserver' => &$this->SoapServer, 'wsdlfile' => &$wsdlFile, 'class' => &$class, 'useproxy' => &$useProxy, 'forcenowsdl' => &$forceNoWsdl, 'andexit' => &$andExit, 'user' => &$user, 'password' => &$password))) {
         self::Debug('Run the SOAP server');
         $this->SoapServer->handle();
         if ($andExit) {
             self::Debug('Exit script execution');
             exit;
         }
     }
     return true;
 }
 /**
  * Get SoapServer object
  *
  * Uses {@link $_wsdl} and return value of {@link getOptions()} to instantiate
  * SoapServer object, and then registers any functions or class with it, as
  * well as peristence.
  *
  * @return SoapServer
  */
 protected function _getSoap()
 {
     $options = $this->getOptions();
     $server = new SoapServer($this->_wsdl, $options);
     if (!empty($this->_functions)) {
         $server->addFunction($this->_functions);
     }
     if (!empty($this->_class)) {
         $args = $this->_classArgs;
         array_unshift($args, $this->_class);
         if ($this->_wsiCompliant) {
             #require_once 'Zend/Soap/Server/Proxy.php';
             array_unshift($args, 'Zend_Soap_Server_Proxy');
         }
         call_user_func_array(array($server, 'setClass'), $args);
     }
     if (!empty($this->_object)) {
         $server->setObject($this->_object);
     }
     if (null !== $this->_persistence) {
         $server->setPersistence($this->_persistence);
     }
     return $server;
 }
Example #26
0
<?php

ini_set("soap.wsdl_cache_enabled", 0);
$server = new SoapServer(null, array('uri' => 'http://localhost/ifa/soap/', 'version' => SOAP_1_2));
class Test
{
    function test()
    {
        return "test";
    }
}
$server->setObject(new Test());
$server->handle();
var_dump($server);
<?php

use WSDL\DocumentLiteralWrapper;
use WSDL\WSDLCreator;
use WSDL\XML\Styles\DocumentLiteralWrapped;
require_once '../../vendor/autoload.php';
ini_set("soap.wsdl_cache_enabled", 0);
$wsdl = new WSDLCreator('SimpleSoapServer', 'http://localhost/wsdl-creator/examples/document_literal_wrapped/SimpleExampleSoapServer.php');
$wsdl->setNamespace("http://foo.bar/")->setBindingStyle(new DocumentLiteralWrapped());
if (isset($_GET['wsdl'])) {
    $wsdl->renderWSDL();
    exit;
}
$wsdl->renderWSDLService();
$server = new SoapServer('http://localhost/wsdl-creator/examples/document_literal_wrapped/SimpleExampleSoapServer.php?wsdl', array('uri' => $wsdl->getNamespaceWithSanitizedClass(), 'location' => $wsdl->getLocation(), 'style' => SOAP_DOCUMENT, 'use' => SOAP_LITERAL, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS));
$server->setObject(new DocumentLiteralWrapper(new SimpleSoapServer()));
$server->handle();
class SimpleSoapServer
{
    /**
     * @WebMethod
     * @param string $name
     * @param int $age
     * @return string $nameWithAge
     */
    public function getNameWithAge($name, $age)
    {
        return 'Your name is: ' . $name . ' and you have ' . $age . ' years old';
    }
    /**
     * @WebMethod
Example #28
0
<?php

ini_set('soap.wsdl_cache_enabled', '0');
class WsCalc
{
    public function soma($num_a, $num_b)
    {
        return $num_a + $num_b;
    }
    public function subtracao($num_a, $num_b)
    {
        return $num_a - $num_b;
    }
    public function multiplicacao($num_a, $num_b)
    {
        return $num_a * $num_b;
    }
}
$servidor_soap = new SoapServer('wscalc.wsdl');
// Criar um instancia da WsCalc
$obj_wscalc = new WsCalc();
// 'registrar' o objeto WsCalc no servidor_soap
$servidor_soap->setObject($obj_wscalc);
$servidor_soap->handle();
Example #29
0
 /**
  * Get SoapServer object
  *
  * Uses {@link $_wsdl} and return value of {@link getOptions()} to instantiate
  * SoapServer object, and then registers any functions or class with it, as
  * well as peristence.
  *
  * @return SoapServer
  */
 protected function _getSoap()
 {
     $options = $this->getOptions();
     $server = new SoapServer($this->_wsdl, $options);
     if (!empty($this->_functions)) {
         $server->addFunction($this->_functions);
     }
     if (!empty($this->_class)) {
         $args = $this->_classArgs;
         array_unshift($args, $this->_class);
         call_user_func_array(array($server, 'setClass'), $args);
     }
     if (!empty($this->_object)) {
         $server->setObject($this->_object);
     }
     if (null !== $this->_persistence) {
         $server->setPersistence($this->_persistence);
     }
     return $server;
 }
Example #30
0
<?php

ini_set('display_errors', 1);
class EchoServer
{
    public function __call($name, $args)
    {
        return array($name, $args);
    }
}
$soapServer = new SoapServer(null, array('uri' => 'urn:schema'));
$soapServer->setObject(new EchoServer());
$soapServer->handle();