To create a WSDL document using Zend, you need to make a common class in a php file. For example
file: mywebservice.php
<?php
/**
* Web service methods
*/
class MyWebService
{
/**
* Get the server date and time
*
* @return string
*/
public function getDate()
{
return date('c');
}
/**
* Get a nicely formatted string of a person's age
*
* @param string $name The name of a person
* @param int $age The age of a person
* @return string
*/
public function getAgeString($name, $age)
{
return sprintf('%s is %d years old', $name, $age);
}
}
?>
Then create another php file, webservice.php
<?php
require_once "mywebservice.php";
require_once "Zend/Soap/AutoDiscover.php";
$auto = new Zend_Soap_AutoDiscover();
$auto->setClass('MyWebService');
$auto->handle();
?>
Then now, point out your browser to http://localhost/webservice.php - you will get an WSDL document. Read more on: http://www.phpriot.com/articles/zend-soap/6
No comments:
Post a Comment