Class: XmlRequestHandler

abstract

Class for handling the XML API requests.

Details

The user should derive from this class and implement the methods with the names of the API actions.

URL: http://smartfactorydev.loc/api/get_rooms/

Action: get_rooms

function get_rooms()
{
   $xsdpath = new \DOMXPath($this->request_xmldoc);

   $nodes = $xsdpath->evaluate("/Request/City");
   if ($nodes->length == 0) {
       throw new SmartException("City is undefined!", "no_city");
   }
   $city = $nodes->item(0)->nodeValue;

   $response = $this->response_xmldoc->createElement("Response");
   $this->response_xmldoc->appendChild($response);

   ...
} // get_rooms

Extends

Authors

Oleg Schildt

Package

Source code

 

Properties
protected

Internal variable for storing the request XML document.

protected

Internal variable for storing the response XML document.

Methods
public

Constructor.

protected

This is an auxiliary function for parsing the incoming XML data.

protected

This is an auxiliary function for sending the response in XML format.


Property: XmlRequestHandler::$request_xmldoc

protected \DOMDocument $request_xmldoc;

Internal variable for storing the request XML document.

Type

\DOMDocument

Authors

Oleg Schildt

Source code


Property: XmlRequestHandler::$response_xmldoc

protected \DOMDocument $response_xmldoc;

Internal variable for storing the response XML document.

Type

\DOMDocument

Authors

Oleg Schildt

Source code


Method: XmlRequestHandler::__construct()

function __construct();

Constructor.

Details

It initializes the XML document variables.

Authors

Oleg Schildt

Source code


Method: XmlRequestHandler::parseInput()

protected function parseInput(): void;

This is an auxiliary function for parsing the incoming XML data.

Details

It validates the content type 'application/xml' and takes the data from RAWDATA.

Returns

void

Throws

\SmartFactory\SmartException|\Exception

It might throw an exception if the content type oк XML data is invalid.

Overrides

Authors

Oleg Schildt

Source code


Method: XmlRequestHandler::sendResponse()

protected function sendResponse(): void;

This is an auxiliary function for sending the response in XML format.

Details

It sends the prepared response XML document and the response headers. The header "Content-type: application/xml" ist sent automatically.

Returns

void

Throws

\SmartFactory\SmartException

It might throw an exception in the case of any errors.

Overrides

Authors

Oleg Schildt

Source code