test_schema.inc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. $val = null;
  3. function test($input) {
  4. global $val;
  5. $val = $input;
  6. }
  7. function test_schema($schema,$type,$param,$style="rpc",$use="encoded", $attributeFormDefault='',$features=0) {
  8. global $HTTP_RAW_POST_DATA, $val;
  9. $wsdl = <<<EOF
  10. <definitions name="InteropTest"
  11. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  12. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  13. xmlns:tns="http://test-uri/"
  14. xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  15. xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  16. xmlns="http://schemas.xmlsoap.org/wsdl/"
  17. targetNamespace="http://test-uri/"
  18. >
  19. <types>
  20. <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://test-uri/" $attributeFormDefault>
  21. <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
  22. <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
  23. $schema
  24. </schema>
  25. </types>
  26. <message name="testMessage">
  27. <part name="testParam" $type/>
  28. </message>
  29. <portType name="testPortType">
  30. <operation name="test">
  31. <input message="testMessage"/>
  32. </operation>
  33. </portType>
  34. <binding name="testBinding" type="testPortType">
  35. <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
  36. <operation name="test">
  37. <soap:operation soapAction="#test" style="$style"/>
  38. <input>
  39. <soap:body use="$use" namespace="http://test-uri/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  40. </input>
  41. </operation>
  42. </binding>
  43. <service name="testService">
  44. <port name="testPort" binding="tns:testBinding">
  45. <soap:address location="test://" />
  46. </port>
  47. </service>
  48. </definitions>
  49. EOF;
  50. $fname = tempnam ("./", "wsdl");
  51. $f = fopen($fname,"w");
  52. fwrite($f,$wsdl);
  53. fclose($f);
  54. ini_set("soap.wsdl_cache_enabled",0);
  55. $x = new SoapClient($fname, array("trace"=>1,"exceptions"=>0,"features"=>$features));
  56. $y = new SoapServer($fname, array("features"=>$features));
  57. $y->addfunction("test");
  58. unlink($fname);
  59. $x->test($param);
  60. $xml = xml_parser_create();
  61. $req = $x->__getlastrequest();
  62. if ($style == "rpc") {
  63. $HTTP_RAW_POST_DATA = $req;
  64. ob_start();
  65. $y->handle($HTTP_RAW_POST_DATA);
  66. ob_end_clean();
  67. echo $req;
  68. var_dump($val);
  69. } else {
  70. echo $req;
  71. }
  72. }
  73. ?>