PHPsoapWebService uses SoapDiscovery. class. php to generate the wsdl file. _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.