Generating WSDL when using PHP's native SOAP class?
Stuart,
If you or anyone else is looking for a solution to this problem here's what I did.
First get this script: http://www.phpclasses.org/browse/download/zip/package/3509/name/php2wsdl-2009-05-15.zip
Then look at its example files. After that I just sliced it the way I needed because I'm using codeigniter:
function wsdl(){ error_reporting(0); require_once(APPPATH."/libraries/WSDLCreator.php"); //Path to the library $test = new WSDLCreator("Webservice", $this->site."/wsdl"); //$test->includeMethodsDocumentation(false); $test->addFile(APPPATH."/controllers/gds.php"); $test->addURLToClass("GDS", $this->site); $test->ignoreMethod(array("GDS"=>"GDS")); $test->ignoreMethod(array("GDS"=>"accessCheck")); $test->createWSDL(); $test->printWSDL(true); // print with headers }
That it, your all done.Btw, I'm using SoapServer and SoapClient in php5+
Generating a WSDL on the fly is not something that happens very often - it would tend to raise a few questions about the stability of your service!
Zend Studio can generate a WSDL from a PHP class, and there are a few other similar tools.
If you do need to generate the WSDL dynamically, take a look at Zend Framework library: Zend_Soap_AutoDiscover
You can try these options:
- https://code.google.com/p/php-wsdl-creator/ (GPLv3)
- https://github.com/piotrooo/wsdl-creator/ (GPLv3)
- http://www.phpclasses.org/package/3509-PHP-Generate-WSDL-from-PHP-classes-code.html (BSD like)
The first one might be your best option if the licence fits your project.