<?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
<?php use WSDL\WSDLCreator; require_once '../../vendor/autoload.php'; ini_set("soap.wsdl_cache_enabled", 0); $wsdl = new WSDLCreator('SimpleSoapServer', 'http://localhost/wsdl-creator/examples/rpc_literal/SimpleExampleSoapServer.php'); $wsdl->setNamespace("http://foo.bar/"); if (isset($_GET['wsdl'])) { $wsdl->renderWSDL(); exit; } $wsdl->renderWSDLService(); $server = new SoapServer('http://localhost/wsdl-creator/examples/rpc_literal/SimpleExampleSoapServer.php?wsdl', array('uri' => $wsdl->getNamespaceWithSanitizedClass(), 'location' => $wsdl->getLocation(), 'style' => SOAP_RPC, 'use' => SOAP_LITERAL)); $server->setClass('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 * @param string[] $names * @return string $userNames
/** * Setup soap server * * @param WSDLCreator $wsdl */ protected function setupSoapServer(WSDLCreator $wsdl) { $request = file_get_contents('php://input'); $server = new SoapServer($this->endpoint . '?' . $this->wsdlQueryString, array_merge(['uri' => $wsdl->getNamespaceWithSanitizedClass(), 'cache_wsdl' => WSDL_CACHE_NONE, 'location' => $wsdl->getLocation(), 'style' => SOAP_RPC, 'use' => SOAP_LITERAL], $this->options)); $server->setClass($this->soapApiClass, $this->listener, $this->callbacks); $server->handle($request); }
<?php use WSDL\WSDLCreator; use WSDL\XML\Styles\RpcEncoded; require_once '../../vendor/autoload.php'; $wsdl = new WSDLCreator('WrapperSoapServer', 'http://localhost/wsdl-creator/examples/rpc_encoded/WrapperExampleSoapServer.php'); $wsdl->setNamespace("http://foo.bar/")->setBindingStyle(new RpcEncoded()); if (isset($_GET['wsdl'])) { $wsdl->renderWSDL(); exit; } $wsdl->renderWSDLService(); $server = new SoapServer('http://localhost/wsdl-creator/examples/rpc_encoded/WrapperExampleSoapServer.php?wsdl', array('uri' => $wsdl->getNamespaceWithSanitizedClass(), 'location' => $wsdl->getLocation(), 'style' => SOAP_RPC, 'use' => SOAP_ENCODED)); $server->setClass('WrapperSoapServer'); $server->handle(); class User { /** * @type string */ public $name; /** * @type int */ public $age; /** * @type double */ public $payment; } class Employee
<?php use WSDL\WSDLCreator; require_once '../../vendor/autoload.php'; $wsdl = new WSDLCreator('WrapperSoapServer', 'http://localhost/wsdl-creator/examples/return_complextypes/WrapperExampleSoapServer.php'); $wsdl->setNamespace("http://foo.bar/"); if (isset($_GET['wsdl'])) { $wsdl->renderWSDL(); exit; } $wsdl->renderWSDLService(); $server = new SoapServer('http://localhost/wsdl-creator/examples/return_complextypes/WrapperExampleSoapServer.php?wsdl', array('uri' => $wsdl->getNamespaceWithSanitizedClass(), 'location' => $wsdl->getLocation(), 'style' => SOAP_RPC, 'use' => SOAP_LITERAL)); $server->setClass('WrapperSoapServer'); $server->handle(); class User { /** * @type string */ public $name; /** * @type int */ public $age; /** * @type double */ public $payment; } class Employee {