Example #1
0
 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();
 }
Example #2
0
 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;
 }
 /**
  * @runInSeparateProcess
  */
 public function testDelegate()
 {
     $server = new Server(__DIR__ . self::WSDL);
     $server->setObject(new DocumentLiteralWrapper(new MyCalculatorService()));
     // The local client needs an abstraction for this pattern as well.
     // This is just a test so we use the messy way.
     $client = new SoapClient($server, __DIR__ . self::WSDL);
     $ret = $client->add(array('x' => 10, 'y' => 20));
     $this->assertInstanceOf('stdClass', $ret);
     $this->assertEquals(30, $ret->addResult);
 }
Example #4
0
 /**
  * {@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();
 }
Example #5
0
 /**
  * 创建一个服务
  */
 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;
     }
 }
Example #6
0
 public function testGetFunctionsWithObjectAttached()
 {
     $server = new Server();
     $server->setObject(new TestAsset\ServerTestClass());
     $this->assertEquals(array('testFunc1', 'testFunc2', 'testFunc3', 'testFunc4', 'testFunc5'), $server->getFunctions());
 }