示例#1
0
 public function process()
 {
     try {
         if ($this->getShowWSDL() == 'show') {
             $this->renderWsdlFile($this->getObjectName());
         } else {
             $this->runServiceMethod($this->getObjectName(), $this->getWsdlParams());
         }
     } catch (\Exception $ex) {
         $responseObj = new RestSoap\Response(self::RESP_XML);
         $response = $responseObj->setHeader($ex->getCode())->getErrorResponse($ex->getMessage(), $ex->getCode());
         echo $response;
     }
 }
示例#2
0
 /**
  * @return string
  */
 public function process()
 {
     try {
         $httpMethod = $this->getRequestType();
         $urlStructure = $this->parseURL();
         $inputParams = $urlStructure['request'];
         if ($httpMethod != $urlStructure['httpMethod']) {
             throw new \Exception("ControllerFront; Request HTTP Method " . $urlStructure['httpMethod'] . " is not the same as WSDL defined HTTP Method", self::ERROR_400);
         }
         $xmlRequestRootTitle = $urlStructure['PHPmethod'] . 'RequestData';
         $xmlResponseRootTitle = $urlStructure['PHPmethod'] . 'ResponseData';
         $httpBodyParameters = $this->getRequestBody($xmlRequestRootTitle, $inputParams);
         $className = $urlStructure['PHPclass'];
         $method = $urlStructure['PHPmethod'];
         if (!class_exists($className)) {
             throw new \Exception("Rest object does no exist", self::ERROR_500);
         }
         $responseObj = new RestSoap\Response($urlStructure['outputType'], $this->getWsdlParams('view_path') . $urlStructure['module'], $xmlResponseRootTitle);
         if ($httpMethod != 'GET' && is_array($httpBodyParameters)) {
             $inputParams = array_merge($inputParams, $httpBodyParameters['request']);
         }
         $inputObjects = $this->arrayToObject($inputParams);
         $class = new $className($this->getWsdlParams());
         $result = $class->{$method}($inputObjects);
         /**
          * Outstanding features are thrown with exceptions
          * HTTP Status 200 is taken from methods.
          * Attention! If you don't throw incorrect http code from method you'll get code 500.
          */
         return $responseObj->setHeader(self::STATUS_200)->getSuccessResponse($result);
     } catch (\Exception $ex) {
         $responseObj = new RestSoap\Response($this->getOutputType());
         return $responseObj->setHeader($ex->getCode())->getErrorResponse($ex->getMessage(), $ex->getCode());
     }
 }