Ejemplo n.º 1
0
 /**
  * @param string $xmlData
  * @return bool
  * @throws \Exception
  */
 private function isValidXmlRequest($xmlData)
 {
     $tpl = new Template\Templater();
     $xsl = $tpl->get(dirname(__FILE__) . '/../xsl/get_xsd_schema.xsl', []);
     $wsdlViewPath = $this->getWsdlParams('view_path');
     $wsdl = $tpl->get($wsdlViewPath . $this->getModuleName() . '.wsdl', []);
     $xslt = new Xslt\Transformer();
     $xmlObj = $xslt->transform($wsdl, $xsl);
     $xsd = $xmlObj->asXML();
     $result = $xslt->validateXmlByXsd($xmlData, $xsd);
     if ($result['validation'] === false) {
         throw new \Exception($result['errors'][0], self::ERROR_500);
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Set SOAP mapping from WSDL to PHP
  *
  * @param $object
  */
 public function setWsdlSoapMap()
 {
     $tpl = new Template\Templater();
     $xsl = $tpl->get(dirname(__FILE__) . '/../xsl/get_soap_class.xsl', array());
     $wsdlContent = $tpl->get($this->getViewParameters('view_path') . $this->getWsdlTitle() . '.wsdl', $this->getViewParameters());
     $xslt = new Xslt\Transformer();
     $xml = $xslt->transform($wsdlContent, $xsl);
     $map = array('class' => (string) $xml->php_class, 'uri' => (string) $xml->uri);
     $this->setMap($map);
     return $this;
 }
Ejemplo n.º 3
0
 private function checkXmlRequestValidation($xmlData)
 {
     if (empty($xmlData)) {
         return true;
     }
     $tpl = new Template\Templater();
     $xsl = $tpl->get(dirname(__FILE__) . '/../xsl/get_xsd_schema.xsl');
     $wsdl = $tpl->get($this->getWsdlParams('view_path') . $this->getObjectName() . '.wsdl');
     $xslt = new Xslt\Transformer();
     $xmlObj = $xslt->transform($wsdl, $xsl);
     $xsd = $xmlObj->asXML();
     $result = $xslt->validateXmlByXsd($xmlData, $xsd);
     if ($result['validation'] === false) {
         throw new \Exception("Output error: " . $result['errors'][0], self::ERROR_500);
     }
     return true;
 }
Ejemplo n.º 4
0
 /**
  *
  * @param string $outputType
  * @return Response
  */
 private function validateXmlResponse($outputType)
 {
     if ($outputType != self::RESP_XML) {
         return $this;
     }
     $tpl = new Template\Templater();
     $xsl = $tpl->get(dirname(__FILE__) . '/xsl/get_xsd_schema.xsl', []);
     $wsdl = $tpl->get($this->getWsdl() . '.wsdl', []);
     $xslt = new Xslt\Transformer();
     $xmlObj = $xslt->transform($wsdl, $xsl);
     $xsd = $xmlObj->asXML();
     $result = $xslt->validateXmlByXsd($this->getResponse(), $xsd);
     if ($result['validation'] === false) {
         throw new \Exception("Output error: " . $result['errors'][0], self::ERROR_500);
     }
     return $this;
 }
Ejemplo n.º 5
0
 protected function getParamsWithDescriptions()
 {
     $restObjectInfo = $this->getRestObjectInfo();
     $tpl = $this->getViewer();
     $xsl = $tpl->get(dirname(__FILE__) . '/../xsl/get_request_params.xsl', ['call' => $restObjectInfo['call'], 'httpMethod' => $restObjectInfo['http_method']]);
     $wsdlViewPath = $this->getWsdlParams('view_path');
     $wsdlContent = $tpl->get($wsdlViewPath . $this->getModuleName() . '.wsdl', $this->getWsdlParams());
     $xslt = new Xslt\Transformer();
     $xml = $xslt->transform($wsdlContent, $xsl);
     $paramsDesc = [];
     foreach ($xml as $xmlRestTag) {
         if ((string) $xmlRestTag->type == 'NMTOKEN') {
             $enum = [];
             foreach ($xmlRestTag->enum->item as $enumItem) {
                 $enum[] = (string) $enumItem;
             }
             $paramsDesc[(string) $xmlRestTag->name] = ['type' => (string) $xmlRestTag->type, 'enum' => $enum, 'required' => (bool) (string) $xmlRestTag->required];
         } else {
             $paramsDesc[(string) $xmlRestTag->name] = ['type' => (string) $xmlRestTag->type, 'required' => (bool) (string) $xmlRestTag->required];
         }
     }
     return $paramsDesc;
 }