PHPsoapWebService uses SoapDiscovery. class. php to generate the wsdl file ,. PHPsoapWebService uses SoapDiscovery. class. php to generate the wsdl file. PHPsoapwebservice uses the wsdl file demo: server PHP soap Web Service uses SoapDiscovery. class. php to generate the wsdl file,
PHP soap web service uses the wsdl file demo:
========================================================== ======================================
Server:
Use the cw. php file to generate the wsdl file before using the soap webservice demo of wsdl. the code is as follows:
Cw. php:
GetWSDL ();
?>
Service. php:
SOAP_1_2); # Service. the wsdl file is the $ server-> setClass ("soapHandle") generated above; // all methods for registering the Service class $ server-> handle (); // process the request?>
SoapHandle. class. php:
The SoapDiscovery. class. php code is as follows:
========================================================== ==============================
Class_name = $ class_name; $ this-> service_name = $ service_name;}/*** SoapDiscovery: getWSDL () Returns the WSDL of a class if the class is instantiable. ** @ return string **/public function getWSDL () {if (empty ($ this-> service_name) {throw new Exception ('No service name. ');} $ headerWSDL =" \ N "; $ headerWSDL. =" Service_name \ "targetNamespace = \" urn: $ this-> service_name \ "xmlns: wsdl = \" http://schemas.xmlsoap.org/wsdl/\ "xmlns: soap = \" comment "xmlns: tns = \" urn: $ this-> service_name \ "xmlns: xsd = \" http://www.w3.org/2001/XMLSchema\ "xmlns: SOAP-ENC = \" comment "xmlns = \" comment "> \ n"; $ headerWSDL. =" \ N "; if (empty ($ this-> class_name) {throw new Exception ('No class name. ');} $ class = new ReflectionClass ($ this-> class_name); if (! $ Class-> isInstantiable () {throw new Exception ('class is not instantiable. ');} $ methods = $ Class-> getMethods (); $ portTypeWSDL =' '; $ BindingWSDL =' \ N \ N "; $ serviceWSDL =' \ N \ N Service_name. 'Port "binding =" tns: '. $ this-> service_name. "Binding \"> \ N \ N \ N "; $ messageWSDL =''; foreach ($ methods as $ method) {if ($ method-> isPublic ()&&! $ Method-> isConstructor () {$ portTypeWSDL. =' \ N ".' \ N GetName (). "Response \"/> \ n \ N "; $ bindingWSDL. =' \ N ".' \ N Service_name \ "encodingStyle = \" http://schemas.xmlsoap.org/soap/encoding/\ "/> \ n\ N \ N Service_name \ "encodingStyle = \" http://schemas.xmlsoap.org/soap/encoding/\ "/> \ n \ N \ N "; $ messageWSDL. =' \ N "; $ parameters = $ method-> getParameters (); foreach ($ parameters as $ parameter) {$ messageWSDL. =' \ N ";}$ messageWSDL. =" \ N "; $ messageWSDL. =' \ N "; $ messageWSDL. =' \ N "; $ messageWSDL. =" \ N ";}}$ portTypeWSDL. =" \ N "; $ bindingWSDL. ="\ N "; // return sprintf ('% s % s', $ headerWSDL, $ portTypeWSDL, $ bindingWSDL, $ serviceWSDL, $ messageWSDL ,' '); $ Fso = fopen ($ this-> class_name. ". wsdl "," w "); fwrite ($ fso, sprintf ('% s % s', $ headerWSDL, $ portTypeWSDL, $ bindingWSDL, $ serviceWSDL, $ messageWSDL ,'');}/*** SoapDiscovery: getDiscovery () Returns discovery of WSDL. ** @ return string **/public function getDiscovery () {return" \ N \ N \ N ";}}?>View Code
Client:
Client. php code:
========================================================== ==================================
Strtolink ('http: // www.baidu.com ')."
"; Echo $ soap-> add (28,100 )."
"; Echo $ soap->__ soapCall ('Add', array (28,200 ))."
"; // Or Call echo $ soap->__ Call ('Add', array (28,300 ))."
"; Echo date ('Y-m-d H: I: S', time ();?>
====================== END ===============================
Http://www.bkjia.com/PHPjc/1119777.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1119777.htmlTechArticlePHP soap Web Service uses SoapDiscovery. class. php generates the wsdl file. PHP soap web service uses the wsdl file demo: ========================================================== ==================================== server...