Ticket #377: patchSoapv1_0.diff
| File patchSoapv1_0.diff, 121.8 kB (added by sylvain261, 10 months ago) |
|---|
-
build/manifests/jelix-dev.mn
old new 134 134 index.php.tpl 135 135 jsonrpc.php.tpl 136 136 rdf.php.tpl 137 soap.php.tpl 137 138 cd lib/jelix-scripts/templates/scripts 138 139 cmdline.php.tpl 139 140 cd lib/jelix-scripts/templates/var/config/ -
build/manifests/jelix-lib.mn
old new 41 41 jXulRequest.class.php 42 42 jRdfRequest.class.php 43 43 jCssRequest.class.php 44 jSoapRequest.class.php 44 45 45 46 cd lib/jelix/core/response 46 47 jResponseBinary.class.php … … 64 65 jResponseCss.class.php 65 66 jResponseLatexToPdf.class.php 66 67 jResponseTcpdf.class.php 68 jResponseSoap.class.php 67 69 68 70 cd lib/jelix/core-modules/jelix 69 71 module.xml … … 227 229 jXmlRpc.class.php 228 230 jZipCreator.class.php 229 231 * jZone.class.php 232 jWSDL.class.php 230 233 231 234 cd lib/jelix-modules 232 235 LICENCE … … 271 274 index.tpl 272 275 cd lib/jelix-modules/jauth/zones 273 276 ! loginform.zone.php 277 cd lib/jelix-modules/jWSDL 278 module.xml 279 cd lib/jelix-modules/jWSDL/controllers 280 WSDL.classic.php 281 cd lib/jelix-modules/jWSDL/templates 282 soap_doc.tpl 274 283 275 284 276 285 cd lib/jelix-plugins … … 499 508 ! jquery.date_input.es_ES.js 500 509 cd lib/jelix-www/jquery/dimensions 501 510 c jquery.dimensions.js 511 cd lib/jelix-www/wshelper/css 512 doc.css 513 cd lib/jelix-www/wshelper/images/doc/ 514 back.gif 515 backbottom.jpg 516 backtop.jpg 517 warning.gif 502 518 503 519 cd lib/clearbricks 504 520 LICENCE … … 546 562 cd lib/tcpdf/config/lang 547 563 ! eng.php 548 564 565 cd lib/wshelper 566 IPPhpDoc.class.php 567 IPReflectionClass.class.php 568 IPReflectionCommentParser.class.php 569 IPReflectionMethod.class.php 570 IPReflectionProperty.class.php 571 IPXMLSchema.class.php 572 WSDLException.class.php 573 WSDLStruct.class.php 574 WSException.class.php 575 WSHelper.class.php -
lib/jelix-modules/jWSDL/module.xml
old new 1 <?xml version="1.0" encoding="UTF-8"?> 2 <module xmlns="http://jelix.org/ns/module/1.0"> 3 4 </module> -
lib/jelix-modules/jWSDL/controllers/WSDL.classic.php
old new 1 <?php 2 /** 3 * @package jelix-modules 4 * @subpackage jelix 5 * @author Sylvain de Vathaire 6 * @copyright 2008 Sylvain de Vathaire 7 * @licence http://www.gnu.org/licenses/gpl.html GNU General Public Licence, see LICENCE file 8 */ 9 10 /** 11 * jWSDL class 12 */ 13 require(JELIX_LIB_UTILS_PATH.'jWSDL.class.php'); 14 15 16 /** 17 * @package jelix-modules 18 * @subpackage jelix 19 */ 20 class WSDLCtrl extends jController { 21 22 /** 23 * Display the web service documentation for the requested service 24 */ 25 public function index() { 26 $rep = $this->getResponse('html'); 27 $rep->addHttpHeader('Content-Type','text/html;charset=UTF-8',false); 28 29 $webservices = jWSDL::getSoapControllers(); 30 if(sizeof($webservices) == 0){ 31 throw new Exception("There is not web services available"); 32 } 33 34 $service = $this->param('service'); 35 36 if (empty($service)) { 37 $module = $webservices[0]['module']; 38 $controller = $webservices[0]['class']; 39 }else{ 40 list($module, $controller) = explode('~',$service); 41 if (empty($module) || empty($controller)) { 42 throw new Exception("Unable to generate WSDL. Invalid service name (Syntax is \$module~\$controller)"); 43 } 44 } 45 46 //Used for documentation of data structures classes 47 $className = $this->param('className'); 48 49 $wsdl = new jWSDL($module, $controller); 50 $doc = $wsdl->doc($className); 51 $doc['menu'] = $webservices; 52 $rep->body->assign("doc", $doc); 53 $rep->title = "Documentation - ".$controller; 54 $rep->addCSSLink('wshelper/css/doc.css'); 55 $rep->bodyTpl = 'jWSDL~soap_doc'; 56 57 return $rep; 58 } 59 60 /** 61 * Return the WSDL file for a soap web service 62 */ 63 public function wsdl() { 64 65 $rep = $this->getResponse('xml'); 66 $rep->sendXMLHeader = FALSE; 67 68 $service = $this->param('service'); 69 70 if (empty($service)) { 71 throw new Exception("Unable to generate WSDL. service parameter is required"); 72 } 73 74 list($module, $controller) = explode('~',$_GET["service"]); 75 if (empty($module) || empty($controller)) { 76 throw new Exception("Unable to generate WSDL. Invalid service name (Syntax is \$module~\$controller)"); 77 } 78 79 $wsdl = new jWSDL($module, $controller); 80 $rep->content = $wsdl->getWSDLFile(); 81 82 return $rep; 83 } 84 } 85 ?> -
lib/jelix-modules/jWSDL/controllers/WSDL.classic.php
old new 1 <?php 2 /** 3 * @package jelix-modules 4 * @subpackage jelix 5 * @author Sylvain de Vathaire 6 * @copyright 2008 Sylvain de Vathaire 7 * @licence http://www.gnu.org/licenses/gpl.html GNU General Public Licence, see LICENCE file 8 */ 9 10 /** 11 * jWSDL class 12 */ 13 require(JELIX_LIB_UTILS_PATH.'jWSDL.class.php'); 14 15 16 /** 17 * @package jelix-modules 18 * @subpackage jelix 19 */ 20 class WSDLCtrl extends jController { 21 22 /** 23 * Display the web service documentation for the requested service 24 */ 25 public function index() { 26 $rep = $this->getResponse('html'); 27 $rep->addHttpHeader('Content-Type','text/html;charset=UTF-8',false); 28 29 $webservices = jWSDL::getSoapControllers(); 30 if(sizeof($webservices) == 0){ 31 throw new Exception("There is not web services available"); 32 } 33 34 $service = $this->param('service'); 35 36 if (empty($service)) { 37 $module = $webservices[0]['module']; 38 $controller = $webservices[0]['class']; 39 }else{ 40 list($module, $controller) = explode('~',$service); 41 if (empty($module) || empty($controller)) { 42 throw new Exception("Unable to generate WSDL. Invalid service name (Syntax is \$module~\$controller)"); 43 } 44 } 45 46 //Used for documentation of data structures classes 47 $className = $this->param('className'); 48 49 $wsdl = new jWSDL($module, $controller); 50 $doc = $wsdl->doc($className); 51 $doc['menu'] = $webservices; 52 $rep->body->assign("doc", $doc); 53 $rep->title = "Documentation - ".$controller; 54 $rep->addCSSLink('wshelper/css/doc.css'); 55 $rep->bodyTpl = 'jWSDL~soap_doc'; 56 57 return $rep; 58 } 59 60 /** 61 * Return the WSDL file for a soap web service 62 */ 63 public function wsdl() { 64 65 $rep = $this->getResponse('xml'); 66 $rep->sendXMLHeader = FALSE; 67 68 $service = $this->param('service'); 69 70 if (empty($service)) { 71 throw new Exception("Unable to generate WSDL. service parameter is required"); 72 } 73 74 list($module, $controller) = explode('~',$_GET["service"]); 75 if (empty($module) || empty($controller)) { 76 throw new Exception("Unable to generate WSDL. Invalid service name (Syntax is \$module~\$controller)"); 77 } 78 79 $wsdl = new jWSDL($module, $controller); 80 $rep->content = $wsdl->getWSDLFile(); 81 82 return $rep; 83 } 84 } 85 ?> -
lib/jelix-modules/jWSDL/module.xml
old new 1 <?xml version="1.0" encoding="UTF-8"?> 2 <module xmlns="http://jelix.org/ns/module/1.0"> 3 4 </module> -
lib/jelix-modules/jWSDL/templates/soap_doc.tpl
old new 1 <div id="main"> 2 <div id="mainheader"> 3 <div id="mainheaderpadded"> 4 <h1>{$doc['class']->name|replace:'Ctrl':''} 5 {if substr($doc['class']->name, strlen($doc['class']->name) -4) == 'Ctrl'} 6 <a target='_blank' href="{jurl 'jWSDL~WSDL:wsdl', array("service"=>$doc['service'])}"> [WSDL]</a> 7 {/if} 8 </h1> 9 </div> 10 </div> 11 <div id="mainpadded"> 12 <table cellpadding="0" cellspacing="0"> 13 <tr> 14 <td id="menu"> 15 <h2>Services</h2> 16 {foreach $doc['menu'] as $webservice} 17 <a href="{jurl 'jWSDL~WSDL:index', array("service"=>$webservice['service'])}">{$webservice['class']}</a><br /> 18 {/foreach} 19 </td> 20 <td id="content"> 21 <h2>Full description</h2> 22 <p>{$doc['class']->fullDescription}</p> 23 24 {if(sizeof($doc['class']->properties))} 25 <h2>Properties</h2> 26 {foreach $doc['class']->properties as $propertie} 27 <a name="property_{$propertie->name}"></a> 28 <div class="property"> 29 <b>{$propertie->name}</b><br /> 30 {if $propertie->type == ''} 31 <div class='warning'><img src='wshelper/images/doc/warning.gif'/> missing type info</div><br /> 32 {else} 33 {if $propertie->type =='int' || $propertie->type =='string' || $propertie->type =='boolean' || $propertie->type =='double' || $propertie->type =='float' ||$propertie->type =='void'} 34 <i>type {$propertie->type}</i><br /> 35 {else} 36 <i>type <a href="{jurl 'jWSDL~WSDL:index', array('service'=>$doc['service'], 'className'=>str_replace('[]' , '',$propertie->type))}">{$propertie->type}</a></i><br /> 37 {/if} 38 {/if} 39 {$propertie->fullDescription} 40 </div> 41 {/foreach} 42 {/if} 43 44 {if(sizeof($doc['class']->methods))} 45 <h2>Methods</h2> 46 {foreach $doc['class']->methods as $method} 47 <a name="method_{$method->name}"></a> 48 <div class="method"> 49 <b>{$method->name}</b> ( 50 {assign $i=0} 51 {foreach $method->parameters as $param} 52 {$param->name}{assign $i=$i+1}{if($i!=(sizeof($method->parameters)))},{/if}{/foreach} 53 ) 54 <br /> 55 {if $method->return == ''} 56 <div class='warning'><img src='wshelper/images/doc/warning.gif'/> missing return value</div><br /> 57 {else} 58 {if $method->return =='int' || $method->return =='string' || $method->return =='boolean' || $method->return =='double' || $method->return =='float' || $method->return =='void'} 59 <i>return {$method->return}</i><br /> 60 {else} 61 <i>return <a href="{jurl 'jWSDL~WSDL:index', array('service'=>$doc['service'], 'className'=>str_replace('[]' , '',$method->return))}">{$method->return}</a></i><br /> 62 {/if} 63 64 {/if} 65 {$method->fullDescription}<br /><br /> 66 </div> 67 {/foreach} 68 {/if} 69 </td> 70 </tr> 71 </table> 72 </div> 73 <div id="mainfooter"><img src="wshelper/images/doc/backbottom.jpg" /></div> 74 </div> -
lib/jelix-modules/jWSDL/templates/soap_doc.tpl
old new 1 <div id="main"> 2 <div id="mainheader"> 3 <div id="mainheaderpadded"> 4 <h1>{$doc['class']->name|replace:'Ctrl':''} 5 {if substr($doc['class']->name, strlen($doc['class']->name) -4) == 'Ctrl'} 6 <a target='_blank' href="{jurl 'jWSDL~WSDL:wsdl', array("service"=>$doc['service'])}"> [WSDL]</a> 7 {/if} 8 </h1> 9 </div> 10 </div> 11 <div id="mainpadded"> 12 <table cellpadding="0" cellspacing="0"> 13 <tr> 14 <td id="menu"> 15 <h2>Services</h2> 16 {foreach $doc['menu'] as $webservice} 17 <a href="{jurl 'jWSDL~WSDL:index', array("service"=>$webservice['service'])}">{$webservice['class']}</a><br /> 18 {/foreach} 19 </td> 20 <td id="content"> 21 <h2>Full description</h2> 22 <p>{$doc['class']->fullDescription}</p> 23 24 {if(sizeof($doc['class']->properties))} 25 <h2>Properties</h2> 26 {foreach $doc['class']->properties as $propertie} 27 <a name="property_{$propertie->name}"></a> 28 <div class="property"> 29 <b>{$propertie->name}</b><br /> 30 {if $propertie->type == ''} 31 <div class='warning'><img src='wshelper/images/doc/warning.gif'/> missing type info</div><br /> 32 {else} 33 {if $propertie->type =='int' || $propertie->type =='string' || $propertie->type =='boolean' || $propertie->type =='double' || $propertie->type =='float' ||$propertie->type =='void'} 34 <i>type {$propertie->type}</i><br /> 35 {else} 36 <i>type <a href="{jurl 'jWSDL~WSDL:index', array('service'=>$doc['service'], 'className'=>str_replace('[]' , '',$propertie->type))}">{$propertie->type}</a></i><br /> 37 {/if} 38 {/if} 39 {$propertie->fullDescription} 40 </div> 41 {/foreach} 42 {/if} 43 44 {if(sizeof($doc['class']->methods))} 45 <h2>Methods</h2> 46 {foreach $doc['class']->methods as $method} 47 <a name="method_{$method->name}"></a> 48 <div class="method"> 49 <b>{$method->name}</b> ( 50 {assign $i=0} 51 {foreach $method->parameters as $param} 52 {$param->name}{assign $i=$i+1}{if($i!=(sizeof($method->parameters)))},{/if}{/foreach} 53 ) 54 <br /> 55 {if $method->return == ''} 56 <div class='warning'><img src='wshelper/images/doc/warning.gif'/> missing return value</div><br /> 57 {else} 58 {if $method->return =='int' || $method->return =='string' || $method->return =='boolean' || $method->return =='double' || $method->return =='float' || $method->return =='void'} 59 <i>return {$method->return}</i><br /> 60 {else} 61 <i>return <a href="{jurl 'jWSDL~WSDL:index', array('service'=>$doc['service'], 'className'=>str_replace('[]' , '',$method->return))}">{$method->return}</a></i><br /> 62 {/if} 63 64 {/if} 65 {$method->fullDescription}<br /><br /> 66 </div> 67 {/foreach} 68 {/if} 69 </td> 70 </tr> 71 </table> 72 </div> 73 <div id="mainfooter"><img src="wshelper/images/doc/backbottom.jpg" /></div> 74 </div> -
lib/jelix-scripts/templates/www/soap.php.tpl
old new 1 <?php 2 /** 3 * @package {$appname} 4 * @subpackage www 5 * @author 6 * @contributor 7 * @copyright 8 */ 9 10 require_once ('../../lib/jelix/init.php'); 11 require_once ('../../testapp/application.init.php'); 12 require_once (JELIX_LIB_CORE_PATH.'request/jSoapRequest.class.php'); 13 14 15 /** 16 * Handler for soap extension call 17 * @package {$appname} 18 * @subpackage www 19 */ 20 class jSoapHandler { 21 22 function __construct($jelix) { 23 $this->jelix = $jelix; 24 } 25 26 function __call($func,$args){ 27 28 $this->jelix->request->initArgs($func, $args); 29 30 $this->jelix->process($this->jelix->request); 31 32 return $this->jelix->response->response; 33 } 34 } 35 36 //Jelix init 37 $config_file = 'index/config.ini.php'; 38 $jelix = new jCoordinator($config_file); 39 $request = new jSoapRequest(); 40 $jelix->request = $request; 41 $request->initService(); 42 43 //Soap server init 44 //encoding param seems to take care of the data encoding, but not the response encoding that is always UTF-8 encoding 45 $soapServer = new SoapServer($request->wsdl->getWSDLFilePath(), array('soap_version' => SOAP_1_1, 'encoding' => $gJConfig->charset)); 46 $soapServer-> setclass('jSoapHandler', $jelix); 47 48 //handling the request 49 if(isset($HTTP_RAW_POST_DATA) && ($HTTP_RAW_POST_DATA!='')){ 50 $requestSoap = $HTTP_RAW_POST_DATA; 51 }else{ 52 $requestSoap = file("php://input"); 53 $requestSoap = implode(" ", $requestSoap); 54 } 55 $soapServer->handle($requestSoap); 56 ?> -
lib/jelix-www/wshelper/css/doc.css
old new 1 body { 2 margin:0; 3 padding:0; 4 text-align: center; 5 background: #ffffff url("../images/doc/back.gif") repeat-y center; 6 } 7 body, table, th, td, p, div { 8 font-family: Arial, Helvetica; 9 font-size: 12pt; 10 line-height:1.4; 11 } 12 #main { 13 margin-right: auto; 14 margin-left: auto; 15 text-align: left; 16 width: 980px; 17 } 18 #mainpadded { 19 padding: 0px 40px 80px 40px; 20 } 21 #mainheader { 22 background: #ffffff url("../images/doc/backtop.jpg") no-repeat; 23 height: 180px; 24 } 25 #mainheaderpadded { 26 padding: 130px 40px 0px 40px; 27 text-align: right; 28 } 29 td { 30 vertical-align: top; 31 } 32 td#menu { 33 width: 300px; 34 } 35 td#content { 36 } 37 div.method { 38 padding-left: 10px; 39 margin-bottom: 20px; 40 border-left: 2px solid #C0C0C0; 41 } 42 div.methodwarning { 43 padding-left: 10px; 44 margin-bottom: 20px; 45 border-left: 4px solid #FF0000; 46 } 47 div.property { 48 padding-left: 10px; 49 margin-bottom: 20px; 50 border-left: 2px solid #C0C0C0; 51 } 52 div.propertywarning { 53 padding-left: 10px; 54 margin-bottom: 20px; 55 border-left: 4px solid #FF0000; 56 } 57 div.warning { 58 font-weight: bold; 59 color: #FF0000; 60 float: left; 61 } 62 a { 63 color: #FFA619; 64 text-decoration: none; 65 font-weight: bold; 66 } 67 a:hover { 68 text-decoration: underline; 69 } 70 p { 71 margin-top: 5px; 72 margin-bottom: 10px; 73 } 74 h1 { 75 margin-top: 0px; 76 margin-bottom: 10px; 77 padding: 0px; 78 font-family: Verdana, Helvetica; 79 font-size: 20pt; 80 color: #000000; 81 } 82 h2 { 83 margin-top: 0px; 84 margin-bottom: 10px; 85 font-family: Verdana, Helvetica; 86 font-size: 16pt; 87 color: #000000; 88 } -
lib/jelix-www/wshelper/css/doc.css
old new 1 body { 2 margin:0; 3 padding:0; 4 text-align: center; 5 background: #ffffff url("../images/doc/back.gif") repeat-y center; 6 } 7 body, table, th, td, p, div { 8 font-family: Arial, Helvetica; 9 font-size: 12pt; 10 line-height:1.4; 11 } 12 #main { 13 margin-right: auto; 14 margin-left: auto; 15 text-align: left; 16 width: 980px; 17 } 18 #mainpadded { 19 padding: 0px 40px 80px 40px; 20 } 21 #mainheader { 22 background: #ffffff url("../images/doc/backtop.jpg") no-repeat; 23 height: 180px; 24 } 25 #mainheaderpadded { 26 padding: 130px 40px 0px 40px; 27 text-align: right; 28 } 29 td { 30 vertical-align: top; 31 } 32 td#menu { 33 width: 300px; 34 } 35 td#content { 36 } 37 div.method { 38 padding-left: 10px; 39 margin-bottom: 20px; 40 border-left: 2px solid #C0C0C0; 41 } 42 div.methodwarning { 43 padding-left: 10px; 44 margin-bottom: 20px; 45 border-left: 4px solid #FF0000; 46 } 47 div.property { 48 padding-left: 10px; 49 margin-bottom: 20px; 50 border-left: 2px solid #C0C0C0; 51 } 52 div.propertywarning { 53 padding-left: 10px; 54 margin-bottom: 20px; 55 border-left: 4px solid #FF0000; 56 } 57 div.warning { 58 font-weight: bold; 59 color: #FF0000; 60 float: left; 61 } 62 a { 63 color: #FFA619; 64 text-decoration: none; 65 font-weight: bold; 66 } 67 a:hover { 68 text-decoration: underline; 69 } 70 p { 71 margin-top: 5px; 72 margin-bottom: 10px; 73 } 74 h1 { 75 margin-top: 0px; 76 margin-bottom: 10px; 77 padding: 0px; 78 font-family: Verdana, Helvetica; 79 font-size: 20pt; 80 color: #000000; 81 } 82 h2 { 83 margin-top: 0px; 84 margin-bottom: 10px; 85 font-family: Verdana, Helvetica; 86 font-size: 16pt; 87 color: #000000; 88 } -
lib/jelix/core/defaultconfig.ini.php
old new 45 45 css= jResponseCss 46 46 ltx2pdf= jResponseLatexToPdf 47 47 tcpdf = jResponseTcpdf 48 soap=jResponseSoap 48 49 49 50 [_coreResponses] 50 51 html = jResponseHtml … … 67 68 css= jResponseCss 68 69 ltx2pdf= jResponseLatexToPdf 69 70 tcpdf = jResponseTcpdf 71 soap=jResponseSoap 70 72 71 73 [error_handling] 72 74 messageLogFormat = "%date%\t[%code%]\t%msg%\t%file%\t%line%\n" -
lib/jelix/core/jCoordinator.class.php
old new 4 4 * @subpackage core 5 5 * @author Laurent Jouanneau 6 6 * @contributor Thibault PIRONT < nuKs > 7 * @contributor Sylvain de Vathaire < sylvain261 > 7 8 * @copyright 2005-2008 laurent Jouanneau 8 9 * @copyright 2007 Thibault PIRONT 10 * @copyright 2008 Sylvain DE VATHAIRE 9 11 * @link http://www.jelix.org 10 12 * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 11 13 */ … … 201 203 } 202 204 } 203 205 204 $this->response = $ctrl->{$this->action->method}(); 206 if($this->request->type == 'soap'){ 207 $this->response = call_user_func_array (array($ctrl, $this->action->method),$this->request->soapArgs); 208 }else{ 209 $this->response = $ctrl->{$this->action->method}(); 210 } 205 211 206 212 if($this->response == null){ 207 213 throw new jException('jelix~errors.response.missing',$this->action->toString()); -
lib/jelix/core/request/jSoapRequest.class.php
old new 1 <?php 2 /** 3 * @package jelix 4 * @subpackage core_request 5 * @author Sylvain de Vathaire 6 * @contributor 7 * @copyright 2008 Sylvain de Vathaire 8 * @link http://www.jelix.org 9 * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 10 */ 11 12 /** 13 * the jSoapRequest require jWSDL class 14 */ 15 require(JELIX_LIB_UTILS_PATH.'jWSDL.class.php'); 16 17 18 /** 19 * handle a soap call. The response has to be a soap response. 20 * @package jelix 21 * @subpackage core_request 22 */ 23 class jSoapRequest extends jRequest { 24 25 public $type = 'soap'; 26 27 public $defaultResponseType = 'soap'; 28 29 public $wsdl; 30 31 public $soapArgs; 32 33 protected function _initParams(){ 34 } 35 36 /** 37 * Défine witch module/controller is called and load the jWSDL object 38 */ 39 public function initService(){ 40 41 $this->_initUrlDatas(); //Necessry because the controller is not yet initialised 42 43 if(isset($_GET["service"]) && $_GET['service'] != ''){ 44 list($module, $action) = explode('~',$_GET["service"]); 45 }else{ 46 die("Soap Call require GET parameter \"service\""); 47 } 48 49 $this->params['module'] = $module; 50 $this->params['action'] = $action; 51 52 $this->wsdl = new jWSDL($this->params['module'], $this->params['action']); 53 } 54 55 /** 56 * Init the parameters of the action 57 * 58 * args array is not an associative array, we use refexive API to be hable to transpose to an associative array 59 */ 60 public function initArgs($func, $args){ 61 62 $this->params['action'] = $this->params['action'].':'.$func; 63 64 $this->soapArgs = $args; 65 66 } 67 68 public function allowedResponses(){ return array('jResponseSoap');} 69 70 } 71 ?> -
lib/jelix/core/response/jResponseSoap.class.php
old new 1 <?php 2 /** 3 * @package jelix 4 * @subpackage core_response 5 * @author Sylvain de Vathaire 6 * @contributor 7 * @copyright 2008 Sylvain de Vathaire 8 * @link http://www.jelix.org 9 * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 10 */ 11 12 /** 13 * Response for soap web services 14 * @package jelix 15 * @subpackage core_response 16 * @see jResponse 17 */ 18 final class jResponseSoap extends jResponse { 19 /** 20 * @var string 21 */ 22 protected $_type = 'soap'; 23 protected $_acceptSeveralErrors=false; 24 25 /** 26 * PHP datas you want to return 27 * @var mixed 28 */ 29 public $response = null; 30 31 32 public function output(){ 33 if($this->hasErrors()) return false; 34 return true; 35 } 36 37 public function outputErrors(){ 38 global $gJCoord, $gJConfig; 39 40 if(count($gJCoord->errorMessages)){ 41 $e = $gJCoord->errorMessages[0]; 42 $errorCode = $e[1]; 43 $errorMessage = '['.$e[0].'] '.$e[2].' (file: '.$e[3].', line: '.$e[4].')'; 44 }else{ 45 $errorMessage = 'Unknow error'; 46 $errorCode = -1; 47 } 48 49 global $soapServer; 50 if(!isset($soapServer)){ 51 $soapServer = new SoapServer(null, array('soap_version' => SOAP_1_1, 'encoding' => $gJConfig->charset, 'uri' => $_SERVER['PHP_SELF'])); 52 } 53 //soapFault param have to be UTF-8 encoded (soapFault seems to not use the encoding param of the SoapServeur 54 if($gJConfig->charset != 'UTF-8'){ 55 $errorCode = utf8_encode($errorCode); 56 $errorMessage = utf8_encode($errorMessage); 57 } 58 $soapServer->fault($errorCode, $errorMessage); 59 } 60 } 61 ?> -
lib/jelix/utils/jWSDL.class.php
old new 1 <?php 2 /** 3 * @package jelix 4 * @subpackage utils 5 * @author Sylvain de Vathaire 6 * @contributor 7 * @copyright 2008 Sylvain de Vathaire 8 * @link http://www.jelix.org 9 * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 10 */ 11 12 /** 13 * object to generate WSDL files and web services documentation 14 * we have 1 WSDL file for each soap web service, each service is implemented by 1 Jelix controller 15 * @package jelix 16 * @subpackage utils 17 */ 18 class jWSDL { 19 20 /** 21 * module name 22 */ 23 public $module; 24 25 /** 26 * controller name 27 */ 28 public $controller; 29 30 /** 31 * WSDL file path (cached file) 32 */ 33 public $WSDLfilePath; 34 35 36 private $_ctrlpath; 37 38 private $_dirname = 'WSDL'; 39 private $_cacheSuffix = '.wsdl'; 40 41 42 public function __construct($module, $controller){ 43 44 $this->module = $module; 45 $this->controller = $controller; 46 47 $this->_createPath(); 48 $this->_createCachePath(); 49 } 50 51 /** 52 * Détermine le chemin du controlleur 53 */ 54 private function _createPath(){ 55 global $gJConfig; 56 57 //Check module availability 58 if(!isset($gJConfig->_modulesPathList[$this->module])){ 59 throw new jExceptionSelector('jelix~errors.module.unknow', $this->module); 60 } 61 62 //Build controller path 63 $this->_ctrlpath = $gJConfig->_modulesPathList[$this->module].'controllers/'.$this->controller.'.soap.php'; 64 65 //Check controller availability 66 if(!file_exists($this->_ctrlpath)){ 67 throw new jException('jelix~errors.action.unknow',$this->controller); 68 } 69 } 70 71 /** 72 * Build the WSDL cache file path 73 */ 74 private function _createCachePath(){ 75 $this->_cachePath = JELIX_APP_TEMP_PATH.'compiled/'.$this->_dirname.'/'.$this->module.'~'.$this->controller.$this->_cacheSuffix; 76 } 77 78 /** 79 * Return the WSDL cache file path (WSDL is updated if necessary) 80 */ 81 public function getWSDLFilePath(){ 82 $this->_updateWSDL(); 83 return $this->_cachePath; 84 85 } 86 87 /** 88 * Return the WSDL file content (WSDL is updated if necessary) 89 */ 90 public function getWSDLFile(){ 91 $this->_updateWSDL(); 92 return file_get_contents($this->_cachePath); 93 } 94 95 /** 96 * Update the WSDL cache file 97 */ 98 private function _updateWSDL(){ 99 100 global $gJConfig; 101 static $updated = FALSE; 102 103 if($updated){ 104 return; 105 } 106 107 $mustCompile = $gJConfig->compilation['force'] || !file_exists($this->_cachePath); 108 109 if($gJConfig->compilation['checkCacheFiletime'] && !$mustCompile){ 110 if( filemtime($this->_ctrlpath) > filemtime($this->_cachePath)){ 111 $mustCompile = true; 112 } 113 } 114 115 if($mustCompile){ 116 jFile::write($this->_cachePath, $this->_compile()); 117 } 118 $updated = TRUE; 119 } 120 121 /** 122 * Generate the WSDL content 123 */ 124 private function _compile(){ 125 126 global $gJConfig; 127 128 require_once($this->_ctrlpath); 129 $class = $this->controller.'Ctrl'; 130 if(!class_exists($class,false)){ 131 throw new jException('jelix~errors.ad.controller.class.unknow', array('WSDL generation', $class, $this->_ctrlpath)); 132 } 133 134 $serviceURL = "http://".$_SERVER['HTTP_HOST'].$gJConfig->urlengine['basePath'].'soap.php?service='.$this->module.'~'.$this->controller; 135 $serviceNameSpace = "http://".$_SERVER['HTTP_HOST'].$gJConfig->urlengine['basePath']; 136 137 138 require_once(LIB_PATH.'wshelper/IPReflectionClass.class.php'); 139 require_once(LIB_PATH.'wshelper/WSDLStruct.class.php'); 140 require_once(LIB_PATH.'wshelper/IPPhpDoc.class.php'); 141 require_once(LIB_PATH.'wshelper/IPReflectionCommentParser.class.php'); 142 require_once(LIB_PATH.'wshelper/IPReflectionMethod.class.php'); 143 require_once(LIB_PATH.'wshelper/IPReflectionProperty.class.php'); 144 require_once(LIB_PATH.'wshelper/IPXMLSchema.class.php'); 145 require_once(LIB_PATH.'wshelper/WSDLException.class.php'); 146 require_once(LIB_PATH.'wshelper/WSDLStruct.class.php'); 147 require_once(LIB_PATH.'wshelper/WSException.class.php'); 148 require_once(LIB_PATH.'wshelper/WSHelper.class.php'); 149 150 $wsdl = new WSDLStruct($serviceNameSpace, $serviceURL, SOAP_RPC, SOAP_ENCODED); 151 $wsdl->setService(new IPReflectionClass($class)); 152 153 try { 154 $gendoc = $wsdl->generateDocument(); 155 } catch (WSDLException $exception) { 156 throw new Exception($exception->msg); 157 } 158 159 return $gendoc; 160 } 161 162 public function doc($className=""){ 163 164 require_once($this->_ctrlpath); 165 $class = $this->controller.'Ctrl'; 166 if(!class_exists($class,false)){ 167 throw new jException('jelix~errors.ad.controller.class.unknow', array('WSDL generation', $class, $this->_ctrlpath)); 168 } 169 170 171 172 require_once(LIB_PATH.'wshelper/IPReflectionClass.class.php'); 173 require_once(LIB_PATH.'wshelper/WSDLStruct.class.php'); 174 require_once(LIB_PATH.'wshelper/IPPhpDoc.class.php'); 175 require_once(LIB_PATH.'wshelper/IPReflectionCommentParser.class.php'); 176 require_once(LIB_PATH.'wshelper/IPReflectionMethod.class.php'); 177 require_once(LIB_PATH.'wshelper/IPReflectionProperty.class.php'); 178 require_once(LIB_PATH.'wshelper/IPXMLSchema.class.php'); 179 require_once(LIB_PATH.'wshelper/WSDLException.class.php'); 180 require_once(LIB_PATH.'wshelper/WSDLStruct.class.php'); 181 require_once(LIB_PATH.'wshelper/WSException.class.php'); 182 require_once(LIB_PATH.'wshelper/WSHelper.class.php'); 183 184 if($className != ""){ 185 if(!class_exists($className,false)){ 186 throw new jException('jelix~errors.ad.controller.class.unknow', array('WSDL generation', $class, $this->_ctrlpath)); 187 } 188 $classObject = new IPReflectionClass($className); 189 }else{ 190 $classObj
