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