/** * Actual "do request" method. * * @internal * @param \Zend\Soap\Client\Common $client * @param string $request * @param string $location * @param string $action * @param int $version * @param int $one_way * @return mixed */ public function _doRequest(Common $client, $request, $location, $action, $version, $one_way = null) { // Perform request as is ob_start(); $this->_server->handle($request); $response = ob_get_clean(); return $response; }
/** * Actual "do request" method. * * @param Common $client * @param string $request * @param string $location * @param string $action * @param int $version * @param int $oneWay * @return mixed */ public function _doRequest(Common $client, $request, $location, $action, $version, $oneWay = null) { // Perform request as is ob_start(); $this->server->handle($request); $response = ob_get_clean(); if ($response === null || $response === '') { $serverResponse = $this->server->getResponse(); if ($serverResponse !== null) { $response = $serverResponse; } } return $response; }
public function handleSOAP($local) { HttpLogin::login(); $soap = new Server(null, array('wsdl' => Constants::WSDL_URI_TESORERIA . $local)); $soapClass = new Tesoreria($this->getServiceLocator()); $soap->setObject($soapClass); $soap->handle(); }
public function indexAction() { $server = new Server(null, array('uri' => 'http://localhost/index/soap')); // set SOAP service class // Bind already initialized object to Soap Server $server->setObject(new EncounterccdadispatchController($this->getServiceLocator())); // handle request $server->handle(); exit; }
/** * @param string $uri * @throws Exception */ private function handleSoap($uri) { /** @var Server $soapServer */ $soapServer = new Server( null, [ 'wsdl' => $uri . '?wsdl' ] ); $soapServer->setClass($this->getHandler()); $soapServer->handle(); }
/** * {@inheritdoc} */ public function serve($params = null) { $uri = $params; if (!class_exists('SoapServer')) { throw new \Exception('SoapServer is required. Please enable this extension'); exit; } if (!class_exists('Zend\\Soap\\Server')) { throw new \Exception("Zend\\Soap\\Server is required. " . "Please install it using 'composer require zend/zend-soap'"); exit; } $serviceHandler = get_class($this->serviceHandler); $obj = new $serviceHandler($this->authentication, $this->connectionStrings, $this->logDir); if (null === $uri) { $uri = strtok($this->request->getUri(), '?'); $uri = dirname($uri) . '/' . basename($uri); } $response = new Response(); $response->headers->set('Access-Control-Allow-Headers', 'origin, content-type, accept'); $response->headers->set('Access-Control-Allow-Origin', '*'); $response->headers->set('Access-Control-Allow-Methods', 'POST, GET, OPTIONS'); $response->headers->set('Content-type', 'text/xml'); $cacheFile = dirname($_SERVER['SCRIPT_FILENAME']) . '/dbinstance.wsdl.xml'; if (isset($_GET['wsdl']) || isset($_GET['WSDL'])) { $xml = ''; if (file_exists($cacheFile)) { $xml = file_get_contents($cacheFile); } else { $autodiscover = new AutoDiscover(); $autodiscover->setUri($uri); $autodiscover->setClass($serviceHandler); $autodiscover->setServiceName('DBInstance'); $wsdl = $autodiscover->generate(); $xml = $wsdl->toXml(); $wsdl->dump($cacheFile); } $response->setContent($xml); return $response->send(); } $response->sendHeaders(); $server = new Server($uri . '?wsdl'); $server->setObject($obj); $server->handle(); }
public function soapAction() { //$view = new ViewModel(); //$view->setTerminal(true); if (isset($_GET['wsdl'])) { $autodiscover = new AutoDiscover(); $autodiscover->setClass('Customers\\Model\\SOAPSave')->setUri('http://zf2_soap.loc/customers/SOAP/soap'); $viewModel = new ViewModel(array('ad' => $autodiscover)); $viewModel->setTerminal(true); return $viewModel; } else { // pointing to the current file here $soap = new Server("http://zf2_soap.loc/customers/SOAP/soap?wsdl"); $soap->setClass('Customers\\Model\\SOAPSave'); $soap->handle(); $viewModel->setTemplate('customers/SOAP/soap_1'); $viewModel->setTerminal(true); return $viewModel; } //return $view; }
/** * 创建一个服务 */ public function soap($uri, $className, $config = null) { if (isset($_GET['wsdl'])) { $autodiscover = new AutoDiscover(); $autodiscover->setClass($className)->setUri($uri); return $autodiscover->toXml(); } else { $wsdl = strpos($uri, '?') === false ? $uri . '?wsdl' : $uri . '&wsdl'; $server = new SoapServer($wsdl); $obj = $config == null ? new $className() : new $className($config); $server->setObject($obj); $server->handle(); $response = $server->getLastRequest(); if ($response instanceof \SoapFault) { $response = exceptionMsg($response); $this->log($response); } return $response; } }
/** * @runInSeparateProcess */ public function testShouldThrowExceptionIfHandledRequestContainsDoctype() { $server = new Server(); $server->setOptions(array('location' => 'test://', 'uri' => 'http://framework.zend.com')); $server->setReturnResponse(true); $server->setClass('\\ZendTest\\Soap\\TestAsset\\ServerTestClass'); $request = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<!DOCTYPE foo>' . "\n" . '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ' . 'xmlns:ns1="http://framework.zend.com" ' . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" ' . 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' . '<SOAP-ENV:Body>' . '<ns1:testFunc2>' . '<param0 xsi:type="xsd:string">World</param0>' . '</ns1:testFunc2>' . '</SOAP-ENV:Body>' . '</SOAP-ENV:Envelope>' . "\n"; $response = $server->handle($request); $this->assertContains('Invalid XML', $response->getMessage()); }
public function __doRequest($request, $location, $action, $version, $one_way = 0) { ob_start(); $this->server->handle($request); $response = ob_get_clean(); return $response; }
public function testErrorHandlingOfSoapServerChangesToThrowingSoapFaultWhenInHandleMode() { if (headers_sent()) { $this->markTestSkipped('Cannot run ' . __METHOD__ . '() when headers have already been sent; enable output buffering to run this test'); return; } $server = new Server(); $server->setOptions(array('location' => 'test://', 'uri' => 'http://framework.zend.com')); $server->setReturnResponse(true); // Requesting Method with enforced parameter without it. $request = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ' . 'xmlns:ns1="http://framework.zend.com" ' . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" ' . 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' . '<SOAP-ENV:Body>' . '<ns1:testFunc5 />' . '</SOAP-ENV:Body>' . '</SOAP-ENV:Envelope>' . "\n"; $server->setClass('\\ZendTest\\Soap\\TestAsset\\ServerTestClass'); $response = $server->handle($request); $this->assertContains('<SOAP-ENV:Fault><faultcode>Receiver</faultcode><faultstring>Test Message</faultstring></SOAP-ENV:Fault>', $response); }
public function soapAction() { $soap = new Soap(null, array('uri' => $this->_WSDL_URI . "/wsdl", 'encoding' => 'UTF-8')); $soap->setClass('\\Application\\Webservices\\gpa'); $soap->setEncoding('UTF-8'); $soap->registerFaultException(array('Exception')); $soap->handle(); return $this->setTerminal(); }
public function SOAPServer() { try { if (isset($this->data->wsdl)) { $ad = new AutoDiscover(); $ad->setClass('SOAPService'); $uri = Manager::getAppURL('exemplos', 'zend/soapServer', true); $ad->setURI($uri); $wsdl = $ad->toXML(); $this->renderStream($wsdl); } else { $uri = Manager::getAppURL('exemplos', 'zend/soapServer?wsdl', true); $server = new Server($uri); $server->setSoapVersion(SOAP_1_2); $server->setClass('SOAPService'); $server->setReturnResponse(true); $response = $server->handle(); $this->renderBinary($response); } } catch (Exception $e) { mdump($e->getMessage()); mdump($e->getTraceAsString()); } }