ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilBMFWSDL_ObjectParser Class Reference

Parses the types and methods used in web service objects into the internal data structures used by ilBMFWSDL. More...

+ Inheritance diagram for ilBMFWSDL_ObjectParser:
+ Collaboration diagram for ilBMFWSDL_ObjectParser:

Public Member Functions

 ilBMFWSDL_ObjectParser (&$objects, &$wsdl, $targetNamespace, $service_name, $service_desc='')
 Constructor. More...
 
 _initialise ($service_name)
 Initialise the ilBMFWSDL tree (destructive). More...
 
 _parse (&$object, $schemaNamespace, $service_name)
 Parser - takes a single object to add to tree (non-destructive). More...
 
 _generateBindingsAndServices ($schemaNamespace, $service_name, $service_desc='')
 Take all the abstract WSDL data and build concrete bindings and services (destructive). More...
 
 _getTypeNs ($type)
 This function is adapted from Dmitri V's implementation of DISCO/WSDL generation. 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

 $tnsPrefix = 'tns'
 Target namespace for the WSDL document will have the following prefix. More...
 
 $wsdl = null
 Reference to the ilBMFWSDL object to populate. More...
 
- 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

Parses the types and methods used in web service objects into the internal data structures used by ilBMFWSDL.

Assumes the ilBMFWSDL class is unpopulated to start with.

Author
Chris Coe info@.nosp@m.inte.nosp@m.llige.nosp@m.ntst.nosp@m.reami.nosp@m.ng.c.nosp@m.om

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

Member Function Documentation

◆ _generateBindingsAndServices()

ilBMFWSDL_ObjectParser::_generateBindingsAndServices (   $schemaNamespace,
  $service_name,
  $service_desc = '' 
)

Take all the abstract WSDL data and build concrete bindings and services (destructive).

XXX Current implementation discards $service_desc.

Parameters
$schemaNamespaceNamespace for types etc.
$service_nameName of the WSDL <service>
$service_descOptional description of the WSDL <service> @access private

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

2088 {
2089 // Populate tree with bindings information
2090 // XXX Current implementation only supports one binding that
2091 // matches the single portType and all of its operations.
2092 // XXX Is this the correct use of $schemaNamespace here?
2093 // *** <wsdl:binding> ***
2094
2095 $this->wsdl->bindings[$service_name . 'Binding'] = array(
2096 'type' => $service_name . 'Port',
2097 'namespace' => $this->tnsPrefix,
2098 'style' => 'rpc',
2099 'transport' => SCHEMA_SOAP_HTTP,
2100 'operations' => array());
2101 $thisBinding =& $this->wsdl->bindings[$service_name . 'Binding'];
2102
2103 foreach ($this->wsdl->portTypes[$service_name . 'Port'] as $operationName => $operationData) {
2104 $thisBinding['operations'][$operationName] = array(
2105 'soapAction' => $schemaNamespace . '#' . $operationName,
2106 'style' => $thisBinding['style']);
2107
2108 foreach (array('input', 'output') as $messageType)
2109 if (isset($operationData[$messageType])) {
2110 $thisBinding['operations'][$operationName][$messageType] = array(
2111 'use' => 'encoded',
2112 'namespace' => $schemaNamespace,
2113 'encodingStyle' => SOAP_SCHEMA_ENCODING);
2114 }
2115 }
2116
2117 // Populate tree with service information
2118 // XXX Current implementation supports one service which groups
2119 // all of the ports together, one port per binding
2120 // XXX What about https?
2121 // *** <wsdl:service> ***
2122
2123 $this->wsdl->services[$service_name . 'Service'] = array('ports' => array());
2124 $thisService =& $this->wsdl->services[$service_name . 'Service']['ports'];
2125
2126 foreach ($this->wsdl->bindings as $bindingName => $bindingData) {
2127 $thisService[$bindingData['type']] = array(
2128 'name' => $bindingData['type'],
2129 'binding' => $bindingName,
2130 'namespace' => $this->tnsPrefix,
2131 'address' => array('location' =>
2132 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] .
2133 (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')),
2134 'type' => 'soap');
2135 }
2136
2137 // Set service
2138 $this->wsdl->set_service($service_name . 'Service');
2139 $this->wsdl->uri = $this->wsdl->namespaces[$this->tnsPrefix];
2140
2141 // Create WSDL definition
2142 // *** <wsdl:definitions> ***
2143
2144 $this->wsdl->definition = array(
2145 'name' => $service_name,
2146 'targetNamespace' => $this->wsdl->namespaces[$this->tnsPrefix],
2147 'xmlns' => SCHEMA_WSDL);
2148
2149 foreach ($this->wsdl->namespaces as $nsPrefix => $namespace) {
2150 $this->wsdl->definition['xmlns:' . $nsPrefix] = $namespace;
2151 }
2152 }
const SCHEMA_SOAP_HTTP
const SCHEMA_WSDL
const SOAP_SCHEMA_ENCODING
$tnsPrefix
Target namespace for the WSDL document will have the following prefix.
parses a WSDL file, allows access to it's data, other utility methods
Definition: nusoap.php:3133
if($err=$client->getError()) $namespace
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

References $_SERVER, $namespace, $tnsPrefix, SCHEMA_SOAP_HTTP, SCHEMA_WSDL, and SOAP_SCHEMA_ENCODING.

Referenced by ilBMFWSDL_ObjectParser().

+ Here is the caller graph for this function:

◆ _getTypeNs()

ilBMFWSDL_ObjectParser::_getTypeNs (   $type)

This function is adapted from Dmitri V's implementation of DISCO/WSDL generation.

It separates namespace from type name in a __typedef key and creates a new namespace entry in the WSDL structure if the namespace has not been used before. The namespace prefix and type name are returned. If no namespace is specified, xsd is assumed.

We will not need this function anymore once __typedef is eliminated.

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

2166 {
2167 preg_match_all("'\{(.*)\}'sm", $type, $m);
2168 if (isset($m[1][0]) && $m[1][0] != '') {
2169 if (!array_key_exists($m[1][0], $this->wsdl->ns)) {
2170 $ns_pref = 'ns' . count($this->wsdl->namespaces);
2171 $this->wsdl->ns[$m[1][0]] = $ns_pref;
2172 $this->wsdl->namespaces[$ns_pref] = $m[1][0];
2173 }
2174 $typens = $this->wsdl->ns[$m[1][0]];
2175 $type = ereg_replace($m[0][0], '', $type);
2176 } else {
2177 $typens = 'xsd';
2178 }
2179
2180 return array($typens, $type);
2181 }

Referenced by _parse().

+ Here is the caller graph for this function:

◆ _initialise()

ilBMFWSDL_ObjectParser::_initialise (   $service_name)

Initialise the ilBMFWSDL tree (destructive).

If the object has already been initialised, the only effect will be to change the tns namespace to the new service name.

Parameters
$service_nameName of the WSDL <service> @access private

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

1913 {
1914 // Set up the basic namespaces that all WSDL definitions use.
1915 $this->wsdl->namespaces['wsdl'] = SCHEMA_WSDL; // WSDL language
1916 $this->wsdl->namespaces['soap'] = SCHEMA_SOAP; // WSDL SOAP bindings
1917 $this->wsdl->namespaces[$this->tnsPrefix] = 'urn:' . $service_name; // Target namespace
1918 $this->wsdl->namespaces['xsd'] = array_search('xsd', $this->_namespaces); // XML Schema
1919 $this->wsdl->namespaces['SOAP-ENC'] = array_search('SOAP-ENC', $this->_namespaces); // SOAP types
1920
1921 // XXX Refactor $namespace/$ns for Shane :-)
1922 unset($this->wsdl->ns['urn:' . $service_name]);
1923 $this->wsdl->ns += array_flip($this->wsdl->namespaces);
1924
1925 // Imports are not implemented in WSDL generation from classes.
1926 // *** <wsdl:import> ***
1927 }
const SCHEMA_SOAP

References $tnsPrefix, SCHEMA_SOAP, and SCHEMA_WSDL.

Referenced by ilBMFWSDL_ObjectParser().

+ Here is the caller graph for this function:

◆ _parse()

ilBMFWSDL_ObjectParser::_parse ( $object,
  $schemaNamespace,
  $service_name 
)

Parser - takes a single object to add to tree (non-destructive).

Parameters
$objectReference to the object to parse
$service_nameName of the WSDL <service> @access private

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

1938 {
1939 // Create namespace prefix for the schema
1940 // XXX not very elegant :-(
1941
1942 list($schPrefix, $foo) = $this->_getTypeNs('{' . $schemaNamespace.'}');
1943 unset($foo);
1944
1945 // Parse all the types defined by the object in whatever
1946 // schema language we are using (currently __typedef arrays)
1947 // *** <wsdl:types> ***
1948
1949 foreach ($object->__typedef as $typeName => $typeValue) {
1950 // Get/create namespace definition
1951
1952 list($nsPrefix, $typeName) = $this->_getTypeNs($typeName);
1953
1954 // Create type definition
1955
1956 $this->wsdl->complexTypes[$schPrefix][$typeName] = array('name' => $typeName);
1957 $thisType =& $this->wsdl->complexTypes[$schPrefix][$typeName];
1958
1959 // According to Dmitri's documentation, __typedef comes in two
1960 // flavors:
1961 // Array = array(array("item" => "value"))
1962 // Struct = array("item1" => "value1", "item2" => "value2", ...)
1963
1964 if (is_array($typeValue)) {
1965 if (is_array(current($typeValue)) && count($typeValue) == 1
1966 && count(current($typeValue)) == 1) {
1967 // It's an array
1968
1969 $thisType['type'] = 'Array';
1970 list($nsPrefix, $typeName) = $this->_getTypeNs(current(current($typeValue)));
1971 $thisType['namespace'] = $nsPrefix;
1972 $thisType['arrayType'] = $typeName . '[]';
1973 } elseif (!is_array(current($typeValue))) {
1974 // It's a struct
1975
1976 $thisType['type'] = 'Struct';
1977 $thisType['order'] = 'all';
1978 $thisType['namespace'] = $nsPrefix;
1979 $thisType['elements'] = array();
1980
1981 foreach ($typeValue as $elementName => $elementType) {
1982 list($nsPrefix, $typeName) = $this->_getTypeNs($elementType);
1983 $thisType['elements'][$elementName]['name'] = $elementName;
1984 $thisType['elements'][$elementName]['type'] = $typeName;
1985 $thisType['elements'][$elementName]['namespace'] = $nsPrefix;
1986 }
1987 } else {
1988 // It's erroneous
1989 return $this->_raiseSoapFault("The type definition for $nsPrefix:$typeName is invalid.", 'urn:' . get_class($object));
1990 }
1991 } else {
1992 // It's erroneous
1993 return $this->_raiseSoapFault("The type definition for $nsPrefix:$typeName is invalid.", 'urn:' . get_class($object));
1994 }
1995 }
1996
1997 // Create an empty element array with the target namespace
1998 // prefix, to match the results of WSDL parsing.
1999
2000 $this->wsdl->elements[$schPrefix] = array();
2001
2002 // Populate tree with message information
2003 // *** <wsdl:message> ***
2004
2005 foreach ($object->__dispatch_map as $operationName => $messages) {
2006 foreach ($messages as $messageType => $messageParts) {
2007 unset($thisMessage);
2008
2009 switch ($messageType) {
2010 case 'in':
2011 $this->wsdl->messages[$operationName . 'Request'] = array();
2012 $thisMessage =& $this->wsdl->messages[$operationName . 'Request'];
2013 break;
2014
2015 case 'out':
2016 $this->wsdl->messages[$operationName . 'Response'] = array();
2017 $thisMessage =& $this->wsdl->messages[$operationName . 'Response'];
2018 break;
2019
2020 case 'alias':
2021 // Do nothing
2022 break;
2023
2024 default:
2025 // Error condition
2026 break;
2027 }
2028
2029 if (isset($thisMessage)) {
2030 foreach ($messageParts as $partName => $partType) {
2031 list ($nsPrefix, $typeName) = $this->_getTypeNs($partType);
2032
2033 $thisMessage[$partName] = array(
2034 'name' => $partName,
2035 'type' => $typeName,
2036 'namespace' => $nsPrefix
2037 );
2038 }
2039 }
2040 }
2041 }
2042
2043 // Populate tree with portType information
2044 // XXX Current implementation only supports one portType that
2045 // encompasses all of the operations available.
2046 // *** <wsdl:portType> ***
2047
2048 if (!isset($this->wsdl->portTypes[$service_name . 'Port'])) {
2049 $this->wsdl->portTypes[$service_name . 'Port'] = array();
2050 }
2051 $thisPortType =& $this->wsdl->portTypes[$service_name . 'Port'];
2052
2053 foreach ($object->__dispatch_map as $operationName => $messages) {
2054 $thisPortType[$operationName] = array('name' => $operationName);
2055
2056 foreach ($messages as $messageType => $messageParts) {
2057 switch ($messageType) {
2058 case 'in':
2059 $thisPortType[$operationName]['input'] = array(
2060 'message' => $operationName . 'Request',
2061 'namespace' => $this->tnsPrefix);
2062 break;
2063
2064 case 'out':
2065 $thisPortType[$operationName]['output'] = array(
2066 'message' => $operationName . 'Response',
2067 'namespace' => $this->tnsPrefix);
2068 break;
2069 }
2070 }
2071 }
2072
2073 return true;
2074 }
& _raiseSoapFault($str, $detail='', $actorURI='', $code=null, $mode=null, $options=null, $skipmsg=false)
Raises a SOAP error.
_getTypeNs($type)
This function is adapted from Dmitri V's implementation of DISCO/WSDL generation.
$messages
Definition: en-x-test.php:7

References $messages, _getTypeNs(), and ilBMFBase_Object\_raiseSoapFault().

Referenced by ilBMFWSDL_ObjectParser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ilBMFWSDL_ObjectParser()

ilBMFWSDL_ObjectParser::ilBMFWSDL_ObjectParser ( $objects,
$wsdl,
  $targetNamespace,
  $service_name,
  $service_desc = '' 
)

Constructor.

Parameters
$objectsReference to the object or array of objects to parse
$wsdlReference to the ilBMFWSDL object to populate
$targetNamespaceThe target namespace of schema types etc.
$service_nameName of the WSDL <service>
$service_descOptional description of the WSDL <service>

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

1878 {
1879 parent::ilBMFBase('WSDLOBJECTPARSER');
1880
1881 $this->wsdl = &$wsdl;
1882
1883 // Set up the ilBMFWSDL object
1884 $this->_initialise($service_name);
1885
1886 // Parse each web service object
1887 $wsdl_ref = (is_array($objects)? $objects : array(&$objects));
1888
1889 foreach ($wsdl_ref as $ref_item) {
1890 if (!is_object($ref_item))
1891 return $this->_raiseSoapFault('Invalid web service object passed to object parser', 'urn:' . get_class($object));
1892
1893 if ($this->_parse($ref_item, $targetNamespace, $service_name) != true)
1894 break;
1895 }
1896
1897 // Build bindings from abstract data.
1898 if ($this->fault == null) {
1899 $this->_generateBindingsAndServices($targetNamespace, $service_name, $service_desc);
1900 }
1901 }
$wsdl
Reference to the ilBMFWSDL object to populate.
_parse(&$object, $schemaNamespace, $service_name)
Parser - takes a single object to add to tree (non-destructive).
_generateBindingsAndServices($schemaNamespace, $service_name, $service_desc='')
Take all the abstract WSDL data and build concrete bindings and services (destructive).
_initialise($service_name)
Initialise the ilBMFWSDL tree (destructive).

References $wsdl, _generateBindingsAndServices(), _initialise(), _parse(), and ilBMFBase_Object\_raiseSoapFault().

+ Here is the call graph for this function:

Field Documentation

◆ $tnsPrefix

ilBMFWSDL_ObjectParser::$tnsPrefix = 'tns'

Target namespace for the WSDL document will have the following prefix.

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

Referenced by _generateBindingsAndServices(), and _initialise().

◆ $wsdl

ilBMFWSDL_ObjectParser::$wsdl = null

Reference to the ilBMFWSDL object to populate.

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

Referenced by ilBMFWSDL_ObjectParser().


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