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(); $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('Zend_Soap_Server_TestClass'); $response = $server->handle($request); $this->assertContains('<SOAP-ENV:Fault><faultcode>Receiver</faultcode><faultstring>Test Message</faultstring></SOAP-ENV:Fault>', $response); }
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\Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $server->setClass('Zend_Soap_Client_TestClass'); $client = new Client\Local($server, dirname(__FILE__) . '/_files/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); }