/**
     * @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();
    }
 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 #3
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 #4
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 #5
0
 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();
 }
Example #7
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());
     }
 }