7
* This source file is subject to the new BSD license that is bundled
8
* with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://framework.zend.com/license/new-bsd
11
* If you did not receive a copy of the license and are unable to
12
* obtain it through the world-wide-web, please send an email
13
* to license@zend.com so we can send you a copy immediately.
17
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
18
* @license http://framework.zend.com/license/new-bsd New BSD License
21
require_once dirname(__FILE__)."/../../TestHelper.php";
23
/** PHPUnit Test Case */
24
require_once "PHPUnit/Framework/TestCase.php";
26
/** Zend_Soap_Server */
27
require_once 'Zend/Soap/Server.php';
29
require_once 'Zend/Soap/Server/Exception.php';
31
require_once "Zend/Config.php";
38
* @uses Zend_Server_Interface
39
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
40
* @license http://framework.zend.com/license/new-bsd New BSD License
41
* @version $Id: ServerTest.php 13731 2009-01-21 12:12:15Z beberlei $
43
class Zend_Soap_ServerTest extends PHPUnit_Framework_TestCase
45
public function setUp()
47
if (!extension_loaded('soap')) {
48
$this->markTestSkipped('SOAP Extension is not loaded');
52
public function testSetOptions()
54
$server = new Zend_Soap_Server();
56
$this->assertTrue($server->getOptions() == array('soap_version' => SOAP_1_2));
58
$options = array('soap_version' => SOAP_1_1,
59
'actor' => 'http://framework.zend.com/Zend_Soap_ServerTest.php',
60
'classmap' => array('TestData1' => 'Zend_Soap_Server_TestData1',
61
'TestData2' => 'Zend_Soap_Server_TestData2',),
62
'encoding' => 'ISO-8859-1',
63
'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php'
65
$server->setOptions($options);
67
$this->assertTrue($server->getOptions() == $options);
70
public function testSetOptionsViaSecondConstructorArgument()
73
'soap_version' => SOAP_1_1,
74
'actor' => 'http://framework.zend.com/Zend_Soap_ServerTest.php',
76
'TestData1' => 'Zend_Soap_Server_TestData1',
77
'TestData2' => 'Zend_Soap_Server_TestData2',
79
'encoding' => 'ISO-8859-1',
80
'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php',
82
$server = new Zend_Soap_Server(null, $options);
84
$this->assertTrue($server->getOptions() == $options);
87
public function testSetWsdlViaOptionsArrayIsPossible()
89
$server = new Zend_Soap_Server();
90
$server->setOptions(array('wsdl' => 'http://www.example.com/test.wsdl'));
92
$this->assertEquals('http://www.example.com/test.wsdl', $server->getWsdl());
95
public function testGetOptions()
97
$server = new Zend_Soap_Server();
99
$this->assertTrue($server->getOptions() == array('soap_version' => SOAP_1_2));
101
$options = array('soap_version' => SOAP_1_1,
102
'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php'
104
$server->setOptions($options);
106
$this->assertTrue($server->getOptions() == $options);
109
public function testEncoding()
111
$server = new Zend_Soap_Server();
113
$this->assertNull($server->getEncoding());
114
$server->setEncoding('ISO-8859-1');
115
$this->assertEquals('ISO-8859-1', $server->getEncoding());
118
$server->setEncoding(array('UTF-8'));
119
$this->fail('Non-string encoding values should fail');
120
} catch (Exception $e) {
125
public function testSoapVersion()
127
$server = new Zend_Soap_Server();
129
$this->assertEquals(SOAP_1_2, $server->getSoapVersion());
130
$server->setSoapVersion(SOAP_1_1);
131
$this->assertEquals(SOAP_1_1, $server->getSoapVersion());
133
$server->setSoapVersion('bogus');
134
$this->fail('Invalid soap versions should fail');
135
} catch (Exception $e) {
140
public function testValidateUrn()
142
$server = new Zend_Soap_Server();
145
$server->validateUrn('bogosity');
146
$this->fail('URNs without schemes should fail');
147
} catch (Exception $e) {
151
$this->assertTrue($server->validateUrn('http://framework.zend.com/'));
152
$this->assertTrue($server->validateUrn('urn:soapHandler/GetOpt'));
155
public function testSetActor()
157
$server = new Zend_Soap_Server();
159
$this->assertNull($server->getActor());
160
$server->setActor('http://framework.zend.com/');
161
$this->assertEquals('http://framework.zend.com/', $server->getActor());
163
$server->setActor('bogus');
164
$this->fail('Invalid actor should fail');
165
} catch (Exception $e) {
170
public function testGetActor()
172
$server = new Zend_Soap_Server();
174
$this->assertNull($server->getActor());
175
$server->setActor('http://framework.zend.com/');
176
$this->assertEquals('http://framework.zend.com/', $server->getActor());
179
public function testSetUri()
181
$server = new Zend_Soap_Server();
183
$this->assertNull($server->getUri());
184
$server->setUri('http://framework.zend.com/');
185
$this->assertEquals('http://framework.zend.com/', $server->getUri());
187
$server->setUri('bogus');
188
$this->fail('Invalid URI should fail');
189
} catch (Exception $e) {
194
public function testGetUri()
196
$server = new Zend_Soap_Server();
198
$this->assertNull($server->getUri());
199
$server->setUri('http://framework.zend.com/');
200
$this->assertEquals('http://framework.zend.com/', $server->getUri());
203
public function testSetClassmap()
205
$server = new Zend_Soap_Server();
207
$classmap = array('TestData1' => 'Zend_Soap_Server_TestData1',
208
'TestData2' => 'Zend_Soap_Server_TestData2');
210
$this->assertNull($server->getClassmap());
211
$server->setClassmap($classmap);
212
$this->assertTrue($classmap == $server->getClassmap());
214
$server->setClassmap('bogus');
215
$this->fail('Classmap which is not an array should fail');
216
} catch (Exception $e) {
220
$server->setClassmap(array('soapTypeName', 'bogusClassName'));
221
$this->fail('Invalid class within classmap should fail');
222
} catch (Exception $e) {
227
public function testGetClassmap()
229
$server = new Zend_Soap_Server();
231
$classmap = array('TestData1' => 'Zend_Soap_Server_TestData1',
232
'TestData2' => 'Zend_Soap_Server_TestData2');
234
$this->assertNull($server->getClassmap());
235
$server->setClassmap($classmap);
236
$this->assertTrue($classmap == $server->getClassmap());
239
public function testSetWsdl()
241
$server = new Zend_Soap_Server();
243
$this->assertNull($server->getWsdl());
244
$server->setWsdl(dirname(__FILE__).'/_files/wsdl_example.wsdl');
245
$this->assertEquals(dirname(__FILE__).'/_files/wsdl_example.wsdl', $server->getWsdl());
247
$server->setWsdl(dirname(__FILE__).'/_files/bogus.wsdl');
248
$this->fail('Invalid WSDL URI or PATH should fail');
249
} catch (Exception $e) {
254
public function testGetWsdl()
256
$server = new Zend_Soap_Server();
258
$this->assertNull($server->getWsdl());
259
$server->setWsdl(dirname(__FILE__).'/_files/wsdl_example.wsdl');
260
$this->assertEquals(dirname(__FILE__).'/_files/wsdl_example.wsdl', $server->getWsdl());
263
public function testAddFunction()
265
$server = new Zend_Soap_Server();
267
// Correct function should pass
268
$server->addFunction('Zend_Soap_Server_TestFunc1');
270
// Array of correct functions should pass
271
$functions = array('Zend_Soap_Server_TestFunc2',
272
'Zend_Soap_Server_TestFunc3',
273
'Zend_Soap_Server_TestFunc4');
274
$server->addFunction($functions);
277
array_merge(array('Zend_Soap_Server_TestFunc1'), $functions),
278
$server->getFunctions()
282
public function testAddBogusFunctionAsInteger()
284
$server = new Zend_Soap_Server();
286
$server->addFunction(126);
287
$this->fail('Invalid value should fail');
288
} catch (Zend_Soap_Server_Exception $e) {
293
public function testAddBogusFunctionsAsString()
295
$server = new Zend_Soap_Server();
298
$server->addFunction('bogus_function');
299
$this->fail('Invalid function should fail.');
300
} catch (Zend_Soap_Server_Exception $e) {
305
public function testAddBogusFunctionsAsArray()
307
$server = new Zend_Soap_Server();
310
$functions = array('Zend_Soap_Server_TestFunc5',
312
'Zend_Soap_Server_TestFunc6');
313
$server->addFunction($functions);
314
$this->fail('Invalid function within a set of functions should fail');
315
} catch (Zend_Soap_Server_Exception $e) {
320
public function testAddAllFunctionsSoapConstant()
322
$server = new Zend_Soap_Server();
324
// SOAP_FUNCTIONS_ALL as a value should pass
325
$server->addFunction(SOAP_FUNCTIONS_ALL);
326
$server->addFunction('substr');
327
$this->assertEquals(array(SOAP_FUNCTIONS_ALL), $server->getFunctions());
330
public function testSetClass()
332
$server = new Zend_Soap_Server();
334
// Correct class name should pass
336
$server->setClass('Zend_Soap_Server_TestClass');
337
} catch(Exception $e) {
338
$this->fail("Setting a correct class name should not fail setClass()");
342
public function testSetClassTwiceThrowsException()
344
$server = new Zend_Soap_Server();
346
// Correct class name should pass
348
$server->setClass('Zend_Soap_Server_TestClass');
349
$server->setClass('Zend_Soap_Server_TestClass');
351
} catch(Zend_Soap_Server_Exception $e) {
352
$this->assertEquals('A class has already been registered with this soap server instance', $e->getMessage());
356
public function testSetClassWithArguments()
358
$server = new Zend_Soap_Server();
360
// Correct class name should pass
362
$server->setClass('Zend_Soap_Server_TestClass', 1, 2, 3, 4);
363
} catch(Exception $e) {
364
$this->fail("Setting a correct class name should not fail setClass()");
368
public function testSetBogusClassWithIntegerName()
370
$server = new Zend_Soap_Server();
373
$server->setClass(465);
374
$this->fail('Non-string value should fail');
375
} catch (Exception $e) {
380
public function testSetBogusClassWithUnknownClassName()
382
$server = new Zend_Soap_Server();
385
$server->setClass('Zend_Soap_Server_Test_BogusClass');
386
$this->fail('Invalid class should fail');
387
} catch (Exception $e) {
395
public function testSetObject()
397
$server = new Zend_Soap_Server();
400
$server->setObject(465);
401
$this->fail('Non-object value should fail');
402
} catch (Exception $e) {
408
$server->setObject($int);
409
$this->fail('Invalid argument should fail');
410
} catch (Exception $e) {
414
// Correct class name should pass
415
$server->setObject(new Zend_Soap_Server_TestClass());
418
$server->setObject(new Zend_Soap_Server_TestClass());
419
$this->fail('setClass() should pass only once');
420
} catch (Exception $e) {
425
public function testGetFunctions()
427
$server = new Zend_Soap_Server();
429
$server->addFunction('Zend_Soap_Server_TestFunc1');
431
$functions = array('Zend_Soap_Server_TestFunc2',
432
'Zend_Soap_Server_TestFunc3',
433
'Zend_Soap_Server_TestFunc4');
434
$server->addFunction($functions);
436
$functions = array('Zend_Soap_Server_TestFunc3',
437
'Zend_Soap_Server_TestFunc5',
438
'Zend_Soap_Server_TestFunc6');
439
$server->addFunction($functions);
441
$allAddedFunctions = array(
442
'Zend_Soap_Server_TestFunc1',
443
'Zend_Soap_Server_TestFunc2',
444
'Zend_Soap_Server_TestFunc3',
445
'Zend_Soap_Server_TestFunc4',
446
'Zend_Soap_Server_TestFunc5',
447
'Zend_Soap_Server_TestFunc6'
449
$this->assertTrue($server->getFunctions() == $allAddedFunctions);
452
public function testGetFunctionsWithClassAttached()
454
$server = new Zend_Soap_Server();
455
$server->setClass('Zend_Soap_Server_TestClass');
458
array('testFunc1', 'testFunc2', 'testFunc3', 'testFunc4', 'testFunc5'),
459
$server->getFunctions()
463
public function testGetFunctionsWithObjectAttached()
465
$server = new Zend_Soap_Server();
466
$server->setObject(new Zend_Soap_Server_TestClass());
469
array('testFunc1', 'testFunc2', 'testFunc3', 'testFunc4', 'testFunc5'),
470
$server->getFunctions()
474
public function testSetPersistence()
476
$server = new Zend_Soap_Server();
478
$this->assertNull($server->getPersistence());
479
$server->setPersistence(SOAP_PERSISTENCE_SESSION);
480
$this->assertEquals(SOAP_PERSISTENCE_SESSION, $server->getPersistence());
482
$server->setSoapVersion('bogus');
483
$this->fail('Invalid soap versions should fail');
484
} catch (Exception $e) {
488
$server->setPersistence(SOAP_PERSISTENCE_REQUEST);
489
$this->assertEquals(SOAP_PERSISTENCE_REQUEST, $server->getPersistence());
492
public function testSetUnknownPersistenceStateThrowsException()
494
$server = new Zend_Soap_Server();
497
$server->setPersistence('bogus');
499
} catch(Zend_Soap_Server_Exception $e) {
504
public function testGetPersistence()
506
$server = new Zend_Soap_Server();
508
$this->assertNull($server->getPersistence());
509
$server->setPersistence(SOAP_PERSISTENCE_SESSION);
510
$this->assertEquals(SOAP_PERSISTENCE_SESSION, $server->getPersistence());
513
public function testGetLastRequest()
515
$server = new Zend_Soap_Server();
516
$server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com'));
517
$server->setReturnResponse(true);
519
$server->setClass('Zend_Soap_Server_TestClass');
522
'<?xml version="1.0" encoding="UTF-8"?>' . "\n"
523
. '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" '
524
. 'xmlns:ns1="http://framework.zend.com" '
525
. 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
526
. 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
527
. 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" '
528
. 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
531
. '<param0 xsi:type="xsd:string">World</param0>'
534
. '</SOAP-ENV:Envelope>' . "\n";
536
$response = $server->handle($request);
538
$this->assertEquals($request, $server->getLastRequest());
541
public function testSetReturnResponse()
543
$server = new Zend_Soap_Server();
545
$this->assertFalse($server->getReturnResponse());
547
$server->setReturnResponse(true);
548
$this->assertTrue($server->getReturnResponse());
550
$server->setReturnResponse(false);
551
$this->assertFalse($server->getReturnResponse());
554
public function testGetReturnResponse()
556
$server = new Zend_Soap_Server();
558
$this->assertFalse($server->getReturnResponse());
560
$server->setReturnResponse(true);
561
$this->assertTrue($server->getReturnResponse());
564
public function testGetLastResponse()
566
$server = new Zend_Soap_Server();
567
$server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com'));
568
$server->setReturnResponse(true);
570
$server->setClass('Zend_Soap_Server_TestClass');
573
'<?xml version="1.0" encoding="UTF-8"?>' . "\n"
574
. '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" '
575
. 'xmlns:ns1="http://framework.zend.com" '
576
. 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
577
. 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
578
. 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" '
579
. 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
582
. '<param0 xsi:type="xsd:string">World</param0>'
585
. '</SOAP-ENV:Envelope>' . "\n";
588
'<?xml version="1.0" encoding="UTF-8"?>' . "\n"
589
. '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" '
590
. 'xmlns:ns1="http://framework.zend.com" '
591
. 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
592
. 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
593
. 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" '
594
. 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
596
. '<ns1:testFunc2Response>'
597
. '<return xsi:type="xsd:string">Hello World!</return>'
598
. '</ns1:testFunc2Response>'
600
. '</SOAP-ENV:Envelope>' . "\n";
602
$server->handle($request);
604
$this->assertEquals($expectedResponse, $server->getLastResponse());
607
public function testHandle()
609
$server = new Zend_Soap_Server();
610
$server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com'));
612
$server->setClass('Zend_Soap_Server_TestClass');
614
$localClient = new Zend_Soap_Server_TestLocalSoapClient($server,
616
array('location'=>'test://',
617
'uri'=>'http://framework.zend.com'));
619
// Local SOAP client call automatically invokes handle method of the provided SOAP server
620
$this->assertEquals('Hello World!', $localClient->testFunc2('World'));
624
'<?xml version="1.0" encoding="UTF-8"?>' . "\n"
625
. '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" '
626
. 'xmlns:ns1="http://framework.zend.com" '
627
. 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
628
. 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
629
. 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" '
630
. 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
633
. '<param0 xsi:type="xsd:string">World</param0>'
636
. '</SOAP-ENV:Envelope>' . "\n";
639
'<?xml version="1.0" encoding="UTF-8"?>' . "\n"
640
. '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" '
641
. 'xmlns:ns1="http://framework.zend.com" '
642
. 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
643
. 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
644
. 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" '
645
. 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
647
. '<ns1:testFunc2Response>'
648
. '<return xsi:type="xsd:string">Hello World!</return>'
649
. '</ns1:testFunc2Response>'
651
. '</SOAP-ENV:Envelope>' . "\n";
653
$server1 = new Zend_Soap_Server();
654
$server1->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com'));
656
$server1->setClass('Zend_Soap_Server_TestClass');
657
$server1->setReturnResponse(true);
659
$this->assertEquals($expectedResponse, $server1->handle($request));
663
* @todo Implement testRegisterFaultException().
665
public function testRegisterFaultException()
667
$server = new Zend_Soap_Server();
669
$server->registerFaultException("Zend_Soap_Server_Exception");
670
$server->registerFaultException(array("OutOfBoundsException", "BogusException"));
672
$this->assertEquals(array(
673
'Zend_Soap_Server_Exception',
674
'OutOfBoundsException',
676
), $server->getFaultExceptions());
680
* @todo Implement testDeregisterFaultException().
682
public function testDeregisterFaultException()
684
$server = new Zend_Soap_Server();
686
$server->registerFaultException(array("OutOfBoundsException", "BogusException"));
687
$ret = $server->deregisterFaultException("BogusException");
688
$this->assertTrue($ret);
690
$this->assertEquals(array(
691
'OutOfBoundsException',
692
), $server->getFaultExceptions());
694
$ret = $server->deregisterFaultException("NonRegisteredException");
695
$this->assertFalse($ret);
699
* @todo Implement testGetFaultExceptions().
701
public function testGetFaultExceptions()
703
$server = new Zend_Soap_Server();
705
$this->assertEquals(array(), $server->getFaultExceptions());
706
$server->registerFaultException("Exception");
707
$this->assertEquals(array("Exception"), $server->getFaultExceptions());
710
public function testFaultWithTextMessage()
712
$server = new Zend_Soap_Server();
713
$fault = $server->fault("Faultmessage!");
715
$this->assertTrue($fault instanceof SOAPFault);
716
$this->assertContains("Faultmessage!", $fault->getMessage());
719
public function testFaultWithUnregisteredException()
721
$server = new Zend_Soap_Server();
722
$fault = $server->fault(new Exception("MyException"));
724
$this->assertTrue($fault instanceof SOAPFault);
725
$this->assertContains("Unknown error", $fault->getMessage());
726
$this->assertNotContains("MyException", $fault->getMessage());
729
public function testFaultWithRegisteredException()
731
$server = new Zend_Soap_Server();
732
$server->registerFaultException("Exception");
733
$fault = $server->fault(new Exception("MyException"));
735
$this->assertTrue($fault instanceof SOAPFault);
736
$this->assertNotContains("Unknown error", $fault->getMessage());
737
$this->assertContains("MyException", $fault->getMessage());
740
public function testFautlWithBogusInput()
742
$server = new Zend_Soap_Server();
743
$fault = $server->fault(array("Here", "There", "Bogus"));
745
$this->assertContains("Unknown error", $fault->getMessage());
751
public function testFaultWithIntegerFailureCodeDoesNotBreakClassSoapFault()
753
$server = new Zend_Soap_Server();
754
$fault = $server->fault("Faultmessage!", 5000);
756
$this->assertTrue($fault instanceof SOAPFault);
760
* @todo Implement testHandlePhpErrors().
762
public function testHandlePhpErrors()
764
$server = new Zend_Soap_Server();
766
// Remove the following line when you implement this test.
767
$this->markTestIncomplete(
768
"This test has not been implemented yet."
772
public function testLoadFunctionsIsNotImplemented()
774
$server = new Zend_Soap_Server();
777
$server->loadFunctions("bogus");
779
} catch(Zend_Soap_Server_Exception $e) {
784
public function testErrorHandlingOfSoapServerChangesToThrowingSoapFaultWhenInHandleMode()
786
$server = new Zend_Soap_Server();
787
$server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com'));
788
$server->setReturnResponse(true);
790
// Requesting Method with enforced parameter without it.
792
'<?xml version="1.0" encoding="UTF-8"?>' . "\n"
793
. '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" '
794
. 'xmlns:ns1="http://framework.zend.com" '
795
. 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
796
. 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
797
. 'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" '
798
. 'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
800
. '<ns1:testFunc5 />'
802
. '</SOAP-ENV:Envelope>' . "\n";
804
$server->setClass('Zend_Soap_Server_TestClass');
805
$response = $server->handle($request);
807
$this->assertContains(
808
'<SOAP-ENV:Fault><faultcode>Receiver</faultcode><faultstring>Test Message</faultstring></SOAP-ENV:Fault>',
816
public function testServerAcceptsZendConfigObject()
818
$options = array('soap_version' => SOAP_1_1,
819
'actor' => 'http://framework.zend.com/Zend_Soap_ServerTest.php',
820
'classmap' => array('TestData1' => 'Zend_Soap_Server_TestData1',
821
'TestData2' => 'Zend_Soap_Server_TestData2',),
822
'encoding' => 'ISO-8859-1',
823
'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php'
825
$config = new Zend_Config($options);
827
$server = new Zend_Soap_Server();
828
$server->setOptions($config);
829
$this->assertEquals($options, $server->getOptions());
835
public function testSetAndGetFeatures()
837
$server = new Zend_Soap_Server();
838
$this->assertNull($server->getSoapFeatures());
839
$server->setSoapFeatures(100);
840
$this->assertEquals(100, $server->getSoapFeatures());
841
$options = $server->getOptions();
842
$this->assertTrue(isset($options['features']));
843
$this->assertEquals(100, $options['features']);
849
public function testSetAndGetWsdlCache()
851
$server = new Zend_Soap_Server();
852
$this->assertNull($server->getWsdlCache());
853
$server->setWsdlCache(100);
854
$this->assertEquals(100, $server->getWsdlCache());
855
$options = $server->getOptions();
856
$this->assertTrue(isset($options['cache_wsdl']));
857
$this->assertEquals(100, $options['cache_wsdl']);
862
if (extension_loaded('soap')) {
864
/** Local SOAP client */
865
class Zend_Soap_Server_TestLocalSoapClient extends SoapClient {
869
* @var Zend_Soap_Server
874
* Local client constructor
876
* @param Zend_Soap_Server $server
877
* @param string $wsdl
878
* @param array $options
880
function __construct(Zend_Soap_Server $server, $wsdl, $options) {
881
$this->server = $server;
882
parent::__construct($wsdl, $options);
885
function __doRequest($request, $location, $action, $version) {
887
$this->server->handle($request);
888
$response = ob_get_contents();
899
class Zend_Soap_Server_TestClass {
907
return "Hello World";
913
* @param string $who Some Arg
916
function testFunc2($who)
918
return "Hello $who!";
924
* @param string $who Some Arg
925
* @param int $when Some
928
function testFunc3($who, $when)
930
return "Hello $who, How are you $when";
938
static function testFunc4()
940
return "I'm Static!";
944
* Test Function 5 raises a user error
950
trigger_error("Test Message", E_USER_ERROR);
956
class Zend_Soap_Server_TestData1 {
973
class Zend_Soap_Server_TestData2 {
998
function Zend_Soap_Server_TestFunc1($who)
1000
return "Hello $who";
1006
function Zend_Soap_Server_TestFunc2()
1008
return "Hello World";
1016
function Zend_Soap_Server_TestFunc3()
1026
function Zend_Soap_Server_TestFunc4()
1036
function Zend_Soap_Server_TestFunc5()
1046
function Zend_Soap_Server_TestFunc6()
b'\\ No newline at end of file'