ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilBMFWSDL_Cache Class Reference
+ Inheritance diagram for ilBMFWSDL_Cache:
+ Collaboration diagram for ilBMFWSDL_Cache:

Public Member Functions

 ilBMFWSDL_Cache ($cacheUse=WSDL_CACHE_USE, $cacheMaxAge=WSDL_CACHE_MAX_AGE)
 ilBMFWSDL_Cache constructor More...
 
 _cacheDir ()
 _cacheDir return the path to the cache, if it doesn't exist, make it More...
 
 get ($wsdl_fname, $proxy_params=array(), $cache=0)
 Retrieves a file from cache if it exists, otherwise retreive from net, add to cache, and return from cache. More...
 
- Public Member Functions inherited from ilBMFBase
 ilBMFBase ($faultcode='Client')
 Constructor. More...
 
 _resetNamespaces ()
 
 _setSchemaVersion ($schemaVersion)
 Sets the schema version used in the SOAP message. More...
 
 _getNamespacePrefix ($ns)
 
 _getNamespaceForPrefix ($prefix)
 
 _isSoapValue (&$value)
 
 _serializeValue (&$value, $name='', $type=false, $elNamespace=NULL, $typeNamespace=NULL, $options=array(), $attributes=array(), $artype='', $OBJTypeNS=array())
 
 _getType (&$value)
 Converts a PHP type to a SOAP type. More...
 
 _multiArrayType (&$value, &$type, &$size, &$xml)
 
 _isBase64 (&$value)
 Returns whether a string is base64 encoded data. More...
 
 _isBase64Type ($type)
 Returns whether a type is a base64 type. More...
 
 _isHash (&$a)
 Returns whether an array is a hash. More...
 
 _un_htmlentities ($string)
 
_decode (&$soapval)
 
 _makeEnvelope (&$method, &$headers, $encoding=SOAP_DEFAULT_ENCODING, $options=array())
 Creates the SOAP envelope with the SOAP envelop data. More...
 
 _makeMimeMessage (&$xml, $encoding=SOAP_DEFAULT_ENCODING)
 
 _makeDIMEMessage ($xml)
 
 _decodeMimeMessage (&$data, &$headers, &$attachments)
 
 _decodeDIMEMessage (&$data, &$headers, &$attachments)
 
 __set_type_translation ($type, $class=null)
 
- Public Member Functions inherited from ilBMFBase_Object
 ilBMFBase_Object ($faultcode='Client')
 Constructor. More...
 
_raiseSoapFault ($str, $detail='', $actorURI='', $code=null, $mode=null, $options=null, $skipmsg=false)
 Raises a SOAP error. More...
 
 __isfault ()
 
__getfault ()
 
 _debug ($string)
 Adds a string to the debug data. More...
 
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Data Fields

 $_cacheUse = null
 
 $_cacheMaxAge = null
 
- Data Fields inherited from ilBMFBase
 $_XMLSchema
 
 $_XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'
 
 $_typemap
 
 $_defaultObjectClassname = 'stdClass'
 Default class name to use for decoded response objects. More...
 
 $_namespaces
 
 $_namespace
 
 $_xmlEntities
 
 $_doconversion = false
 
 $__attachments = array()
 
 $_wsdl = null
 
 $_section5 = true
 True if we use section 5 encoding, or false if this is literal. More...
 
 $_auto_translation = false
 
 $_type_translation = array()
 
- Data Fields inherited from ilBMFBase_Object
 $_debug_flag = false
 Store debugging information in $_debug_data? More...
 
 $_debug_data = ''
 String containing debugging information if $_debug_flag is true. More...
 
 $_encodings = array('ISO-8859-1', 'US-ASCII', 'UTF-8')
 Supported encodings, limited by XML extension. More...
 
 $_myfaultcode = ''
 Fault code. More...
 
 $fault = null
 Recent PEAR_Error object. More...
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 

Detailed Description

Definition at line 873 of file class.ilBMFWSDL.php.

Member Function Documentation

◆ _cacheDir()

ilBMFWSDL_Cache::_cacheDir ( )

_cacheDir return the path to the cache, if it doesn't exist, make it

Definition at line 910 of file class.ilBMFWSDL.php.

911 {
912 $dir = getenv("WSDLCACHE");
913 if (!$dir) $dir = " ./wsdlcache";
914 @mkdir($dir, 0700);
915 return $dir;
916 }

Referenced by get().

+ Here is the caller graph for this function:

◆ get()

ilBMFWSDL_Cache::get (   $wsdl_fname,
  $proxy_params = array(),
  $cache = 0 
)

Retrieves a file from cache if it exists, otherwise retreive from net, add to cache, and return from cache.

Parameters
stringURL to WSDL
arrayproxy parameters
intexpected MD5 of WSDL URL @access public
Returns
string data

Definition at line 928 of file class.ilBMFWSDL.php.

929 {
930 $cachename = $md5_wsdl = $file_data = '';
931 if ($this->_cacheUse) {
932 // Try to retrieve WSDL from cache
933 $cachename = ilBMFWSDL_Cache::_cacheDir() . '/' . md5($wsdl_fname). ' .wsdl';
934 if (file_exists($cachename)) {
935 $wf = fopen($cachename, 'rb');
936 if ($wf) {
937 // Reading cached file
938 $file_data = fread($wf, filesize($cachename));
939 $md5_wsdl = md5($file_data);
940 fclose($wf);
941 }
942 if ($cache) {
943 if ($cache != $md5_wsdl) {
944 return $this->_raiseSoapFault('WSDL Checksum error!', $wsdl_fname);
945 }
946 } else {
947 $fi = stat($cachename);
948 $cache_mtime = $fi[8];
949 //print cache_mtime, time()
950 if ($cache_mtime + $this->_cacheMaxAge < time()) {
951 // expired
952 $md5_wsdl = ''; // refetch
953 }
954 }
955 }
956 }
957
958 if (!$md5_wsdl) {
959 // Not cached or not using cache. Retrieve WSDL from URL
960
961 // is it a local file?
962 // this section should be replace by curl at some point
963 if (!preg_match('/^(https?|file):\/\//', $wsdl_fname)) {
964 if (!file_exists($wsdl_fname)) {
965 return $this->_raiseSoapFault("Unable to read local WSDL $wsdl_fname", $wsdl_fname);
966 }
967 if (function_exists('file_get_contents')) {
968 $file_data = file_get_contents($wsdl_fname);
969 } else {
970 $file_data = implode('',file($wsdl_fname));
971 }
972 } else {
973 $uri = explode('?', $wsdl_fname);
974 $rq =& new HTTP_Request($uri[0], $proxy_params);
975 // the user agent HTTP_Request uses fouls things up
976 if (isset($uri[1])) {
977 $rq->addRawQueryString($uri[1]);
978 }
979
980 if (isset($proxy_params['proxy_host']) &&
981 isset($proxy_params['proxy_port']) &&
982 isset($proxy_params['proxy_user']) &&
983 isset($proxy_params['proxy_pass'])) {
984 $rq->setProxy($proxy_params['proxy_host'], $proxy_params['proxy_port'],
985 $proxy_params['proxy_user'], $proxy_params['proxy_pass']);
986 } elseif (isset($proxy_params['proxy_host']) &&
987 isset($proxy_params['proxy_port'])) {
988 $rq->setProxy($proxy_params['proxy_host'], $proxy_params['proxy_port']);
989 }
990
991 $result = $rq->sendRequest();
992 if (PEAR::isError($result)) {
993 return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname," . $rq->getResponseCode(), $wsdl_fname);
994 }
995 $file_data = $rq->getResponseBody();
996 if (!$file_data) {
997 return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname, no http body", $wsdl_fname);
998 }
999 }
1000
1001 $md5_wsdl = md5($file_data);
1002
1003 if ($this->_cacheUse) {
1004 $fp = fopen($cachename, "wb");
1005 fwrite($fp, $file_data);
1006 fclose($fp);
1007 }
1008 }
1009 if ($this->_cacheUse && $cache && $cache != $md5_wsdl) {
1010 return $this->_raiseSoapFault("WSDL Checksum error!", $wsdl_fname);
1011 }
1012 return $file_data;
1013 }
$result
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279
& _raiseSoapFault($str, $detail='', $actorURI='', $code=null, $mode=null, $options=null, $skipmsg=false)
Raises a SOAP error.
_cacheDir()
_cacheDir return the path to the cache, if it doesn't exist, make it

References $result, _cacheDir(), ilBMFBase_Object\_raiseSoapFault(), and PEAR\isError().

+ Here is the call graph for this function:

◆ ilBMFWSDL_Cache()

ilBMFWSDL_Cache::ilBMFWSDL_Cache (   $cacheUse = WSDL_CACHE_USE,
  $cacheMaxAge = WSDL_CACHE_MAX_AGE 
)

ilBMFWSDL_Cache constructor

Parameters
booleanuse caching
intcache max lifetime (in seconds) @access public

Definition at line 898 of file class.ilBMFWSDL.php.

900 {
901 parent::ilBMFBase('WSDLCACHE');
902 $this->_cacheUse = $cacheUse;
903 $this->_cacheMaxAge = $cacheMaxAge;
904 }

Field Documentation

◆ $_cacheMaxAge

ilBMFWSDL_Cache::$_cacheMaxAge = null

Definition at line 889 of file class.ilBMFWSDL.php.

◆ $_cacheUse

ilBMFWSDL_Cache::$_cacheUse = null

Definition at line 882 of file class.ilBMFWSDL.php.


The documentation for this class was generated from the following file: