server025.phpt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. SOAP Server 25: One-way SOAP headers encoding using WSDL
  3. --EXTENSIONS--
  4. soap
  5. --INI--
  6. soap.wsdl_cache_enabled=0
  7. --FILE--
  8. <?php
  9. class TestHeader1 extends SoapHeader {
  10. function __construct($data) {
  11. parent::__construct("http://testuri.org", "Test1", $data);
  12. }
  13. }
  14. class TestHeader2 extends SoapHeader {
  15. function __construct($data) {
  16. parent::__construct("http://testuri.org", "Test2", $data);
  17. }
  18. }
  19. function test() {
  20. global $server;
  21. $server->addSoapHeader(new TestHeader1("Hello Header!"));
  22. $server->addSoapHeader(new TestHeader2("Hello Header!"));
  23. return "Hello Body!";
  24. }
  25. $server = new soapserver(__DIR__."/server025.wsdl");
  26. $server->addfunction("test");
  27. $HTTP_RAW_POST_DATA = <<<EOF
  28. <?xml version="1.0" encoding="ISO-8859-1"?>
  29. <SOAP-ENV:Envelope
  30. SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  31. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  32. <SOAP-ENV:Body>
  33. <ns1:test xmlns:ns1="http://testuri.org"/>
  34. </SOAP-ENV:Body>
  35. </SOAP-ENV:Envelope>
  36. EOF;
  37. $server->handle($HTTP_RAW_POST_DATA);
  38. echo "ok\n";
  39. ?>
  40. --EXPECT--
  41. <?xml version="1.0" encoding="UTF-8"?>
  42. <SOAP-ENV:Envelope 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:ns1="http://testuri.org"><SOAP-ENV:Header><ns1:Test1 xsi:type="xsd:string">Hello Header!</ns1:Test1><ns1:Test2 xsi:type="xsd:string">Hello Header!</ns1:Test2></SOAP-ENV:Header><SOAP-ENV:Body><ns1:testResponse><result>Hello Body!</result></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
  43. ok