I'm using TYPO3 6.2 and I want to implement a SOAP Server within my existing extbase extension. Later on I want to be able to push data through a SOAP request which is then saved to a database.
The extensinon key of my plugin is soap_parking_deck and the vendor is Comkom. In my extension I have a class Classes/Service/SOAPService.php :
namespace Comkom\SoapParkingDeck\Service;
class SOAPService {
public function __construct() {
try {
$server = new SOAPServer (
NULL,
array (
'uri' => 'http://localhost/test/SOAPService',
'encoding' => 'UTF-8',
'soap_version' => SOAP_1_2
)
);
$server->addFunction('helloWorld');
$server->handle();
}
catch (SOAPFault $fault) {
print $fault->faultstring;
}
}
public function helloWorld() {
return 'Hello World';
}
}
Within the class I'm defining a PHP SOAPServer and a function helloWorld(). But when I try to make a request I get a 404 error.
With the hint of Arek van Schaijk I figured out a solution.
The 404-Error occured because the uri actually has to be the full path to the Server file.
namespace Comkom\SoapParkingDeck\Service;
class SOAPService {
public function helloWorld() {
return 'Hello World';
}
}
try {
$server = new \SOAPServer (
NULL,
array (
'uri' => 'http://localhost/test/typo3conf/ext/soap_parking_deck/Classes/Service/SOAPService',
'encoding' => 'UTF-8',
'soap_version' => SOAP_1_1
)
);
$server->setClass('Comkom\SoapParkingDeck\Service\SOAPService');
$server->handle();
}
catch (\SOAPFault $fault) {
print $fault->faultstring;
}