0

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;
}
diealtebremse
  • 335
  • 1
  • 15

1 Answers1

0

Your code example can't work since you're trying to call the class \Comkom\SoapParkingDeck\Service\SOAPServer instead of \SoapServer and \Comkom\SoapParkingDeck\Service\SOAPFault instead of \SoapFault.

In a namespaced environment you should declare the \ (backward slash) for calling php- classes (see also How to use “root” namespace of php?).

Debugging

While development you should enable debug output, deprecation logs and set logging to info level. This can be easily done in the install tool under Configuration presets => Development / Production settings => Development.

Please check also always your apache errorlog if you deal with rare behavior like white screens, 500 internal server errors etc.

Community
  • 1
  • 1
Arek van Schaijk
  • 1,432
  • 11
  • 34