I am trying to generate a WSDL for a working Soap web service using the following PHP code (the code is running in Xampp on Windows 7):
<?php
include('Zend/Soap/AutoDiscover');
$autodiscover = new Zend_Soap_AutoDiscover();
$autodiscover->setClass('MyService')
->setUri('http://localhost/Public_Web_Service')
->setLocation('http://localhost/Public_Web_Service/server.php')
->setServiceName('MyService');
$wsdl = $autodiscover->generate();
$wsdl->dump("C:/xampp/htdocs/file.wsdl");
?>
Warning: include(C:\xampp\php\pear\Zend\Soap\AutoDiscover): failed to open stream: Permission denied in C:\xampp\htdocs\Public_Web_Service\zend-wsdl.php on line 2
Warning: include(): Failed opening 'Zend/Soap/AutoDiscover' for inclusion (include_path='.;C:\xampp\php\PEAR;c:\xampp\php\PEAR\Zend') in C:\xampp\htdocs\Public_Web_Service\zend-wsdl.php on line 2
I am very new to Zend and my main focus is on creating Soap web services in PHP.
Any help would be greatly appreciated.
Thanks,
John Cleaver
Change:
include('Zend/Soap/AutoDiscover");
To:
include('Zend/Soap/AutoDiscover.php");
include() looks for a physical file on your server - so the file part needs to reflect the exact file name.
You're working with Zend Framework 1 it looks like. In your application you could use something like this in your bootstrap (startup) scripts:
function myAutoload($className)
{
$classArray = explode("_", $className);
foreach ($classArray as $key => $value) {
$classArray[$key] = ucfirst($value);
}
$className = implode('/', $classArray);
require_once($className . ".php");
}
spl_autoload_register("myAutoload");
Then you never need to include() anything - it just automatically loads. But please note that this is legacy functionality. Zend Framework 2 as well as other modern frameworks do not use this feature for a reason. I'm still a big fan of Zend Framework 1 because of its user friendliness - something that most modern frameworks lack. If you want to keep using Zend Framework 1, the above snippet can save you a lot of time.