Пример #1
0
 /**
  * Set request
  *
  * $request may be any of:
  * - DOMDocument; if so, then cast to XML
  * - DOMNode; if so, then grab owner document and cast to XML
  * - SimpleXMLElement; if so, then cast to XML
  * - stdClass; if so, calls __toString() and verifies XML
  * - string; if so, verifies XML
  *
  * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request
  * @return Zend_Soap_Server
  */
 private function _setRequest($request)
 {
     if ($request instanceof DOMDocument) {
         $xml = $request->saveXML();
     } elseif ($request instanceof DOMNode) {
         $xml = $request->ownerDocument->saveXML();
     } elseif ($request instanceof SimpleXMLElement) {
         $xml = $request->asXML();
     } elseif (is_object($request) || is_string($request)) {
         if (is_object($request)) {
             $xml = $request->__toString();
         } else {
             $xml = $request;
         }
         $dom = new DOMDocument();
         if (strlen($xml) == 0 || !$dom->loadXML($xml)) {
             throw new Zend_Soap_Server_Exception('Invalid XML');
         }
     }
     $this->_request = $xml;
     return $this;
 }
Пример #2
0
 /**
  * Set request
  *
  * $request may be any of:
  * - DOMDocument; if so, then cast to XML
  * - DOMNode; if so, then grab owner document and cast to XML
  * - SimpleXMLElement; if so, then cast to XML
  * - stdClass; if so, calls __toString() and verifies XML
  * - string; if so, verifies XML
  *
  * @param  DOMDocument|DOMNode|SimpleXMLElement|\stdClass|string $request
  * @return self
  * @throws Exception\InvalidArgumentException
  */
 protected function _setRequest($request)
 {
     $xml = null;
     if ($request instanceof DOMDocument) {
         $xml = $request->saveXML();
     } elseif ($request instanceof DOMNode) {
         $xml = $request->ownerDocument->saveXML();
     } elseif ($request instanceof SimpleXMLElement) {
         $xml = $request->asXML();
     } elseif (is_object($request) || is_string($request)) {
         if (is_object($request)) {
             $xml = $request->__toString();
         } else {
             $xml = $request;
         }
         $xml = trim($xml);
         $loadEntities = libxml_disable_entity_loader(true);
         $dom = new DOMDocument();
         $loadStatus = $dom->loadXML($xml);
         libxml_disable_entity_loader($loadEntities);
         // @todo check libxml errors ? validate document ?
         if (strlen($xml) == 0 || !$loadStatus) {
             throw new Exception\InvalidArgumentException('Invalid XML');
         }
         foreach ($dom->childNodes as $child) {
             if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
                 throw new Exception\InvalidArgumentException('Invalid XML: Detected use of illegal DOCTYPE');
             }
         }
     }
     $this->request = $xml;
     return $this;
 }
 /**
  * Set request
  *
  * $request may be any of:
  * - DOMDocument; if so, then cast to XML
  * - DOMNode; if so, then grab owner document and cast to XML
  * - SimpleXMLElement; if so, then cast to XML
  * - stdClass; if so, calls __toString() and verifies XML
  * - string; if so, verifies XML
  *
  * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request
  * @return Zend_Soap_Server
  */
 protected function _setRequest($request)
 {
     if ($request instanceof DOMDocument) {
         $xml = $request->saveXML();
     } elseif ($request instanceof DOMNode) {
         $xml = $request->ownerDocument->saveXML();
     } elseif ($request instanceof SimpleXMLElement) {
         $xml = $request->asXML();
     } elseif (is_object($request) || is_string($request)) {
         if (is_object($request)) {
             $xml = $request->__toString();
         } else {
             $xml = $request;
         }
         $dom = new DOMDocument();
         try {
             if (strlen($xml) == 0 || !($dom = Zend_Xml_Security::scan($xml, $dom))) {
                 #require_once 'Zend/Soap/Server/Exception.php';
                 throw new Zend_Soap_Server_Exception('Invalid XML');
             }
         } catch (Zend_Xml_Exception $e) {
             #require_once 'Zend/Soap/Server/Exception.php';
             throw new Zend_Soap_Server_Exception($e->getMessage());
         }
     }
     $this->_request = $xml;
     return $this;
 }
Пример #4
0
 /**
  * Set request
  *
  * $request may be any of:
  * - DOMDocument; if so, then cast to XML
  * - DOMNode; if so, then grab owner document and cast to XML
  * - SimpleXMLElement; if so, then cast to XML
  * - stdClass; if so, calls __toString() and verifies XML
  * - string; if so, verifies XML
  *
  * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request
  * @return \Zend\Soap\Server
  */
 protected function _setRequest($request)
 {
     if ($request instanceof \DOMDocument) {
         $xml = $request->saveXML();
     } elseif ($request instanceof \DOMNode) {
         $xml = $request->ownerDocument->saveXML();
     } elseif ($request instanceof \SimpleXMLElement) {
         $xml = $request->asXML();
     } elseif (is_object($request) || is_string($request)) {
         if (is_object($request)) {
             $xml = $request->__toString();
         } else {
             $xml = $request;
         }
         $dom = new \DOMDocument();
         if (strlen($xml) == 0 || !$dom->loadXML($xml)) {
             throw new Exception\InvalidArgumentException('Invalid XML');
         }
     }
     $this->_request = $xml;
     return $this;
 }
Пример #5
0
 /**
  * Set request
  *
  * $request may be any of:
  * - DOMDocument; if so, then cast to XML
  * - DOMNode; if so, then grab owner document and cast to XML
  * - SimpleXMLElement; if so, then cast to XML
  * - stdClass; if so, calls __toString() and verifies XML
  * - string; if so, verifies XML
  *
  * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request
  * @return Zend_Soap_Server
  */
 protected function _setRequest($request)
 {
     if ($request instanceof DOMDocument) {
         $xml = $request->saveXML();
     } elseif ($request instanceof DOMNode) {
         $xml = $request->ownerDocument->saveXML();
     } elseif ($request instanceof SimpleXMLElement) {
         $xml = $request->asXML();
     } elseif (is_object($request) || is_string($request)) {
         if (is_object($request)) {
             $xml = $request->__toString();
         } else {
             $xml = $request;
         }
         libxml_disable_entity_loader(true);
         $dom = new DOMDocument();
         if (strlen($xml) == 0 || !$dom->loadXML($xml)) {
             require_once 'Zend/Soap/Server/Exception.php';
             throw new Zend_Soap_Server_Exception('Invalid XML');
         }
         foreach ($dom->childNodes as $child) {
             if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
                 require_once 'Zend/Soap/Server/Exception.php';
                 throw new Zend_Soap_Server_Exception('Invalid XML: Detected use of illegal DOCTYPE');
             }
         }
         libxml_disable_entity_loader(false);
     }
     $this->_request = $xml;
     return $this;
 }
Пример #6
0
 /**
  * Set request
  *
  * $request may be any of:
  * - DOMDocument; if so, then cast to XML
  * - DOMNode; if so, then grab owner document and cast to XML
  * - SimpleXMLElement; if so, then cast to XML
  * - stdClass; if so, calls __toString() and verifies XML
  * - string; if so, verifies XML
  *
  * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request
  * @return Zend_Soap_Server
  */
 protected function _setRequest($request)
 {
     if ($request instanceof DOMDocument) {
         $xml = $request->saveXML();
     } elseif ($request instanceof DOMNode) {
         $xml = $request->ownerDocument->saveXML();
     } elseif ($request instanceof SimpleXMLElement) {
         $xml = $request->asXML();
     } elseif (is_object($request) || is_string($request)) {
         if (is_object($request)) {
             $xml = $request->__toString();
         } else {
             $xml = $request;
         }
         $dom = new DOMDocument();
         if (strlen($xml) == 0 || !$dom->loadXML($xml)) {
             require_once PHP_LIBRARY_PATH . 'Zend/Soap/Server/Exception.php';
             throw new Zend_Soap_Server_Exception('Invalid XML');
         }
     }
     $this->_request = $xml;
     return $this;
 }