20if(basename($_SERVER[
'SCRIPT_FILENAME'])==basename(__FILE__))
36require_once(dirname(__FILE__).
'/class.phpwsdlformatter.php');
37require_once(dirname(__FILE__).
'/class.phpwsdlobject.php');
38require_once(dirname(__FILE__).
'/class.phpwsdlparser.php');
39require_once(dirname(__FILE__).
'/class.phpwsdlproxy.php');
40require_once(dirname(__FILE__).
'/class.phpwsdlparam.php');
41require_once(dirname(__FILE__).
'/class.phpwsdlmethod.php');
42require_once(dirname(__FILE__).
'/class.phpwsdlelement.php');
43require_once(dirname(__FILE__).
'/class.phpwsdlcomplex.php');
46require_once(dirname(__FILE__).
'/../webServicesServer.class');
322 public static $classRx=
'/^.*class\s+([^\s]+)\s*\{.*$/is';
419 $outputOnRequest=
false,
443 $outputOnRequest=
false,
449 if($nameSpace===
true){
453 if(!is_null($endPoint)){
455 self::Debug(
'Filename(s): '.print_r($endPoint,
true));
460 $this->SoapServerOptions=Array(
461 'soap_version' => SOAP_1_2,
462 'encoding' =>
'UTF-8',
463 'compression' => SOAP_COMPRESSION_ACCEPT|SOAP_COMPRESSION_GZIP|9
466 $this->Optimize=!isset($_GET[
'readable']);
467 self::Debug(
'Optimizer is '.(($this->Optimize)?
'enabled':
'disabled'));
469 if(!is_null($cacheFolder)){
471 self::$CacheFolder=$cacheFolder;
488 $this->Files=array_merge($this->Files,(is_array($file))?$file:Array($file));
491 $this->Methods=(!is_null($methods))?$methods:Array();
492 if(
sizeof($this->Methods)>0&&self::$Debugging)
493 self::Debug(
'Methods: '.print_r($this->Methods,
true));
495 $this->Types=(!is_null($types))?$types:Array();
496 if(
sizeof($this->Types)>0&&self::$Debugging)
503 'output' => &$outputOnRequest,
504 'run' => &$runServer,
505 'quickmode' => &$quickRun
509 if($outputOnRequest&&!$runServer)
512 if($quickRun||$runServer)
513 $this->
RunServer(
null,(is_bool($runServer))?
null:$runServer);
540 $outputOnRequest=
false,
546 'BeforeCreateInstanceHook',
549 'namespace' => &$nameSpace,
550 'endpoint' => &$endPoint,
551 'cachefolder' => &$cacheFolder,
554 'methods' => &$methods,
556 'outputonrequest'=> &$outputOnRequest,
557 'runserver' => &$runServer
561 $obj=
new PhpWsdl($nameSpace,$endPoint,$cacheFolder,$file,$name,$methods,$types,$outputOnRequest,$runServer);
563 'CreateInstanceHook',
580 $server->Files=(is_array($file))?$file:Array($file);
581 $server->RunServer();
590 return $this->ForceOutputWsdl||((isset($_GET[
'wsdl'])||isset($_GET[
'WSDL']))&&!$this->ForceNotOutputWsdl);
608 return $this->ForceOutputPhp||((isset($_GET[
'phpsoapclient'])||isset($_GET[
'PHPSOAPCLIENT']))&&!$this->ForceNotOutputPhp);
630 if(!$this->Methods[$i]->IsGlobal){
643 self::Debug(
'Disable '.(($allCaching)?
'all':
'this').
' caching');
645 self::$CacheFolder=
null;
657 if(is_null($folder)){
658 if(self::IsCacheFolderWriteAble(
'./cache')){
660 }
else if(self::IsCacheFolderWriteAble(dirname(__FILE__).
'/cache')){
661 $folder=dirname(__FILE__).
'/cache';
662 }
else if(self::IsCacheFolderWriteAble(sys_get_temp_dir())){
663 $folder=sys_get_temp_dir();
668 if(is_null($timeout))
669 $timeout=(self::$CacheTime!=0)?self::$CacheTime:3600;
670 self::Debug(
'Enable cache in folder "'.((is_null($folder))?
'(none)':$folder).
'" with timeout '.$timeout.
' seconds');
671 self::$CacheFolder=$folder;
672 self::$CacheTime=$timeout;
687 if($this->ConfigurationDetermined)
688 return ($mLen>0||$tLen>0)&&!is_null($this->Name);
690 $this->ConfigurationDetermined=
true;
694 file_exists(
'class.webservice.php')||
695 file_exists(dirname(__FILE__).
'/class.webservice.php')
698 if($mLen<1&&$tLen<1){
701 if(file_exists(
'class.webservice.php'))
702 $tryFiles[]=
'class.webservice.php';
703 if(file_exists(dirname(__FILE__).
'/class.webservice.php'))
704 $tryFiles[]=dirname(__FILE__).
'/class.webservice.php';
707 $tryFiles[]=$_SERVER[
'SCRIPT_FILENAME'];
709 $len=
sizeof($tryFiles);
713 $this->
ParseSource(
false,file_get_contents($file));
718 self::Debug(
'Found objects, adding the file to list');
719 $this->Files[]=$file;
727 if(!is_null($this->Name))
731 $tryFiles[]=$_SERVER[
'SCRIPT_FILENAME'];
733 if(file_exists(
'class.webservice.php'))
734 $tryFiles[]=
'class.webservice.php';
735 if(file_exists(dirname(__FILE__).
'/class.webservice.php'))
736 $tryFiles[]=dirname(__FILE__).
'/class.webservice.php';
738 $tryFiles=array_merge($this->Files,$tryFiles);
740 $len=
sizeof($tryFiles);
743 self::Debug(
'Try to determine the class name from '.$file);
744 $temp=file_get_contents($file);
745 if(!preg_match(self::$classRx,$temp))
747 $class=preg_replace(self::$classRx,
"$1",$temp);
754 $class=
'SoapWebService';
757 return !is_null($class);
764 return ((isset($_SERVER[
'HTTPS'])&&$_SERVER[
'HTTPS']==
'on')?
'https':
'http').
'://'.$_SERVER[
'SERVER_NAME'].$_SERVER[
'SCRIPT_NAME'];
773 if( isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on' )
775 $protocolo =
'https';
777 return $protocolo .
'://'.$_SERVER[
'SERVER_NAME'].str_replace(basename($_SERVER[
'SCRIPT_NAME']),
'',$_SERVER[
'SCRIPT_NAME']);
787 $file=preg_quote(basename($file));
791 if(preg_match(
'/^(.*\/)?'.$file.
'$/i',$this->Files[$i]))
803 public function CreateWsdl($reCreate=
false,$optimizer=
false){
806 if(!$reCreate&&(self::$CacheAllWsdl||!$this->IncludeDocs||$optimizer||$this->Optimize)){
818 if($mLen<1&&$tLen<1){
820 throw(
new Exception(
'No methods and no complex types are available'));
822 if(is_null($this->Name)){
824 throw(
new Exception(
'Could not determine webservice handler class name'));
830 'CreateWsdlHeaderHook',
834 'optimizer' => &$optimizer
839 'CreateWsdlTypeSchemaHook',
843 'optimizer' => &$optimizer
848 'CreateWsdlMessagesHook',
852 'optimizer' => &$optimizer
857 'CreateWsdlPortsHook',
861 'optimizer' => &$optimizer
866 'CreateWsdlBindingsHook',
870 'optimizer' => &$optimizer
875 'CreateWsdlServiceHook',
879 'optimizer' => &$optimizer
884 'CreateWsdlFooterHook',
888 'optimizer' => &$optimizer
893 'CreateWsdlOptimizeHook',
897 'optimizer' => &$optimizer
901 if(self::$CacheAllWsdl||!$this->IncludeDocs||$optimizer||$this->Optimize){
905 !self::$CacheAllWsdl&&
909 ?self::OptimizeXml($res)
929 $server=$data[
'server'];
930 $res[]=
'<?xml version="1.0" encoding="UTF-8"?>';
932 $keys=array_keys(self::$NameSpaces);
936 $temp[]=
'xmlns:'.$keys[$i].
'="'.self::$NameSpaces[$keys[$i]].
'"';
937 $res[]=
'<wsdl:definitions xmlns:tns="'.$server->NameSpace.
'" targetNamespace="'.$server->NameSpace.
'" '.implode(
' ',$temp).
'>';
950 $server=$data[
'server'];
951 $tLen=
sizeof($server->Types);
953 $res[]=
'<wsdl:types>';
954 $res[]=
'<s:schema targetNamespace="'.$server->NameSpace.
'">';
957 $res[]=$server->Types[$i]->CreateType($server);
959 'CreateWsdlTypesHook',
962 $res[]=
'</s:schema>';
963 $res[]=
'</wsdl:types>';
977 $server=$data[
'server'];
979 $mLen=
sizeof($server->Methods);
981 $res[]=$server->Methods[$i]->CreateMessages($server);
994 $server=$data[
'server'];
995 $res[]=
'<wsdl:portType name="'.$server->Name.
'Soap">';
997 $mLen=
sizeof($server->Methods);
999 $res[]=$server->Methods[$i]->CreatePortType($server);
1001 'CreateWsdlPortsAddHook',
1004 $res[]=
'</wsdl:portType>';
1017 $server=$data[
'server'];
1018 $res[]=
'<wsdl:binding name="'.$server->Name.
'Soap" type="tns:'.$server->Name.
'Soap">';
1019 $res[]=
'<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />';
1021 $mLen=
sizeof($server->Methods);
1023 $res[]=$server->Methods[$i]->CreateBinding($server);
1025 'CreateWsdlBindingsAddHook',
1028 $res[]=
'</wsdl:binding>';
1041 $server=$data[
'server'];
1042 $res[]=
'<wsdl:service name="'.$server->Name.
'">';
1043 if($server->IncludeDocs&&!$server->Optimize&&!is_null($server->Docs))
1044 $res[]=
'<wsdl:documentation><![CDATA['.$server->Docs.
']]></wsdl:documentation>';
1045 $res[]=
'<wsdl:port name="'.$server->Name.
'Soap" binding="tns:'.$server->Name.
'Soap">';
1046 $res[]=
'<soap:address location="'.$server->EndPoint.
'" />';
1047 $res[]=
'</wsdl:port>';
1049 'CreateWsdlServiceAddHook',
1052 $res[]=
'</wsdl:service>';
1065 $res[]=
'</wsdl:definitions>';
1078 $server=$data[
'server'];
1079 $optimizer=&$data[
'optimizer'];
1080 $res=implode(
'',$res);
1081 $res=(!$optimizer&&!$server->Optimize)
1082 ?self::FormatXml($res)
1096 return preg_replace(
'/[\n|\t]/',
'',$xml);
1107 $input=fopen(
'data://text/plain,'.$xml,
'r');
1108 $output=fopen(
'php://temp',
'w');
1112 $xml=stream_get_contents($output);
1126 $server=$data[
'server'];
1127 $info=explode(
' ',$data[
'keyword'][1],2);
1128 if(
sizeof($info)<1){
1129 self::Debug(
'WARNING: Invalid service definition');
1132 $server->Name=$info[0];
1133 if($server->ParseDocs&&
sizeof($info)>1&&is_null($server->Docs))
1134 $server->Docs=$info[1];
1148 $this->Methods=Array();
1149 $this->Types=Array();
1150 $this->SourcesParsed=
false;
1153 if($this->SourcesParsed)
1156 $this->SourcesParsed=
true;
1164 $src[]=trim(file_get_contents($this->Files[$i]));
1172 $parser->Parse(implode(
"\n",$src));
1191 header(
'Content-Type: text/xml; charset=UTF-8',
true);
1220 public function OutputHtml($withHeaders=
true,$echo=
true,$cache=
true){
1222 if(
sizeof($this->Methods)<1)
1234 header(
'Content-Type: text/html; charset=UTF-8',
true);
1236 if(!is_null($this->HTML)){
1244 $res[]=
'<title>'.((is_null($this->HtmlHeadLine))?$this->Name.
' interface description':nl2br(htmlentities($this->HtmlHeadLine))).
'</title>';
1245 $res[]=
'<style type="text/css" media="all">';
1246 $res[]=
'body{font-family:Calibri,Arial;background-color:#fefefe;}';
1247 $res[]=
'.pre{font-family:Courier;}';
1248 $res[]=
'.normal{font-family:Calibri,Arial;}';
1249 $res[]=
'.bold{font-weight:bold;}';
1250 $res[]=
'h1,h2,h3{font-family:Verdana,Times;}';
1251 $res[]=
'h1{border-bottom:1px solid gray;}';
1252 $res[]=
'h2{border-bottom:1px solid silver;}';
1253 $res[]=
'h3{border-bottom:1px dashed silver;}';
1254 $res[]=
'a{text-decoration:none;}';
1255 $res[]=
'a:hover{text-decoration:underline;}';
1256 $res[]=
'.blue{color:#3400FF;}';
1257 $res[]=
'.lightBlue{color:#5491AF;}';
1258 if(!is_null(self::$HTML2PDFLicenseKey)&&self::$HTML2PDFSettings[
'attachments']==
'1')
1259 $res[]=
'.print{display:none;}';
1261 'CreateHtmlCssHook',
1268 $res[]=
'<style type="text/css" media="print">';
1269 $res[]=
'.noprint{display:none;}';
1270 if(!is_null(self::$HTML2PDFLicenseKey)&&self::$HTML2PDFSettings[
'attachments']==
'1')
1271 $res[]=
'.print{display:block;}';
1273 'CreateHtmlCssPrintHook',
1286 'CreateHtmlGeneralHook',
1290 'methods' => &$methods,
1296 'CreateHtmlIndexHook',
1300 'methods' => &$methods,
1306 'CreateHtmlComplexTypesHook',
1310 'methods' => &$methods,
1316 'CreateHtmlMethodsHook',
1320 'methods' => &$methods,
1327 'filename' => $this->Name.
'-webservices.pdf',
1330 if(!is_null(self::$HTML2PDFLicenseKey)){
1332 $temp=array_merge(self::$HTML2PDFSettings,Array(
1335 if($temp[
'attachments']==
'1'){
1336 $temp[
'attachment_1']=$this->Name.
'.wsdl:'.$this->
GetWsdlUri();
1338 if($this->ParseDocs&&$this->IncludeDocs){
1340 $temp[
'attachment_2']=$this->Name.
'-doc.wsdl:'.$this->
GetWsdlUri().
'&readable';
1343 $temp[
'attachment_'.$cnt]=$this->Name.
'.soapclient.php:'.$this->
GetPhpUri();
1345 'PdfAttachmentHook',
1351 'methods' => &$methods,
1357 $keys=array_keys($temp);
1361 $options[]=$keys[$i].
'='.$temp[$keys[$i]];
1362 $options=
'$'.base64_encode(implode(
"\n",$options));
1363 $license=sha1(self::$HTML2PDFLicenseKey.self::$HTML2PDFLicenseKey).
'-'.sha1($options.self::$HTML2PDFLicenseKey);
1364 $param[
'url']=$options;
1365 $param[
'license']=$license;
1369 $keys=array_keys($temp);
1373 $param[]=urlencode($keys[$i]).
'='.urlencode($temp[$keys[$i]]);
1374 $pdfLink=self::$HTML2PDFAPI.
'?'.implode(
'&',$param);
1377 $res[]=
'<p><small>Powered by <a href="http://code.google.com/p/php-wsdl-creator/">PhpWsdl</a><span class="noprint"> - PDF download: <a href="'.$pdfLink.
'">Download this page as PDF</a></span></small></p>';
1381 $res=implode(
"\n",$res);
1382 $res=str_replace(
'<br />',
'<br>',$res);
1410 $server=$data[
'server'];
1411 $res[]=
'<h1>'.$server->Name.
' SOAP WebService interface description</h1>';
1412 $res[]=
'<p>Endpoint URI: <span class="pre">'.$server->EndPoint.
'</span></p>';
1413 $res[]=
'<p>WSDL URI: <span class="pre"><a href="'.$server->GetWsdlUri().
'&readable">'.$server->GetWsdlUri().
'</a></span></p>';
1414 $res[]=
'<p>PHP SOAP client download URI: <span class="pre"><a href="'.$server->GetPhpUri().
'">'.$server->GetPhpUri().
'</a></span></p>';
1415 if(self::$HTML2PDFSettings[
'attachments']==
'1'&&!is_null(self::$HTML2PDFLicenseKey))
1416 $res[]=
'<p class="print">The WSDL files and client proxy class(es) are attached to this PDF documentation.</p>';
1417 if(!is_null($server->Docs))
1418 $res[]=
'<p>'.nl2br(htmlentities($server->Docs)).
'</p>';
1431 $types=&$data[
'types'];
1432 $methods=&$data[
'methods'];
1433 $tLen=
sizeof($types);
1434 $mLen=
sizeof($methods);
1435 $res[]=
'<div class="noprint">';
1436 $res[]=
'<h2>Index</h2>';
1438 $res[]=
'<p>Complex types:</p>';
1442 $res[]=
'<li><a href="#'.$types[$i]->Name.
'"><span class="pre">'.$types[$i]->Name.
'</span></a></li>';
1446 $res[]=
'<p>Public methods:</p>';
1450 $res[]=
'<li><a href="#'.$methods[$i]->Name.
'"><span class="pre">'.$methods[$i]->Name.
'</span></a></li>';
1466 $methods=&$data[
'methods'];
1467 $mLen=
sizeof($methods);
1469 $res[]=
'<h2>Public methods</h2>';
1472 $methods[$i]->CreateMethodHtml(array_merge(
1475 'method' => $methods[$i]
1491 $types=&$data[
'types'];
1492 $server=$data[
'server'];
1493 $tLen=
sizeof($server->Types);
1495 $res[]=
'<h2>Complex types</h2>';
1498 $types[$i]->CreateTypeHtml(array_merge(
1501 'type' => $types[$i]
1520 $temp[$obj[$i]->Name]=$obj[$i];
1521 $keys=array_keys($temp);
1526 $res[]=$temp[$keys[$i]];
1556 public function OutputPhp($withHeaders=
true,$echo=
true,$options=Array(),$cache=
true){
1558 if(
sizeof($this->Methods)<1)
1564 'withHeaders' => &$withHeaders,
1566 'options' => &$options
1572 $hasOptions=
sizeof(array_keys($options))>0;
1573 if(!isset($options[
'class']))
1574 $options[
'class']=$this->Name.
'SoapClient';
1575 if(!isset($options[
'openphp']))
1576 $options[
'openphp']=
true;
1577 if(!isset($options[
'phpclient']))
1578 $options[
'phpclient']=
true;
1581 'withHeaders' => &$withHeaders,
1583 'options' => &$options,
1588 header(
'Content-Type: text/plain; charset=UTF-8',
true);
1589 header(
'Content-Disposition: attachment; filename='.$options[
'class'].
'.php');
1592 if(is_null($this->PHP))
1594 if(!is_null($this->PHP)){
1599 }
else if(isset($options[
'php'])&&!is_null($options[
'php'])){
1600 echo $options[
'php'];
1601 return $options[
'php'];
1604 if($options[
'openphp'])
1607 if(!is_null($this->Docs)){
1608 $res[]=
" * ".implode(
"\n * ",explode(
"\n",$this->Docs));
1611 $res[]=
" * @service ".$options[
'class'];
1613 $res[]=
"class ".$options[
'class'].
"{";
1615 $res[]=
"\t * The WSDL URI";
1617 $res[]=
"\t * @var string";
1619 $res[]=
"\tpublic static \$_WsdlUri='".(!is_null($this->WsdlUri)?$this->WsdlUri:$this->EndPoint.
'?WSDL').
"';";
1621 $res[]=
"\t * The PHP SoapClient object";
1623 $res[]=
"\t * @var object";
1625 $res[]=
"\tpublic static \$_Server=null;";
1629 $res[]=
"\t * Send a SOAP request to the server";
1631 $res[]=
"\t * @param string \$method The method name";
1632 $res[]=
"\t * @param array \$param The parameters";
1633 $res[]=
"\t * @return mixed The server response";
1635 $res[]=
"\tpublic static function _Call(\$method,\$param){";
1636 if(self::CallHook(
'CreatePhpCallHook',$data)){
1637 $res[]=
"\t\tif(is_null(self::\$_Server))";
1638 if($options[
'phpclient']){
1639 $res[]=
"\t\t\tself::\$_Server=new SoapClient(self::\$_WsdlUri);";
1640 $res[]=
"\t\treturn self::\$_Server->__soapCall(\$method,\$param);";
1642 $res[]=
"\t\t\tself::\$_Server=new PhpWsdlClient(self::\$_WsdlUri);";
1643 $res[]=
"\t\treturn self::\$_Server->DoRequest(\$method,\$param);";
1652 $this->Methods[$i]->CreateMethodPhp($data);
1660 $this->Types[$i]->CreateTypePhp($data);
1663 $res=implode(
"\n",$res);
1665 if(is_null($this->PHP))
1701 public function RunServer($wsdlFile=
null,$class=
null,$andExit=
true,$forceNoWsdl=
false){
1706 'BeforeRunServerHook',
1709 'wsdlfile' => &$wsdlFile,
1711 'andexit' => &$andExit,
1712 'forcenowsdl' => &$forceNoWsdl
1729 if($this->RequireLogin){
1730 if(isset($_SERVER[
'PHP_AUTH_USER'])||isset($_SERVER[
'PHP_AUTH_PW'])){
1731 $user=(isset($_SERVER[
'PHP_AUTH_USER']))?$_SERVER[
'PHP_AUTH_USER']:
null;
1732 $password=(isset($_SERVER[
'PHP_AUTH_PW']))?$_SERVER[
'PHP_AUTH_PW']:
null;
1734 self::Debug(
'Check login '.$user.
':'.str_repeat(
'*',strlen($password)));
1740 'password' => &$password
1745 header(
'WWW-Authenticate: Basic realm="SOAP webservice login required"');
1746 header(
'HTTP/1.0 401 Unauthorized');
1756 if(is_array($class)){
1758 self::$ProxyObject=$class[1];
1759 self::$ProxyServer=$this;
1764 if(is_null($class)){
1767 throw(
new Exception(
'Invalid configuration'));
1768 if(!is_null($this->Name))
1770 }
else if(is_string($class)){
1771 self::Debug(
'Using '.$class.
' as webservice name');
1774 self::Debug(
'Use class '.((!is_object($class))?$class:get_class($class)));
1776 if(!$forceNoWsdl&&(!$useProxy||self::$UseProxyWsdl)){
1779 if(is_null($wsdlFile))
1781 if(!is_null($wsdlFile))
1782 if(!file_exists($wsdlFile)){
1783 self::Debug(
'WSDL file "'.$wsdlFile.
'" does not exists');
1788 if(!is_object($class))
1790 self::Debug(
'Try to load the webservice handler class');
1795 require_once($this->Files[$i]);
1797 if(!class_exists($class)){
1799 if(file_exists(
'class.webservice.php')){
1801 require_once(
'class.webservice.php');
1802 if(class_exists($class))
1803 $this->Files[]=
'class.webservice.php';
1805 if(!class_exists($class))
1806 if(file_exists(dirname(__FILE__).
'/class.webservice.php')){
1807 self::Debug(
'Try to load '.dirname(__FILE__).
'/class.webservice.php');
1808 require_once(dirname(__FILE__).
'/class.webservice.php');
1809 if(class_exists($class))
1810 $this->Files[]=dirname(__FILE__).
'/class.webservice.php';
1812 if(!class_exists($class))
1814 throw(
new Exception(
'Webservice handler class not present'));
1818 $this->SoapServer=
null;
1820 'PrepareServerHook',
1823 'soapserver' => &$this->SoapServer,
1824 'wsdlfile' => &$wsdlFile,
1826 'useproxy' => &$useProxy,
1827 'forcenowsdl' => &$forceNoWsdl,
1828 'andexit' => &$andExit,
1830 'password' => &$password
1837 if(!is_null($wsdlFile)){
1844 'actor' => $this->EndPoint,
1845 'uri' => $this->NameSpace,
1847 $temp=array_merge($this->SoapServerOptions,$temp);
1848 if(self::$Debugging)
1849 self::Debug(
'Server options: '.print_r($temp,
true));
1857 if($useProxy||!is_object($class)){
1858 $temp=($useProxy)?
'PhpWsdlProxy':$class;
1859 if(!is_null($temp)){
1861 $this->SoapServer->setClass($temp);
1866 self::Debug(
'Setting server object '.get_class($class));
1867 $this->SoapServer->setObject($class);
1873 if($this->Methods[$i]->IsGlobal){
1874 self::Debug(
'Adding global method '.$this->Methods[$i]->Name);
1875 $this->SoapServer->addFunction($this->Methods[$i]->Name);
1883 'soapserver' => &$this->SoapServer,
1884 'wsdlfile' => &$wsdlFile,
1886 'useproxy' => &$useProxy,
1887 'forcenowsdl' => &$forceNoWsdl,
1888 'andexit' => &$andExit,
1890 'password' => &$password
1895 $this->SoapServer->handle();
1910 return ((is_null($this->WsdlUri))?$this->EndPoint:
$this->WsdlUri).
'?WSDL';
1919 return ((is_null($this->PhpUri))?$this->EndPoint:
$this->PhpUri).
'?PHPSOAPCLIENT';
1928 return (is_null($this->PhpUri))?$this->EndPoint:
$this->DocUri;
1942 if($this->Methods[$i]->Name==$name){
1944 return $this->Methods[$i];
1960 if($this->Types[$i]->Name==$name){
1962 return $this->Types[$i];
1976 'endpoint' => $endpoint,
1977 'filename' => (is_null(self::$CacheFolder))?
null:self::$CacheFolder.
'/'.sha1((is_null($endpoint))?$this->EndPoint:$endpoint).
'.wsdl'
1980 'CacheFileNameHook',
1983 return $data[
'filename'];
1996 return file_exists($file)&&file_exists($file.
'.cache');
2011 return self::$CacheTime<0||time()-file_get_contents($file.
'.cache')<=
self::$CacheTime;
2024 if(!is_null($this->WSDL))
2034 $this->WSDL=file_get_contents($file);
2035 if(!$nounserialize){
2036 self::Debug(
'Unserialize methods, types and files');
2037 $data=unserialize(file_get_contents($file.
'.obj'));
2038 $this->Methods=$data[
'methods'];
2039 $this->Types=$data[
'types'];
2040 $this->Files=$data[
'files'];
2041 $this->Name=$data[
'name'];
2042 $this->Docs=$data[
'docs'];
2043 $this->HTML=$data[
'html'];
2044 $this->PHP=$data[
'php'];
2045 $this->WsdlUri=$data[
'wsdluri'];
2046 $this->PhpUri=$data[
'phpuri'];
2047 $this->DocUri=$data[
'docuri'];
2055 if($data[
'version']!=self::$VERSION){
2056 self::Debug(
'Could not use cache from version '.$data[
'version']);
2057 $this->Methods=Array();
2058 $this->Types=Array();
2059 $this->Files=Array();
2064 $this->WsdlUri=
null;
2072 $this->ConfigurationDetermined=
true;
2073 $this->SourcesParsed=
true;
2088 if(is_null($endpoint))
2090 if($endpoint==$this->EndPoint&&!is_null($wsdl))
2093 if(is_null($this->WSDL)){
2106 $temp=substr($file,0,1);
2107 if($temp!=
'/'&&$temp!=
'.'){
2108 if(is_null(self::$CacheFolder)){
2112 $file=self::$CacheFolder.
'/'.$file;
2120 if(file_put_contents($file,$wsdl)===
false){
2124 if(file_put_contents($file.
'.cache',time())===
false){
2129 'version' => self::$VERSION,
2130 'methods' => $this->Methods,
2131 'types' => $this->Types,
2132 'files' => $this->Files,
2133 'name' => $this->Name,
2134 'docs' => $this->Docs,
2135 'html' => $this->HTML,
2136 'php' => $this->PHP,
2137 'wsdluri' => $this->WsdlUri,
2138 'phpuri' => $this->PhpUri,
2139 'docuri' => $this->DocUri
2148 if(file_put_contents($file.
'.obj',serialize($data))===
false){
2162 if(!is_null(self::$CacheFolderWriteAble))
2164 if(is_null($folder))
2166 if(is_null($folder)){
2167 self::$CacheFolderWriteAble=
false;
2170 if(!is_dir($folder)){
2171 self::Debug(
'Invalid cache folder (not a directory?)');
2172 self::$CacheFolderWriteAble=
false;
2176 while(file_exists($folder.
'/'.$file))
2178 $file=$folder.
'/'.$file;
2180 if(file_put_contents($file,$temp)===
false){
2181 self::$CacheFolderWriteAble=
false;
2184 $res=file_get_contents($file)===$temp;
2186 self::$CacheFolderWriteAble=$res;
2197 self::Debug(
'Determine if the cache is different from this instance');
2199 $temp=
new PhpWsdl(
null,$this->EndPoint);
2200 $temp->GetWsdlFromCache();
2201 if(is_null($temp->WSDL))
2218 self::Debug(
'Cache is '.(($res)?
'equal':
'different'));
2231 if(is_null(self::$CacheFolder))
2236 }
else if($mineOnly){
2247 if(file_exists($file))
2250 if(file_exists($file.
'.cache'))
2251 if(unlink($file.
'.cache'))
2252 $deleted[]=$file.
'.cache';
2253 if(file_exists($file.
'.obj'))
2254 if(unlink($file.
'.obj'))
2255 $deleted[]=$file.
'.obj';
2259 $files=glob(self::$CacheFolder.(($cleanUp)?
'/*.wsdl':
'/*.wsd*'));
2263 $len=
sizeof($files);
2270 $toDelete[]=$file.
'.cache';
2271 $toDelete[]=$file.
'.obj';
2273 if(!preg_match(
'/\.wsdl(\.cache|\.obj)?$/',$file))
2275 if(unlink($files[$i]))
2276 $deleted[]=$files[$i];
2281 $len=
sizeof($toDelete);
2283 if(file_exists($toDelete[$i]))
2284 if(unlink($toDelete[$i]))
2285 $deleted[]=$toDelete[$i];
2303 'TranslateTypeHook',
2310 return ((in_array($type,self::$BasicTypes))?self::$Config[
'xsd']:self::$Config[
'tns']).
':'.$type;
2322 if(!self::HasHookHandler($name))
2324 $keys=array_keys(self::$Config[
'extensions'][$name]);
2328 self::Debug(
'Call '.self::$Config[
'extensions'][$name][$keys[$i]]);
2329 if(!call_user_func(self::$Config[
'extensions'][$name][$keys[$i]],$data)){
2345 if(!self::HasHookHandler($hook))
2346 self::$Config[
'extensions'][$hook]=Array();
2347 if(self::$Debugging){
2349 if(is_array($handler)){
2351 $method=$handler[1];
2352 if(is_object($class))
2353 $class=get_class($class);
2354 $handler=$class.
'.'.$method;
2356 self::Debug(
'Register hook '.$hook.
' handler '.$name.
': '.$handler);
2358 self::$Config[
'extensions'][$hook][$name]=$data;
2368 if(!self::HasHookHandler($hook))
2370 if(!is_null($name)){
2371 if(!isset(self::$Config[
'extensions'][$hook][$name]))
2374 unset(self::$Config[
'extensions'][$hook]);
2377 unset(self::$Config[
'extensions'][$hook][$name]);
2378 if(self::$Debugging)
2379 self::Debug(
'Unregister hook '.$hook.
' handler '.$name);
2380 if(
sizeof(self::$Config[
'extensions'][$hook])<1)
2381 unset(self::$Config[
'extensions'][$hook]);
2391 return isset(self::$Config[
'extensions'][$hook]);
2400 if(!self::$Debugging)
2402 $temp=date(
'Y-m-d H:i:s').
"\t".$str;
2403 if(self::$DebugBackTrace){
2404 $trace=debug_backtrace();
2405 $temp.=
" ('".$trace[1][
'function'].
"' in '".basename($trace[1][
'file']).
"' at line #".$trace[1][
'line'].
")";
2407 self::$DebugInfo[]=$temp;
2408 if(!is_null(self::$DebugFile))
2409 if(file_put_contents(self::$DebugFile,$temp.
"\n",FILE_APPEND)===
false){
2410 self::Debug(
'Could not write to debug file '.self::$DebugFile);
2411 self::$DebugFile=
null;
2418 public static function Init(){
2421 self::$HTML2PDFSettings=Array(
2422 'attachments' =>
'1',
2425 self::$NameSpaces=Array(
2426 'soap' =>
'http://schemas.xmlsoap.org/wsdl/soap/',
2427 's' =>
'http://www.w3.org/2001/XMLSchema',
2428 'wsdl' =>
'http://schemas.xmlsoap.org/wsdl/',
2429 'soapenc' =>
'http://schemas.xmlsoap.org/soap/encoding/'
2432 self::$Config[
'extensions']=Array();
2433 self::$Config[
'tns']=
'tns';
2434 self::$Config[
'xsd']=
's';
2436 self::RegisterHook(
'InterpretKeywordserviceHook',
'internal',
'PhpWsdl::InterpretService');
2439 self::RegisterHook(
'CreateWsdlTypeSchemaHook',
'internal',
'PhpWsdl::CreateWsdlTypeSchema');
2440 self::RegisterHook(
'CreateWsdlMessagesHook',
'internal',
'PhpWsdl::CreateWsdlMessages');
2442 self::RegisterHook(
'CreateWsdlBindingsHook',
'internal',
'PhpWsdl::CreateWsdlBindings');
2445 self::RegisterHook(
'CreateWsdlOptimizeHook',
'internal',
'PhpWsdl::CreateWsdlOptimize');
2450 self::RegisterHook(
'CreateHtmlComplexTypesHook',
'internal',
'PhpWsdl::CreateHtmlComplexTypes');
2453 $files=glob(dirname(__FILE__).
'/'.
'class.phpwsdl.*.php');
2456 $len=
sizeof($files);
2459 require_once($files[$i]);
2469 public static function PostInit(){
OutputPhpOnRequest($andExit=true)
CacheFileExists($file=null)
static InterpretService($data)
ParseSource($init=false, $str=null)
static $HTML2PDFLicenseKey
static CreateWsdlService($data)
OutputWsdl($withHeaders=true)
static CreateWsdlPorts($data)
TidyCacheFolder($mineOnly=false, $cleanUp=false, $wsdlFile=null)
GetCacheFileName($endpoint=null)
static EnableCache($folder=null, $timeout=null)
static CreateHtmlMethods($data)
static CreateWsdlFooter($data)
static RegisterHook($hook, $name, $data)
__construct( $nameSpace=null, $endPoint=null, $cacheFolder=null, $file=null, $name=null, $methods=null, $types=null, $outputOnRequest=false, $runServer=false)
PhpWsdl( $nameSpace=null, $endPoint=null, $cacheFolder=null, $file=null, $name=null, $methods=null, $types=null, $outputOnRequest=false, $runServer=false)
static CreateInstance( $nameSpace=null, $endPoint=null, $cacheFolder=null, $file=null, $name=null, $methods=null, $types=null, $outputOnRequest=false, $runServer=false)
OutputHtmlOnRequest($andExit=true)
CreateWsdl($reCreate=false, $optimizer=false)
static TranslateType($type)
static CreateHtmlIndex($data)
static CreateWsdlHeader($data)
static $CacheFolderWriteAble
static CreateHtmlGeneral($data)
static CreateHtmlComplexTypes($data)
static UnregisterHook($hook, $name=null)
RunServer($wsdlFile=null, $class=null, $andExit=true, $forceNoWsdl=false)
static CreateWsdlMessages($data)
static RunQuickMode($file=null)
static HasHookHandler($hook)
WriteWsdlToCache($wsdl=null, $endpoint=null, $file=null, $force=false)
static CreateWsdlOptimize($data)
static DisableCache($allCaching=true)
static CreateWsdlBindings($data)
static CallHook($name, $data=null)
OutputWsdlOnRequest($andExit=true)
GetWsdlFromCache($file=null, $force=false, $nounserialize=false)
OutputHtml($withHeaders=true, $echo=true, $cache=true)
static IsCacheFolderWriteAble($folder=null)
OutputPhp($withHeaders=true, $echo=true, $options=Array(), $cache=true)
static CreateWsdlTypeSchema($data)