What is wrong in my code? How to create SOAP service for my Math class?
Please note that, i don't mentioned namespace for Math.php because if i did that i got class Math does not exist
message on browser.
Without mentioning namespace of Math class how to create Math object in indexAction().
Please guid me how to create my first wsdl for Math class.
Folder structure
Module
--Soap
----Controller
------>IndexController.php
----Services
------>Math.php
IndexController.php
include_once __DIR__ . '/../Services/Math.php'
class IndexController extends AbstractActionController
{
private $_URI = "http://zf2.services/soap";
public function indexAction()
{
$server = new Server(null, array('uri' => $this->_URI));
$server->setClass('Math');
//$server->setObject(new Math());
$server->handle();
}
}
Math.php
//namespace Soap\Services;
class Math
{
/**
* Method
* @return string
*/
public function greeting()
{
return 'Hello world';
}
}
Resulted XML
<SOAP-ENV ..>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>sender</faultcode>
<faultstring>Invalid XML</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV>