<?php class Foo { function Foo() { } function test() { return $this->str; } } $server = new soapserver(null, array('uri' => "http://testuri.org")); $server->setclass("Foo"); var_dump($server->getfunctions()); echo "ok\n";
<?php class foo { private $sum = 0; function Sum($num) { return $this->sum += $num; } } $server = new soapserver(null, array('uri' => "http://testuri.org")); $server->setclass("foo"); $server->setpersistence(SOAP_PERSISTENCE_REQUEST); ob_start(); $HTTP_RAW_POST_DATA = <<<EOF <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:si="http://soapinterop.org/xsd"> <SOAP-ENV:Body> <ns1:Sum xmlns:ns1="http://testuri.org"> <num xsi:type="xsd:int">5</num> </ns1:Sum> </SOAP-ENV:Body> </SOAP-ENV:Envelope> EOF; $server->handle($HTTP_RAW_POST_DATA); ob_clean();
<?php function test1() { throw new SoapFault("Server", "test1"); } function test2() { return new SoapFault("Server", "test2"); } $server = new soapserver(null, array('uri' => "http://testuri.org")); $server->addfunction(array("test1", "test2")); $HTTP_RAW_POST_DATA = <<<EOF <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:si="http://soapinterop.org/xsd"> <SOAP-ENV:Body> <ns1:test1 xmlns:ns1="http://testuri.org" /> </SOAP-ENV:Body> </SOAP-ENV:Envelope> EOF; $server->handle($HTTP_RAW_POST_DATA); $HTTP_RAW_POST_DATA = <<<EOF <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
} class TestHeader2 extends SoapHeader { function __construct($data) { parent::__construct("http://testuri.org", "Test2", $data); } } function test() { global $server; $server->addSoapHeader(new TestHeader1("Hello Header!")); $server->addSoapHeader(new TestHeader2("Hello Header!")); return "Hello Body!"; } $server = new soapserver(null, array('uri' => "http://testuri.org")); $server->addfunction("test"); $HTTP_RAW_POST_DATA = <<<EOF <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:si="http://soapinterop.org/xsd"> <SOAP-ENV:Body> <ns1:test xmlns:ns1="http://testuri.org"/> </SOAP-ENV:Body> </SOAP-ENV:Envelope> EOF; $server->handle($HTTP_RAW_POST_DATA);
<?php function Add($x, $y) { return $x + $y; } function Sub($x, $y) { return $x - $y; } $server = new soapserver(null, array('uri' => "http://testuri.org")); $server->addfunction(array("Sub", "Add")); var_dump($server->getfunctions()); echo "ok\n";
<?php class Foo { function test() { return "Hello World"; } } $foo = new Foo(); $server = new soapserver(null, array('uri' => "http://testuri.org")); $server->setObject($foo); $HTTP_RAW_POST_DATA = <<<EOF <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:si="http://soapinterop.org/xsd"> <SOAP-ENV:Body> <ns1:test xmlns:ns1="http://testuri.org" /> </SOAP-ENV:Body> </SOAP-ENV:Envelope> EOF; $server->handle($HTTP_RAW_POST_DATA); echo "ok\n";
<?php function test() { return "Hello World"; } $server = new soapserver(null, array('uri' => "http://testuri.org")); $server->addfunction("test"); $envelope = <<<EOF <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:si="http://soapinterop.org/xsd"> <SOAP-ENV:Body> <ns1:test xmlns:ns1="http://testuri.org" /> </SOAP-ENV:Body> </SOAP-ENV:Envelope> EOF; $server->handle($envelope); echo "ok\n";
<?php function Add($x, $y) { return $x + $y; } $server = new soapserver(dirname(__FILE__) . "/test.wsdl"); ob_start(); $server->handle(); $wsdl = ob_get_contents(); ob_end_clean(); if ($wsdl == file_get_contents(dirname(__FILE__) . "/test.wsdl")) { echo "ok\n"; } else { echo "fail\n"; }
<?php class Foo { function test() { return "Hello World"; } } $server = new soapserver(null, array('uri' => "http://testuri.org")); $server->setclass("Foo"); $HTTP_RAW_POST_DATA = <<<EOF <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:si="http://soapinterop.org/xsd"> <SOAP-ENV:Body> <ns1:test xmlns:ns1="http://testuri.org" /> </SOAP-ENV:Body> </SOAP-ENV:Envelope> EOF; $server->handle($HTTP_RAW_POST_DATA); echo "ok\n";
<?php echo "INPUT: \n"; echo file_get_contents("php://input") . "\n"; echo "\n\n-----------\n\n"; function test() { return "Hello World"; } $server = new soapserver(null, array('uri' => "http://testuri.org")); $server->addfunction("test"); $server->handle(); echo "ok\n";
<?php function Add($x, $y) { return $x + $y; } function Sub($x, $y) { return $x - $y; } $server = new soapserver(null, array('uri' => "http://testuri.org")); $server->addfunction(array("Sub", "Add")); $HTTP_RAW_POST_DATA = <<<EOF <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:si="http://soapinterop.org/xsd"> <SOAP-ENV:Body> <ns1:Add xmlns:ns1="http://testuri.org"> <x xsi:type="xsd:int">22</x> <y xsi:type="xsd:int">33</y> </ns1:Add> </SOAP-ENV:Body> </SOAP-ENV:Envelope> EOF; $server->handle($HTTP_RAW_POST_DATA); echo "ok\n";
<?php $server = new soapserver(null, array('uri' => "http://testuri.org")); $server->addfunction(SOAP_FUNCTIONS_ALL); $HTTP_RAW_POST_DATA = <<<EOF <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:si="http://soapinterop.org/xsd"> <SOAP-ENV:Body> <ns1:strlen xmlns:ns1="http://testuri.org"> <x xsi:type="xsd:string">Hello World</x> </ns1:strlen> </SOAP-ENV:Body> </SOAP-ENV:Envelope> EOF; $server->handle($HTTP_RAW_POST_DATA); echo "ok\n";
<?php function Add($x, $y) { return $x + $y; } $server = new soapserver(null, array('uri' => "http://testuri.org")); $server->addfunction("Add"); $server->handle(); echo "ok\n";