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
 /**
  * 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;
 }
Example #3
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);
 }
    /**
     * @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();
    }
Example #6
0
 /**
  * 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;
 }
 protected function _getSoap()
 {
     if ($this->server instanceof \SoapServer) {
         return $this->server;
     }
     $this->server = parent::_getSoap();
     return $this->server;
 }
Example #8
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 #9
0
 /**
  * Catch exceptions if request is invalid and output fault message.
  *
  * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request
  * @return Mage_Webapi_Model_Soap_Server
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 protected function _setRequest($request)
 {
     try {
         parent::_setRequest($request);
     } catch (Exception $e) {
         $fault = new Mage_Webapi_Model_Soap_Fault($e->getMessage(), Mage_Webapi_Model_Soap_Fault::FAULT_CODE_SENDER);
         die($fault->toXml($this->_application->isDeveloperMode()));
     }
     return $this;
 }
Example #10
0
 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;
 }
Example #11
0
    public function testSetInputHeaders()
    {
        if (headers_sent()) {
            $this->markTestSkipped('Cannot run testSetInputHeaders() when headers have already been sent; enable output buffering to run this test');
            return;
        }

        $server = new Server(__DIR__ . '/TestAsset/wsdl_example.wsdl');
        $server->setClass('\ZendTest\Soap\TestAsset\TestClass');

        $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl');

        // Add request header
        $client->addSoapInputHeader(new \SoapHeader('http://www.example.com/namespace', 'MyHeader1', 'SOAP header content 1'));
        // Add permanent request header
        $client->addSoapInputHeader(new \SoapHeader('http://www.example.com/namespace', 'MyHeader2', 'SOAP header content 2'), true);

        // Perform request
        $client->testFunc2('World');

        $expectedRequest = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"
                         . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" '
                         .               'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
                         .               'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
                         .               'xmlns:ns1="http://www.example.com/namespace" '
                         .               'xmlns:enc="http://www.w3.org/2003/05/soap-encoding">'
                         .     '<env:Header>'
                         .         '<ns1:MyHeader2>SOAP header content 2</ns1:MyHeader2>'
                         .         '<ns1:MyHeader1>SOAP header content 1</ns1:MyHeader1>'
                         .     '</env:Header>'
                         .     '<env:Body>'
                         .         '<env:testFunc2 env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">'
                         .             '<who xsi:type="xsd:string">World</who>'
                         .         '</env:testFunc2>'
                         .     '</env:Body>'
                         . '</env:Envelope>' . "\n";

        $this->assertEquals($client->getLastRequest(), $expectedRequest);


        // Add request header
        $client->addSoapInputHeader(new \SoapHeader('http://www.example.com/namespace', 'MyHeader3', 'SOAP header content 3'));

        // Perform request
        $client->testFunc2('World');

        $expectedRequest = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"
                         . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" '
                         .               'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
                         .               'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
                         .               'xmlns:ns1="http://www.example.com/namespace" '
                         .               'xmlns:enc="http://www.w3.org/2003/05/soap-encoding">'
                         .     '<env:Header>'
                         .         '<ns1:MyHeader2>SOAP header content 2</ns1:MyHeader2>'
                         .         '<ns1:MyHeader3>SOAP header content 3</ns1:MyHeader3>'
                         .     '</env:Header>'
                         .     '<env:Body>'
                         .         '<env:testFunc2 env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">'
                         .             '<who xsi:type="xsd:string">World</who>'
                         .         '</env:testFunc2>'
                         .     '</env:Body>'
                         . '</env:Envelope>' . "\n";

        $this->assertEquals($client->getLastRequest(), $expectedRequest);


        $client->resetSoapInputHeaders();

        // Add request header
        $client->addSoapInputHeader(new \SoapHeader('http://www.example.com/namespace', 'MyHeader4', 'SOAP header content 4'));

        // Perform request
        $client->testFunc2('World');

        $expectedRequest = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"
                         . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" '
                         .               'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
                         .               'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
                         .               'xmlns:ns1="http://www.example.com/namespace" '
                         .               'xmlns:enc="http://www.w3.org/2003/05/soap-encoding">'
                         .     '<env:Header>'
                         .         '<ns1:MyHeader4>SOAP header content 4</ns1:MyHeader4>'
                         .     '</env:Header>'
                         .     '<env:Body>'
                         .         '<env:testFunc2 env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">'
                         .             '<who xsi:type="xsd:string">World</who>'
                         .         '</env:testFunc2>'
                         .     '</env:Body>'
                         . '</env:Envelope>' . "\n";

        $this->assertEquals($client->getLastRequest(), $expectedRequest);
    }
Example #12
0
 public function testGetSoapInternalInstance()
 {
     $server = new Server();
     $server->setOptions(array('location' => 'test://', 'uri' => 'http://framework.zend.com'));
     $internalServer = $server->getSoap();
     $this->assertInstanceOf('\\SoapServer', $internalServer);
     $this->assertSame($internalServer, $server->getSoap());
 }
Example #13
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;
     }
 }
 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();
 }
Example #15
0
 /**
  * @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());
 }
Example #16
0
 public function __doRequest($request, $location, $action, $version, $one_way = 0)
 {
     ob_start();
     $this->server->handle($request);
     $response = ob_get_clean();
     return $response;
 }
Example #17
0
 /**
  * @group ZF-5300
  */
 public function testSetAndGetWSDLCache()
 {
     $server = new Server();
     $this->assertNull($server->getWSDLCache());
     $server->setWSDLCache(100);
     $this->assertEquals(100, $server->getWSDLCache());
     $options = $server->getOptions();
     $this->assertTrue(isset($options['cache_wsdl']));
     $this->assertEquals(100, $options['cache_wsdl']);
 }
Example #18
0
 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());
     }
 }