Back to index

php5  5.3.10
test_schema.inc
Go to the documentation of this file.
00001 <?php
00002 $val = null;
00003 
00004 function test($input) {
00005        global $val;
00006        $val = $input;
00007 }
00008 
00009 function test_schema($schema,$type,$param,$style="rpc",$use="encoded", $attributeFormDefault='',$features=0) {
00010   global $HTTP_RAW_POST_DATA, $val;
00011 $wsdl  = <<<EOF
00012 <definitions name="InteropTest"
00013     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
00014     xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
00015     xmlns:tns="http://test-uri/"
00016     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
00017     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
00018     xmlns="http://schemas.xmlsoap.org/wsdl/"
00019     targetNamespace="http://test-uri/"
00020     >
00021   <types>
00022   <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://test-uri/" $attributeFormDefault>
00023    <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
00024    <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
00025        $schema
00026   </schema>
00027   </types>
00028   <message name="testMessage">
00029        <part name="testParam" $type/>
00030   </message>
00031        <portType name="testPortType">
00032               <operation name="test">
00033                      <input message="testMessage"/>
00034               </operation>
00035        </portType>
00036        <binding name="testBinding" type="testPortType">
00037               <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
00038               <operation name="test">
00039                      <soap:operation soapAction="#test" style="$style"/>
00040                      <input>
00041                             <soap:body use="$use" namespace="http://test-uri/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
00042                      </input>
00043               </operation>
00044        </binding>
00045        <service name="testService">
00046    <port name="testPort" binding="tns:testBinding">
00047      <soap:address location="test://" /> 
00048    </port>
00049  </service>
00050 </definitions>
00051 EOF;
00052 
00053   $fname = tempnam ("./", "wsdl");
00054   $f = fopen($fname,"w");
00055   fwrite($f,$wsdl);
00056   fclose($f);
00057   ini_set("soap.wsdl_cache_enabled",0);
00058   $x = new SoapClient($fname, array("trace"=>1,"exceptions"=>0,"features"=>$features));
00059   $y = new SoapServer($fname, array("features"=>$features));
00060        $y->addfunction("test");
00061   unlink($fname);
00062 
00063   $x->test($param);
00064   $xml = xml_parser_create();
00065   $req = $x->__getlastrequest();
00066   if ($style == "rpc") {
00067     $HTTP_RAW_POST_DATA = $req;
00068     ob_start();
00069     $y->handle($HTTP_RAW_POST_DATA);
00070     ob_end_clean();
00071     echo $req;
00072     var_dump($val);
00073   } else {
00074     echo $req;
00075   }
00076 }
00077 ?>