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. | |
| _initialise ($service_name) | |
| Initialise the ilBMFWSDL tree (destructive). | |
| _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). | |
| _getTypeNs ($type) | |
| This function is adapted from Dmitri V's implementation of DISCO/WSDL generation. | |
Data Fields | |
| $tnsPrefix = 'tns' | |
| Target namespace for the WSDL document will have the following prefix. | |
| $wsdl = null | |
| Reference to the ilBMFWSDL object to populate. | |
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.
Definition at line 1856 of file class.ilBMFWSDL.php.
| 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.
| $schemaNamespace | Namespace for types etc. | |
| $service_name | Name of the WSDL <service> | |
| $service_desc | Optional description of the WSDL <service> private |
Definition at line 2087 of file class.ilBMFWSDL.php.
References $namespace.
Referenced by ilBMFWSDL_ObjectParser().
{
// Populate tree with bindings information
// XXX Current implementation only supports one binding that
// matches the single portType and all of its operations.
// XXX Is this the correct use of $schemaNamespace here?
// *** <wsdl:binding> ***
$this->wsdl->bindings[$service_name . 'Binding'] = array(
'type' => $service_name . 'Port',
'namespace' => $this->tnsPrefix,
'style' => 'rpc',
'transport' => SCHEMA_SOAP_HTTP,
'operations' => array());
$thisBinding =& $this->wsdl->bindings[$service_name . 'Binding'];
foreach ($this->wsdl->portTypes[$service_name . 'Port'] as $operationName => $operationData) {
$thisBinding['operations'][$operationName] = array(
'soapAction' => $schemaNamespace . '#' . $operationName,
'style' => $thisBinding['style']);
foreach (array('input', 'output') as $messageType)
if (isset($operationData[$messageType])) {
$thisBinding['operations'][$operationName][$messageType] = array(
'use' => 'encoded',
'namespace' => $schemaNamespace,
'encodingStyle' => SOAP_SCHEMA_ENCODING);
}
}
// Populate tree with service information
// XXX Current implementation supports one service which groups
// all of the ports together, one port per binding
// XXX What about https?
// *** <wsdl:service> ***
$this->wsdl->services[$service_name . 'Service'] = array('ports' => array());
$thisService =& $this->wsdl->services[$service_name . 'Service']['ports'];
foreach ($this->wsdl->bindings as $bindingName => $bindingData) {
$thisService[$bindingData['type']] = array(
'name' => $bindingData['type'],
'binding' => $bindingName,
'namespace' => $this->tnsPrefix,
'address' => array('location' =>
'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] .
(isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')),
'type' => 'soap');
}
// Set service
$this->wsdl->set_service($service_name . 'Service');
$this->wsdl->uri = $this->wsdl->namespaces[$this->tnsPrefix];
// Create WSDL definition
// *** <wsdl:definitions> ***
$this->wsdl->definition = array(
'name' => $service_name,
'targetNamespace' => $this->wsdl->namespaces[$this->tnsPrefix],
'xmlns' => SCHEMA_WSDL);
foreach ($this->wsdl->namespaces as $nsPrefix => $namespace) {
$this->wsdl->definition['xmlns:' . $nsPrefix] = $namespace;
}
}
Here is the caller graph for this function:| 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.
Referenced by _parse().
{
preg_match_all("'\{(.*)\}'sm", $type, $m);
if (isset($m[1][0]) && $m[1][0] != '') {
if (!array_key_exists($m[1][0], $this->wsdl->ns)) {
$ns_pref = 'ns' . count($this->wsdl->namespaces);
$this->wsdl->ns[$m[1][0]] = $ns_pref;
$this->wsdl->namespaces[$ns_pref] = $m[1][0];
}
$typens = $this->wsdl->ns[$m[1][0]];
$type = ereg_replace($m[0][0], '', $type);
} else {
$typens = 'xsd';
}
return array($typens, $type);
}
Here is the caller graph for this function:| 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.
| $service_name | Name of the WSDL <service> private |
Definition at line 1912 of file class.ilBMFWSDL.php.
Referenced by ilBMFWSDL_ObjectParser().
{
// Set up the basic namespaces that all WSDL definitions use.
$this->wsdl->namespaces['wsdl'] = SCHEMA_WSDL; // WSDL language
$this->wsdl->namespaces['soap'] = SCHEMA_SOAP; // WSDL SOAP bindings
$this->wsdl->namespaces[$this->tnsPrefix] = 'urn:' . $service_name; // Target namespace
$this->wsdl->namespaces['xsd'] = array_search('xsd', $this->_namespaces); // XML Schema
$this->wsdl->namespaces['SOAP-ENC'] = array_search('SOAP-ENC', $this->_namespaces); // SOAP types
// XXX Refactor $namespace/$ns for Shane :-)
unset($this->wsdl->ns['urn:' . $service_name]);
$this->wsdl->ns += array_flip($this->wsdl->namespaces);
// Imports are not implemented in WSDL generation from classes.
// *** <wsdl:import> ***
}
Here is the caller graph for this function:| ilBMFWSDL_ObjectParser::_parse | ( | &$ | object, | |
| $ | schemaNamespace, | |||
| $ | service_name | |||
| ) |
Parser - takes a single object to add to tree (non-destructive).
| $object | Reference to the object to parse | |
| $service_name | Name of the WSDL <service> private |
Definition at line 1937 of file class.ilBMFWSDL.php.
References _getTypeNs(), and ilBMFBase_Object::_raiseSoapFault().
Referenced by ilBMFWSDL_ObjectParser().
{
// Create namespace prefix for the schema
// XXX not very elegant :-(
list($schPrefix, $foo) = $this->_getTypeNs('{' . $schemaNamespace.'}');
unset($foo);
// Parse all the types defined by the object in whatever
// schema language we are using (currently __typedef arrays)
// *** <wsdl:types> ***
foreach ($object->__typedef as $typeName => $typeValue) {
// Get/create namespace definition
list($nsPrefix, $typeName) = $this->_getTypeNs($typeName);
// Create type definition
$this->wsdl->complexTypes[$schPrefix][$typeName] = array('name' => $typeName);
$thisType =& $this->wsdl->complexTypes[$schPrefix][$typeName];
// According to Dmitri's documentation, __typedef comes in two
// flavors:
// Array = array(array("item" => "value"))
// Struct = array("item1" => "value1", "item2" => "value2", ...)
if (is_array($typeValue)) {
if (is_array(current($typeValue)) && count($typeValue) == 1
&& count(current($typeValue)) == 1) {
// It's an array
$thisType['type'] = 'Array';
list($nsPrefix, $typeName) = $this->_getTypeNs(current(current($typeValue)));
$thisType['namespace'] = $nsPrefix;
$thisType['arrayType'] = $typeName . '[]';
} elseif (!is_array(current($typeValue))) {
// It's a struct
$thisType['type'] = 'Struct';
$thisType['order'] = 'all';
$thisType['namespace'] = $nsPrefix;
$thisType['elements'] = array();
foreach ($typeValue as $elementName => $elementType) {
list($nsPrefix, $typeName) = $this->_getTypeNs($elementType);
$thisType['elements'][$elementName]['name'] = $elementName;
$thisType['elements'][$elementName]['type'] = $typeName;
$thisType['elements'][$elementName]['namespace'] = $nsPrefix;
}
} else {
// It's erroneous
return $this->_raiseSoapFault("The type definition for $nsPrefix:$typeName is invalid.", 'urn:' . get_class($object));
}
} else {
// It's erroneous
return $this->_raiseSoapFault("The type definition for $nsPrefix:$typeName is invalid.", 'urn:' . get_class($object));
}
}
// Create an empty element array with the target namespace
// prefix, to match the results of WSDL parsing.
$this->wsdl->elements[$schPrefix] = array();
// Populate tree with message information
// *** <wsdl:message> ***
foreach ($object->__dispatch_map as $operationName => $messages) {
foreach ($messages as $messageType => $messageParts) {
unset($thisMessage);
switch ($messageType) {
case 'in':
$this->wsdl->messages[$operationName . 'Request'] = array();
$thisMessage =& $this->wsdl->messages[$operationName . 'Request'];
break;
case 'out':
$this->wsdl->messages[$operationName . 'Response'] = array();
$thisMessage =& $this->wsdl->messages[$operationName . 'Response'];
break;
case 'alias':
// Do nothing
break;
default:
// Error condition
break;
}
if (isset($thisMessage)) {
foreach ($messageParts as $partName => $partType) {
list ($nsPrefix, $typeName) = $this->_getTypeNs($partType);
$thisMessage[$partName] = array(
'name' => $partName,
'type' => $typeName,
'namespace' => $nsPrefix
);
}
}
}
}
// Populate tree with portType information
// XXX Current implementation only supports one portType that
// encompasses all of the operations available.
// *** <wsdl:portType> ***
if (!isset($this->wsdl->portTypes[$service_name . 'Port'])) {
$this->wsdl->portTypes[$service_name . 'Port'] = array();
}
$thisPortType =& $this->wsdl->portTypes[$service_name . 'Port'];
foreach ($object->__dispatch_map as $operationName => $messages) {
$thisPortType[$operationName] = array('name' => $operationName);
foreach ($messages as $messageType => $messageParts) {
switch ($messageType) {
case 'in':
$thisPortType[$operationName]['input'] = array(
'message' => $operationName . 'Request',
'namespace' => $this->tnsPrefix);
break;
case 'out':
$thisPortType[$operationName]['output'] = array(
'message' => $operationName . 'Response',
'namespace' => $this->tnsPrefix);
break;
}
}
}
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilBMFWSDL_ObjectParser::ilBMFWSDL_ObjectParser | ( | &$ | objects, | |
| &$ | wsdl, | |||
| $ | targetNamespace, | |||
| $ | service_name, | |||
| $ | service_desc = '' | |||
| ) |
Constructor.
| $objects | Reference to the object or array of objects to parse | |
| $wsdl | Reference to the ilBMFWSDL object to populate | |
| $targetNamespace | The target namespace of schema types etc. | |
| $service_name | Name of the WSDL <service> | |
| $service_desc | Optional description of the WSDL <service> |
Definition at line 1877 of file class.ilBMFWSDL.php.
References $wsdl, _generateBindingsAndServices(), _initialise(), _parse(), ilBMFBase_Object::_raiseSoapFault(), and ilBMFBase::ilBMFBase().
{
parent::ilBMFBase('WSDLOBJECTPARSER');
$this->wsdl = &$wsdl;
// Set up the ilBMFWSDL object
$this->_initialise($service_name);
// Parse each web service object
$wsdl_ref = (is_array($objects)? $objects : array(&$objects));
foreach ($wsdl_ref as $ref_item) {
if (!is_object($ref_item))
return $this->_raiseSoapFault('Invalid web service object passed to object parser', 'urn:' . get_class($object));
if ($this->_parse($ref_item, $targetNamespace, $service_name) != true)
break;
}
// Build bindings from abstract data.
if ($this->fault == null) {
$this->_generateBindingsAndServices($targetNamespace, $service_name, $service_desc);
}
}
Here is the call graph for this function:| ilBMFWSDL_ObjectParser::$tnsPrefix = 'tns' |
Target namespace for the WSDL document will have the following prefix.
Definition at line 1862 of file class.ilBMFWSDL.php.
| ilBMFWSDL_ObjectParser::$wsdl = null |
Reference to the ilBMFWSDL object to populate.
Definition at line 1867 of file class.ilBMFWSDL.php.
Referenced by ilBMFWSDL_ObjectParser().
1.7.1