For enterprise-level applications, PHP 5 implements webservice (the following programs can be normally called by JAVA, NET, and C)
For enterprise-level applications, PHP 5 implements webservice (the following programs can be normally called by JAVA, NET, and C)
There are very few webservices written using PHP in China, and there is not much information on the internet. during the company's project development process, there have been many such things, write it for your reference (thanks to the WSDL and program files provided by Lao Nong)
Client
| Header ("Content-Type: text/html; charset = utf-8 "); /* * Specify the WebService path and initialize a WebService client. */ $ Ws = "http: // soap/soapCspMessage. php? Wsdl "; $ Client = new SoapClient ($ ws, array ('Trace '=> 1, 'uri' => 'http: // www.zxsv.com/SoapDiscovery /')); /* * Obtain all methods provided by the service referenced by the SoapClient object */ Echo ("open functions provided by the SOAP server :"); Echo (' '); var_dump ( $client->__getFunctions () ); echo (' '); Echo ("Type provided by the SOAP server :"); Echo (''); var_dump ( $client->__getTypes () ); echo (' '); Echo ("result of GetGUIDNode execution :"); // $ Users = $ client-> GetUsers (); // Var_dump ($ HelloWorld ); $ Parameters = array ('uname' => 'zxsv', "upassword" => '123 '); $ Out = $ client-> HelloWorld ($ parameters ); $ Datadb = $ out-> HelloWorldResponse; Var_dump ($ out ); ?> |
Server
| Class Member { Public $ UserId; Public $ Name; Public function _ construct ($ parmas ){ $ This-> UserId = $ parmas [0]; $ This-> Name = $ parmas [1]; } } $ ServidorSoap = new SoapServer ('testphp. xml ', array ('uri' => 'http: // www.testphp.com/', 'encoding' => 'utf-8', 'soap _ version' => SOAP_1_2 )); $ ServidorSoap-> setClass (Testphp ); $ ServidorSoap-> handle (); Class Testphp { Public function HelloWorld ($ uid ){ Return array ('helloworldresult' => "mystring". $ uid-> {'uname'}. 'and'. $ uid-> {'upassword '}); } Public function GetMember ($ uid ){ $ S = array (); For ($ I = 0; $ I <$ uid-> {'uid'}; $ I ++ ){ $ S [] = & new Member (array ($ I, $ uid-> {'uname'}. 'test '. $ I )); } Return array ('getmemberresult' => $ s ); } } ?> |
I should understand it all here.
Below is the WSDL file