?> </strong>: <small> <a href="<?php echo $halLink; ?> "> <?php echo $halLink; ?> </a> </small> <br /> <?php if ($soapEnabled) { $wsdlLink = RApiHalHelper::buildWebserviceFullUrl($view->client, $view->webserviceName, $view->webserviceVersion, 'soap') . '&wsdl'; ?> <strong><?php echo JText::_('LIB_REDCORE_API_HAL_WEBSERVICE_DOCUMENTATION_WSDL_ACCESS_URL'); ?> </strong>: <small> <a href="<?php echo $wsdlLink; ?> "> <?php echo $wsdlLink; ?> </a> </small>
/** * Returns generated WSDL file for the webservice * * @param string $wsdlPath Path of WSDL file * * @return SimpleXMLElement */ public function generateWsdl($wsdlPath) { $wsdlFullPath = JUri::root() . $wsdlPath; $client = RApiHalHelper::attributeToString($this->webserviceXml, 'client', 'site'); $version = !empty($this->webserviceXml->config->version) ? $this->webserviceXml->config->version : '1.0.0'; $this->webserviceFullName = $client . '.' . $this->webserviceXml->config->name . '.' . $version; $this->webserviceUrl = RApiHalHelper::buildWebserviceFullUrl($client, $this->webserviceXml->config->name, $version, 'soap'); // Root of the document $this->wsdl = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?><wsdl:definitions' . ' xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"' . ' xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"' . ' xmlns:tns="' . $wsdlFullPath . '"' . ' xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/"' . ' xmlns:s="http://www.w3.org/2001/XMLSchema"' . ' xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"' . ' targetNamespace="' . $wsdlFullPath . '"' . ' xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"' . ' ></wsdl:definitions>', 0, false, 'wsdl', true); $types = $this->wsdl->addChild('types'); $this->typeSchema = $types->addChild('schema', null, 'http://www.w3.org/2001/XMLSchema'); $this->typeSchema->addAttribute('targetNamespace', $wsdlFullPath); $this->typeSchema->addAttribute('elementFormDefault', 'unqualified'); $this->addGlobalTypes($this->typeSchema); // Adding service $this->wsdlServices = $this->wsdl->addChild('service'); $this->wsdlServices->addAttribute('name', $this->webserviceFullName); $this->wsdlServices->addChild('documentation', $this->webserviceXml->description); // Add new port binding $port = $this->wsdlServices->addChild('port'); $port->addAttribute('name', $this->webserviceFullName . '_Soap'); $port->addAttribute('binding', 'tns:' . $this->webserviceFullName); // Add soap addresses $soapAddress = $port->addChild('soap:address', null, 'http://schemas.xmlsoap.org/wsdl/soap12/'); $soapAddress->addAttribute('location', $this->webserviceUrl); // Add webservice operations if (isset($this->webserviceXml->operations)) { // Read list if (isset($this->webserviceXml->operations->read->list)) { $filters = RApiHalHelper::getFilterFields($this->webserviceXml->operations->read->list, true, true); if (empty($filters)) { $filtersDef = array('name' => 'filters', 'transform' => 'array'); } else { $filtersDef = array('name' => 'filters', 'transform' => 'arraydefined', 'fields' => $filters); } // Add read list messages $inputFields = array(array('name' => 'limitStart', 'transform' => 'int'), array('name' => 'limit', 'transform' => 'int'), array('name' => 'filterSearch', 'transform' => 'string'), $filtersDef, array('name' => 'ordering', 'transform' => 'string'), array('name' => 'orderingDirection', 'transform' => 'string'), array('name' => 'language', 'transform' => 'string')); // Add read list response messages $outputFields = array(array('name' => 'list', 'transform' => 'arrayrequired', 'fields' => array(array('name' => 'item', 'maxOccurs' => 'unbounded', 'transform' => 'arrayrequired', 'fields' => RApiSoapHelper::getOutputResources($this->webserviceXml->operations->read->list, 'listItem'))))); $this->addOperation($this->wsdl, 'readList', $inputFields, $outputFields, true, true); } // Read item if (isset($this->webserviceXml->operations->read->item)) { // Add read item messages $inputFields = array_merge(RApiHalHelper::getFieldsArray($this->webserviceXml->operations->read->item, true), array(array('name' => 'language', 'transform' => 'string'))); // Add read item response messages $outputFields = array(array('name' => 'item', 'typeName' => 'item', 'transform' => 'arrayrequired', 'fields' => RApiSoapHelper::getOutputResources($this->webserviceXml->operations->read->item))); $this->addOperation($this->wsdl, 'readItem', $inputFields, $outputFields, false, true); } // Create operation if (isset($this->webserviceXml->operations->create)) { // Add create messages $inputFields = RApiHalHelper::getFieldsArray($this->webserviceXml->operations->create); // Add create response messages $outputFields = array(RApiSoapHelper::getResultResource($this->webserviceXml->operations->create)); $this->addOperation($this->wsdl, 'create', $inputFields, $outputFields, true); } // Update operation if (isset($this->webserviceXml->operations->update)) { // Add update messages $inputFields = RApiHalHelper::getFieldsArray($this->webserviceXml->operations->update); // Add update response messages $outputFields = array(RApiSoapHelper::getResultResource($this->webserviceXml->operations->update)); $this->addOperation($this->wsdl, 'update', $inputFields, $outputFields, true); } // Delete operation if (isset($this->webserviceXml->operations->delete)) { // Add delete messages $inputFields = RApiHalHelper::getFieldsArray($this->webserviceXml->operations->delete, true); // Add delete response messages $outputFields = array(RApiSoapHelper::getResultResource($this->webserviceXml->operations->delete)); $this->addOperation($this->wsdl, 'delete', $inputFields, $outputFields); } // Task operation if (isset($this->webserviceXml->operations->task)) { foreach ($this->webserviceXml->operations->task->children() as $taskName => $task) { // Add task messages $inputFields = RApiHalHelper::getFieldsArray($task); // Add task response messages $outputFields = array(RApiSoapHelper::getResultResource($task)); $this->addOperation($this->wsdl, 'task_' . $taskName, $inputFields, $outputFields, true); } } } return $this->wsdl; }
<?php /** * @package Redcore.Webservice * @subpackage Layouts * * @copyright Copyright (C) 2008 - 2015 redCOMPONENT.com. All rights reserved. * @license GNU General Public License version 2 or later, see LICENSE. */ defined('_JEXEC') or die; $view = !empty($displayData['view']) ? $displayData['view'] : null; $operationXml = !empty($displayData['options']['operationXml']) ? $displayData['options']['operationXml'] : array(); $operationName = !empty($displayData['options']['operationName']) ? $displayData['options']['operationName'] : ''; $authorizationNotNeeded = isset($operationXml['authorizationNeeded']) && strtolower($operationXml['authorizationNeeded']) == 'false'; $url = RApiHalHelper::buildWebserviceFullUrl($view->client, $view->webserviceName, $view->webserviceVersion); $view->resetDocumentResources(); $resources = $view->loadResourceFromConfiguration($operationXml); $method = 'GET'; $taskName = ''; $noteName = ''; $currentDisplayGroup = ''; $basicUrl = ''; $errorList = array(); if (!empty($displayData['options']['taskName'])) { $taskName = $displayData['options']['taskName']; $operationName = 'task'; } switch ($operationName) { case 'create': $method = 'POST'; $errorList = array(201, 400, 404, 405, 406, 500);