|
@@ -6,15 +6,15 @@
|
|
|
/**
|
|
|
* parses a WSDL file, allows access to it's data, other utility methods.
|
|
|
* also builds WSDL structures programmatically.
|
|
|
-*
|
|
|
+*
|
|
|
* @author Dietrich Ayala <dietrich@ganx4.com>
|
|
|
* @author Scott Nichol <snichol@users.sourceforge.net>
|
|
|
* @version $Id: class.wsdl.php,v 1.76 2010/04/26 20:15:08 snichol Exp $
|
|
|
-* @access public
|
|
|
+* @access public
|
|
|
*/
|
|
|
class wsdl extends nusoap_base {
|
|
|
// URL or filename of the root of this WSDL
|
|
|
- var $wsdl;
|
|
|
+ var $wsdl;
|
|
|
// define internal arrays of bindings, ports, operations, messages, etc.
|
|
|
var $schemas = array();
|
|
|
var $currentSchema;
|
|
@@ -32,9 +32,9 @@ class wsdl extends nusoap_base {
|
|
|
var $opData = array();
|
|
|
var $status = '';
|
|
|
var $documentation = false;
|
|
|
- var $endpoint = '';
|
|
|
+ var $endpoint = '';
|
|
|
// array of wsdl docs to import
|
|
|
- var $import = array();
|
|
|
+ var $import = array();
|
|
|
// parser vars
|
|
|
var $parser;
|
|
|
var $position = 0;
|
|
@@ -57,7 +57,7 @@ class wsdl extends nusoap_base {
|
|
|
|
|
|
/**
|
|
|
* constructor
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $wsdl WSDL document URL
|
|
|
* @param string $proxyhost
|
|
|
* @param string $proxyport
|
|
@@ -67,7 +67,7 @@ class wsdl extends nusoap_base {
|
|
|
* @param integer $response_timeout set the response timeout
|
|
|
* @param array $curl_options user-specified cURL options
|
|
|
* @param boolean $use_curl try to use cURL
|
|
|
- * @access public
|
|
|
+ * @access public
|
|
|
*/
|
|
|
function wsdl($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){
|
|
|
parent::nusoap_base();
|
|
@@ -127,7 +127,7 @@ class wsdl extends nusoap_base {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// WSDL imports
|
|
@@ -153,18 +153,18 @@ class wsdl extends nusoap_base {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
// add new data to operation data
|
|
|
foreach($this->bindings as $binding => $bindingData) {
|
|
|
if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
|
|
|
foreach($bindingData['operations'] as $operation => $data) {
|
|
|
$this->debug('post-parse data gathering for ' . $operation);
|
|
|
- $this->bindings[$binding]['operations'][$operation]['input'] =
|
|
|
- isset($this->bindings[$binding]['operations'][$operation]['input']) ?
|
|
|
+ $this->bindings[$binding]['operations'][$operation]['input'] =
|
|
|
+ isset($this->bindings[$binding]['operations'][$operation]['input']) ?
|
|
|
array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) :
|
|
|
$this->portTypes[ $bindingData['portType'] ][$operation]['input'];
|
|
|
- $this->bindings[$binding]['operations'][$operation]['output'] =
|
|
|
+ $this->bindings[$binding]['operations'][$operation]['output'] =
|
|
|
isset($this->bindings[$binding]['operations'][$operation]['output']) ?
|
|
|
array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) :
|
|
|
$this->portTypes[ $bindingData['portType'] ][$operation]['output'];
|
|
@@ -181,16 +181,16 @@ class wsdl extends nusoap_base {
|
|
|
$this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : '';
|
|
|
$this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : '';
|
|
|
$this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : '';
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* parses the wsdl document
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $wsdl path or URL
|
|
|
- * @access private
|
|
|
+ * @access private
|
|
|
*/
|
|
|
function parseWSDL($wsdl = '') {
|
|
|
$this->debug("parse WSDL at path=$wsdl");
|
|
@@ -200,7 +200,7 @@ class wsdl extends nusoap_base {
|
|
|
$this->setError('no wsdl passed to parseWSDL()!!');
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// parse $wsdl for url format
|
|
|
$wsdl_props = parse_url($wsdl);
|
|
|
|
|
@@ -243,24 +243,24 @@ class wsdl extends nusoap_base {
|
|
|
$wsdl_string = '';
|
|
|
while ($data = fread($fp, 32768)) {
|
|
|
$wsdl_string .= $data;
|
|
|
- }
|
|
|
+ }
|
|
|
fclose($fp);
|
|
|
} else {
|
|
|
$errstr = "Bad path to WSDL file $path";
|
|
|
$this->debug($errstr);
|
|
|
$this->setError($errstr);
|
|
|
return false;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
$this->debug('Parse WSDL');
|
|
|
// end new code added
|
|
|
// Create an XML parser.
|
|
|
- $this->parser = xml_parser_create();
|
|
|
+ $this->parser = xml_parser_create();
|
|
|
// Set the options for parsing the XML data.
|
|
|
// xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
|
|
|
- xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
|
|
|
+ xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
|
|
|
// Set the object for the parser.
|
|
|
- xml_set_object($this->parser, $this);
|
|
|
+ xml_set_object($this->parser, $this);
|
|
|
// Set the element handlers for the parser.
|
|
|
xml_set_element_handler($this->parser, 'start_element', 'end_element');
|
|
|
xml_set_character_data_handler($this->parser, 'character_data');
|
|
@@ -277,7 +277,7 @@ class wsdl extends nusoap_base {
|
|
|
$this->debug("XML payload:\n" . $wsdl_string);
|
|
|
$this->setError($errstr);
|
|
|
return false;
|
|
|
- }
|
|
|
+ }
|
|
|
// free the parser
|
|
|
xml_parser_free($this->parser);
|
|
|
$this->debug('Parsing WSDL done');
|
|
@@ -286,15 +286,15 @@ class wsdl extends nusoap_base {
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* start-element handler
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $parser XML parser object
|
|
|
* @param string $name element name
|
|
|
* @param string $attrs associative array of attributes
|
|
|
- * @access private
|
|
|
+ * @access private
|
|
|
*/
|
|
|
function start_element($parser, $name, $attrs)
|
|
|
{
|
|
@@ -313,10 +313,10 @@ class wsdl extends nusoap_base {
|
|
|
} else {
|
|
|
// position in the total number of elements, starting from 0
|
|
|
$pos = $this->position++;
|
|
|
- $depth = $this->depth++;
|
|
|
+ $depth = $this->depth++;
|
|
|
// set self as current value for this depth
|
|
|
$this->depth_array[$depth] = $pos;
|
|
|
- $this->message[$pos] = array('cdata' => '');
|
|
|
+ $this->message[$pos] = array('cdata' => '');
|
|
|
// process attributes
|
|
|
if (count($attrs) > 0) {
|
|
|
// register namespace declarations
|
|
@@ -326,11 +326,11 @@ class wsdl extends nusoap_base {
|
|
|
$this->namespaces[$ns_prefix] = $v;
|
|
|
} else {
|
|
|
$this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
|
|
|
- }
|
|
|
+ }
|
|
|
if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
|
|
|
$this->XMLSchemaVersion = $v;
|
|
|
$this->namespaces['xsi'] = $v . '-instance';
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// expand each attribute prefix to its namespace
|
|
@@ -338,22 +338,22 @@ class wsdl extends nusoap_base {
|
|
|
$k = strpos($k, ':') ? $this->expandQname($k) : $k;
|
|
|
if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') {
|
|
|
$v = strpos($v, ':') ? $this->expandQname($v) : $v;
|
|
|
- }
|
|
|
+ }
|
|
|
$eAttrs[$k] = $v;
|
|
|
- }
|
|
|
+ }
|
|
|
$attrs = $eAttrs;
|
|
|
} else {
|
|
|
$attrs = array();
|
|
|
- }
|
|
|
+ }
|
|
|
// get element prefix, namespace and name
|
|
|
if (preg_match('/:/', $name)) {
|
|
|
// get ns prefix
|
|
|
- $prefix = substr($name, 0, strpos($name, ':'));
|
|
|
+ $prefix = substr($name, 0, strpos($name, ':'));
|
|
|
// get ns
|
|
|
- $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : '';
|
|
|
+ $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : '';
|
|
|
// get unqualified name
|
|
|
$name = substr(strstr($name, ':'), 1);
|
|
|
- }
|
|
|
+ }
|
|
|
// process attributes, expanding any prefixes to namespaces
|
|
|
// find status, register data
|
|
|
switch ($this->status) {
|
|
@@ -362,12 +362,12 @@ class wsdl extends nusoap_base {
|
|
|
if (isset($attrs['type'])) {
|
|
|
$this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
|
|
|
$this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
|
|
|
- }
|
|
|
+ }
|
|
|
if (isset($attrs['element'])) {
|
|
|
$this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
|
|
|
$this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
case 'portType':
|
|
|
switch ($name) {
|
|
@@ -376,25 +376,25 @@ class wsdl extends nusoap_base {
|
|
|
$this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
|
|
|
if (isset($attrs['parameterOrder'])) {
|
|
|
$this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
|
|
|
- }
|
|
|
+ }
|
|
|
break;
|
|
|
case 'documentation':
|
|
|
$this->documentation = true;
|
|
|
- break;
|
|
|
+ break;
|
|
|
// merge input/output data
|
|
|
default:
|
|
|
$m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
|
|
|
$this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
|
|
|
break;
|
|
|
- }
|
|
|
+ }
|
|
|
break;
|
|
|
case 'binding':
|
|
|
switch ($name) {
|
|
|
- case 'binding':
|
|
|
+ case 'binding':
|
|
|
// get ns prefix
|
|
|
if (isset($attrs['style'])) {
|
|
|
$this->bindings[$this->currentBinding]['prefix'] = $prefix;
|
|
|
- }
|
|
|
+ }
|
|
|
$this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
|
|
|
break;
|
|
|
case 'header':
|
|
@@ -403,17 +403,17 @@ class wsdl extends nusoap_base {
|
|
|
case 'operation':
|
|
|
if (isset($attrs['soapAction'])) {
|
|
|
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction'];
|
|
|
- }
|
|
|
+ }
|
|
|
if (isset($attrs['style'])) {
|
|
|
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style'];
|
|
|
- }
|
|
|
+ }
|
|
|
if (isset($attrs['name'])) {
|
|
|
$this->currentOperation = $attrs['name'];
|
|
|
$this->debug("current binding operation: $this->currentOperation");
|
|
|
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name'];
|
|
|
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding;
|
|
|
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : '';
|
|
|
- }
|
|
|
+ }
|
|
|
break;
|
|
|
case 'input':
|
|
|
$this->opStatus = 'input';
|
|
@@ -426,9 +426,9 @@ class wsdl extends nusoap_base {
|
|
|
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs);
|
|
|
} else {
|
|
|
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs;
|
|
|
- }
|
|
|
+ }
|
|
|
break;
|
|
|
- }
|
|
|
+ }
|
|
|
break;
|
|
|
case 'service':
|
|
|
switch ($name) {
|
|
@@ -436,7 +436,7 @@ class wsdl extends nusoap_base {
|
|
|
$this->currentPort = $attrs['name'];
|
|
|
$this->debug('current port: ' . $this->currentPort);
|
|
|
$this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
|
|
|
-
|
|
|
+
|
|
|
break;
|
|
|
case 'address':
|
|
|
$this->ports[$this->currentPort]['location'] = $attrs['location'];
|
|
@@ -444,9 +444,9 @@ class wsdl extends nusoap_base {
|
|
|
$this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
|
|
|
$this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
|
|
|
break;
|
|
|
- }
|
|
|
+ }
|
|
|
break;
|
|
|
- }
|
|
|
+ }
|
|
|
// set status
|
|
|
switch ($name) {
|
|
|
case 'import':
|
|
@@ -482,11 +482,11 @@ class wsdl extends nusoap_base {
|
|
|
$this->currentBinding = $this->getLocalPart($attrs['name']);
|
|
|
} else {
|
|
|
$this->currentBinding = $attrs['name'];
|
|
|
- }
|
|
|
+ }
|
|
|
$this->status = 'binding';
|
|
|
$this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
|
|
|
$this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
|
|
|
- }
|
|
|
+ }
|
|
|
break;
|
|
|
case 'service':
|
|
|
$this->serviceName = $attrs['name'];
|
|
@@ -496,20 +496,20 @@ class wsdl extends nusoap_base {
|
|
|
case 'definitions':
|
|
|
foreach ($attrs as $name => $value) {
|
|
|
$this->wsdl_info[$name] = $value;
|
|
|
- }
|
|
|
+ }
|
|
|
break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* end-element handler
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $parser XML parser object
|
|
|
* @param string $name element name
|
|
|
- * @access private
|
|
|
+ * @access private
|
|
|
*/
|
|
|
- function end_element($parser, $name){
|
|
|
+ function end_element($parser, $name){
|
|
|
// unset schema status
|
|
|
if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
|
|
|
$this->status = "";
|
|
@@ -517,38 +517,38 @@ class wsdl extends nusoap_base {
|
|
|
$this->currentSchema->clearDebug();
|
|
|
$this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
|
|
|
$this->debug('Parsing WSDL schema done');
|
|
|
- }
|
|
|
+ }
|
|
|
if ($this->status == 'schema') {
|
|
|
$this->currentSchema->schemaEndElement($parser, $name);
|
|
|
} else {
|
|
|
// bring depth down a notch
|
|
|
$this->depth--;
|
|
|
- }
|
|
|
+ }
|
|
|
// end documentation
|
|
|
if ($this->documentation) {
|
|
|
//TODO: track the node to which documentation should be assigned; it can be a part, message, etc.
|
|
|
//$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation;
|
|
|
$this->documentation = false;
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* element content handler
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $parser XML parser object
|
|
|
* @param string $data element content
|
|
|
- * @access private
|
|
|
+ * @access private
|
|
|
*/
|
|
|
function character_data($parser, $data)
|
|
|
{
|
|
|
$pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
|
|
|
if (isset($this->message[$pos]['cdata'])) {
|
|
|
$this->message[$pos]['cdata'] .= $data;
|
|
|
- }
|
|
|
+ }
|
|
|
if ($this->documentation) {
|
|
|
$this->documentation .= $data;
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* if authenticating, set user credentials here
|
|
@@ -567,21 +567,21 @@ class wsdl extends nusoap_base {
|
|
|
$this->authtype = $authtype;
|
|
|
$this->certRequest = $certRequest;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function getBindingData($binding)
|
|
|
{
|
|
|
if (is_array($this->bindings[$binding])) {
|
|
|
return $this->bindings[$binding];
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* returns an assoc array of operation names => operation data
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $portName WSDL port name
|
|
|
* @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported)
|
|
|
- * @return array
|
|
|
- * @access public
|
|
|
+ * @return array
|
|
|
+ * @access public
|
|
|
*/
|
|
|
function getOperations($portName = '', $bindingType = 'soap') {
|
|
|
$ops = array();
|
|
@@ -613,15 +613,15 @@ class wsdl extends nusoap_base {
|
|
|
$this->debug("getOperations found no operations for port '$portName' bindingType $bindingType");
|
|
|
}
|
|
|
return $ops;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* returns an associative array of data necessary for calling an operation
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $operation name of operation
|
|
|
* @param string $bindingType type of binding eg: soap, soap12
|
|
|
- * @return array
|
|
|
- * @access public
|
|
|
+ * @return array
|
|
|
+ * @access public
|
|
|
*/
|
|
|
function getOperationData($operation, $bindingType = 'soap')
|
|
|
{
|
|
@@ -641,19 +641,19 @@ class wsdl extends nusoap_base {
|
|
|
if ($operation == $bOperation) {
|
|
|
$opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
|
|
|
return $opData;
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* returns an associative array of data necessary for calling an operation
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $soapAction soapAction for operation
|
|
|
* @param string $bindingType type of binding eg: soap, soap12
|
|
|
- * @return array
|
|
|
- * @access public
|
|
|
+ * @return array
|
|
|
+ * @access public
|
|
|
*/
|
|
|
function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') {
|
|
|
if ($bindingType == 'soap') {
|
|
@@ -669,12 +669,12 @@ class wsdl extends nusoap_base {
|
|
|
foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
|
|
|
if ($opData['soapAction'] == $soapAction) {
|
|
|
return $opData;
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* returns an array of information about a given type
|
|
|
* returns false if no type exists by the given name
|
|
@@ -885,7 +885,7 @@ class wsdl extends nusoap_base {
|
|
|
*
|
|
|
* @param mixed $debug whether to put debug=1 in endpoint URL
|
|
|
* @return string serialization of WSDL
|
|
|
- * @access public
|
|
|
+ * @access public
|
|
|
*/
|
|
|
function serialize($debug = 0)
|
|
|
{
|
|
@@ -893,15 +893,15 @@ class wsdl extends nusoap_base {
|
|
|
$xml .= "\n<definitions";
|
|
|
foreach($this->namespaces as $k => $v) {
|
|
|
$xml .= " xmlns:$k=\"$v\"";
|
|
|
- }
|
|
|
+ }
|
|
|
// 10.9.02 - add poulter fix for wsdl and tns declarations
|
|
|
if (isset($this->namespaces['wsdl'])) {
|
|
|
$xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
|
|
|
- }
|
|
|
+ }
|
|
|
if (isset($this->namespaces['tns'])) {
|
|
|
$xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
|
|
|
- }
|
|
|
- $xml .= '>';
|
|
|
+ }
|
|
|
+ $xml .= '>';
|
|
|
// imports
|
|
|
if (sizeof($this->import) > 0) {
|
|
|
foreach($this->import as $ns => $list) {
|
|
@@ -912,8 +912,8 @@ class wsdl extends nusoap_base {
|
|
|
$xml .= '<import namespace="' . $ns . '" />';
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
// types
|
|
|
if (count($this->schemas)>=1) {
|
|
|
$xml .= "\n<types>\n";
|
|
@@ -923,7 +923,7 @@ class wsdl extends nusoap_base {
|
|
|
}
|
|
|
}
|
|
|
$xml .= '</types>';
|
|
|
- }
|
|
|
+ }
|
|
|
// messages
|
|
|
if (count($this->messages) >= 1) {
|
|
|
foreach($this->messages as $msgName => $msgParts) {
|
|
@@ -940,11 +940,11 @@ class wsdl extends nusoap_base {
|
|
|
foreach($this->typemap as $ns => $types) {
|
|
|
if (isset($types[$partType])) {
|
|
|
$typePrefix = $this->getPrefixFromNamespace($ns);
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!isset($typePrefix)) {
|
|
|
die("$partType has no namespace!");
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
$ns = $this->getNamespaceFromPrefix($typePrefix);
|
|
|
$localPart = $this->getLocalPart($partType);
|
|
@@ -961,8 +961,8 @@ class wsdl extends nusoap_base {
|
|
|
}
|
|
|
}
|
|
|
$xml .= '</message>';
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
// bindings & porttypes
|
|
|
if (count($this->bindings) >= 1) {
|
|
|
$binding_xml = '';
|
|
@@ -990,7 +990,7 @@ class wsdl extends nusoap_base {
|
|
|
$portType_xml .= "\n" . ' <operation name="' . $opParts['name'] . '"';
|
|
|
if (isset($opParts['parameterOrder'])) {
|
|
|
$portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
|
|
|
- }
|
|
|
+ }
|
|
|
$portType_xml .= '>';
|
|
|
if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
|
|
|
$portType_xml .= "\n" . ' <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
|
|
@@ -998,12 +998,12 @@ class wsdl extends nusoap_base {
|
|
|
$portType_xml .= "\n" . ' <input message="tns:' . $opParts['input']['message'] . '"/>';
|
|
|
$portType_xml .= "\n" . ' <output message="tns:' . $opParts['output']['message'] . '"/>';
|
|
|
$portType_xml .= "\n" . ' </operation>';
|
|
|
- }
|
|
|
+ }
|
|
|
$portType_xml .= "\n" . '</portType>';
|
|
|
$binding_xml .= "\n" . '</binding>';
|
|
|
- }
|
|
|
+ }
|
|
|
$xml .= $portType_xml . $binding_xml;
|
|
|
- }
|
|
|
+ }
|
|
|
// services
|
|
|
$xml .= "\n<service name=\"" . $this->serviceName . '">';
|
|
|
if (count($this->ports) >= 1) {
|
|
@@ -1011,11 +1011,11 @@ class wsdl extends nusoap_base {
|
|
|
$xml .= "\n" . ' <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
|
|
|
$xml .= "\n" . ' <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
|
|
|
$xml .= "\n" . ' </port>';
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
$xml .= "\n" . '</service>';
|
|
|
return $xml . "\n</definitions>";
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* determine whether a set of parameters are unwrapped
|
|
@@ -1060,7 +1060,7 @@ class wsdl extends nusoap_base {
|
|
|
$phpType = $typeDef['phpType'];
|
|
|
$arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '');
|
|
|
$this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
|
|
|
-
|
|
|
+
|
|
|
// we expect a complexType or element of complexType
|
|
|
if ($phpType != 'struct') {
|
|
|
$this->debug("in parametersMatchWrapped: not a struct");
|
|
@@ -1101,7 +1101,7 @@ class wsdl extends nusoap_base {
|
|
|
* TODO
|
|
|
* - multi-ref serialization
|
|
|
* - validate PHP values against type definitions, return errors if invalid
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $operation operation name
|
|
|
* @param string $direction (input|output)
|
|
|
* @param mixed $parameters parameter value(s)
|
|
@@ -1112,12 +1112,12 @@ class wsdl extends nusoap_base {
|
|
|
function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
|
|
|
$this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
|
|
|
$this->appendDebug('parameters=' . $this->varDump($parameters));
|
|
|
-
|
|
|
+
|
|
|
if ($direction != 'input' && $direction != 'output') {
|
|
|
$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
|
|
|
$this->setError('The value of the \$direction argument needs to be either "input" or "output"');
|
|
|
return false;
|
|
|
- }
|
|
|
+ }
|
|
|
if (!$opData = $this->getOperationData($operation, $bindingType)) {
|
|
|
$this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
|
|
|
$this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
|
|
@@ -1168,7 +1168,7 @@ class wsdl extends nusoap_base {
|
|
|
$this->debug("serializing part $name of type $type");
|
|
|
// Track encoding style
|
|
|
if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
|
|
|
- $encodingStyle = $opData[$direction]['encodingStyle'];
|
|
|
+ $encodingStyle = $opData[$direction]['encodingStyle'];
|
|
|
$enc_style = $encodingStyle;
|
|
|
} else {
|
|
|
$enc_style = false;
|
|
@@ -1194,15 +1194,15 @@ class wsdl extends nusoap_base {
|
|
|
}
|
|
|
$this->debug("serializeRPCParameters returning: $xml");
|
|
|
return $xml;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* serialize a PHP value according to a WSDL message definition
|
|
|
- *
|
|
|
+ *
|
|
|
* TODO
|
|
|
* - multi-ref serialization
|
|
|
* - validate PHP values against type definitions, return errors if invalid
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $operation operation name
|
|
|
* @param string $direction (input|output)
|
|
|
* @param mixed $parameters parameter value(s)
|
|
@@ -1212,14 +1212,14 @@ class wsdl extends nusoap_base {
|
|
|
*/
|
|
|
function serializeParameters($operation, $direction, $parameters)
|
|
|
{
|
|
|
- $this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
|
|
|
+ $this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
|
|
|
$this->appendDebug('parameters=' . $this->varDump($parameters));
|
|
|
-
|
|
|
+
|
|
|
if ($direction != 'input' && $direction != 'output') {
|
|
|
$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
|
|
|
$this->setError('The value of the \$direction argument needs to be either "input" or "output"');
|
|
|
return false;
|
|
|
- }
|
|
|
+ }
|
|
|
if (!$opData = $this->getOperationData($operation)) {
|
|
|
$this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
|
|
|
$this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
|
|
@@ -1227,18 +1227,18 @@ class wsdl extends nusoap_base {
|
|
|
}
|
|
|
$this->debug('opData:');
|
|
|
$this->appendDebug($this->varDump($opData));
|
|
|
-
|
|
|
+
|
|
|
// Get encoding style for output and set to current
|
|
|
$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
|
|
|
if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
|
|
|
$encodingStyle = $opData['output']['encodingStyle'];
|
|
|
$enc_style = $encodingStyle;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// set input params
|
|
|
$xml = '';
|
|
|
if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
|
|
|
-
|
|
|
+
|
|
|
$use = $opData[$direction]['use'];
|
|
|
$this->debug("use=$use");
|
|
|
$this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
|
|
@@ -1249,7 +1249,7 @@ class wsdl extends nusoap_base {
|
|
|
$this->debug('serializing part "'.$name.'" of type "'.$type.'"');
|
|
|
// Track encoding style
|
|
|
if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
|
|
|
- $encodingStyle = $opData[$direction]['encodingStyle'];
|
|
|
+ $encodingStyle = $opData[$direction]['encodingStyle'];
|
|
|
$enc_style = $encodingStyle;
|
|
|
} else {
|
|
|
$enc_style = false;
|
|
@@ -1275,11 +1275,11 @@ class wsdl extends nusoap_base {
|
|
|
}
|
|
|
$this->debug("serializeParameters returning: $xml");
|
|
|
return $xml;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* serializes a PHP value according a given type definition
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $name name of value (part or element)
|
|
|
* @param string $type XML schema type of value (type or element)
|
|
|
* @param mixed $value a native PHP value (parameter value)
|
|
@@ -1365,7 +1365,7 @@ class wsdl extends nusoap_base {
|
|
|
} else {
|
|
|
$value = 'true';
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
if ($uqType == 'string' && gettype($value) == 'string') {
|
|
|
$value = $this->expandEntities($value);
|
|
|
}
|
|
@@ -1446,7 +1446,7 @@ class wsdl extends nusoap_base {
|
|
|
return false;
|
|
|
}
|
|
|
$phpType = $typeDef['phpType'];
|
|
|
- $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
|
|
|
+ $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
|
|
|
// if php type == struct, map value to the <all> element names
|
|
|
if ($phpType == 'struct') {
|
|
|
if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
|
|
@@ -1538,22 +1538,22 @@ class wsdl extends nusoap_base {
|
|
|
foreach($value as $v) {
|
|
|
$cols = ',' . sizeof($v);
|
|
|
$nv = array_merge($nv, $v);
|
|
|
- }
|
|
|
+ }
|
|
|
$value = $nv;
|
|
|
} else {
|
|
|
$cols = '';
|
|
|
- }
|
|
|
+ }
|
|
|
if (is_array($value) && sizeof($value) >= 1) {
|
|
|
$rows = sizeof($value);
|
|
|
$contents = '';
|
|
|
foreach($value as $k => $v) {
|
|
|
- $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
|
|
|
+ //$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
|
|
|
//if (strpos($typeDef['arrayType'], ':') ) {
|
|
|
if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
|
|
|
$contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
|
|
|
} else {
|
|
|
$contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
$rows = 0;
|
|
@@ -1597,7 +1597,7 @@ class wsdl extends nusoap_base {
|
|
|
$this->debug("in serializeType: returning: $xml");
|
|
|
return $xml;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* serializes the attributes for a complexType
|
|
|
*
|
|
@@ -1652,7 +1652,7 @@ class wsdl extends nusoap_base {
|
|
|
if ($xname) {
|
|
|
$xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
} else {
|
|
|
$this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
|
|
|
}
|
|
@@ -1710,7 +1710,7 @@ class wsdl extends nusoap_base {
|
|
|
}
|
|
|
// if user took advantage of a minOccurs=0, then only serialize named parameters
|
|
|
if (isset($optionals)
|
|
|
- && (!isset($xvalue[$eName]))
|
|
|
+ && (!isset($xvalue[$eName]))
|
|
|
&& ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
|
|
|
){
|
|
|
if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
|
|
@@ -1758,7 +1758,7 @@ class wsdl extends nusoap_base {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
} else {
|
|
|
$this->debug("no elements to serialize for XML Schema type $ns:$uqType");
|
|
|
}
|
|
@@ -1794,7 +1794,7 @@ class wsdl extends nusoap_base {
|
|
|
}
|
|
|
$elements = $eElements;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (count($attrs) > 0) {
|
|
|
foreach($attrs as $n => $a){
|
|
|
// expand each attribute
|
|
@@ -1847,7 +1847,7 @@ class wsdl extends nusoap_base {
|
|
|
|
|
|
/**
|
|
|
* register an operation with the server
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $name operation (method) name
|
|
|
* @param array $in assoc array of input values: key = param name, value = param type
|
|
|
* @param array $out assoc array of output values: key = param name, value = param type
|
|
@@ -1857,7 +1857,7 @@ class wsdl extends nusoap_base {
|
|
|
* @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now)
|
|
|
* @param string $documentation optional The description to include in the WSDL
|
|
|
* @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
|
|
|
- * @access public
|
|
|
+ * @access public
|
|
|
*/
|
|
|
function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
|
|
|
if ($use == 'encoded' && $encodingStyle == '') {
|
|
@@ -1904,7 +1904,7 @@ class wsdl extends nusoap_base {
|
|
|
'parts' => $out),
|
|
|
'namespace' => $namespace,
|
|
|
'transport' => 'http://schemas.xmlsoap.org/soap/http',
|
|
|
- 'documentation' => $documentation);
|
|
|
+ 'documentation' => $documentation);
|
|
|
// add portTypes
|
|
|
// add messages
|
|
|
if($in)
|
|
@@ -1932,7 +1932,7 @@ class wsdl extends nusoap_base {
|
|
|
$this->messages[$name.'Response']= '0';
|
|
|
}
|
|
|
return true;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-?>
|
|
|
+?>
|