Completed
Pull Request — 1.11.x (#1679)
by José
102:46 queued 74:20
created
main/inc/lib/nusoap/class.nusoap_base.php 3 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	/**
307 307
 	* gets the current debug data for this instance
308 308
 	*
309
-	* @return   debug data
309
+	* @return   string data
310 310
 	* @access   public
311 311
 	*/
312 312
 	function &getDebug() {
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	* gets the current debug data for this instance as an XML comment
320 320
 	* this may change the contents of the debug data
321 321
 	*
322
-	* @return   debug data as an XML comment
322
+	* @return   string data as an XML comment
323 323
 	* @access   public
324 324
 	*/
325 325
 	function &getDebugAsXMLComment() {
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	/**
353 353
 	* returns error string if present
354 354
 	*
355
-	* @return   mixed error string or false
355
+	* @return   string|false error string or false
356 356
 	* @access   public
357 357
 	*/
358 358
 	function getError(){
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	/**
366 366
 	* sets error string
367 367
 	*
368
-	* @return   boolean $string error string
368
+	* @return   boolean|null $string error string
369 369
 	* @access   private
370 370
 	*/
371 371
 	function setError($str){
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
     * returns false, if not prefixed
802 802
     *
803 803
     * @param string $str The prefixed string
804
-    * @return mixed The prefix or false if there is no prefix
804
+    * @return string|false The prefix or false if there is no prefix
805 805
     * @access public
806 806
     */
807 807
 	function getPrefix($str){
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
     * or false if no prefixes registered for the given namespace
833 833
     *
834 834
     * @param string $ns The namespace
835
-    * @return mixed The prefix, false if the namespace has no prefixes
835
+    * @return string The prefix, false if the namespace has no prefixes
836 836
     * @access public
837 837
     */
838 838
 	function getPrefixFromNamespace($ns) {
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 *
899 899
 * @param    int $timestamp Unix time stamp
900 900
 * @param	boolean $utc Whether the time stamp is UTC or local
901
-* @return	mixed ISO 8601 date string or false
901
+* @return	string|false ISO 8601 date string or false
902 902
 * @access   public
903 903
 */
904 904
 function timestamp_to_iso8601($timestamp,$utc=true){
Please login to merge, or discard this patch.
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -183,26 +183,26 @@  discard block
 block discarded – undo
183 183
 	*/
184 184
 	var $typemap = array(
185 185
 	'http://www.w3.org/2001/XMLSchema' => array(
186
-		'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double',
187
-		'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'',
188
-		'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string',
186
+		'string'=>'string', 'boolean'=>'boolean', 'float'=>'double', 'double'=>'double', 'decimal'=>'double',
187
+		'duration'=>'', 'dateTime'=>'string', 'time'=>'string', 'date'=>'string', 'gYearMonth'=>'',
188
+		'gYear'=>'', 'gMonthDay'=>'', 'gDay'=>'', 'gMonth'=>'', 'hexBinary'=>'string', 'base64Binary'=>'string',
189 189
 		// abstract "any" types
190
-		'anyType'=>'string','anySimpleType'=>'string',
190
+		'anyType'=>'string', 'anySimpleType'=>'string',
191 191
 		// derived datatypes
192
-		'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'',
193
-		'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer',
194
-		'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer',
195
-		'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''),
192
+		'normalizedString'=>'string', 'token'=>'string', 'language'=>'', 'NMTOKEN'=>'', 'NMTOKENS'=>'', 'Name'=>'', 'NCName'=>'', 'ID'=>'',
193
+		'IDREF'=>'', 'IDREFS'=>'', 'ENTITY'=>'', 'ENTITIES'=>'', 'integer'=>'integer', 'nonPositiveInteger'=>'integer',
194
+		'negativeInteger'=>'integer', 'long'=>'integer', 'int'=>'integer', 'short'=>'integer', 'byte'=>'integer', 'nonNegativeInteger'=>'integer',
195
+		'unsignedLong'=>'', 'unsignedInt'=>'', 'unsignedShort'=>'', 'unsignedByte'=>'', 'positiveInteger'=>''),
196 196
 	'http://www.w3.org/2000/10/XMLSchema' => array(
197
-		'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
198
-		'float'=>'double','dateTime'=>'string',
199
-		'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
197
+		'i4'=>'', 'int'=>'integer', 'boolean'=>'boolean', 'string'=>'string', 'double'=>'double',
198
+		'float'=>'double', 'dateTime'=>'string',
199
+		'timeInstant'=>'string', 'base64Binary'=>'string', 'base64'=>'string', 'ur-type'=>'array'),
200 200
 	'http://www.w3.org/1999/XMLSchema' => array(
201
-		'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
202
-		'float'=>'double','dateTime'=>'string',
203
-		'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
201
+		'i4'=>'', 'int'=>'integer', 'boolean'=>'boolean', 'string'=>'string', 'double'=>'double',
202
+		'float'=>'double', 'dateTime'=>'string',
203
+		'timeInstant'=>'string', 'base64Binary'=>'string', 'base64'=>'string', 'ur-type'=>'array'),
204 204
 	'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
205
-	'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
205
+	'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string', 'array'=>'array', 'Array'=>'array'),
206 206
     'http://xml.apache.org/xml-soap' => array('Map')
207 207
 	);
208 208
 
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	* @deprecated
215 215
 	* @see	expandEntities
216 216
 	*/
217
-	var $xmlEntities = array('quot' => '"','amp' => '&',
218
-		'lt' => '<','gt' => '>','apos' => "'");
217
+	var $xmlEntities = array('quot' => '"', 'amp' => '&',
218
+		'lt' => '<', 'gt' => '>', 'apos' => "'");
219 219
 
220 220
 	/**
221 221
 	* constructor
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	* @param    string $string debug data
273 273
 	* @access   private
274 274
 	*/
275
-	function debug($string){
275
+	function debug($string) {
276 276
 		if ($this->debugLevel > 0) {
277 277
 			$this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n");
278 278
 		}
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	* @param    string $string debug data
285 285
 	* @access   public
286 286
 	*/
287
-	function appendDebug($string){
287
+	function appendDebug($string) {
288 288
 		if ($this->debugLevel > 0) {
289 289
 			// it would be nice to use a memory stream here to use
290 290
 			// memory more efficiently
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		while (strpos($this->debug_str, '--')) {
329 329
 			$this->debug_str = str_replace('--', '- -', $this->debug_str);
330 330
 		}
331
-		$ret = "<!--\n" . $this->debug_str . "\n-->";
331
+		$ret = "<!--\n".$this->debug_str."\n-->";
332 332
     	return $ret;
333 333
 	}
334 334
 
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 	* @return   mixed error string or false
356 356
 	* @access   public
357 357
 	*/
358
-	function getError(){
359
-		if($this->error_str != ''){
358
+	function getError() {
359
+		if ($this->error_str != '') {
360 360
 			return $this->error_str;
361 361
 		}
362 362
 		return false;
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	* @return   boolean $string error string
369 369
 	* @access   private
370 370
 	*/
371
-	function setError($str){
371
+	function setError($str) {
372 372
 		$this->error_str = $str;
373 373
 	}
374 374
 
@@ -404,12 +404,12 @@  discard block
 block discarded – undo
404 404
 	* @return	string	The serialized element, possibly with child elements
405 405
     * @access	public
406 406
 	*/
407
-	function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) {
407
+	function serialize_val($val, $name = false, $type = false, $name_ns = false, $type_ns = false, $attributes = false, $use = 'encoded', $soapval = false) {
408 408
 		$this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
409
-		$this->appendDebug('value=' . $this->varDump($val));
410
-		$this->appendDebug('attributes=' . $this->varDump($attributes));
409
+		$this->appendDebug('value='.$this->varDump($val));
410
+		$this->appendDebug('attributes='.$this->varDump($attributes));
411 411
 
412
-    	if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
412
+    	if (is_object($val) && get_class($val) == 'soapval' && (!$soapval)) {
413 413
     		$this->debug("serialize_val: serialize soapval");
414 414
         	$xml = $val->serialize($use);
415 415
 			$this->appendDebug($val->getDebug());
@@ -419,30 +419,30 @@  discard block
 block discarded – undo
419 419
         }
420 420
 		// force valid name if necessary
421 421
 		if (is_numeric($name)) {
422
-			$name = '__numeric_' . $name;
423
-		} elseif (! $name) {
422
+			$name = '__numeric_'.$name;
423
+		} elseif (!$name) {
424 424
 			$name = 'noname';
425 425
 		}
426 426
 		// if name has ns, add ns prefix to name
427 427
 		$xmlns = '';
428
-        if($name_ns){
429
-			$prefix = 'nu'.rand(1000,9999);
428
+        if ($name_ns) {
429
+			$prefix = 'nu'.rand(1000, 9999);
430 430
 			$name = $prefix.':'.$name;
431 431
 			$xmlns .= " xmlns:$prefix=\"$name_ns\"";
432 432
 		}
433 433
 		// if type is prefixed, create type prefix
434
-		if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
434
+		if ($type_ns != '' && $type_ns == $this->namespaces['xsd']) {
435 435
 			// need to fix this. shouldn't default to xsd if no ns specified
436 436
 		    // w/o checking against typemap
437 437
 			$type_prefix = 'xsd';
438
-		} elseif($type_ns){
439
-			$type_prefix = 'ns'.rand(1000,9999);
438
+		} elseif ($type_ns) {
439
+			$type_prefix = 'ns'.rand(1000, 9999);
440 440
 			$xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
441 441
 		}
442 442
 		// serialize attributes if present
443 443
 		$atts = '';
444
-		if($attributes){
445
-			foreach($attributes as $k => $v){
444
+		if ($attributes) {
445
+			foreach ($attributes as $k => $v) {
446 446
 				$atts .= " $k=\"".$this->expandEntities($v).'"';
447 447
 			}
448 448
 		}
@@ -466,12 +466,12 @@  discard block
 block discarded – undo
466 466
         	}
467 467
 		}
468 468
         // serialize if an xsd built-in primitive type
469
-        if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){
469
+        if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) {
470 470
     		$this->debug("serialize_val: serialize xsd built-in primitive type");
471 471
         	if (is_bool($val)) {
472 472
         		if ($type == 'boolean') {
473 473
 	        		$val = $val ? 'true' : 'false';
474
-	        	} elseif (! $val) {
474
+	        	} elseif (!$val) {
475 475
 	        		$val = 0;
476 476
 	        	}
477 477
 			} else if (is_string($val)) {
@@ -489,12 +489,12 @@  discard block
 block discarded – undo
489 489
         }
490 490
 		// detect type and serialize
491 491
 		$xml = '';
492
-		switch(true) {
492
+		switch (true) {
493 493
 			case (is_bool($val) || $type == 'boolean'):
494 494
 		   		$this->debug("serialize_val: serialize boolean");
495 495
         		if ($type == 'boolean') {
496 496
 	        		$val = $val ? 'true' : 'false';
497
-	        	} elseif (! $val) {
497
+	        	} elseif (!$val) {
498 498
 	        		$val = 0;
499 499
 	        	}
500 500
 				if ($use == 'literal') {
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 					$xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
512 512
 				}
513 513
 				break;
514
-			case (is_float($val)|| is_double($val) || $type == 'float'):
514
+			case (is_float($val) || is_double($val) || $type == 'float'):
515 515
 		   		$this->debug("serialize_val: serialize float");
516 516
 				if ($use == 'literal') {
517 517
 					$xml .= "<$name$xmlns$atts>$val</$name>";
@@ -536,17 +536,17 @@  discard block
 block discarded – undo
536 536
 					$this->appendDebug($val->getDebug());
537 537
 					$val->clearDebug();
538 538
 		        } else {
539
-					if (! $name) {
539
+					if (!$name) {
540 540
 						$name = get_class($val);
541 541
 						$this->debug("In serialize_val, used class name $name as element name");
542 542
 					} else {
543
-						$this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
543
+						$this->debug("In serialize_val, do not override name $name for element name for class ".get_class($val));
544 544
 					}
545
-					foreach(get_object_vars($val) as $k => $v){
546
-						$pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use);
545
+					foreach (get_object_vars($val) as $k => $v) {
546
+						$pXml = isset($pXml) ? $pXml.$this->serialize_val($v, $k, false, false, false, false, $use) : $this->serialize_val($v, $k, false, false, false, false, $use);
547 547
 					}
548 548
 				}
549
-				if(isset($type) && isset($type_prefix)){
549
+				if (isset($type) && isset($type_prefix)) {
550 550
 					$type_str = " xsi:type=\"$type_prefix:$type\"";
551 551
 				} else {
552 552
 					$type_str = '';
@@ -561,12 +561,12 @@  discard block
 block discarded – undo
561 561
 			case (is_array($val) || $type):
562 562
 				// detect if struct or array
563 563
 				$valueType = $this->isArraySimpleOrStruct($val);
564
-                if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){
564
+                if ($valueType == 'arraySimple' || preg_match('/^ArrayOf/', $type)) {
565 565
 			   		$this->debug("serialize_val: serialize array");
566 566
 					$i = 0;
567
-					if(is_array($val) && count($val)> 0){
568
-						foreach($val as $v){
569
-	                    	if(is_object($v) && get_class($v) ==  'soapval'){
567
+					if (is_array($val) && count($val) > 0) {
568
+						foreach ($val as $v) {
569
+	                    	if (is_object($v) && get_class($v) == 'soapval') {
570 570
 								$tt_ns = $v->type_ns;
571 571
 								$tt = $v->type;
572 572
 							} elseif (is_array($v)) {
@@ -576,26 +576,26 @@  discard block
 block discarded – undo
576 576
 	                        }
577 577
 							$array_types[$tt] = 1;
578 578
 							// TODO: for literal, the name should be $name
579
-							$xml .= $this->serialize_val($v,'item',false,false,false,false,$use);
579
+							$xml .= $this->serialize_val($v, 'item', false, false, false, false, $use);
580 580
 							++$i;
581 581
 						}
582
-						if(count($array_types) > 1){
582
+						if (count($array_types) > 1) {
583 583
 							$array_typename = 'xsd:anyType';
584
-						} elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
584
+						} elseif (isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
585 585
 							if ($tt == 'integer') {
586 586
 								$tt = 'int';
587 587
 							}
588 588
 							$array_typename = 'xsd:'.$tt;
589
-						} elseif(isset($tt) && $tt == 'arraySimple'){
589
+						} elseif (isset($tt) && $tt == 'arraySimple') {
590 590
 							$array_typename = 'SOAP-ENC:Array';
591
-						} elseif(isset($tt) && $tt == 'arrayStruct'){
591
+						} elseif (isset($tt) && $tt == 'arrayStruct') {
592 592
 							$array_typename = 'unnamed_struct_use_soapval';
593 593
 						} else {
594 594
 							// if type is prefixed, create type prefix
595
-							if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
596
-								 $array_typename = 'xsd:' . $tt;
595
+							if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']) {
596
+								 $array_typename = 'xsd:'.$tt;
597 597
 							} elseif ($tt_ns) {
598
-								$tt_prefix = 'ns' . rand(1000, 9999);
598
+								$tt_prefix = 'ns'.rand(1000, 9999);
599 599
 								$array_typename = "$tt_prefix:$tt";
600 600
 								$xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
601 601
 							} else {
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 				} else {
626 626
 					// got a struct
627 627
 			   		$this->debug("serialize_val: serialize struct");
628
-					if(isset($type) && isset($type_prefix)){
628
+					if (isset($type) && isset($type_prefix)) {
629 629
 						$type_str = " xsi:type=\"$type_prefix:$type\"";
630 630
 					} else {
631 631
 						$type_str = '';
@@ -635,15 +635,15 @@  discard block
 block discarded – undo
635 635
 					} else {
636 636
 						$xml .= "<$name$xmlns$type_str$atts>";
637 637
 					}
638
-					foreach($val as $k => $v){
638
+					foreach ($val as $k => $v) {
639 639
 						// Apache Map
640 640
 						if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
641 641
 							$xml .= '<item>';
642
-							$xml .= $this->serialize_val($k,'key',false,false,false,false,$use);
643
-							$xml .= $this->serialize_val($v,'value',false,false,false,false,$use);
642
+							$xml .= $this->serialize_val($k, 'key', false, false, false, false, $use);
643
+							$xml .= $this->serialize_val($v, 'value', false, false, false, false, $use);
644 644
 							$xml .= '</item>';
645 645
 						} else {
646
-							$xml .= $this->serialize_val($v,$k,false,false,false,false,$use);
646
+							$xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
647 647
 						}
648 648
 					}
649 649
 					$xml .= "</$name>";
@@ -670,12 +670,12 @@  discard block
 block discarded – undo
670 670
     * @return string the message
671 671
     * @access public
672 672
     */
673
-    function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){
673
+    function serializeEnvelope($body, $headers = false, $namespaces = array(), $style = 'rpc', $use = 'encoded', $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/') {
674 674
     // TODO: add an option to automatically run utf8_encode on $body and $headers
675 675
     // if $this->soap_defencoding is UTF-8.  Not doing this automatically allows
676 676
     // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1
677 677
 
678
-	$this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
678
+	$this->debug("In serializeEnvelope length=".strlen($body)." body (max 1000 characters)=".substr($body, 0, 1000)." style=$style use=$use encodingStyle=$encodingStyle");
679 679
 	$this->debug("headers:");
680 680
 	$this->appendDebug($this->varDump($headers));
681 681
 	$this->debug("namespaces:");
@@ -683,15 +683,15 @@  discard block
 block discarded – undo
683 683
 
684 684
 	// serialize namespaces
685 685
     $ns_string = '';
686
-	foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
686
+	foreach (array_merge($this->namespaces, $namespaces) as $k => $v) {
687 687
 		$ns_string .= " xmlns:$k=\"$v\"";
688 688
 	}
689
-	if($encodingStyle) {
689
+	if ($encodingStyle) {
690 690
 		$ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
691 691
 	}
692 692
 
693 693
 	// serialize headers
694
-	if($headers){
694
+	if ($headers) {
695 695
 		if (is_array($headers)) {
696 696
 			$xml = '';
697 697
 			foreach ($headers as $k => $v) {
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 	}
709 709
 	// serialize envelope
710 710
 	return
711
-	'<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">".
711
+	'<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?'.">".
712 712
 	'<SOAP-ENV:Envelope'.$ns_string.">".
713 713
 	$headers.
714 714
 	"<SOAP-ENV:Body>".
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 	 * @access public
726 726
 	 * @deprecated
727 727
 	 */
728
-    function formatDump($str){
728
+    function formatDump($str) {
729 729
 		$str = htmlspecialchars($str);
730 730
 		return nl2br($str);
731 731
     }
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 	* @return	string contracted qname
738 738
 	* @access   private
739 739
 	*/
740
-	function contractQname($qname){
740
+	function contractQname($qname) {
741 741
 		// get element namespace
742 742
 		//$this->xdebug("Contract $qname");
743 743
 		if (strrpos($qname, ':')) {
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 			$ns = substr($qname, 0, strrpos($qname, ':'));
748 748
 			$p = $this->getPrefixFromNamespace($ns);
749 749
 			if ($p) {
750
-				return $p . ':' . $name;
750
+				return $p.':'.$name;
751 751
 			}
752 752
 			return $qname;
753 753
 		} else {
@@ -762,14 +762,14 @@  discard block
 block discarded – undo
762 762
 	* @return	string expanded qname
763 763
 	* @access   private
764 764
 	*/
765
-	function expandQname($qname){
765
+	function expandQname($qname) {
766 766
 		// get element prefix
767
-		if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
767
+		if (strpos($qname, ':') && !preg_match('/^http:\/\//', $qname)) {
768 768
 			// get unqualified name
769
-			$name = substr(strstr($qname,':'),1);
769
+			$name = substr(strstr($qname, ':'), 1);
770 770
 			// get ns prefix
771
-			$prefix = substr($qname,0,strpos($qname,':'));
772
-			if(isset($this->namespaces[$prefix])){
771
+			$prefix = substr($qname, 0, strpos($qname, ':'));
772
+			if (isset($this->namespaces[$prefix])) {
773 773
 				return $this->namespaces[$prefix].':'.$name;
774 774
 			} else {
775 775
 				return $qname;
@@ -787,10 +787,10 @@  discard block
 block discarded – undo
787 787
     * @return string The local part
788 788
     * @access public
789 789
     */
790
-	function getLocalPart($str){
791
-		if($sstr = strrchr($str,':')){
790
+	function getLocalPart($str) {
791
+		if ($sstr = strrchr($str, ':')) {
792 792
 			// get unqualified name
793
-			return substr( $sstr, 1 );
793
+			return substr($sstr, 1);
794 794
 		} else {
795 795
 			return $str;
796 796
 		}
@@ -804,10 +804,10 @@  discard block
 block discarded – undo
804 804
     * @return mixed The prefix or false if there is no prefix
805 805
     * @access public
806 806
     */
807
-	function getPrefix($str){
808
-		if($pos = strrpos($str,':')){
807
+	function getPrefix($str) {
808
+		if ($pos = strrpos($str, ':')) {
809 809
 			// get prefix
810
-			return substr($str,0,$pos);
810
+			return substr($str, 0, $pos);
811 811
 		}
812 812
 		return false;
813 813
 	}
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
     * @return mixed The namespace, false if no namespace has the specified prefix
820 820
     * @access public
821 821
     */
822
-	function getNamespaceFromPrefix($prefix){
822
+	function getNamespaceFromPrefix($prefix) {
823 823
 		if (isset($this->namespaces[$prefix])) {
824 824
 			return $this->namespaces[$prefix];
825 825
 		}
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 			$sec = time();
861 861
 			$usec = 0;
862 862
 		}
863
-		return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
863
+		return strftime('%Y-%m-%d %H:%M:%S', $sec).'.'.sprintf('%06d', $usec);
864 864
 	}
865 865
 
866 866
 	/**
@@ -901,31 +901,31 @@  discard block
 block discarded – undo
901 901
 * @return	mixed ISO 8601 date string or false
902 902
 * @access   public
903 903
 */
904
-function timestamp_to_iso8601($timestamp,$utc=true){
905
-	$datestr = date('Y-m-d\TH:i:sO',$timestamp);
904
+function timestamp_to_iso8601($timestamp, $utc = true) {
905
+	$datestr = date('Y-m-d\TH:i:sO', $timestamp);
906 906
 	$pos = strrpos($datestr, "+");
907 907
 	if ($pos === FALSE) {
908 908
 		$pos = strrpos($datestr, "-");
909 909
 	}
910 910
 	if ($pos !== FALSE) {
911 911
 		if (strlen($datestr) == $pos + 5) {
912
-			$datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
912
+			$datestr = substr($datestr, 0, $pos + 3).':'.substr($datestr, -2);
913 913
 		}
914 914
 	}
915
-	if($utc){
915
+	if ($utc) {
916 916
 		$pattern = '/'.
917
-		'([0-9]{4})-'.	// centuries & years CCYY-
918
-		'([0-9]{2})-'.	// months MM-
919
-		'([0-9]{2})'.	// days DD
920
-		'T'.			// separator T
921
-		'([0-9]{2}):'.	// hours hh:
922
-		'([0-9]{2}):'.	// minutes mm:
923
-		'([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
924
-		'(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
917
+		'([0-9]{4})-'.// centuries & years CCYY-
918
+		'([0-9]{2})-'.// months MM-
919
+		'([0-9]{2})'.// days DD
920
+		'T'.// separator T
921
+		'([0-9]{2}):'.// hours hh:
922
+		'([0-9]{2}):'.// minutes mm:
923
+		'([0-9]{2})(\.[0-9]*)?'.// seconds ss.ss...
924
+		'(Z|[+\-][0-9]{2}:?[0-9]{2})?'.// Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
925 925
 		'/';
926 926
 
927
-		if(preg_match($pattern,$datestr,$regs)){
928
-			return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
927
+		if (preg_match($pattern, $datestr, $regs)) {
928
+			return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ', $regs[1], $regs[2], $regs[3], $regs[4], $regs[5], $regs[6]);
929 929
 		}
930 930
 		return false;
931 931
 	} else {
@@ -940,27 +940,27 @@  discard block
 block discarded – undo
940 940
 * @return	mixed Unix timestamp (int) or false
941 941
 * @access   public
942 942
 */
943
-function iso8601_to_timestamp($datestr){
943
+function iso8601_to_timestamp($datestr) {
944 944
 	$pattern = '/'.
945
-	'([0-9]{4})-'.	// centuries & years CCYY-
946
-	'([0-9]{2})-'.	// months MM-
947
-	'([0-9]{2})'.	// days DD
948
-	'T'.			// separator T
949
-	'([0-9]{2}):'.	// hours hh:
950
-	'([0-9]{2}):'.	// minutes mm:
951
-	'([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
952
-	'(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
945
+	'([0-9]{4})-'.// centuries & years CCYY-
946
+	'([0-9]{2})-'.// months MM-
947
+	'([0-9]{2})'.// days DD
948
+	'T'.// separator T
949
+	'([0-9]{2}):'.// hours hh:
950
+	'([0-9]{2}):'.// minutes mm:
951
+	'([0-9]{2})(\.[0-9]+)?'.// seconds ss.ss...
952
+	'(Z|[+\-][0-9]{2}:?[0-9]{2})?'.// Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
953 953
 	'/';
954
-	if(preg_match($pattern,$datestr,$regs)){
954
+	if (preg_match($pattern, $datestr, $regs)) {
955 955
 		// not utc
956
-		if($regs[8] != 'Z'){
957
-			$op = substr($regs[8],0,1);
958
-			$h = substr($regs[8],1,2);
959
-			$m = substr($regs[8],strlen($regs[8])-2,2);
960
-			if($op == '-'){
956
+		if ($regs[8] != 'Z') {
957
+			$op = substr($regs[8], 0, 1);
958
+			$h = substr($regs[8], 1, 2);
959
+			$m = substr($regs[8], strlen($regs[8]) - 2, 2);
960
+			if ($op == '-') {
961 961
 				$regs[4] = $regs[4] + $h;
962 962
 				$regs[5] = $regs[5] + $m;
963
-			} elseif($op == '+'){
963
+			} elseif ($op == '+') {
964 964
 				$regs[4] = $regs[4] - $h;
965 965
 				$regs[5] = $regs[5] - $m;
966 966
 			}
Please login to merge, or discard this patch.
Indentation   +845 added lines, -845 removed lines patch added patch discarded remove patch
@@ -84,810 +84,810 @@  discard block
 block discarded – undo
84 84
 */
85 85
 class nusoap_base
86 86
 {
87
-	/**
88
-	 * Identification for HTTP headers.
89
-	 *
90
-	 * @var string
91
-	 * @access private
92
-	 */
93
-	var $title = 'NuSOAP';
94
-	/**
95
-	 * Version for HTTP headers.
96
-	 *
97
-	 * @var string
98
-	 * @access private
99
-	 */
100
-	var $version = '0.9.5';
101
-	/**
102
-	 * CVS revision for HTTP headers.
103
-	 *
104
-	 * @var string
105
-	 * @access private
106
-	 */
107
-	var $revision = '$Revision: 1.56 $';
87
+    /**
88
+     * Identification for HTTP headers.
89
+     *
90
+     * @var string
91
+     * @access private
92
+     */
93
+    var $title = 'NuSOAP';
94
+    /**
95
+     * Version for HTTP headers.
96
+     *
97
+     * @var string
98
+     * @access private
99
+     */
100
+    var $version = '0.9.5';
101
+    /**
102
+     * CVS revision for HTTP headers.
103
+     *
104
+     * @var string
105
+     * @access private
106
+     */
107
+    var $revision = '$Revision: 1.56 $';
108 108
     /**
109 109
      * Current error string (manipulated by getError/setError)
110
-	 *
111
-	 * @var string
112
-	 * @access private
113
-	 */
114
-	var $error_str = '';
110
+     *
111
+     * @var string
112
+     * @access private
113
+     */
114
+    var $error_str = '';
115 115
     /**
116 116
      * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment)
117
-	 *
118
-	 * @var string
119
-	 * @access private
120
-	 */
117
+     *
118
+     * @var string
119
+     * @access private
120
+     */
121 121
     var $debug_str = '';
122 122
     /**
123
-	 * toggles automatic encoding of special characters as entities
124
-	 * (should always be true, I think)
125
-	 *
126
-	 * @var boolean
127
-	 * @access private
128
-	 */
129
-	var $charencoding = true;
130
-	/**
131
-	 * the debug level for this instance
132
-	 *
133
-	 * @var	integer
134
-	 * @access private
135
-	 */
136
-	var $debugLevel;
137
-
138
-    /**
139
-	* set schema version
140
-	*
141
-	* @var      string
142
-	* @access   public
143
-	*/
144
-	var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
145
-
146
-    /**
147
-	* charset encoding for outgoing messages
148
-	*
149
-	* @var      string
150
-	* @access   public
151
-	*/
123
+     * toggles automatic encoding of special characters as entities
124
+     * (should always be true, I think)
125
+     *
126
+     * @var boolean
127
+     * @access private
128
+     */
129
+    var $charencoding = true;
130
+    /**
131
+     * the debug level for this instance
132
+     *
133
+     * @var	integer
134
+     * @access private
135
+     */
136
+    var $debugLevel;
137
+
138
+    /**
139
+     * set schema version
140
+     *
141
+     * @var      string
142
+     * @access   public
143
+     */
144
+    var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
145
+
146
+    /**
147
+     * charset encoding for outgoing messages
148
+     *
149
+     * @var      string
150
+     * @access   public
151
+     */
152 152
     var $soap_defencoding = 'ISO-8859-1';
153
-	//var $soap_defencoding = 'UTF-8';
154
-
155
-	/**
156
-	* namespaces in an array of prefix => uri
157
-	*
158
-	* this is "seeded" by a set of constants, but it may be altered by code
159
-	*
160
-	* @var      array
161
-	* @access   public
162
-	*/
163
-	var $namespaces = array(
164
-		'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
165
-		'xsd' => 'http://www.w3.org/2001/XMLSchema',
166
-		'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
167
-		'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/'
168
-		);
169
-
170
-	/**
171
-	* namespaces used in the current context, e.g. during serialization
172
-	*
173
-	* @var      array
174
-	* @access   private
175
-	*/
176
-	var $usedNamespaces = array();
177
-
178
-	/**
179
-	* XML Schema types in an array of uri => (array of xml type => php type)
180
-	* is this legacy yet?
181
-	* no, this is used by the nusoap_xmlschema class to verify type => namespace mappings.
182
-	* @var      array
183
-	* @access   public
184
-	*/
185
-	var $typemap = array(
186
-	'http://www.w3.org/2001/XMLSchema' => array(
187
-		'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double',
188
-		'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'',
189
-		'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string',
190
-		// abstract "any" types
191
-		'anyType'=>'string','anySimpleType'=>'string',
192
-		// derived datatypes
193
-		'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'',
194
-		'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer',
195
-		'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer',
196
-		'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''),
197
-	'http://www.w3.org/2000/10/XMLSchema' => array(
198
-		'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
199
-		'float'=>'double','dateTime'=>'string',
200
-		'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
201
-	'http://www.w3.org/1999/XMLSchema' => array(
202
-		'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
203
-		'float'=>'double','dateTime'=>'string',
204
-		'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
205
-	'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
206
-	'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
153
+    //var $soap_defencoding = 'UTF-8';
154
+
155
+    /**
156
+     * namespaces in an array of prefix => uri
157
+     *
158
+     * this is "seeded" by a set of constants, but it may be altered by code
159
+     *
160
+     * @var      array
161
+     * @access   public
162
+     */
163
+    var $namespaces = array(
164
+        'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
165
+        'xsd' => 'http://www.w3.org/2001/XMLSchema',
166
+        'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
167
+        'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/'
168
+        );
169
+
170
+    /**
171
+     * namespaces used in the current context, e.g. during serialization
172
+     *
173
+     * @var      array
174
+     * @access   private
175
+     */
176
+    var $usedNamespaces = array();
177
+
178
+    /**
179
+     * XML Schema types in an array of uri => (array of xml type => php type)
180
+     * is this legacy yet?
181
+     * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings.
182
+     * @var      array
183
+     * @access   public
184
+     */
185
+    var $typemap = array(
186
+    'http://www.w3.org/2001/XMLSchema' => array(
187
+        'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double',
188
+        'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'',
189
+        'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string',
190
+        // abstract "any" types
191
+        'anyType'=>'string','anySimpleType'=>'string',
192
+        // derived datatypes
193
+        'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'',
194
+        'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer',
195
+        'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer',
196
+        'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''),
197
+    'http://www.w3.org/2000/10/XMLSchema' => array(
198
+        'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
199
+        'float'=>'double','dateTime'=>'string',
200
+        'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
201
+    'http://www.w3.org/1999/XMLSchema' => array(
202
+        'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
203
+        'float'=>'double','dateTime'=>'string',
204
+        'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
205
+    'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
206
+    'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
207 207
     'http://xml.apache.org/xml-soap' => array('Map')
208
-	);
209
-
210
-	/**
211
-	* XML entities to convert
212
-	*
213
-	* @var      array
214
-	* @access   public
215
-	* @deprecated
216
-	* @see	expandEntities
217
-	*/
218
-	var $xmlEntities = array('quot' => '"','amp' => '&',
219
-		'lt' => '<','gt' => '>','apos' => "'");
220
-
221
-	/**
222
-	* constructor
223
-	*
224
-	* @access	public
225
-	*/
226
-	public function __construct()
208
+    );
209
+
210
+    /**
211
+     * XML entities to convert
212
+     *
213
+     * @var      array
214
+     * @access   public
215
+     * @deprecated
216
+     * @see	expandEntities
217
+     */
218
+    var $xmlEntities = array('quot' => '"','amp' => '&',
219
+        'lt' => '<','gt' => '>','apos' => "'");
220
+
221
+    /**
222
+     * constructor
223
+     *
224
+     * @access	public
225
+     */
226
+    public function __construct()
227 227
     {
228
-		$this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
229
-	}
230
-
231
-	/**
232
-	* gets the global debug level, which applies to future instances
233
-	*
234
-	* @return	integer	Debug level 0-9, where 0 turns off
235
-	* @access	public
236
-	*/
237
-	function getGlobalDebugLevel() {
238
-		return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
239
-	}
240
-
241
-	/**
242
-	* sets the global debug level, which applies to future instances
243
-	*
244
-	* @param	int	$level	Debug level 0-9, where 0 turns off
245
-	* @access	public
246
-	*/
247
-	function setGlobalDebugLevel($level) {
248
-		$GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level;
249
-	}
250
-
251
-	/**
252
-	* gets the debug level for this instance
253
-	*
254
-	* @return	int	Debug level 0-9, where 0 turns off
255
-	* @access	public
256
-	*/
257
-	function getDebugLevel() {
258
-		return $this->debugLevel;
259
-	}
260
-
261
-	/**
262
-	* sets the debug level for this instance
263
-	*
264
-	* @param	int	$level	Debug level 0-9, where 0 turns off
265
-	* @access	public
266
-	*/
267
-	function setDebugLevel($level) {
268
-		$this->debugLevel = $level;
269
-	}
270
-
271
-	/**
272
-	* adds debug data to the instance debug string with formatting
273
-	*
274
-	* @param    string $string debug data
275
-	* @access   private
276
-	*/
277
-	function debug($string){
278
-		if ($this->debugLevel > 0) {
279
-			$this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n");
280
-		}
281
-	}
282
-
283
-	/**
284
-	* adds debug data to the instance debug string without formatting
285
-	*
286
-	* @param    string $string debug data
287
-	* @access   public
288
-	*/
289
-	function appendDebug($string){
290
-		if ($this->debugLevel > 0) {
291
-			// it would be nice to use a memory stream here to use
292
-			// memory more efficiently
293
-			$this->debug_str .= $string;
294
-		}
295
-	}
296
-
297
-	/**
298
-	* clears the current debug data for this instance
299
-	*
300
-	* @access   public
301
-	*/
302
-	function clearDebug() {
303
-		// it would be nice to use a memory stream here to use
304
-		// memory more efficiently
305
-		$this->debug_str = '';
306
-	}
307
-
308
-	/**
309
-	* gets the current debug data for this instance
310
-	*
311
-	* @return   debug data
312
-	* @access   public
313
-	*/
314
-	function &getDebug() {
315
-		// it would be nice to use a memory stream here to use
316
-		// memory more efficiently
317
-		return $this->debug_str;
318
-	}
319
-
320
-	/**
321
-	* gets the current debug data for this instance as an XML comment
322
-	* this may change the contents of the debug data
323
-	*
324
-	* @return   debug data as an XML comment
325
-	* @access   public
326
-	*/
327
-	function &getDebugAsXMLComment() {
328
-		// it would be nice to use a memory stream here to use
329
-		// memory more efficiently
330
-		while (strpos($this->debug_str, '--')) {
331
-			$this->debug_str = str_replace('--', '- -', $this->debug_str);
332
-		}
333
-		$ret = "<!--\n" . $this->debug_str . "\n-->";
334
-    	return $ret;
335
-	}
336
-
337
-	/**
338
-	* expands entities, e.g. changes '<' to '&lt;'.
339
-	*
340
-	* @param	string	$val	The string in which to expand entities.
341
-	* @access	private
342
-	*/
343
-	function expandEntities($val) {
344
-		if ($this->charencoding) {
345
-	    	$val = str_replace('&', '&amp;', $val);
346
-	    	$val = str_replace("'", '&apos;', $val);
347
-	    	$val = str_replace('"', '&quot;', $val);
348
-	    	$val = str_replace('<', '&lt;', $val);
349
-	    	$val = str_replace('>', '&gt;', $val);
350
-	    }
351
-	    return $val;
352
-	}
353
-
354
-	/**
355
-	* returns error string if present
356
-	*
357
-	* @return   mixed error string or false
358
-	* @access   public
359
-	*/
360
-	function getError(){
361
-		if($this->error_str != ''){
362
-			return $this->error_str;
363
-		}
364
-		return false;
365
-	}
366
-
367
-	/**
368
-	* sets error string
369
-	*
370
-	* @return   boolean $string error string
371
-	* @access   private
372
-	*/
373
-	function setError($str){
374
-		$this->error_str = $str;
375
-	}
376
-
377
-	/**
378
-	* detect if array is a simple array or a struct (associative array)
379
-	*
380
-	* @param	mixed	$val	The PHP array
381
-	* @return	string	(arraySimple|arrayStruct)
382
-	* @access	private
383
-	*/
384
-	function isArraySimpleOrStruct($val) {
228
+        $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
229
+    }
230
+
231
+    /**
232
+     * gets the global debug level, which applies to future instances
233
+     *
234
+     * @return	integer	Debug level 0-9, where 0 turns off
235
+     * @access	public
236
+     */
237
+    function getGlobalDebugLevel() {
238
+        return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
239
+    }
240
+
241
+    /**
242
+     * sets the global debug level, which applies to future instances
243
+     *
244
+     * @param	int	$level	Debug level 0-9, where 0 turns off
245
+     * @access	public
246
+     */
247
+    function setGlobalDebugLevel($level) {
248
+        $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level;
249
+    }
250
+
251
+    /**
252
+     * gets the debug level for this instance
253
+     *
254
+     * @return	int	Debug level 0-9, where 0 turns off
255
+     * @access	public
256
+     */
257
+    function getDebugLevel() {
258
+        return $this->debugLevel;
259
+    }
260
+
261
+    /**
262
+     * sets the debug level for this instance
263
+     *
264
+     * @param	int	$level	Debug level 0-9, where 0 turns off
265
+     * @access	public
266
+     */
267
+    function setDebugLevel($level) {
268
+        $this->debugLevel = $level;
269
+    }
270
+
271
+    /**
272
+     * adds debug data to the instance debug string with formatting
273
+     *
274
+     * @param    string $string debug data
275
+     * @access   private
276
+     */
277
+    function debug($string){
278
+        if ($this->debugLevel > 0) {
279
+            $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n");
280
+        }
281
+    }
282
+
283
+    /**
284
+     * adds debug data to the instance debug string without formatting
285
+     *
286
+     * @param    string $string debug data
287
+     * @access   public
288
+     */
289
+    function appendDebug($string){
290
+        if ($this->debugLevel > 0) {
291
+            // it would be nice to use a memory stream here to use
292
+            // memory more efficiently
293
+            $this->debug_str .= $string;
294
+        }
295
+    }
296
+
297
+    /**
298
+     * clears the current debug data for this instance
299
+     *
300
+     * @access   public
301
+     */
302
+    function clearDebug() {
303
+        // it would be nice to use a memory stream here to use
304
+        // memory more efficiently
305
+        $this->debug_str = '';
306
+    }
307
+
308
+    /**
309
+     * gets the current debug data for this instance
310
+     *
311
+     * @return   debug data
312
+     * @access   public
313
+     */
314
+    function &getDebug() {
315
+        // it would be nice to use a memory stream here to use
316
+        // memory more efficiently
317
+        return $this->debug_str;
318
+    }
319
+
320
+    /**
321
+     * gets the current debug data for this instance as an XML comment
322
+     * this may change the contents of the debug data
323
+     *
324
+     * @return   debug data as an XML comment
325
+     * @access   public
326
+     */
327
+    function &getDebugAsXMLComment() {
328
+        // it would be nice to use a memory stream here to use
329
+        // memory more efficiently
330
+        while (strpos($this->debug_str, '--')) {
331
+            $this->debug_str = str_replace('--', '- -', $this->debug_str);
332
+        }
333
+        $ret = "<!--\n" . $this->debug_str . "\n-->";
334
+        return $ret;
335
+    }
336
+
337
+    /**
338
+     * expands entities, e.g. changes '<' to '&lt;'.
339
+     *
340
+     * @param	string	$val	The string in which to expand entities.
341
+     * @access	private
342
+     */
343
+    function expandEntities($val) {
344
+        if ($this->charencoding) {
345
+            $val = str_replace('&', '&amp;', $val);
346
+            $val = str_replace("'", '&apos;', $val);
347
+            $val = str_replace('"', '&quot;', $val);
348
+            $val = str_replace('<', '&lt;', $val);
349
+            $val = str_replace('>', '&gt;', $val);
350
+        }
351
+        return $val;
352
+    }
353
+
354
+    /**
355
+     * returns error string if present
356
+     *
357
+     * @return   mixed error string or false
358
+     * @access   public
359
+     */
360
+    function getError(){
361
+        if($this->error_str != ''){
362
+            return $this->error_str;
363
+        }
364
+        return false;
365
+    }
366
+
367
+    /**
368
+     * sets error string
369
+     *
370
+     * @return   boolean $string error string
371
+     * @access   private
372
+     */
373
+    function setError($str){
374
+        $this->error_str = $str;
375
+    }
376
+
377
+    /**
378
+     * detect if array is a simple array or a struct (associative array)
379
+     *
380
+     * @param	mixed	$val	The PHP array
381
+     * @return	string	(arraySimple|arrayStruct)
382
+     * @access	private
383
+     */
384
+    function isArraySimpleOrStruct($val) {
385 385
         $keyList = array_keys($val);
386
-		foreach ($keyList as $keyListValue) {
387
-			if (!is_int($keyListValue)) {
388
-				return 'arrayStruct';
389
-			}
390
-		}
391
-		return 'arraySimple';
392
-	}
393
-
394
-	/**
395
-	* serializes PHP values in accordance w/ section 5. Type information is
396
-	* not serialized if $use == 'literal'.
397
-	*
398
-	* @param	mixed	$val	The value to serialize
399
-	* @param	string	$name	The name (local part) of the XML element
400
-	* @param	string	$type	The XML schema type (local part) for the element
401
-	* @param	string	$name_ns	The namespace for the name of the XML element
402
-	* @param	string	$type_ns	The namespace for the type of the element
403
-	* @param	array	$attributes	The attributes to serialize as name=>value pairs
404
-	* @param	string	$use	The WSDL "use" (encoded|literal)
405
-	* @param	boolean	$soapval	Whether this is called from soapval.
406
-	* @return	string	The serialized element, possibly with child elements
407
-    * @access	public
408
-	*/
409
-	function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) {
410
-		$this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
411
-		$this->appendDebug('value=' . $this->varDump($val));
412
-		$this->appendDebug('attributes=' . $this->varDump($attributes));
413
-
414
-    	if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
415
-    		$this->debug("serialize_val: serialize soapval");
416
-        	$xml = $val->serialize($use);
417
-			$this->appendDebug($val->getDebug());
418
-			$val->clearDebug();
419
-			$this->debug("serialize_val of soapval returning $xml");
420
-			return $xml;
386
+        foreach ($keyList as $keyListValue) {
387
+            if (!is_int($keyListValue)) {
388
+                return 'arrayStruct';
389
+            }
390
+        }
391
+        return 'arraySimple';
392
+    }
393
+
394
+    /**
395
+     * serializes PHP values in accordance w/ section 5. Type information is
396
+     * not serialized if $use == 'literal'.
397
+     *
398
+     * @param	mixed	$val	The value to serialize
399
+     * @param	string	$name	The name (local part) of the XML element
400
+     * @param	string	$type	The XML schema type (local part) for the element
401
+     * @param	string	$name_ns	The namespace for the name of the XML element
402
+     * @param	string	$type_ns	The namespace for the type of the element
403
+     * @param	array	$attributes	The attributes to serialize as name=>value pairs
404
+     * @param	string	$use	The WSDL "use" (encoded|literal)
405
+     * @param	boolean	$soapval	Whether this is called from soapval.
406
+     * @return	string	The serialized element, possibly with child elements
407
+     * @access	public
408
+     */
409
+    function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) {
410
+        $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
411
+        $this->appendDebug('value=' . $this->varDump($val));
412
+        $this->appendDebug('attributes=' . $this->varDump($attributes));
413
+
414
+        if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
415
+            $this->debug("serialize_val: serialize soapval");
416
+            $xml = $val->serialize($use);
417
+            $this->appendDebug($val->getDebug());
418
+            $val->clearDebug();
419
+            $this->debug("serialize_val of soapval returning $xml");
420
+            return $xml;
421 421
         }
422
-		// force valid name if necessary
423
-		if (is_numeric($name)) {
424
-			$name = '__numeric_' . $name;
425
-		} elseif (! $name) {
426
-			$name = 'noname';
427
-		}
428
-		// if name has ns, add ns prefix to name
429
-		$xmlns = '';
422
+        // force valid name if necessary
423
+        if (is_numeric($name)) {
424
+            $name = '__numeric_' . $name;
425
+        } elseif (! $name) {
426
+            $name = 'noname';
427
+        }
428
+        // if name has ns, add ns prefix to name
429
+        $xmlns = '';
430 430
         if($name_ns){
431
-			$prefix = 'nu'.rand(1000,9999);
432
-			$name = $prefix.':'.$name;
433
-			$xmlns .= " xmlns:$prefix=\"$name_ns\"";
434
-		}
435
-		// if type is prefixed, create type prefix
436
-		if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
437
-			// need to fix this. shouldn't default to xsd if no ns specified
438
-		    // w/o checking against typemap
439
-			$type_prefix = 'xsd';
440
-		} elseif($type_ns){
441
-			$type_prefix = 'ns'.rand(1000,9999);
442
-			$xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
443
-		}
444
-		// serialize attributes if present
445
-		$atts = '';
446
-		if($attributes){
447
-			foreach($attributes as $k => $v){
448
-				$atts .= " $k=\"".$this->expandEntities($v).'"';
449
-			}
450
-		}
451
-		// serialize null value
452
-		if (is_null($val)) {
453
-    		$this->debug("serialize_val: serialize null");
454
-			if ($use == 'literal') {
455
-				// TODO: depends on minOccurs
456
-				$xml = "<$name$xmlns$atts/>";
457
-				$this->debug("serialize_val returning $xml");
458
-	        	return $xml;
459
-        	} else {
460
-				if (isset($type) && isset($type_prefix)) {
461
-					$type_str = " xsi:type=\"$type_prefix:$type\"";
462
-				} else {
463
-					$type_str = '';
464
-				}
465
-				$xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
466
-				$this->debug("serialize_val returning $xml");
467
-	        	return $xml;
468
-        	}
469
-		}
431
+            $prefix = 'nu'.rand(1000,9999);
432
+            $name = $prefix.':'.$name;
433
+            $xmlns .= " xmlns:$prefix=\"$name_ns\"";
434
+        }
435
+        // if type is prefixed, create type prefix
436
+        if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
437
+            // need to fix this. shouldn't default to xsd if no ns specified
438
+            // w/o checking against typemap
439
+            $type_prefix = 'xsd';
440
+        } elseif($type_ns){
441
+            $type_prefix = 'ns'.rand(1000,9999);
442
+            $xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
443
+        }
444
+        // serialize attributes if present
445
+        $atts = '';
446
+        if($attributes){
447
+            foreach($attributes as $k => $v){
448
+                $atts .= " $k=\"".$this->expandEntities($v).'"';
449
+            }
450
+        }
451
+        // serialize null value
452
+        if (is_null($val)) {
453
+            $this->debug("serialize_val: serialize null");
454
+            if ($use == 'literal') {
455
+                // TODO: depends on minOccurs
456
+                $xml = "<$name$xmlns$atts/>";
457
+                $this->debug("serialize_val returning $xml");
458
+                return $xml;
459
+            } else {
460
+                if (isset($type) && isset($type_prefix)) {
461
+                    $type_str = " xsi:type=\"$type_prefix:$type\"";
462
+                } else {
463
+                    $type_str = '';
464
+                }
465
+                $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
466
+                $this->debug("serialize_val returning $xml");
467
+                return $xml;
468
+            }
469
+        }
470 470
         // serialize if an xsd built-in primitive type
471 471
         if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){
472
-    		$this->debug("serialize_val: serialize xsd built-in primitive type");
473
-        	if (is_bool($val)) {
474
-        		if ($type == 'boolean') {
475
-	        		$val = $val ? 'true' : 'false';
476
-	        	} elseif (! $val) {
477
-	        		$val = 0;
478
-	        	}
479
-			} else if (is_string($val)) {
480
-				$val = $this->expandEntities($val);
481
-			}
482
-			if ($use == 'literal') {
483
-				$xml = "<$name$xmlns$atts>$val</$name>";
484
-				$this->debug("serialize_val returning $xml");
485
-	        	return $xml;
486
-        	} else {
487
-				$xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
488
-				$this->debug("serialize_val returning $xml");
489
-	        	return $xml;
490
-        	}
472
+            $this->debug("serialize_val: serialize xsd built-in primitive type");
473
+            if (is_bool($val)) {
474
+                if ($type == 'boolean') {
475
+                    $val = $val ? 'true' : 'false';
476
+                } elseif (! $val) {
477
+                    $val = 0;
478
+                }
479
+            } else if (is_string($val)) {
480
+                $val = $this->expandEntities($val);
481
+            }
482
+            if ($use == 'literal') {
483
+                $xml = "<$name$xmlns$atts>$val</$name>";
484
+                $this->debug("serialize_val returning $xml");
485
+                return $xml;
486
+            } else {
487
+                $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
488
+                $this->debug("serialize_val returning $xml");
489
+                return $xml;
490
+            }
491 491
         }
492
-		// detect type and serialize
493
-		$xml = '';
494
-		switch(true) {
495
-			case (is_bool($val) || $type == 'boolean'):
496
-		   		$this->debug("serialize_val: serialize boolean");
497
-        		if ($type == 'boolean') {
498
-	        		$val = $val ? 'true' : 'false';
499
-	        	} elseif (! $val) {
500
-	        		$val = 0;
501
-	        	}
502
-				if ($use == 'literal') {
503
-					$xml .= "<$name$xmlns$atts>$val</$name>";
504
-				} else {
505
-					$xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
506
-				}
507
-				break;
508
-			case (is_int($val) || is_long($val) || $type == 'int'):
509
-		   		$this->debug("serialize_val: serialize int");
510
-				if ($use == 'literal') {
511
-					$xml .= "<$name$xmlns$atts>$val</$name>";
512
-				} else {
513
-					$xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
514
-				}
515
-				break;
516
-			case (is_float($val)|| is_double($val) || $type == 'float'):
517
-		   		$this->debug("serialize_val: serialize float");
518
-				if ($use == 'literal') {
519
-					$xml .= "<$name$xmlns$atts>$val</$name>";
520
-				} else {
521
-					$xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
522
-				}
523
-				break;
524
-			case (is_string($val) || $type == 'string'):
525
-		   		$this->debug("serialize_val: serialize string");
526
-				$val = $this->expandEntities($val);
527
-				if ($use == 'literal') {
528
-					$xml .= "<$name$xmlns$atts>$val</$name>";
529
-				} else {
530
-					$xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
531
-				}
532
-				break;
533
-			case is_object($val):
534
-		   		$this->debug("serialize_val: serialize object");
535
-		    	if (get_class($val) == 'soapval') {
536
-		    		$this->debug("serialize_val: serialize soapval object");
537
-		        	$pXml = $val->serialize($use);
538
-					$this->appendDebug($val->getDebug());
539
-					$val->clearDebug();
540
-		        } else {
541
-					if (! $name) {
542
-						$name = get_class($val);
543
-						$this->debug("In serialize_val, used class name $name as element name");
544
-					} else {
545
-						$this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
546
-					}
547
-					foreach(get_object_vars($val) as $k => $v){
548
-						$pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use);
549
-					}
550
-				}
551
-				if(isset($type) && isset($type_prefix)){
552
-					$type_str = " xsi:type=\"$type_prefix:$type\"";
553
-				} else {
554
-					$type_str = '';
555
-				}
556
-				if ($use == 'literal') {
557
-					$xml .= "<$name$xmlns$atts>$pXml</$name>";
558
-				} else {
559
-					$xml .= "<$name$xmlns$type_str$atts>$pXml</$name>";
560
-				}
561
-				break;
562
-			case (is_array($val) || $type):
563
-				// detect if struct or array
564
-				$valueType = $this->isArraySimpleOrStruct($val);
492
+        // detect type and serialize
493
+        $xml = '';
494
+        switch(true) {
495
+            case (is_bool($val) || $type == 'boolean'):
496
+                   $this->debug("serialize_val: serialize boolean");
497
+                if ($type == 'boolean') {
498
+                    $val = $val ? 'true' : 'false';
499
+                } elseif (! $val) {
500
+                    $val = 0;
501
+                }
502
+                if ($use == 'literal') {
503
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
504
+                } else {
505
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
506
+                }
507
+                break;
508
+            case (is_int($val) || is_long($val) || $type == 'int'):
509
+                   $this->debug("serialize_val: serialize int");
510
+                if ($use == 'literal') {
511
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
512
+                } else {
513
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
514
+                }
515
+                break;
516
+            case (is_float($val)|| is_double($val) || $type == 'float'):
517
+                   $this->debug("serialize_val: serialize float");
518
+                if ($use == 'literal') {
519
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
520
+                } else {
521
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
522
+                }
523
+                break;
524
+            case (is_string($val) || $type == 'string'):
525
+                   $this->debug("serialize_val: serialize string");
526
+                $val = $this->expandEntities($val);
527
+                if ($use == 'literal') {
528
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
529
+                } else {
530
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
531
+                }
532
+                break;
533
+            case is_object($val):
534
+                   $this->debug("serialize_val: serialize object");
535
+                if (get_class($val) == 'soapval') {
536
+                    $this->debug("serialize_val: serialize soapval object");
537
+                    $pXml = $val->serialize($use);
538
+                    $this->appendDebug($val->getDebug());
539
+                    $val->clearDebug();
540
+                } else {
541
+                    if (! $name) {
542
+                        $name = get_class($val);
543
+                        $this->debug("In serialize_val, used class name $name as element name");
544
+                    } else {
545
+                        $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
546
+                    }
547
+                    foreach(get_object_vars($val) as $k => $v){
548
+                        $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use);
549
+                    }
550
+                }
551
+                if(isset($type) && isset($type_prefix)){
552
+                    $type_str = " xsi:type=\"$type_prefix:$type\"";
553
+                } else {
554
+                    $type_str = '';
555
+                }
556
+                if ($use == 'literal') {
557
+                    $xml .= "<$name$xmlns$atts>$pXml</$name>";
558
+                } else {
559
+                    $xml .= "<$name$xmlns$type_str$atts>$pXml</$name>";
560
+                }
561
+                break;
562
+            case (is_array($val) || $type):
563
+                // detect if struct or array
564
+                $valueType = $this->isArraySimpleOrStruct($val);
565 565
                 if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){
566
-			   		$this->debug("serialize_val: serialize array");
567
-					$i = 0;
568
-					if(is_array($val) && count($val)> 0){
569
-						foreach($val as $v){
570
-	                    	if(is_object($v) && get_class($v) ==  'soapval'){
571
-								$tt_ns = $v->type_ns;
572
-								$tt = $v->type;
573
-							} elseif (is_array($v)) {
574
-								$tt = $this->isArraySimpleOrStruct($v);
575
-							} else {
576
-								$tt = gettype($v);
577
-	                        }
578
-							$array_types[$tt] = 1;
579
-							// TODO: for literal, the name should be $name
580
-							$xml .= $this->serialize_val($v,'item',false,false,false,false,$use);
581
-							++$i;
582
-						}
583
-						if(count($array_types) > 1){
584
-							$array_typename = 'xsd:anyType';
585
-						} elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
586
-							if ($tt == 'integer') {
587
-								$tt = 'int';
588
-							}
589
-							$array_typename = 'xsd:'.$tt;
590
-						} elseif(isset($tt) && $tt == 'arraySimple'){
591
-							$array_typename = 'SOAP-ENC:Array';
592
-						} elseif(isset($tt) && $tt == 'arrayStruct'){
593
-							$array_typename = 'unnamed_struct_use_soapval';
594
-						} else {
595
-							// if type is prefixed, create type prefix
596
-							if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
597
-								 $array_typename = 'xsd:' . $tt;
598
-							} elseif ($tt_ns) {
599
-								$tt_prefix = 'ns' . rand(1000, 9999);
600
-								$array_typename = "$tt_prefix:$tt";
601
-								$xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
602
-							} else {
603
-								$array_typename = $tt;
604
-							}
605
-						}
606
-						$array_type = $i;
607
-						if ($use == 'literal') {
608
-							$type_str = '';
609
-						} else if (isset($type) && isset($type_prefix)) {
610
-							$type_str = " xsi:type=\"$type_prefix:$type\"";
611
-						} else {
612
-							$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\"";
613
-						}
614
-					// empty array
615
-					} else {
616
-						if ($use == 'literal') {
617
-							$type_str = '';
618
-						} else if (isset($type) && isset($type_prefix)) {
619
-							$type_str = " xsi:type=\"$type_prefix:$type\"";
620
-						} else {
621
-							$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
622
-						}
623
-					}
624
-					// TODO: for array in literal, there is no wrapper here
625
-					$xml = "<$name$xmlns$type_str$atts>".$xml."</$name>";
626
-				} else {
627
-					// got a struct
628
-			   		$this->debug("serialize_val: serialize struct");
629
-					if(isset($type) && isset($type_prefix)){
630
-						$type_str = " xsi:type=\"$type_prefix:$type\"";
631
-					} else {
632
-						$type_str = '';
633
-					}
634
-					if ($use == 'literal') {
635
-						$xml .= "<$name$xmlns$atts>";
636
-					} else {
637
-						$xml .= "<$name$xmlns$type_str$atts>";
638
-					}
639
-					foreach($val as $k => $v){
640
-						// Apache Map
641
-						if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
642
-							$xml .= '<item>';
643
-							$xml .= $this->serialize_val($k,'key',false,false,false,false,$use);
644
-							$xml .= $this->serialize_val($v,'value',false,false,false,false,$use);
645
-							$xml .= '</item>';
646
-						} else {
647
-							$xml .= $this->serialize_val($v,$k,false,false,false,false,$use);
648
-						}
649
-					}
650
-					$xml .= "</$name>";
651
-				}
652
-				break;
653
-			default:
654
-		   		$this->debug("serialize_val: serialize unknown");
655
-				$xml .= 'not detected, got '.gettype($val).' for '.$val;
656
-				break;
657
-		}
658
-		$this->debug("serialize_val returning $xml");
659
-		return $xml;
660
-	}
661
-
662
-    /**
663
-    * serializes a message
664
-    *
665
-    * @param string $body the XML of the SOAP body
666
-    * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
667
-    * @param array $namespaces optional the namespaces used in generating the body and headers
668
-    * @param string $style optional (rpc|document)
669
-    * @param string $use optional (encoded|literal)
670
-    * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
671
-    * @return string the message
672
-    * @access public
673
-    */
566
+                        $this->debug("serialize_val: serialize array");
567
+                    $i = 0;
568
+                    if(is_array($val) && count($val)> 0){
569
+                        foreach($val as $v){
570
+                            if(is_object($v) && get_class($v) ==  'soapval'){
571
+                                $tt_ns = $v->type_ns;
572
+                                $tt = $v->type;
573
+                            } elseif (is_array($v)) {
574
+                                $tt = $this->isArraySimpleOrStruct($v);
575
+                            } else {
576
+                                $tt = gettype($v);
577
+                            }
578
+                            $array_types[$tt] = 1;
579
+                            // TODO: for literal, the name should be $name
580
+                            $xml .= $this->serialize_val($v,'item',false,false,false,false,$use);
581
+                            ++$i;
582
+                        }
583
+                        if(count($array_types) > 1){
584
+                            $array_typename = 'xsd:anyType';
585
+                        } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
586
+                            if ($tt == 'integer') {
587
+                                $tt = 'int';
588
+                            }
589
+                            $array_typename = 'xsd:'.$tt;
590
+                        } elseif(isset($tt) && $tt == 'arraySimple'){
591
+                            $array_typename = 'SOAP-ENC:Array';
592
+                        } elseif(isset($tt) && $tt == 'arrayStruct'){
593
+                            $array_typename = 'unnamed_struct_use_soapval';
594
+                        } else {
595
+                            // if type is prefixed, create type prefix
596
+                            if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
597
+                                    $array_typename = 'xsd:' . $tt;
598
+                            } elseif ($tt_ns) {
599
+                                $tt_prefix = 'ns' . rand(1000, 9999);
600
+                                $array_typename = "$tt_prefix:$tt";
601
+                                $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
602
+                            } else {
603
+                                $array_typename = $tt;
604
+                            }
605
+                        }
606
+                        $array_type = $i;
607
+                        if ($use == 'literal') {
608
+                            $type_str = '';
609
+                        } else if (isset($type) && isset($type_prefix)) {
610
+                            $type_str = " xsi:type=\"$type_prefix:$type\"";
611
+                        } else {
612
+                            $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\"";
613
+                        }
614
+                    // empty array
615
+                    } else {
616
+                        if ($use == 'literal') {
617
+                            $type_str = '';
618
+                        } else if (isset($type) && isset($type_prefix)) {
619
+                            $type_str = " xsi:type=\"$type_prefix:$type\"";
620
+                        } else {
621
+                            $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
622
+                        }
623
+                    }
624
+                    // TODO: for array in literal, there is no wrapper here
625
+                    $xml = "<$name$xmlns$type_str$atts>".$xml."</$name>";
626
+                } else {
627
+                    // got a struct
628
+                        $this->debug("serialize_val: serialize struct");
629
+                    if(isset($type) && isset($type_prefix)){
630
+                        $type_str = " xsi:type=\"$type_prefix:$type\"";
631
+                    } else {
632
+                        $type_str = '';
633
+                    }
634
+                    if ($use == 'literal') {
635
+                        $xml .= "<$name$xmlns$atts>";
636
+                    } else {
637
+                        $xml .= "<$name$xmlns$type_str$atts>";
638
+                    }
639
+                    foreach($val as $k => $v){
640
+                        // Apache Map
641
+                        if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
642
+                            $xml .= '<item>';
643
+                            $xml .= $this->serialize_val($k,'key',false,false,false,false,$use);
644
+                            $xml .= $this->serialize_val($v,'value',false,false,false,false,$use);
645
+                            $xml .= '</item>';
646
+                        } else {
647
+                            $xml .= $this->serialize_val($v,$k,false,false,false,false,$use);
648
+                        }
649
+                    }
650
+                    $xml .= "</$name>";
651
+                }
652
+                break;
653
+            default:
654
+                   $this->debug("serialize_val: serialize unknown");
655
+                $xml .= 'not detected, got '.gettype($val).' for '.$val;
656
+                break;
657
+        }
658
+        $this->debug("serialize_val returning $xml");
659
+        return $xml;
660
+    }
661
+
662
+    /**
663
+     * serializes a message
664
+     *
665
+     * @param string $body the XML of the SOAP body
666
+     * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
667
+     * @param array $namespaces optional the namespaces used in generating the body and headers
668
+     * @param string $style optional (rpc|document)
669
+     * @param string $use optional (encoded|literal)
670
+     * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
671
+     * @return string the message
672
+     * @access public
673
+     */
674 674
     function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){
675 675
     // TODO: add an option to automatically run utf8_encode on $body and $headers
676 676
     // if $this->soap_defencoding is UTF-8.  Not doing this automatically allows
677 677
     // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1
678 678
 
679
-	$this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
680
-	$this->debug("headers:");
681
-	$this->appendDebug($this->varDump($headers));
682
-	$this->debug("namespaces:");
683
-	$this->appendDebug($this->varDump($namespaces));
679
+    $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
680
+    $this->debug("headers:");
681
+    $this->appendDebug($this->varDump($headers));
682
+    $this->debug("namespaces:");
683
+    $this->appendDebug($this->varDump($namespaces));
684 684
 
685
-	// serialize namespaces
685
+    // serialize namespaces
686 686
     $ns_string = '';
687
-	foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
688
-		$ns_string .= " xmlns:$k=\"$v\"";
689
-	}
690
-	if($encodingStyle) {
691
-		$ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
692
-	}
693
-
694
-	// serialize headers
695
-	if($headers){
696
-		if (is_array($headers)) {
697
-			$xml = '';
698
-			foreach ($headers as $k => $v) {
699
-				if (is_object($v) && get_class($v) == 'soapval') {
700
-					$xml .= $this->serialize_val($v, false, false, false, false, false, $use);
701
-				} else {
702
-					$xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
703
-				}
704
-			}
705
-			$headers = $xml;
706
-			$this->debug("In serializeEnvelope, serialized array of headers to $headers");
707
-		}
708
-		$headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>";
709
-	}
710
-	// serialize envelope
711
-	return
712
-	'<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">".
713
-	'<SOAP-ENV:Envelope'.$ns_string.">".
714
-	$headers.
715
-	"<SOAP-ENV:Body>".
716
-		$body.
717
-	"</SOAP-ENV:Body>".
718
-	"</SOAP-ENV:Envelope>";
719
-    }
720
-
721
-	/**
722
-	 * formats a string to be inserted into an HTML stream
723
-	 *
724
-	 * @param string $str The string to format
725
-	 * @return string The formatted string
726
-	 * @access public
727
-	 * @deprecated
728
-	 */
687
+    foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
688
+        $ns_string .= " xmlns:$k=\"$v\"";
689
+    }
690
+    if($encodingStyle) {
691
+        $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
692
+    }
693
+
694
+    // serialize headers
695
+    if($headers){
696
+        if (is_array($headers)) {
697
+            $xml = '';
698
+            foreach ($headers as $k => $v) {
699
+                if (is_object($v) && get_class($v) == 'soapval') {
700
+                    $xml .= $this->serialize_val($v, false, false, false, false, false, $use);
701
+                } else {
702
+                    $xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
703
+                }
704
+            }
705
+            $headers = $xml;
706
+            $this->debug("In serializeEnvelope, serialized array of headers to $headers");
707
+        }
708
+        $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>";
709
+    }
710
+    // serialize envelope
711
+    return
712
+    '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">".
713
+    '<SOAP-ENV:Envelope'.$ns_string.">".
714
+    $headers.
715
+    "<SOAP-ENV:Body>".
716
+        $body.
717
+    "</SOAP-ENV:Body>".
718
+    "</SOAP-ENV:Envelope>";
719
+    }
720
+
721
+    /**
722
+     * formats a string to be inserted into an HTML stream
723
+     *
724
+     * @param string $str The string to format
725
+     * @return string The formatted string
726
+     * @access public
727
+     * @deprecated
728
+     */
729 729
     function formatDump($str){
730
-		$str = htmlspecialchars($str);
731
-		return nl2br($str);
732
-    }
733
-
734
-	/**
735
-	* contracts (changes namespace to prefix) a qualified name
736
-	*
737
-	* @param    string $qname qname
738
-	* @return	string contracted qname
739
-	* @access   private
740
-	*/
741
-	function contractQname($qname){
742
-		// get element namespace
743
-		//$this->xdebug("Contract $qname");
744
-		if (strrpos($qname, ':')) {
745
-			// get unqualified name
746
-			$name = substr($qname, strrpos($qname, ':') + 1);
747
-			// get ns
748
-			$ns = substr($qname, 0, strrpos($qname, ':'));
749
-			$p = $this->getPrefixFromNamespace($ns);
750
-			if ($p) {
751
-				return $p . ':' . $name;
752
-			}
753
-			return $qname;
754
-		} else {
755
-			return $qname;
756
-		}
757
-	}
758
-
759
-	/**
760
-	* expands (changes prefix to namespace) a qualified name
761
-	*
762
-	* @param    string $qname qname
763
-	* @return	string expanded qname
764
-	* @access   private
765
-	*/
766
-	function expandQname($qname){
767
-		// get element prefix
768
-		if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
769
-			// get unqualified name
770
-			$name = substr(strstr($qname,':'),1);
771
-			// get ns prefix
772
-			$prefix = substr($qname,0,strpos($qname,':'));
773
-			if(isset($this->namespaces[$prefix])){
774
-				return $this->namespaces[$prefix].':'.$name;
775
-			} else {
776
-				return $qname;
777
-			}
778
-		} else {
779
-			return $qname;
780
-		}
781
-	}
782
-
783
-    /**
784
-    * returns the local part of a prefixed string
785
-    * returns the original string, if not prefixed
786
-    *
787
-    * @param string $str The prefixed string
788
-    * @return string The local part
789
-    * @access public
790
-    */
791
-	function getLocalPart($str){
792
-		if($sstr = strrchr($str,':')){
793
-			// get unqualified name
794
-			return substr( $sstr, 1 );
795
-		} else {
796
-			return $str;
797
-		}
798
-	}
799
-
800
-	/**
801
-    * returns the prefix part of a prefixed string
802
-    * returns false, if not prefixed
803
-    *
804
-    * @param string $str The prefixed string
805
-    * @return mixed The prefix or false if there is no prefix
806
-    * @access public
807
-    */
808
-	function getPrefix($str){
809
-		if($pos = strrpos($str,':')){
810
-			// get prefix
811
-			return substr($str,0,$pos);
812
-		}
813
-		return false;
814
-	}
815
-
816
-	/**
817
-    * pass it a prefix, it returns a namespace
818
-    *
819
-    * @param string $prefix The prefix
820
-    * @return mixed The namespace, false if no namespace has the specified prefix
821
-    * @access public
822
-    */
823
-	function getNamespaceFromPrefix($prefix){
824
-		if (isset($this->namespaces[$prefix])) {
825
-			return $this->namespaces[$prefix];
826
-		}
827
-		//$this->setError("No namespace registered for prefix '$prefix'");
828
-		return false;
829
-	}
830
-
831
-	/**
832
-    * returns the prefix for a given namespace (or prefix)
833
-    * or false if no prefixes registered for the given namespace
834
-    *
835
-    * @param string $ns The namespace
836
-    * @return mixed The prefix, false if the namespace has no prefixes
837
-    * @access public
838
-    */
839
-	function getPrefixFromNamespace($ns) {
840
-		foreach ($this->namespaces as $p => $n) {
841
-			if ($ns == $n || $ns == $p) {
842
-			    $this->usedNamespaces[$p] = $n;
843
-				return $p;
844
-			}
845
-		}
846
-		return false;
847
-	}
848
-
849
-	/**
850
-    * returns the time in ODBC canonical form with microseconds
851
-    *
852
-    * @return string The time in ODBC canonical form with microseconds
853
-    * @access public
854
-    */
855
-	function getmicrotime() {
856
-		if (function_exists('gettimeofday')) {
857
-			$tod = gettimeofday();
858
-			$sec = $tod['sec'];
859
-			$usec = $tod['usec'];
860
-		} else {
861
-			$sec = time();
862
-			$usec = 0;
863
-		}
864
-		return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
865
-	}
866
-
867
-	/**
868
-	 * Returns a string with the output of var_dump
869
-	 *
870
-	 * @param mixed $data The variable to var_dump
871
-	 * @return string The output of var_dump
872
-	 * @access public
873
-	 */
730
+        $str = htmlspecialchars($str);
731
+        return nl2br($str);
732
+    }
733
+
734
+    /**
735
+     * contracts (changes namespace to prefix) a qualified name
736
+     *
737
+     * @param    string $qname qname
738
+     * @return	string contracted qname
739
+     * @access   private
740
+     */
741
+    function contractQname($qname){
742
+        // get element namespace
743
+        //$this->xdebug("Contract $qname");
744
+        if (strrpos($qname, ':')) {
745
+            // get unqualified name
746
+            $name = substr($qname, strrpos($qname, ':') + 1);
747
+            // get ns
748
+            $ns = substr($qname, 0, strrpos($qname, ':'));
749
+            $p = $this->getPrefixFromNamespace($ns);
750
+            if ($p) {
751
+                return $p . ':' . $name;
752
+            }
753
+            return $qname;
754
+        } else {
755
+            return $qname;
756
+        }
757
+    }
758
+
759
+    /**
760
+     * expands (changes prefix to namespace) a qualified name
761
+     *
762
+     * @param    string $qname qname
763
+     * @return	string expanded qname
764
+     * @access   private
765
+     */
766
+    function expandQname($qname){
767
+        // get element prefix
768
+        if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
769
+            // get unqualified name
770
+            $name = substr(strstr($qname,':'),1);
771
+            // get ns prefix
772
+            $prefix = substr($qname,0,strpos($qname,':'));
773
+            if(isset($this->namespaces[$prefix])){
774
+                return $this->namespaces[$prefix].':'.$name;
775
+            } else {
776
+                return $qname;
777
+            }
778
+        } else {
779
+            return $qname;
780
+        }
781
+    }
782
+
783
+    /**
784
+     * returns the local part of a prefixed string
785
+     * returns the original string, if not prefixed
786
+     *
787
+     * @param string $str The prefixed string
788
+     * @return string The local part
789
+     * @access public
790
+     */
791
+    function getLocalPart($str){
792
+        if($sstr = strrchr($str,':')){
793
+            // get unqualified name
794
+            return substr( $sstr, 1 );
795
+        } else {
796
+            return $str;
797
+        }
798
+    }
799
+
800
+    /**
801
+     * returns the prefix part of a prefixed string
802
+     * returns false, if not prefixed
803
+     *
804
+     * @param string $str The prefixed string
805
+     * @return mixed The prefix or false if there is no prefix
806
+     * @access public
807
+     */
808
+    function getPrefix($str){
809
+        if($pos = strrpos($str,':')){
810
+            // get prefix
811
+            return substr($str,0,$pos);
812
+        }
813
+        return false;
814
+    }
815
+
816
+    /**
817
+     * pass it a prefix, it returns a namespace
818
+     *
819
+     * @param string $prefix The prefix
820
+     * @return mixed The namespace, false if no namespace has the specified prefix
821
+     * @access public
822
+     */
823
+    function getNamespaceFromPrefix($prefix){
824
+        if (isset($this->namespaces[$prefix])) {
825
+            return $this->namespaces[$prefix];
826
+        }
827
+        //$this->setError("No namespace registered for prefix '$prefix'");
828
+        return false;
829
+    }
830
+
831
+    /**
832
+     * returns the prefix for a given namespace (or prefix)
833
+     * or false if no prefixes registered for the given namespace
834
+     *
835
+     * @param string $ns The namespace
836
+     * @return mixed The prefix, false if the namespace has no prefixes
837
+     * @access public
838
+     */
839
+    function getPrefixFromNamespace($ns) {
840
+        foreach ($this->namespaces as $p => $n) {
841
+            if ($ns == $n || $ns == $p) {
842
+                $this->usedNamespaces[$p] = $n;
843
+                return $p;
844
+            }
845
+        }
846
+        return false;
847
+    }
848
+
849
+    /**
850
+     * returns the time in ODBC canonical form with microseconds
851
+     *
852
+     * @return string The time in ODBC canonical form with microseconds
853
+     * @access public
854
+     */
855
+    function getmicrotime() {
856
+        if (function_exists('gettimeofday')) {
857
+            $tod = gettimeofday();
858
+            $sec = $tod['sec'];
859
+            $usec = $tod['usec'];
860
+        } else {
861
+            $sec = time();
862
+            $usec = 0;
863
+        }
864
+        return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
865
+    }
866
+
867
+    /**
868
+     * Returns a string with the output of var_dump
869
+     *
870
+     * @param mixed $data The variable to var_dump
871
+     * @return string The output of var_dump
872
+     * @access public
873
+     */
874 874
     function varDump($data) {
875
-		ob_start();
876
-		var_dump($data);
877
-		$ret_val = ob_get_contents();
878
-		ob_end_clean();
879
-		return $ret_val;
880
-	}
881
-
882
-	/**
883
-	* represents the object as a string
884
-	*
885
-	* @return	string
886
-	* @access   public
887
-	*/
888
-	function __toString() {
889
-		return $this->varDump($this);
890
-	}
875
+        ob_start();
876
+        var_dump($data);
877
+        $ret_val = ob_get_contents();
878
+        ob_end_clean();
879
+        return $ret_val;
880
+    }
881
+
882
+    /**
883
+     * represents the object as a string
884
+     *
885
+     * @return	string
886
+     * @access   public
887
+     */
888
+    function __toString() {
889
+        return $this->varDump($this);
890
+    }
891 891
 }
892 892
 
893 893
 // XML Schema Datatype Helper Functions
@@ -903,35 +903,35 @@  discard block
 block discarded – undo
903 903
 * @access   public
904 904
 */
905 905
 function timestamp_to_iso8601($timestamp,$utc=true){
906
-	$datestr = date('Y-m-d\TH:i:sO',$timestamp);
907
-	$pos = strrpos($datestr, "+");
908
-	if ($pos === FALSE) {
909
-		$pos = strrpos($datestr, "-");
910
-	}
911
-	if ($pos !== FALSE) {
912
-		if (strlen($datestr) == $pos + 5) {
913
-			$datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
914
-		}
915
-	}
916
-	if($utc){
917
-		$pattern = '/'.
918
-		'([0-9]{4})-'.	// centuries & years CCYY-
919
-		'([0-9]{2})-'.	// months MM-
920
-		'([0-9]{2})'.	// days DD
921
-		'T'.			// separator T
922
-		'([0-9]{2}):'.	// hours hh:
923
-		'([0-9]{2}):'.	// minutes mm:
924
-		'([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
925
-		'(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
926
-		'/';
927
-
928
-		if(preg_match($pattern,$datestr,$regs)){
929
-			return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
930
-		}
931
-		return false;
932
-	} else {
933
-		return $datestr;
934
-	}
906
+    $datestr = date('Y-m-d\TH:i:sO',$timestamp);
907
+    $pos = strrpos($datestr, "+");
908
+    if ($pos === FALSE) {
909
+        $pos = strrpos($datestr, "-");
910
+    }
911
+    if ($pos !== FALSE) {
912
+        if (strlen($datestr) == $pos + 5) {
913
+            $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
914
+        }
915
+    }
916
+    if($utc){
917
+        $pattern = '/'.
918
+        '([0-9]{4})-'.	// centuries & years CCYY-
919
+        '([0-9]{2})-'.	// months MM-
920
+        '([0-9]{2})'.	// days DD
921
+        'T'.			// separator T
922
+        '([0-9]{2}):'.	// hours hh:
923
+        '([0-9]{2}):'.	// minutes mm:
924
+        '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
925
+        '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
926
+        '/';
927
+
928
+        if(preg_match($pattern,$datestr,$regs)){
929
+            return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
930
+        }
931
+        return false;
932
+    } else {
933
+        return $datestr;
934
+    }
935 935
 }
936 936
 
937 937
 /**
@@ -942,35 +942,35 @@  discard block
 block discarded – undo
942 942
 * @access   public
943 943
 */
944 944
 function iso8601_to_timestamp($datestr){
945
-	$pattern = '/'.
946
-	'([0-9]{4})-'.	// centuries & years CCYY-
947
-	'([0-9]{2})-'.	// months MM-
948
-	'([0-9]{2})'.	// days DD
949
-	'T'.			// separator T
950
-	'([0-9]{2}):'.	// hours hh:
951
-	'([0-9]{2}):'.	// minutes mm:
952
-	'([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
953
-	'(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
954
-	'/';
955
-	if(preg_match($pattern,$datestr,$regs)){
956
-		// not utc
957
-		if($regs[8] != 'Z'){
958
-			$op = substr($regs[8],0,1);
959
-			$h = substr($regs[8],1,2);
960
-			$m = substr($regs[8],strlen($regs[8])-2,2);
961
-			if($op == '-'){
962
-				$regs[4] = $regs[4] + $h;
963
-				$regs[5] = $regs[5] + $m;
964
-			} elseif($op == '+'){
965
-				$regs[4] = $regs[4] - $h;
966
-				$regs[5] = $regs[5] - $m;
967
-			}
968
-		}
969
-		return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
945
+    $pattern = '/'.
946
+    '([0-9]{4})-'.	// centuries & years CCYY-
947
+    '([0-9]{2})-'.	// months MM-
948
+    '([0-9]{2})'.	// days DD
949
+    'T'.			// separator T
950
+    '([0-9]{2}):'.	// hours hh:
951
+    '([0-9]{2}):'.	// minutes mm:
952
+    '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
953
+    '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
954
+    '/';
955
+    if(preg_match($pattern,$datestr,$regs)){
956
+        // not utc
957
+        if($regs[8] != 'Z'){
958
+            $op = substr($regs[8],0,1);
959
+            $h = substr($regs[8],1,2);
960
+            $m = substr($regs[8],strlen($regs[8])-2,2);
961
+            if($op == '-'){
962
+                $regs[4] = $regs[4] + $h;
963
+                $regs[5] = $regs[5] + $m;
964
+            } elseif($op == '+'){
965
+                $regs[4] = $regs[4] - $h;
966
+                $regs[5] = $regs[5] - $m;
967
+            }
968
+        }
969
+        return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
970 970
 //		return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z");
971
-	} else {
972
-		return false;
973
-	}
971
+    } else {
972
+        return false;
973
+    }
974 974
 }
975 975
 
976 976
 /**
@@ -982,13 +982,13 @@  discard block
 block discarded – undo
982 982
 */
983 983
 function usleepWindows($usec)
984 984
 {
985
-	$start = gettimeofday();
986
-
987
-	do
988
-	{
989
-		$stop = gettimeofday();
990
-		$timePassed = 1000000 * ($stop['sec'] - $start['sec'])
991
-		+ $stop['usec'] - $start['usec'];
992
-	}
993
-	while ($timePassed < $usec);
985
+    $start = gettimeofday();
986
+
987
+    do
988
+    {
989
+        $stop = gettimeofday();
990
+        $timePassed = 1000000 * ($stop['sec'] - $start['sec'])
991
+        + $stop['usec'] - $start['usec'];
992
+    }
993
+    while ($timePassed < $usec);
994 994
 }
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soap_server.php 3 patches
Doc Comments   +8 added lines, -7 removed lines patch added patch discarded remove patch
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 	*
844 844
 	* @param	array	$headers	The HTTP headers
845 845
 	* @param	string	$data		unprocessed request data from client
846
-	* @return	mixed	value of the message, decoded into a PHP type
846
+	* @return	false|null	value of the message, decoded into a PHP type
847 847
 	* @access   private
848 848
 	*/
849 849
     function parseRequest($headers, $data) {
@@ -951,10 +951,10 @@  discard block
 block discarded – undo
951 951
 	* @param    string $name the name of the PHP function, class.method or class..method
952 952
 	* @param    array $in assoc array of input values: key = param name, value = param type
953 953
 	* @param    array $out assoc array of output values: key = param name, value = param type
954
-	* @param	mixed $namespace the element namespace for the method or false
955
-	* @param	mixed $soapaction the soapaction for the method or false
956
-	* @param	mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
957
-	* @param	mixed $use optional (encoded|literal) or false
954
+	* @param	string $namespace the element namespace for the method or false
955
+	* @param	string $soapaction the soapaction for the method or false
956
+	* @param	string $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
957
+	* @param	string $use optional (encoded|literal) or false
958 958
 	* @param	string $documentation optional Description to include in WSDL
959 959
 	* @param	string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
960 960
 	* @access   public
@@ -1041,11 +1041,12 @@  discard block
 block discarded – undo
1041 1041
     * Acts as a flag to enable internal WSDL generation
1042 1042
     *
1043 1043
     * @param string $serviceName, name of the service
1044
-    * @param mixed $namespace optional 'tns' service namespace or false
1044
+    * @param string $namespace optional 'tns' service namespace or false
1045 1045
     * @param mixed $endpoint optional URL of service endpoint or false
1046 1046
     * @param string $style optional (rpc|document) WSDL style (also specified by operation)
1047 1047
     * @param string $transport optional SOAP transport
1048
-    * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1048
+    * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1049
+    * @param string $serviceName
1049 1050
     */
1050 1051
     function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
1051 1052
     {
Please login to merge, or discard this patch.
Indentation   +1020 added lines, -1020 removed lines patch added patch discarded remove patch
@@ -12,1079 +12,1079 @@  discard block
 block discarded – undo
12 12
 */
13 13
 class nusoap_server extends nusoap_base
14 14
 {
15
-	/**
16
-	 * HTTP headers of request
17
-	 * @var array
18
-	 * @access private
19
-	 */
20
-	var $headers = array();
21
-	/**
22
-	 * HTTP request
23
-	 * @var string
24
-	 * @access private
25
-	 */
26
-	var $request = '';
27
-	/**
28
-	 * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text)
29
-	 * @var string
30
-	 * @access public
31
-	 */
32
-	var $requestHeaders = '';
33
-	/**
34
-	 * SOAP Headers from request (parsed)
35
-	 * @var mixed
36
-	 * @access public
37
-	 */
38
-	var $requestHeader = NULL;
39
-	/**
40
-	 * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text)
41
-	 * @var string
42
-	 * @access public
43
-	 */
44
-	var $document = '';
45
-	/**
46
-	 * SOAP payload for request (text)
47
-	 * @var string
48
-	 * @access public
49
-	 */
50
-	var $requestSOAP = '';
51
-	/**
52
-	 * requested method namespace URI
53
-	 * @var string
54
-	 * @access private
55
-	 */
56
-	var $methodURI = '';
57
-	/**
58
-	 * name of method requested
59
-	 * @var string
60
-	 * @access private
61
-	 */
62
-	var $methodname = '';
63
-	/**
64
-	 * method parameters from request
65
-	 * @var array
66
-	 * @access private
67
-	 */
68
-	var $methodparams = array();
69
-	/**
70
-	 * SOAP Action from request
71
-	 * @var string
72
-	 * @access private
73
-	 */
74
-	var $SOAPAction = '';
75
-	/**
76
-	 * character set encoding of incoming (request) messages
77
-	 * @var string
78
-	 * @access public
79
-	 */
80
-	var $xml_encoding = '';
81
-	/**
82
-	 * toggles whether the parser decodes element content w/ utf8_decode()
83
-	 * @var boolean
84
-	 * @access public
85
-	 */
15
+    /**
16
+     * HTTP headers of request
17
+     * @var array
18
+     * @access private
19
+     */
20
+    var $headers = array();
21
+    /**
22
+     * HTTP request
23
+     * @var string
24
+     * @access private
25
+     */
26
+    var $request = '';
27
+    /**
28
+     * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text)
29
+     * @var string
30
+     * @access public
31
+     */
32
+    var $requestHeaders = '';
33
+    /**
34
+     * SOAP Headers from request (parsed)
35
+     * @var mixed
36
+     * @access public
37
+     */
38
+    var $requestHeader = NULL;
39
+    /**
40
+     * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text)
41
+     * @var string
42
+     * @access public
43
+     */
44
+    var $document = '';
45
+    /**
46
+     * SOAP payload for request (text)
47
+     * @var string
48
+     * @access public
49
+     */
50
+    var $requestSOAP = '';
51
+    /**
52
+     * requested method namespace URI
53
+     * @var string
54
+     * @access private
55
+     */
56
+    var $methodURI = '';
57
+    /**
58
+     * name of method requested
59
+     * @var string
60
+     * @access private
61
+     */
62
+    var $methodname = '';
63
+    /**
64
+     * method parameters from request
65
+     * @var array
66
+     * @access private
67
+     */
68
+    var $methodparams = array();
69
+    /**
70
+     * SOAP Action from request
71
+     * @var string
72
+     * @access private
73
+     */
74
+    var $SOAPAction = '';
75
+    /**
76
+     * character set encoding of incoming (request) messages
77
+     * @var string
78
+     * @access public
79
+     */
80
+    var $xml_encoding = '';
81
+    /**
82
+     * toggles whether the parser decodes element content w/ utf8_decode()
83
+     * @var boolean
84
+     * @access public
85
+     */
86 86
     var $decode_utf8 = true;
87 87
 
88
-	/**
89
-	 * HTTP headers of response
90
-	 * @var array
91
-	 * @access public
92
-	 */
93
-	var $outgoing_headers = array();
94
-	/**
95
-	 * HTTP response
96
-	 * @var string
97
-	 * @access private
98
-	 */
99
-	var $response = '';
100
-	/**
101
-	 * SOAP headers for response (text or array of soapval or associative array)
102
-	 * @var mixed
103
-	 * @access public
104
-	 */
105
-	var $responseHeaders = '';
106
-	/**
107
-	 * SOAP payload for response (text)
108
-	 * @var string
109
-	 * @access private
110
-	 */
111
-	var $responseSOAP = '';
112
-	/**
113
-	 * method return value to place in response
114
-	 * @var mixed
115
-	 * @access private
116
-	 */
117
-	var $methodreturn = false;
118
-	/**
119
-	 * whether $methodreturn is a string of literal XML
120
-	 * @var boolean
121
-	 * @access public
122
-	 */
123
-	var $methodreturnisliteralxml = false;
124
-	/**
125
-	 * SOAP fault for response (or false)
126
-	 * @var mixed
127
-	 * @access private
128
-	 */
129
-	var $fault = false;
130
-	/**
131
-	 * text indication of result (for debugging)
132
-	 * @var string
133
-	 * @access private
134
-	 */
135
-	var $result = 'successful';
88
+    /**
89
+     * HTTP headers of response
90
+     * @var array
91
+     * @access public
92
+     */
93
+    var $outgoing_headers = array();
94
+    /**
95
+     * HTTP response
96
+     * @var string
97
+     * @access private
98
+     */
99
+    var $response = '';
100
+    /**
101
+     * SOAP headers for response (text or array of soapval or associative array)
102
+     * @var mixed
103
+     * @access public
104
+     */
105
+    var $responseHeaders = '';
106
+    /**
107
+     * SOAP payload for response (text)
108
+     * @var string
109
+     * @access private
110
+     */
111
+    var $responseSOAP = '';
112
+    /**
113
+     * method return value to place in response
114
+     * @var mixed
115
+     * @access private
116
+     */
117
+    var $methodreturn = false;
118
+    /**
119
+     * whether $methodreturn is a string of literal XML
120
+     * @var boolean
121
+     * @access public
122
+     */
123
+    var $methodreturnisliteralxml = false;
124
+    /**
125
+     * SOAP fault for response (or false)
126
+     * @var mixed
127
+     * @access private
128
+     */
129
+    var $fault = false;
130
+    /**
131
+     * text indication of result (for debugging)
132
+     * @var string
133
+     * @access private
134
+     */
135
+    var $result = 'successful';
136 136
 
137
-	/**
138
-	 * assoc array of operations => opData; operations are added by the register()
139
-	 * method or by parsing an external WSDL definition
140
-	 * @var array
141
-	 * @access private
142
-	 */
143
-	var $operations = array();
144
-	/**
145
-	 * wsdl instance (if one)
146
-	 * @var mixed
147
-	 * @access private
148
-	 */
149
-	var $wsdl = false;
150
-	/**
151
-	 * URL for WSDL (if one)
152
-	 * @var mixed
153
-	 * @access private
154
-	 */
155
-	var $externalWSDLURL = false;
156
-	/**
157
-	 * whether to append debug to response as XML comment
158
-	 * @var boolean
159
-	 * @access public
160
-	 */
161
-	var $debug_flag = false;
137
+    /**
138
+     * assoc array of operations => opData; operations are added by the register()
139
+     * method or by parsing an external WSDL definition
140
+     * @var array
141
+     * @access private
142
+     */
143
+    var $operations = array();
144
+    /**
145
+     * wsdl instance (if one)
146
+     * @var mixed
147
+     * @access private
148
+     */
149
+    var $wsdl = false;
150
+    /**
151
+     * URL for WSDL (if one)
152
+     * @var mixed
153
+     * @access private
154
+     */
155
+    var $externalWSDLURL = false;
156
+    /**
157
+     * whether to append debug to response as XML comment
158
+     * @var boolean
159
+     * @access public
160
+     */
161
+    var $debug_flag = false;
162 162
 
163 163
 
164
-	/**
165
-	* constructor
166
-    * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
167
-	*
168
-    * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
169
-	* @access   public
170
-	*/
171
-	function __construct($wsdl=false)
164
+    /**
165
+     * constructor
166
+     * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
167
+     *
168
+     * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
169
+     * @access   public
170
+     */
171
+    function __construct($wsdl=false)
172 172
     {
173
-		parent::__construct();
174
-		// turn on debugging?
175
-		global $debug;
176
-		global $HTTP_SERVER_VARS;
173
+        parent::__construct();
174
+        // turn on debugging?
175
+        global $debug;
176
+        global $HTTP_SERVER_VARS;
177 177
 
178
-		if (isset($_SERVER)) {
179
-			$this->debug("_SERVER is defined:");
180
-			$this->appendDebug($this->varDump($_SERVER));
181
-		} elseif (isset($HTTP_SERVER_VARS)) {
182
-			$this->debug("HTTP_SERVER_VARS is defined:");
183
-			$this->appendDebug($this->varDump($HTTP_SERVER_VARS));
184
-		} else {
185
-			$this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
186
-		}
178
+        if (isset($_SERVER)) {
179
+            $this->debug("_SERVER is defined:");
180
+            $this->appendDebug($this->varDump($_SERVER));
181
+        } elseif (isset($HTTP_SERVER_VARS)) {
182
+            $this->debug("HTTP_SERVER_VARS is defined:");
183
+            $this->appendDebug($this->varDump($HTTP_SERVER_VARS));
184
+        } else {
185
+            $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
186
+        }
187 187
 
188
-		if (isset($debug)) {
189
-			$this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
190
-			$this->debug_flag = $debug;
191
-		} elseif (isset($_SERVER['QUERY_STRING'])) {
192
-			$qs = explode('&', $_SERVER['QUERY_STRING']);
193
-			foreach ($qs as $v) {
194
-				if (substr($v, 0, 6) == 'debug=') {
195
-					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
196
-					$this->debug_flag = substr($v, 6);
197
-				}
198
-			}
199
-		} elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
200
-			$qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
201
-			foreach ($qs as $v) {
202
-				if (substr($v, 0, 6) == 'debug=') {
203
-					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
204
-					$this->debug_flag = substr($v, 6);
205
-				}
206
-			}
207
-		}
188
+        if (isset($debug)) {
189
+            $this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
190
+            $this->debug_flag = $debug;
191
+        } elseif (isset($_SERVER['QUERY_STRING'])) {
192
+            $qs = explode('&', $_SERVER['QUERY_STRING']);
193
+            foreach ($qs as $v) {
194
+                if (substr($v, 0, 6) == 'debug=') {
195
+                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
196
+                    $this->debug_flag = substr($v, 6);
197
+                }
198
+            }
199
+        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
200
+            $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
201
+            foreach ($qs as $v) {
202
+                if (substr($v, 0, 6) == 'debug=') {
203
+                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
204
+                    $this->debug_flag = substr($v, 6);
205
+                }
206
+            }
207
+        }
208 208
 
209
-		// wsdl
210
-		if($wsdl){
211
-			$this->debug("In nusoap_server, WSDL is specified");
212
-			if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
213
-				$this->wsdl = $wsdl;
209
+        // wsdl
210
+        if($wsdl){
211
+            $this->debug("In nusoap_server, WSDL is specified");
212
+            if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
213
+                $this->wsdl = $wsdl;
214 214
                 $this->wsdl->soap_defencoding = $this->soap_defencoding;
215
-				$this->externalWSDLURL = $this->wsdl->wsdl;
216
-				$this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
217
-			} else {
218
-				$this->debug('Create wsdl from ' . $wsdl);
219
-				$this->wsdl = new wsdl($wsdl);
215
+                $this->externalWSDLURL = $this->wsdl->wsdl;
216
+                $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
217
+            } else {
218
+                $this->debug('Create wsdl from ' . $wsdl);
219
+                $this->wsdl = new wsdl($wsdl);
220 220
                 $this->wsdl->soap_defencoding = $this->soap_defencoding;
221
-				$this->externalWSDLURL = $wsdl;
222
-			}
223
-			$this->appendDebug($this->wsdl->getDebug());
224
-			$this->wsdl->clearDebug();
225
-			if($err = $this->wsdl->getError()){
226
-				die('WSDL ERROR: '.$err);
227
-			}
228
-		}
229
-	}
221
+                $this->externalWSDLURL = $wsdl;
222
+            }
223
+            $this->appendDebug($this->wsdl->getDebug());
224
+            $this->wsdl->clearDebug();
225
+            if($err = $this->wsdl->getError()){
226
+                die('WSDL ERROR: '.$err);
227
+            }
228
+        }
229
+    }
230 230
 
231
-	/**
232
-	* processes request and returns response
233
-	*
234
-	* @param    string $data usually is the value of $HTTP_RAW_POST_DATA
235
-	* @access   public
236
-	*/
237
-	function service($data){
238
-		global $HTTP_SERVER_VARS;
231
+    /**
232
+     * processes request and returns response
233
+     *
234
+     * @param    string $data usually is the value of $HTTP_RAW_POST_DATA
235
+     * @access   public
236
+     */
237
+    function service($data){
238
+        global $HTTP_SERVER_VARS;
239 239
 
240
-		if (isset($_SERVER['REQUEST_METHOD'])) {
241
-			$rm = $_SERVER['REQUEST_METHOD'];
242
-		} elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
243
-			$rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
244
-		} else {
245
-			$rm = '';
246
-		}
240
+        if (isset($_SERVER['REQUEST_METHOD'])) {
241
+            $rm = $_SERVER['REQUEST_METHOD'];
242
+        } elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
243
+            $rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
244
+        } else {
245
+            $rm = '';
246
+        }
247 247
 
248
-		if (isset($_SERVER['QUERY_STRING'])) {
249
-			$qs = $_SERVER['QUERY_STRING'];
250
-		} elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
251
-			$qs = $HTTP_SERVER_VARS['QUERY_STRING'];
252
-		} else {
253
-			$qs = '';
254
-		}
255
-		$this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
248
+        if (isset($_SERVER['QUERY_STRING'])) {
249
+            $qs = $_SERVER['QUERY_STRING'];
250
+        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
251
+            $qs = $HTTP_SERVER_VARS['QUERY_STRING'];
252
+        } else {
253
+            $qs = '';
254
+        }
255
+        $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
256 256
 
257
-		if ($rm == 'POST') {
258
-			$this->debug("In service, invoke the request");
259
-			$this->parse_request($data);
260
-			if (! $this->fault) {
261
-				$this->invoke_method();
262
-			}
263
-			if (! $this->fault) {
264
-				$this->serialize_return();
265
-			}
266
-			$this->send_response();
267
-		} elseif (preg_match('/wsdl/', $qs) ){
268
-			$this->debug("In service, this is a request for WSDL");
269
-			if ($this->externalWSDLURL){
270
-              if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
271
-				$this->debug("In service, re-direct for WSDL");
272
-				header('Location: '.$this->externalWSDLURL);
273
-              } else { // assume file
274
-				$this->debug("In service, use file passthru for WSDL");
257
+        if ($rm == 'POST') {
258
+            $this->debug("In service, invoke the request");
259
+            $this->parse_request($data);
260
+            if (! $this->fault) {
261
+                $this->invoke_method();
262
+            }
263
+            if (! $this->fault) {
264
+                $this->serialize_return();
265
+            }
266
+            $this->send_response();
267
+        } elseif (preg_match('/wsdl/', $qs) ){
268
+            $this->debug("In service, this is a request for WSDL");
269
+            if ($this->externalWSDLURL){
270
+                if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
271
+                $this->debug("In service, re-direct for WSDL");
272
+                header('Location: '.$this->externalWSDLURL);
273
+                } else { // assume file
274
+                $this->debug("In service, use file passthru for WSDL");
275 275
                 header("Content-Type: text/xml\r\n");
276
-				$pos = strpos($this->externalWSDLURL, "file://");
277
-				if ($pos === false) {
278
-					$filename = $this->externalWSDLURL;
279
-				} else {
280
-					$filename = substr($this->externalWSDLURL, $pos + 7);
281
-				}
276
+                $pos = strpos($this->externalWSDLURL, "file://");
277
+                if ($pos === false) {
278
+                    $filename = $this->externalWSDLURL;
279
+                } else {
280
+                    $filename = substr($this->externalWSDLURL, $pos + 7);
281
+                }
282 282
                 $fp = fopen($this->externalWSDLURL, 'r');
283 283
                 fpassthru($fp);
284
-              }
285
-			} elseif ($this->wsdl) {
286
-				$this->debug("In service, serialize WSDL");
284
+                }
285
+            } elseif ($this->wsdl) {
286
+                $this->debug("In service, serialize WSDL");
287 287
                 header("Content-Type: text/xml; charset=".$this->soap_defencoding."\r\n");
288
-				print $this->wsdl->serialize($this->debug_flag);
289
-				if ($this->debug_flag) {
290
-					$this->debug('wsdl:');
291
-					$this->appendDebug($this->varDump($this->wsdl));
292
-					print $this->getDebugAsXMLComment();
293
-				}
294
-			} else {
295
-				$this->debug("In service, there is no WSDL");
288
+                print $this->wsdl->serialize($this->debug_flag);
289
+                if ($this->debug_flag) {
290
+                    $this->debug('wsdl:');
291
+                    $this->appendDebug($this->varDump($this->wsdl));
292
+                    print $this->getDebugAsXMLComment();
293
+                }
294
+            } else {
295
+                $this->debug("In service, there is no WSDL");
296 296
                 header("Content-Type: text/html; charset=".$this->soap_defencoding."\r\n");
297
-				print "This service does not provide WSDL";
298
-			}
299
-		} elseif ($this->wsdl) {
300
-			$this->debug("In service, return Web description");
301
-			print $this->wsdl->webDescription();
302
-		} else {
303
-			$this->debug("In service, no Web description");
304
-			header("Content-Type: text/html; charset=ISO-8859-1\r\n");
305
-			print "This service does not provide a Web description";
306
-		}
307
-	}
297
+                print "This service does not provide WSDL";
298
+            }
299
+        } elseif ($this->wsdl) {
300
+            $this->debug("In service, return Web description");
301
+            print $this->wsdl->webDescription();
302
+        } else {
303
+            $this->debug("In service, no Web description");
304
+            header("Content-Type: text/html; charset=ISO-8859-1\r\n");
305
+            print "This service does not provide a Web description";
306
+        }
307
+    }
308 308
 
309
-	/**
310
-	* parses HTTP request headers.
311
-	*
312
-	* The following fields are set by this function (when successful)
313
-	*
314
-	* headers
315
-	* request
316
-	* xml_encoding
317
-	* SOAPAction
318
-	*
319
-	* @access   private
320
-	*/
321
-	function parse_http_headers() {
322
-		global $HTTP_SERVER_VARS;
309
+    /**
310
+     * parses HTTP request headers.
311
+     *
312
+     * The following fields are set by this function (when successful)
313
+     *
314
+     * headers
315
+     * request
316
+     * xml_encoding
317
+     * SOAPAction
318
+     *
319
+     * @access   private
320
+     */
321
+    function parse_http_headers() {
322
+        global $HTTP_SERVER_VARS;
323 323
 
324
-		$this->request = '';
325
-		$this->SOAPAction = '';
326
-		if(function_exists('getallheaders')){
327
-			$this->debug("In parse_http_headers, use getallheaders");
328
-			$headers = getallheaders();
329
-			foreach($headers as $k=>$v){
330
-				$k = strtolower($k);
331
-				$this->headers[$k] = $v;
332
-				$this->request .= "$k: $v\r\n";
333
-				$this->debug("$k: $v");
334
-			}
335
-			// get SOAPAction header
336
-			if(isset($this->headers['soapaction'])){
337
-				$this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
338
-			}
339
-			// get the character encoding of the incoming request
340
-			if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
341
-				$enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
342
-				if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
343
-					$this->xml_encoding = strtoupper($enc);
344
-				} else {
345
-					$this->xml_encoding = 'US-ASCII';
346
-				}
347
-			} else {
348
-				// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
349
-				$this->xml_encoding = 'ISO-8859-1';
350
-			}
351
-		} elseif(isset($_SERVER) && is_array($_SERVER)){
352
-			$this->debug("In parse_http_headers, use _SERVER");
353
-			foreach ($_SERVER as $k => $v) {
354
-				if (substr($k, 0, 5) == 'HTTP_') {
355
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
356
-				} else {
357
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
358
-				}
359
-				if ($k == 'soapaction') {
360
-					// get SOAPAction header
361
-					$k = 'SOAPAction';
362
-					$v = str_replace('"', '', $v);
363
-					$v = str_replace('\\', '', $v);
364
-					$this->SOAPAction = $v;
365
-				} else if ($k == 'content-type') {
366
-					// get the character encoding of the incoming request
367
-					if (strpos($v, '=')) {
368
-						$enc = substr(strstr($v, '='), 1);
369
-						$enc = str_replace('"', '', $enc);
370
-						$enc = str_replace('\\', '', $enc);
371
-						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
372
-							$this->xml_encoding = strtoupper($enc);
373
-						} else {
374
-							$this->xml_encoding = 'US-ASCII';
375
-						}
376
-					} else {
377
-						// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
378
-						$this->xml_encoding = 'ISO-8859-1';
379
-					}
380
-				}
381
-				$this->headers[$k] = $v;
382
-				$this->request .= "$k: $v\r\n";
383
-				$this->debug("$k: $v");
384
-			}
385
-		} elseif (is_array($HTTP_SERVER_VARS)) {
386
-			$this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
387
-			foreach ($HTTP_SERVER_VARS as $k => $v) {
388
-				if (substr($k, 0, 5) == 'HTTP_') {
389
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); 	                                         $k = strtolower(substr($k, 5));
390
-				} else {
391
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); 	                                         $k = strtolower($k);
392
-				}
393
-				if ($k == 'soapaction') {
394
-					// get SOAPAction header
395
-					$k = 'SOAPAction';
396
-					$v = str_replace('"', '', $v);
397
-					$v = str_replace('\\', '', $v);
398
-					$this->SOAPAction = $v;
399
-				} else if ($k == 'content-type') {
400
-					// get the character encoding of the incoming request
401
-					if (strpos($v, '=')) {
402
-						$enc = substr(strstr($v, '='), 1);
403
-						$enc = str_replace('"', '', $enc);
404
-						$enc = str_replace('\\', '', $enc);
405
-						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
406
-							$this->xml_encoding = strtoupper($enc);
407
-						} else {
408
-							$this->xml_encoding = 'US-ASCII';
409
-						}
410
-					} else {
411
-						// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
412
-						$this->xml_encoding = 'ISO-8859-1';
413
-					}
414
-				}
415
-				$this->headers[$k] = $v;
416
-				$this->request .= "$k: $v\r\n";
417
-				$this->debug("$k: $v");
418
-			}
419
-		} else {
420
-			$this->debug("In parse_http_headers, HTTP headers not accessible");
421
-			$this->setError("HTTP headers not accessible");
422
-		}
423
-	}
324
+        $this->request = '';
325
+        $this->SOAPAction = '';
326
+        if(function_exists('getallheaders')){
327
+            $this->debug("In parse_http_headers, use getallheaders");
328
+            $headers = getallheaders();
329
+            foreach($headers as $k=>$v){
330
+                $k = strtolower($k);
331
+                $this->headers[$k] = $v;
332
+                $this->request .= "$k: $v\r\n";
333
+                $this->debug("$k: $v");
334
+            }
335
+            // get SOAPAction header
336
+            if(isset($this->headers['soapaction'])){
337
+                $this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
338
+            }
339
+            // get the character encoding of the incoming request
340
+            if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
341
+                $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
342
+                if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
343
+                    $this->xml_encoding = strtoupper($enc);
344
+                } else {
345
+                    $this->xml_encoding = 'US-ASCII';
346
+                }
347
+            } else {
348
+                // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
349
+                $this->xml_encoding = 'ISO-8859-1';
350
+            }
351
+        } elseif(isset($_SERVER) && is_array($_SERVER)){
352
+            $this->debug("In parse_http_headers, use _SERVER");
353
+            foreach ($_SERVER as $k => $v) {
354
+                if (substr($k, 0, 5) == 'HTTP_') {
355
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
356
+                } else {
357
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
358
+                }
359
+                if ($k == 'soapaction') {
360
+                    // get SOAPAction header
361
+                    $k = 'SOAPAction';
362
+                    $v = str_replace('"', '', $v);
363
+                    $v = str_replace('\\', '', $v);
364
+                    $this->SOAPAction = $v;
365
+                } else if ($k == 'content-type') {
366
+                    // get the character encoding of the incoming request
367
+                    if (strpos($v, '=')) {
368
+                        $enc = substr(strstr($v, '='), 1);
369
+                        $enc = str_replace('"', '', $enc);
370
+                        $enc = str_replace('\\', '', $enc);
371
+                        if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
372
+                            $this->xml_encoding = strtoupper($enc);
373
+                        } else {
374
+                            $this->xml_encoding = 'US-ASCII';
375
+                        }
376
+                    } else {
377
+                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
378
+                        $this->xml_encoding = 'ISO-8859-1';
379
+                    }
380
+                }
381
+                $this->headers[$k] = $v;
382
+                $this->request .= "$k: $v\r\n";
383
+                $this->debug("$k: $v");
384
+            }
385
+        } elseif (is_array($HTTP_SERVER_VARS)) {
386
+            $this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
387
+            foreach ($HTTP_SERVER_VARS as $k => $v) {
388
+                if (substr($k, 0, 5) == 'HTTP_') {
389
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); 	                                         $k = strtolower(substr($k, 5));
390
+                } else {
391
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); 	                                         $k = strtolower($k);
392
+                }
393
+                if ($k == 'soapaction') {
394
+                    // get SOAPAction header
395
+                    $k = 'SOAPAction';
396
+                    $v = str_replace('"', '', $v);
397
+                    $v = str_replace('\\', '', $v);
398
+                    $this->SOAPAction = $v;
399
+                } else if ($k == 'content-type') {
400
+                    // get the character encoding of the incoming request
401
+                    if (strpos($v, '=')) {
402
+                        $enc = substr(strstr($v, '='), 1);
403
+                        $enc = str_replace('"', '', $enc);
404
+                        $enc = str_replace('\\', '', $enc);
405
+                        if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
406
+                            $this->xml_encoding = strtoupper($enc);
407
+                        } else {
408
+                            $this->xml_encoding = 'US-ASCII';
409
+                        }
410
+                    } else {
411
+                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
412
+                        $this->xml_encoding = 'ISO-8859-1';
413
+                    }
414
+                }
415
+                $this->headers[$k] = $v;
416
+                $this->request .= "$k: $v\r\n";
417
+                $this->debug("$k: $v");
418
+            }
419
+        } else {
420
+            $this->debug("In parse_http_headers, HTTP headers not accessible");
421
+            $this->setError("HTTP headers not accessible");
422
+        }
423
+    }
424 424
 
425
-	/**
426
-	* parses a request
427
-	*
428
-	* The following fields are set by this function (when successful)
429
-	*
430
-	* headers
431
-	* request
432
-	* xml_encoding
433
-	* SOAPAction
434
-	* request
435
-	* requestSOAP
436
-	* methodURI
437
-	* methodname
438
-	* methodparams
439
-	* requestHeaders
440
-	* document
441
-	*
442
-	* This sets the fault field on error
443
-	*
444
-	* @param    string $data XML string
445
-	* @access   private
446
-	*/
447
-	function parse_request($data='') {
448
-		$this->debug('entering parse_request()');
449
-		$this->parse_http_headers();
450
-		$this->debug('got character encoding: '.$this->xml_encoding);
451
-		// uncompress if necessary
452
-		if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
453
-			$this->debug('got content encoding: ' . $this->headers['content-encoding']);
454
-			if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
455
-		    	// if decoding works, use it. else assume data wasn't gzencoded
456
-				if (function_exists('gzuncompress')) {
457
-					if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
458
-						$data = $degzdata;
459
-					} elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
460
-						$data = $degzdata;
461
-					} else {
462
-						$this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
463
-						return;
464
-					}
465
-				} else {
466
-					$this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
467
-					return;
468
-				}
469
-			}
470
-		}
471
-		$this->request .= "\r\n".$data;
472
-		$data = $this->parseRequest($this->headers, $data);
473
-		$this->requestSOAP = $data;
474
-		$this->debug('leaving parse_request');
475
-	}
425
+    /**
426
+     * parses a request
427
+     *
428
+     * The following fields are set by this function (when successful)
429
+     *
430
+     * headers
431
+     * request
432
+     * xml_encoding
433
+     * SOAPAction
434
+     * request
435
+     * requestSOAP
436
+     * methodURI
437
+     * methodname
438
+     * methodparams
439
+     * requestHeaders
440
+     * document
441
+     *
442
+     * This sets the fault field on error
443
+     *
444
+     * @param    string $data XML string
445
+     * @access   private
446
+     */
447
+    function parse_request($data='') {
448
+        $this->debug('entering parse_request()');
449
+        $this->parse_http_headers();
450
+        $this->debug('got character encoding: '.$this->xml_encoding);
451
+        // uncompress if necessary
452
+        if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
453
+            $this->debug('got content encoding: ' . $this->headers['content-encoding']);
454
+            if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
455
+                // if decoding works, use it. else assume data wasn't gzencoded
456
+                if (function_exists('gzuncompress')) {
457
+                    if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
458
+                        $data = $degzdata;
459
+                    } elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
460
+                        $data = $degzdata;
461
+                    } else {
462
+                        $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
463
+                        return;
464
+                    }
465
+                } else {
466
+                    $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
467
+                    return;
468
+                }
469
+            }
470
+        }
471
+        $this->request .= "\r\n".$data;
472
+        $data = $this->parseRequest($this->headers, $data);
473
+        $this->requestSOAP = $data;
474
+        $this->debug('leaving parse_request');
475
+    }
476 476
 
477
-	/**
478
-	* invokes a PHP function for the requested SOAP method
479
-	*
480
-	* The following fields are set by this function (when successful)
481
-	*
482
-	* methodreturn
483
-	*
484
-	* Note that the PHP function that is called may also set the following
485
-	* fields to affect the response sent to the client
486
-	*
487
-	* responseHeaders
488
-	* outgoing_headers
489
-	*
490
-	* This sets the fault field on error
491
-	*
492
-	* @access   private
493
-	*/
494
-	function invoke_method() {
495
-		$this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
477
+    /**
478
+     * invokes a PHP function for the requested SOAP method
479
+     *
480
+     * The following fields are set by this function (when successful)
481
+     *
482
+     * methodreturn
483
+     *
484
+     * Note that the PHP function that is called may also set the following
485
+     * fields to affect the response sent to the client
486
+     *
487
+     * responseHeaders
488
+     * outgoing_headers
489
+     *
490
+     * This sets the fault field on error
491
+     *
492
+     * @access   private
493
+     */
494
+    function invoke_method() {
495
+        $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
496 496
 
497
-		//
498
-		// if you are debugging in this area of the code, your service uses a class to implement methods,
499
-		// you use SOAP RPC, and the client is .NET, please be aware of the following...
500
-		// when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the
501
-		// method name.  that is fine for naming the .NET methods.  it is not fine for properly constructing
502
-		// the XML request and reading the XML response.  you need to add the RequestElementName and
503
-		// ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe
504
-		// generates for the method.  these parameters are used to specify the correct XML element names
505
-		// for .NET to use, i.e. the names with the '.' in them.
506
-		//
507
-		$orig_methodname = $this->methodname;
508
-		if ($this->wsdl) {
509
-			if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
510
-				$this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
511
-				$this->appendDebug('opData=' . $this->varDump($this->opData));
512
-			} elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
513
-				// Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
514
-				$this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
515
-				$this->appendDebug('opData=' . $this->varDump($this->opData));
516
-				$this->methodname = $this->opData['name'];
517
-			} else {
518
-				$this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
519
-				$this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
520
-				return;
521
-			}
522
-		} else {
523
-			$this->debug('in invoke_method, no WSDL to validate method');
524
-		}
497
+        //
498
+        // if you are debugging in this area of the code, your service uses a class to implement methods,
499
+        // you use SOAP RPC, and the client is .NET, please be aware of the following...
500
+        // when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the
501
+        // method name.  that is fine for naming the .NET methods.  it is not fine for properly constructing
502
+        // the XML request and reading the XML response.  you need to add the RequestElementName and
503
+        // ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe
504
+        // generates for the method.  these parameters are used to specify the correct XML element names
505
+        // for .NET to use, i.e. the names with the '.' in them.
506
+        //
507
+        $orig_methodname = $this->methodname;
508
+        if ($this->wsdl) {
509
+            if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
510
+                $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
511
+                $this->appendDebug('opData=' . $this->varDump($this->opData));
512
+            } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
513
+                // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
514
+                $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
515
+                $this->appendDebug('opData=' . $this->varDump($this->opData));
516
+                $this->methodname = $this->opData['name'];
517
+            } else {
518
+                $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
519
+                $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
520
+                return;
521
+            }
522
+        } else {
523
+            $this->debug('in invoke_method, no WSDL to validate method');
524
+        }
525 525
 
526
-		// if a . is present in $this->methodname, we see if there is a class in scope,
527
-		// which could be referred to. We will also distinguish between two deliminators,
528
-		// to allow methods to be called a the class or an instance
529
-		if (strpos($this->methodname, '..') > 0) {
530
-			$delim = '..';
531
-		} else if (strpos($this->methodname, '.') > 0) {
532
-			$delim = '.';
533
-		} else {
534
-			$delim = '';
535
-		}
536
-		$this->debug("in invoke_method, delim=$delim");
526
+        // if a . is present in $this->methodname, we see if there is a class in scope,
527
+        // which could be referred to. We will also distinguish between two deliminators,
528
+        // to allow methods to be called a the class or an instance
529
+        if (strpos($this->methodname, '..') > 0) {
530
+            $delim = '..';
531
+        } else if (strpos($this->methodname, '.') > 0) {
532
+            $delim = '.';
533
+        } else {
534
+            $delim = '';
535
+        }
536
+        $this->debug("in invoke_method, delim=$delim");
537 537
 
538
-		$class = '';
539
-		$method = '';
540
-		if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
541
-			$try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
542
-			if (class_exists($try_class)) {
543
-				// get the class and method name
544
-				$class = $try_class;
545
-				$method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
546
-				$this->debug("in invoke_method, class=$class method=$method delim=$delim");
547
-			} else {
548
-				$this->debug("in invoke_method, class=$try_class not found");
549
-			}
550
-		} else {
551
-			$try_class = '';
552
-			$this->debug("in invoke_method, no class to try");
553
-		}
538
+        $class = '';
539
+        $method = '';
540
+        if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
541
+            $try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
542
+            if (class_exists($try_class)) {
543
+                // get the class and method name
544
+                $class = $try_class;
545
+                $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
546
+                $this->debug("in invoke_method, class=$class method=$method delim=$delim");
547
+            } else {
548
+                $this->debug("in invoke_method, class=$try_class not found");
549
+            }
550
+        } else {
551
+            $try_class = '';
552
+            $this->debug("in invoke_method, no class to try");
553
+        }
554 554
 
555
-		// does method exist?
556
-		if ($class == '') {
557
-			if (!function_exists($this->methodname)) {
558
-				$this->debug("in invoke_method, function '$this->methodname' not found!");
559
-				$this->result = 'fault: method not found';
560
-				$this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
561
-				return;
562
-			}
563
-		} else {
564
-			$method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
565
-			if (!in_array($method_to_compare, get_class_methods($class))) {
566
-				$this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
567
-				$this->result = 'fault: method not found';
568
-				$this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
569
-				return;
570
-			}
571
-		}
555
+        // does method exist?
556
+        if ($class == '') {
557
+            if (!function_exists($this->methodname)) {
558
+                $this->debug("in invoke_method, function '$this->methodname' not found!");
559
+                $this->result = 'fault: method not found';
560
+                $this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
561
+                return;
562
+            }
563
+        } else {
564
+            $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
565
+            if (!in_array($method_to_compare, get_class_methods($class))) {
566
+                $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
567
+                $this->result = 'fault: method not found';
568
+                $this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
569
+                return;
570
+            }
571
+        }
572 572
 
573
-		// evaluate message, getting back parameters
574
-		// verify that request parameters match the method's signature
575
-		if(! $this->verify_method($this->methodname,$this->methodparams)){
576
-			// debug
577
-			$this->debug('ERROR: request not verified against method signature');
578
-			$this->result = 'fault: request failed validation against method signature';
579
-			// return fault
580
-			$this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
581
-			return;
582
-		}
573
+        // evaluate message, getting back parameters
574
+        // verify that request parameters match the method's signature
575
+        if(! $this->verify_method($this->methodname,$this->methodparams)){
576
+            // debug
577
+            $this->debug('ERROR: request not verified against method signature');
578
+            $this->result = 'fault: request failed validation against method signature';
579
+            // return fault
580
+            $this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
581
+            return;
582
+        }
583 583
 
584
-		// if there are parameters to pass
585
-		$this->debug('in invoke_method, params:');
586
-		$this->appendDebug($this->varDump($this->methodparams));
587
-		$this->debug("in invoke_method, calling '$this->methodname'");
588
-		if (!function_exists('call_user_func_array')) {
589
-			if ($class == '') {
590
-				$this->debug('in invoke_method, calling function using eval()');
591
-				$funcCall = "\$this->methodreturn = $this->methodname(";
592
-			} else {
593
-				if ($delim == '..') {
594
-					$this->debug('in invoke_method, calling class method using eval()');
595
-					$funcCall = "\$this->methodreturn = ".$class."::".$method."(";
596
-				} else {
597
-					$this->debug('in invoke_method, calling instance method using eval()');
598
-					// generate unique instance name
599
-					$instname = "\$inst_".time();
600
-					$funcCall = $instname." = new ".$class."(); ";
601
-					$funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
602
-				}
603
-			}
604
-			if ($this->methodparams) {
605
-				foreach ($this->methodparams as $param) {
606
-					if (is_array($param) || is_object($param)) {
607
-						$this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
608
-						return;
609
-					}
610
-					$funcCall .= "\"$param\",";
611
-				}
612
-				$funcCall = substr($funcCall, 0, -1);
613
-			}
614
-			$funcCall .= ');';
615
-			$this->debug('in invoke_method, function call: '.$funcCall);
616
-			@eval($funcCall);
617
-		} else {
618
-			if ($class == '') {
619
-				$this->debug('in invoke_method, calling function using call_user_func_array()');
620
-				$call_arg = "$this->methodname";	// straight assignment changes $this->methodname to lower case after call_user_func_array()
621
-			} elseif ($delim == '..') {
622
-				$this->debug('in invoke_method, calling class method using call_user_func_array()');
623
-				$call_arg = array ($class, $method);
624
-			} else {
625
-				$this->debug('in invoke_method, calling instance method using call_user_func_array()');
626
-				$instance = new $class ();
627
-				$call_arg = array(&$instance, $method);
628
-			}
629
-			if (is_array($this->methodparams)) {
630
-				$this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
631
-			} else {
632
-				$this->methodreturn = call_user_func_array($call_arg, array());
633
-			}
634
-		}
584
+        // if there are parameters to pass
585
+        $this->debug('in invoke_method, params:');
586
+        $this->appendDebug($this->varDump($this->methodparams));
587
+        $this->debug("in invoke_method, calling '$this->methodname'");
588
+        if (!function_exists('call_user_func_array')) {
589
+            if ($class == '') {
590
+                $this->debug('in invoke_method, calling function using eval()');
591
+                $funcCall = "\$this->methodreturn = $this->methodname(";
592
+            } else {
593
+                if ($delim == '..') {
594
+                    $this->debug('in invoke_method, calling class method using eval()');
595
+                    $funcCall = "\$this->methodreturn = ".$class."::".$method."(";
596
+                } else {
597
+                    $this->debug('in invoke_method, calling instance method using eval()');
598
+                    // generate unique instance name
599
+                    $instname = "\$inst_".time();
600
+                    $funcCall = $instname." = new ".$class."(); ";
601
+                    $funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
602
+                }
603
+            }
604
+            if ($this->methodparams) {
605
+                foreach ($this->methodparams as $param) {
606
+                    if (is_array($param) || is_object($param)) {
607
+                        $this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
608
+                        return;
609
+                    }
610
+                    $funcCall .= "\"$param\",";
611
+                }
612
+                $funcCall = substr($funcCall, 0, -1);
613
+            }
614
+            $funcCall .= ');';
615
+            $this->debug('in invoke_method, function call: '.$funcCall);
616
+            @eval($funcCall);
617
+        } else {
618
+            if ($class == '') {
619
+                $this->debug('in invoke_method, calling function using call_user_func_array()');
620
+                $call_arg = "$this->methodname";	// straight assignment changes $this->methodname to lower case after call_user_func_array()
621
+            } elseif ($delim == '..') {
622
+                $this->debug('in invoke_method, calling class method using call_user_func_array()');
623
+                $call_arg = array ($class, $method);
624
+            } else {
625
+                $this->debug('in invoke_method, calling instance method using call_user_func_array()');
626
+                $instance = new $class ();
627
+                $call_arg = array(&$instance, $method);
628
+            }
629
+            if (is_array($this->methodparams)) {
630
+                $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
631
+            } else {
632
+                $this->methodreturn = call_user_func_array($call_arg, array());
633
+            }
634
+        }
635 635
         $this->debug('in invoke_method, methodreturn:');
636 636
         $this->appendDebug($this->varDump($this->methodreturn));
637
-		$this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
638
-	}
637
+        $this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
638
+    }
639 639
 
640
-	/**
641
-	* serializes the return value from a PHP function into a full SOAP Envelope
642
-	*
643
-	* The following fields are set by this function (when successful)
644
-	*
645
-	* responseSOAP
646
-	*
647
-	* This sets the fault field on error
648
-	*
649
-	* @access   private
650
-	*/
651
-	function serialize_return() {
652
-		$this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
653
-		// if fault
654
-		if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
655
-			$this->debug('got a fault object from method');
656
-			$this->fault = $this->methodreturn;
657
-			return;
658
-		} elseif ($this->methodreturnisliteralxml) {
659
-			$return_val = $this->methodreturn;
660
-		// returned value(s)
661
-		} else {
662
-			$this->debug('got a(n) '.gettype($this->methodreturn).' from method');
663
-			$this->debug('serializing return value');
664
-			if($this->wsdl){
665
-				$opParams = "";
666
-				if (sizeof($this->opData['output']['parts']) > 1) {
667
-					$this->debug('more than one output part, so use the method return unchanged');
668
-			    	$opParams = $this->methodreturn;
669
-			    } elseif (sizeof($this->opData['output']['parts']) == 1) {
670
-					$this->debug('exactly one output part, so wrap the method return in a simple array');
671
-					// TODO: verify that it is not already wrapped!
672
-			    	//foreach ($this->opData['output']['parts'] as $name => $type) {
673
-					//	$this->debug('wrap in element named ' . $name);
674
-			    	//}
675
-			    	$opParams = array($this->methodreturn);
676
-			    }
677
-			    $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
678
-			    $this->appendDebug($this->wsdl->getDebug());
679
-			    $this->wsdl->clearDebug();
680
-				if($errstr = $this->wsdl->getError()){
681
-					$this->debug('got wsdl error: '.$errstr);
682
-					$this->fault('SOAP-ENV:Server', 'unable to serialize result');
683
-					return;
684
-				}
685
-			} else {
686
-				if (isset($this->methodreturn)) {
687
-					$return_val = $this->serialize_val($this->methodreturn, 'return');
688
-				} else {
689
-					$return_val = '';
690
-					$this->debug('in absence of WSDL, assume void return for backward compatibility');
691
-				}
692
-			}
693
-		}
694
-		$this->debug('return value:');
695
-		$this->appendDebug($this->varDump($return_val));
640
+    /**
641
+     * serializes the return value from a PHP function into a full SOAP Envelope
642
+     *
643
+     * The following fields are set by this function (when successful)
644
+     *
645
+     * responseSOAP
646
+     *
647
+     * This sets the fault field on error
648
+     *
649
+     * @access   private
650
+     */
651
+    function serialize_return() {
652
+        $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
653
+        // if fault
654
+        if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
655
+            $this->debug('got a fault object from method');
656
+            $this->fault = $this->methodreturn;
657
+            return;
658
+        } elseif ($this->methodreturnisliteralxml) {
659
+            $return_val = $this->methodreturn;
660
+        // returned value(s)
661
+        } else {
662
+            $this->debug('got a(n) '.gettype($this->methodreturn).' from method');
663
+            $this->debug('serializing return value');
664
+            if($this->wsdl){
665
+                $opParams = "";
666
+                if (sizeof($this->opData['output']['parts']) > 1) {
667
+                    $this->debug('more than one output part, so use the method return unchanged');
668
+                    $opParams = $this->methodreturn;
669
+                } elseif (sizeof($this->opData['output']['parts']) == 1) {
670
+                    $this->debug('exactly one output part, so wrap the method return in a simple array');
671
+                    // TODO: verify that it is not already wrapped!
672
+                    //foreach ($this->opData['output']['parts'] as $name => $type) {
673
+                    //	$this->debug('wrap in element named ' . $name);
674
+                    //}
675
+                    $opParams = array($this->methodreturn);
676
+                }
677
+                $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
678
+                $this->appendDebug($this->wsdl->getDebug());
679
+                $this->wsdl->clearDebug();
680
+                if($errstr = $this->wsdl->getError()){
681
+                    $this->debug('got wsdl error: '.$errstr);
682
+                    $this->fault('SOAP-ENV:Server', 'unable to serialize result');
683
+                    return;
684
+                }
685
+            } else {
686
+                if (isset($this->methodreturn)) {
687
+                    $return_val = $this->serialize_val($this->methodreturn, 'return');
688
+                } else {
689
+                    $return_val = '';
690
+                    $this->debug('in absence of WSDL, assume void return for backward compatibility');
691
+                }
692
+            }
693
+        }
694
+        $this->debug('return value:');
695
+        $this->appendDebug($this->varDump($return_val));
696 696
 
697
-		$this->debug('serializing response');
698
-		if ($this->wsdl) {
699
-			$this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
700
-			if ($this->opData['style'] == 'rpc') {
701
-				$this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
702
-				if ($this->opData['output']['use'] == 'literal') {
703
-					// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
704
-					if ($this->methodURI) {
705
-						$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
706
-					} else {
707
-						$payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
708
-					}
709
-				} else {
710
-					if ($this->methodURI) {
711
-						$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
712
-					} else {
713
-						$payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
714
-					}
715
-				}
716
-			} else {
717
-				$this->debug('style is not rpc for serialization: assume document');
718
-				$payload = $return_val;
719
-			}
720
-		} else {
721
-			$this->debug('do not have WSDL for serialization: assume rpc/encoded');
722
-			$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
723
-		}
724
-		$this->result = 'successful';
725
-		if($this->wsdl){
726
-			//if($this->debug_flag){
727
-            	$this->appendDebug($this->wsdl->getDebug());
697
+        $this->debug('serializing response');
698
+        if ($this->wsdl) {
699
+            $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
700
+            if ($this->opData['style'] == 'rpc') {
701
+                $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
702
+                if ($this->opData['output']['use'] == 'literal') {
703
+                    // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
704
+                    if ($this->methodURI) {
705
+                        $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
706
+                    } else {
707
+                        $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
708
+                    }
709
+                } else {
710
+                    if ($this->methodURI) {
711
+                        $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
712
+                    } else {
713
+                        $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
714
+                    }
715
+                }
716
+            } else {
717
+                $this->debug('style is not rpc for serialization: assume document');
718
+                $payload = $return_val;
719
+            }
720
+        } else {
721
+            $this->debug('do not have WSDL for serialization: assume rpc/encoded');
722
+            $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
723
+        }
724
+        $this->result = 'successful';
725
+        if($this->wsdl){
726
+            //if($this->debug_flag){
727
+                $this->appendDebug($this->wsdl->getDebug());
728 728
             //	}
729
-			if (isset($this->opData['output']['encodingStyle'])) {
730
-				$encodingStyle = $this->opData['output']['encodingStyle'];
731
-			} else {
732
-				$encodingStyle = '';
733
-			}
734
-			// Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
735
-			$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
736
-		} else {
737
-			$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
738
-		}
739
-		$this->debug("Leaving serialize_return");
740
-	}
729
+            if (isset($this->opData['output']['encodingStyle'])) {
730
+                $encodingStyle = $this->opData['output']['encodingStyle'];
731
+            } else {
732
+                $encodingStyle = '';
733
+            }
734
+            // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
735
+            $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
736
+        } else {
737
+            $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
738
+        }
739
+        $this->debug("Leaving serialize_return");
740
+    }
741 741
 
742
-	/**
743
-	* sends an HTTP response
744
-	*
745
-	* The following fields are set by this function (when successful)
746
-	*
747
-	* outgoing_headers
748
-	* response
749
-	*
750
-	* @access   private
751
-	*/
752
-	function send_response() {
753
-		$this->debug('Enter send_response');
754
-		if ($this->fault) {
755
-			$payload = $this->fault->serialize();
756
-			$this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
757
-			$this->outgoing_headers[] = "Status: 500 Internal Server Error";
758
-		} else {
759
-			$payload = $this->responseSOAP;
760
-			// Some combinations of PHP+Web server allow the Status
761
-			// to come through as a header.  Since OK is the default
762
-			// just do nothing.
763
-			// $this->outgoing_headers[] = "HTTP/1.0 200 OK";
764
-			// $this->outgoing_headers[] = "Status: 200 OK";
765
-		}
742
+    /**
743
+     * sends an HTTP response
744
+     *
745
+     * The following fields are set by this function (when successful)
746
+     *
747
+     * outgoing_headers
748
+     * response
749
+     *
750
+     * @access   private
751
+     */
752
+    function send_response() {
753
+        $this->debug('Enter send_response');
754
+        if ($this->fault) {
755
+            $payload = $this->fault->serialize();
756
+            $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
757
+            $this->outgoing_headers[] = "Status: 500 Internal Server Error";
758
+        } else {
759
+            $payload = $this->responseSOAP;
760
+            // Some combinations of PHP+Web server allow the Status
761
+            // to come through as a header.  Since OK is the default
762
+            // just do nothing.
763
+            // $this->outgoing_headers[] = "HTTP/1.0 200 OK";
764
+            // $this->outgoing_headers[] = "Status: 200 OK";
765
+        }
766 766
         // add debug data if in debug mode
767
-		if(isset($this->debug_flag) && $this->debug_flag){
768
-        	$payload .= $this->getDebugAsXMLComment();
767
+        if(isset($this->debug_flag) && $this->debug_flag){
768
+            $payload .= $this->getDebugAsXMLComment();
769
+        }
770
+        $this->outgoing_headers[] = "Server: $this->title Server v$this->version";
771
+        preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
772
+        $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
773
+        // Let the Web server decide about this
774
+        //$this->outgoing_headers[] = "Connection: Close\r\n";
775
+        $payload = $this->getHTTPBody($payload);
776
+        $type = $this->getHTTPContentType();
777
+        $charset = $this->getHTTPContentTypeCharset();
778
+        $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
779
+        //begin code to compress payload - by John
780
+        // NOTE: there is no way to know whether the Web server will also compress
781
+        // this data.
782
+        if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
783
+            if (strstr($this->headers['accept-encoding'], 'gzip')) {
784
+                if (function_exists('gzencode')) {
785
+                    if (isset($this->debug_flag) && $this->debug_flag) {
786
+                        $payload .= "<!-- Content being gzipped -->";
787
+                    }
788
+                    $this->outgoing_headers[] = "Content-Encoding: gzip";
789
+                    $payload = gzencode($payload);
790
+                } else {
791
+                    if (isset($this->debug_flag) && $this->debug_flag) {
792
+                        $payload .= "<!-- Content will not be gzipped: no gzencode -->";
793
+                    }
794
+                }
795
+            } elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
796
+                // Note: MSIE requires gzdeflate output (no Zlib header and checksum),
797
+                // instead of gzcompress output,
798
+                // which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
799
+                if (function_exists('gzdeflate')) {
800
+                    if (isset($this->debug_flag) && $this->debug_flag) {
801
+                        $payload .= "<!-- Content being deflated -->";
802
+                    }
803
+                    $this->outgoing_headers[] = "Content-Encoding: deflate";
804
+                    $payload = gzdeflate($payload);
805
+                } else {
806
+                    if (isset($this->debug_flag) && $this->debug_flag) {
807
+                        $payload .= "<!-- Content will not be deflated: no gzcompress -->";
808
+                    }
809
+                }
810
+            }
769 811
         }
770
-		$this->outgoing_headers[] = "Server: $this->title Server v$this->version";
771
-		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
772
-		$this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
773
-		// Let the Web server decide about this
774
-		//$this->outgoing_headers[] = "Connection: Close\r\n";
775
-		$payload = $this->getHTTPBody($payload);
776
-		$type = $this->getHTTPContentType();
777
-		$charset = $this->getHTTPContentTypeCharset();
778
-		$this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
779
-		//begin code to compress payload - by John
780
-		// NOTE: there is no way to know whether the Web server will also compress
781
-		// this data.
782
-		if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
783
-			if (strstr($this->headers['accept-encoding'], 'gzip')) {
784
-				if (function_exists('gzencode')) {
785
-					if (isset($this->debug_flag) && $this->debug_flag) {
786
-						$payload .= "<!-- Content being gzipped -->";
787
-					}
788
-					$this->outgoing_headers[] = "Content-Encoding: gzip";
789
-					$payload = gzencode($payload);
790
-				} else {
791
-					if (isset($this->debug_flag) && $this->debug_flag) {
792
-						$payload .= "<!-- Content will not be gzipped: no gzencode -->";
793
-					}
794
-				}
795
-			} elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
796
-				// Note: MSIE requires gzdeflate output (no Zlib header and checksum),
797
-				// instead of gzcompress output,
798
-				// which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
799
-				if (function_exists('gzdeflate')) {
800
-					if (isset($this->debug_flag) && $this->debug_flag) {
801
-						$payload .= "<!-- Content being deflated -->";
802
-					}
803
-					$this->outgoing_headers[] = "Content-Encoding: deflate";
804
-					$payload = gzdeflate($payload);
805
-				} else {
806
-					if (isset($this->debug_flag) && $this->debug_flag) {
807
-						$payload .= "<!-- Content will not be deflated: no gzcompress -->";
808
-					}
809
-				}
810
-			}
811
-		}
812
-		//end code
813
-		$this->outgoing_headers[] = "Content-Length: ".strlen($payload);
814
-		reset($this->outgoing_headers);
815
-		foreach($this->outgoing_headers as $hdr){
816
-			header($hdr, false);
817
-		}
818
-		print $payload;
819
-		$this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
820
-	}
812
+        //end code
813
+        $this->outgoing_headers[] = "Content-Length: ".strlen($payload);
814
+        reset($this->outgoing_headers);
815
+        foreach($this->outgoing_headers as $hdr){
816
+            header($hdr, false);
817
+        }
818
+        print $payload;
819
+        $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
820
+    }
821 821
 
822
-	/**
823
-	* takes the value that was created by parsing the request
824
-	* and compares to the method's signature, if available.
825
-	*
826
-	* @param	string	$operation	The operation to be invoked
827
-	* @param	array	$request	The array of parameter values
828
-	* @return	boolean	Whether the operation was found
829
-	* @access   private
830
-	*/
831
-	function verify_method($operation,$request){
832
-		if(isset($this->wsdl) && is_object($this->wsdl)){
833
-			if($this->wsdl->getOperationData($operation)){
834
-				return true;
835
-			}
836
-	    } elseif(isset($this->operations[$operation])){
837
-			return true;
838
-		}
839
-		return false;
840
-	}
822
+    /**
823
+     * takes the value that was created by parsing the request
824
+     * and compares to the method's signature, if available.
825
+     *
826
+     * @param	string	$operation	The operation to be invoked
827
+     * @param	array	$request	The array of parameter values
828
+     * @return	boolean	Whether the operation was found
829
+     * @access   private
830
+     */
831
+    function verify_method($operation,$request){
832
+        if(isset($this->wsdl) && is_object($this->wsdl)){
833
+            if($this->wsdl->getOperationData($operation)){
834
+                return true;
835
+            }
836
+        } elseif(isset($this->operations[$operation])){
837
+            return true;
838
+        }
839
+        return false;
840
+    }
841 841
 
842
-	/**
843
-	* processes SOAP message received from client
844
-	*
845
-	* @param	array	$headers	The HTTP headers
846
-	* @param	string	$data		unprocessed request data from client
847
-	* @return	mixed	value of the message, decoded into a PHP type
848
-	* @access   private
849
-	*/
842
+    /**
843
+     * processes SOAP message received from client
844
+     *
845
+     * @param	array	$headers	The HTTP headers
846
+     * @param	string	$data		unprocessed request data from client
847
+     * @return	mixed	value of the message, decoded into a PHP type
848
+     * @access   private
849
+     */
850 850
     function parseRequest($headers, $data) {
851
-		$this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
852
-		$this->appendDebug($this->varDump($headers));
853
-    	if (!isset($headers['content-type'])) {
854
-			$this->setError('Request not of type text/xml (no content-type header)');
855
-			return false;
856
-    	}
857
-		if (!strstr($headers['content-type'], 'text/xml')) {
858
-			$this->setError('Request not of type text/xml');
859
-			return false;
860
-		}
861
-		if (strpos($headers['content-type'], '=')) {
862
-			$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
863
-			$this->debug('Got response encoding: ' . $enc);
864
-			if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
865
-				$this->xml_encoding = strtoupper($enc);
866
-			} else {
867
-				$this->xml_encoding = 'US-ASCII';
868
-			}
869
-		} else {
870
-			// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
871
-			$this->xml_encoding = 'ISO-8859-1';
872
-		}
873
-		$this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
874
-		// parse response, get soap parser obj
875
-		$parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
851
+        $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
852
+        $this->appendDebug($this->varDump($headers));
853
+        if (!isset($headers['content-type'])) {
854
+            $this->setError('Request not of type text/xml (no content-type header)');
855
+            return false;
856
+        }
857
+        if (!strstr($headers['content-type'], 'text/xml')) {
858
+            $this->setError('Request not of type text/xml');
859
+            return false;
860
+        }
861
+        if (strpos($headers['content-type'], '=')) {
862
+            $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
863
+            $this->debug('Got response encoding: ' . $enc);
864
+            if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
865
+                $this->xml_encoding = strtoupper($enc);
866
+            } else {
867
+                $this->xml_encoding = 'US-ASCII';
868
+            }
869
+        } else {
870
+            // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
871
+            $this->xml_encoding = 'ISO-8859-1';
872
+        }
873
+        $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
874
+        // parse response, get soap parser obj
875
+        $parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
876 876
 
877
-		// parser debug
878
-		$this->debug("parser debug: \n".$parser->getDebug());
879
-		// if fault occurred during message parsing
880
-		if($err = $parser->getError()){
881
-			$this->result = 'fault: error in msg parsing: '.$err;
882
-			$this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
883
-		// else successfully parsed request into soapval object
884
-		} else {
885
-			// get/set methodname
886
-			$this->methodURI = $parser->root_struct_namespace;
887
-			$this->methodname = $parser->root_struct_name;
888
-			$this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
889
-			$this->debug('calling parser->get_soapbody()');
890
-			$this->methodparams = $parser->get_soapbody();
891
-			// get SOAP headers
892
-			$this->requestHeaders = $parser->getHeaders();
893
-			// get SOAP Header
894
-			$this->requestHeader = $parser->get_soapheader();
877
+        // parser debug
878
+        $this->debug("parser debug: \n".$parser->getDebug());
879
+        // if fault occurred during message parsing
880
+        if($err = $parser->getError()){
881
+            $this->result = 'fault: error in msg parsing: '.$err;
882
+            $this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
883
+        // else successfully parsed request into soapval object
884
+        } else {
885
+            // get/set methodname
886
+            $this->methodURI = $parser->root_struct_namespace;
887
+            $this->methodname = $parser->root_struct_name;
888
+            $this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
889
+            $this->debug('calling parser->get_soapbody()');
890
+            $this->methodparams = $parser->get_soapbody();
891
+            // get SOAP headers
892
+            $this->requestHeaders = $parser->getHeaders();
893
+            // get SOAP Header
894
+            $this->requestHeader = $parser->get_soapheader();
895 895
             // add document for doclit support
896 896
             $this->document = $parser->document;
897
-		}
898
-	 }
897
+        }
898
+        }
899 899
 
900
-	/**
901
-	* gets the HTTP body for the current response.
902
-	*
903
-	* @param string $soapmsg The SOAP payload
904
-	* @return string The HTTP body, which includes the SOAP payload
905
-	* @access private
906
-	*/
907
-	function getHTTPBody($soapmsg) {
908
-		return $soapmsg;
909
-	}
900
+    /**
901
+     * gets the HTTP body for the current response.
902
+     *
903
+     * @param string $soapmsg The SOAP payload
904
+     * @return string The HTTP body, which includes the SOAP payload
905
+     * @access private
906
+     */
907
+    function getHTTPBody($soapmsg) {
908
+        return $soapmsg;
909
+    }
910 910
 
911
-	/**
912
-	* gets the HTTP content type for the current response.
913
-	*
914
-	* Note: getHTTPBody must be called before this.
915
-	*
916
-	* @return string the HTTP content type for the current response.
917
-	* @access private
918
-	*/
919
-	function getHTTPContentType() {
920
-		return 'text/xml';
921
-	}
911
+    /**
912
+     * gets the HTTP content type for the current response.
913
+     *
914
+     * Note: getHTTPBody must be called before this.
915
+     *
916
+     * @return string the HTTP content type for the current response.
917
+     * @access private
918
+     */
919
+    function getHTTPContentType() {
920
+        return 'text/xml';
921
+    }
922 922
 
923
-	/**
924
-	* gets the HTTP content type charset for the current response.
925
-	* returns false for non-text content types.
926
-	*
927
-	* Note: getHTTPBody must be called before this.
928
-	*
929
-	* @return string the HTTP content type charset for the current response.
930
-	* @access private
931
-	*/
932
-	function getHTTPContentTypeCharset() {
933
-		return $this->soap_defencoding;
934
-	}
923
+    /**
924
+     * gets the HTTP content type charset for the current response.
925
+     * returns false for non-text content types.
926
+     *
927
+     * Note: getHTTPBody must be called before this.
928
+     *
929
+     * @return string the HTTP content type charset for the current response.
930
+     * @access private
931
+     */
932
+    function getHTTPContentTypeCharset() {
933
+        return $this->soap_defencoding;
934
+    }
935 935
 
936
-	/**
937
-	* add a method to the dispatch map (this has been replaced by the register method)
938
-	*
939
-	* @param    string $methodname
940
-	* @param    string $in array of input values
941
-	* @param    string $out array of output values
942
-	* @access   public
943
-	* @deprecated
944
-	*/
945
-	function add_to_map($methodname,$in,$out){
946
-			$this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
947
-	}
936
+    /**
937
+     * add a method to the dispatch map (this has been replaced by the register method)
938
+     *
939
+     * @param    string $methodname
940
+     * @param    string $in array of input values
941
+     * @param    string $out array of output values
942
+     * @access   public
943
+     * @deprecated
944
+     */
945
+    function add_to_map($methodname,$in,$out){
946
+            $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
947
+    }
948 948
 
949
-	/**
950
-	* register a service function with the server
951
-	*
952
-	* @param    string $name the name of the PHP function, class.method or class..method
953
-	* @param    array $in assoc array of input values: key = param name, value = param type
954
-	* @param    array $out assoc array of output values: key = param name, value = param type
955
-	* @param	mixed $namespace the element namespace for the method or false
956
-	* @param	mixed $soapaction the soapaction for the method or false
957
-	* @param	mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
958
-	* @param	mixed $use optional (encoded|literal) or false
959
-	* @param	string $documentation optional Description to include in WSDL
960
-	* @param	string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
961
-	* @access   public
962
-	*/
963
-	function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
964
-		global $HTTP_SERVER_VARS;
949
+    /**
950
+     * register a service function with the server
951
+     *
952
+     * @param    string $name the name of the PHP function, class.method or class..method
953
+     * @param    array $in assoc array of input values: key = param name, value = param type
954
+     * @param    array $out assoc array of output values: key = param name, value = param type
955
+     * @param	mixed $namespace the element namespace for the method or false
956
+     * @param	mixed $soapaction the soapaction for the method or false
957
+     * @param	mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
958
+     * @param	mixed $use optional (encoded|literal) or false
959
+     * @param	string $documentation optional Description to include in WSDL
960
+     * @param	string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
961
+     * @access   public
962
+     */
963
+    function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
964
+        global $HTTP_SERVER_VARS;
965 965
 
966
-		if($this->externalWSDLURL){
967
-			die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
968
-		}
969
-		if (! $name) {
970
-			die('You must specify a name when you register an operation');
971
-		}
972
-		if (!is_array($in)) {
973
-			die('You must provide an array for operation inputs');
974
-		}
975
-		if (!is_array($out)) {
976
-			die('You must provide an array for operation outputs');
977
-		}
978
-		if(false == $namespace) {
979
-		}
980
-		if(false == $soapaction) {
981
-			if (isset($_SERVER)) {
982
-				$SERVER_NAME = $_SERVER['SERVER_NAME'];
983
-				$SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
984
-				$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
985
-			} elseif (isset($HTTP_SERVER_VARS)) {
986
-				$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
987
-				$SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
988
-				$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
989
-			} else {
990
-				$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
991
-			}
992
-        	if ($HTTPS == '1' || $HTTPS == 'on') {
993
-        		$SCHEME = 'https';
994
-        	} else {
995
-        		$SCHEME = 'http';
996
-        	}
997
-			$soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
998
-		}
999
-		if(false == $style) {
1000
-			$style = "rpc";
1001
-		}
1002
-		if(false == $use) {
1003
-			$use = "encoded";
1004
-		}
1005
-		if ($use == 'encoded' && $encodingStyle == '') {
1006
-			$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1007
-		}
966
+        if($this->externalWSDLURL){
967
+            die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
968
+        }
969
+        if (! $name) {
970
+            die('You must specify a name when you register an operation');
971
+        }
972
+        if (!is_array($in)) {
973
+            die('You must provide an array for operation inputs');
974
+        }
975
+        if (!is_array($out)) {
976
+            die('You must provide an array for operation outputs');
977
+        }
978
+        if(false == $namespace) {
979
+        }
980
+        if(false == $soapaction) {
981
+            if (isset($_SERVER)) {
982
+                $SERVER_NAME = $_SERVER['SERVER_NAME'];
983
+                $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
984
+                $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
985
+            } elseif (isset($HTTP_SERVER_VARS)) {
986
+                $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
987
+                $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
988
+                $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
989
+            } else {
990
+                $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
991
+            }
992
+            if ($HTTPS == '1' || $HTTPS == 'on') {
993
+                $SCHEME = 'https';
994
+            } else {
995
+                $SCHEME = 'http';
996
+            }
997
+            $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
998
+        }
999
+        if(false == $style) {
1000
+            $style = "rpc";
1001
+        }
1002
+        if(false == $use) {
1003
+            $use = "encoded";
1004
+        }
1005
+        if ($use == 'encoded' && $encodingStyle == '') {
1006
+            $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1007
+        }
1008 1008
 
1009
-		$this->operations[$name] = array(
1010
-	    'name' => $name,
1011
-	    'in' => $in,
1012
-	    'out' => $out,
1013
-	    'namespace' => $namespace,
1014
-	    'soapaction' => $soapaction,
1015
-	    'style' => $style);
1009
+        $this->operations[$name] = array(
1010
+        'name' => $name,
1011
+        'in' => $in,
1012
+        'out' => $out,
1013
+        'namespace' => $namespace,
1014
+        'soapaction' => $soapaction,
1015
+        'style' => $style);
1016 1016
         if($this->wsdl){
1017
-        	$this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
1018
-	    }
1019
-		return true;
1020
-	}
1017
+            $this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
1018
+        }
1019
+        return true;
1020
+    }
1021 1021
 
1022
-	/**
1023
-	* Specify a fault to be returned to the client.
1024
-	* This also acts as a flag to the server that a fault has occured.
1025
-	*
1026
-	* @param	string $faultcode
1027
-	* @param	string $faultstring
1028
-	* @param	string $faultactor
1029
-	* @param	string $faultdetail
1030
-	* @access   public
1031
-	*/
1032
-	function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
1033
-		if ($faultdetail == '' && $this->debug_flag) {
1034
-			$faultdetail = $this->getDebug();
1035
-		}
1036
-		$this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
1037
-		$this->fault->soap_defencoding = $this->soap_defencoding;
1038
-	}
1022
+    /**
1023
+     * Specify a fault to be returned to the client.
1024
+     * This also acts as a flag to the server that a fault has occured.
1025
+     *
1026
+     * @param	string $faultcode
1027
+     * @param	string $faultstring
1028
+     * @param	string $faultactor
1029
+     * @param	string $faultdetail
1030
+     * @access   public
1031
+     */
1032
+    function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
1033
+        if ($faultdetail == '' && $this->debug_flag) {
1034
+            $faultdetail = $this->getDebug();
1035
+        }
1036
+        $this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
1037
+        $this->fault->soap_defencoding = $this->soap_defencoding;
1038
+    }
1039 1039
 
1040 1040
     /**
1041
-    * Sets up wsdl object.
1042
-    * Acts as a flag to enable internal WSDL generation
1043
-    *
1044
-    * @param string $serviceName, name of the service
1045
-    * @param mixed $namespace optional 'tns' service namespace or false
1046
-    * @param mixed $endpoint optional URL of service endpoint or false
1047
-    * @param string $style optional (rpc|document) WSDL style (also specified by operation)
1048
-    * @param string $transport optional SOAP transport
1049
-    * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1050
-    */
1041
+     * Sets up wsdl object.
1042
+     * Acts as a flag to enable internal WSDL generation
1043
+     *
1044
+     * @param string $serviceName, name of the service
1045
+     * @param mixed $namespace optional 'tns' service namespace or false
1046
+     * @param mixed $endpoint optional URL of service endpoint or false
1047
+     * @param string $style optional (rpc|document) WSDL style (also specified by operation)
1048
+     * @param string $transport optional SOAP transport
1049
+     * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1050
+     */
1051 1051
     function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
1052 1052
     {
1053
-    	global $HTTP_SERVER_VARS;
1053
+        global $HTTP_SERVER_VARS;
1054 1054
 
1055
-		if (isset($_SERVER)) {
1056
-			$SERVER_NAME = $_SERVER['SERVER_NAME'];
1057
-			$SERVER_PORT = $_SERVER['SERVER_PORT'];
1058
-			$SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
1059
-			$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
1060
-		} elseif (isset($HTTP_SERVER_VARS)) {
1061
-			$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
1062
-			$SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
1063
-			$SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
1064
-			$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
1065
-		} else {
1066
-			$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
1067
-		}
1068
-		// If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
1069
-		$colon = strpos($SERVER_NAME,":");
1070
-		if ($colon) {
1071
-		    $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
1072
-		}
1073
-		if ($SERVER_PORT == 80) {
1074
-			$SERVER_PORT = '';
1075
-		} else {
1076
-			$SERVER_PORT = ':' . $SERVER_PORT;
1077
-		}
1055
+        if (isset($_SERVER)) {
1056
+            $SERVER_NAME = $_SERVER['SERVER_NAME'];
1057
+            $SERVER_PORT = $_SERVER['SERVER_PORT'];
1058
+            $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
1059
+            $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
1060
+        } elseif (isset($HTTP_SERVER_VARS)) {
1061
+            $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
1062
+            $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
1063
+            $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
1064
+            $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
1065
+        } else {
1066
+            $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
1067
+        }
1068
+        // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
1069
+        $colon = strpos($SERVER_NAME,":");
1070
+        if ($colon) {
1071
+            $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
1072
+        }
1073
+        if ($SERVER_PORT == 80) {
1074
+            $SERVER_PORT = '';
1075
+        } else {
1076
+            $SERVER_PORT = ':' . $SERVER_PORT;
1077
+        }
1078 1078
         if(false == $namespace) {
1079 1079
             $namespace = "http://$SERVER_NAME/soap/$serviceName";
1080 1080
         }
1081 1081
 
1082 1082
         if(false == $endpoint) {
1083
-        	if ($HTTPS == '1' || $HTTPS == 'on') {
1084
-        		$SCHEME = 'https';
1085
-        	} else {
1086
-        		$SCHEME = 'http';
1087
-        	}
1083
+            if ($HTTPS == '1' || $HTTPS == 'on') {
1084
+                $SCHEME = 'https';
1085
+            } else {
1086
+                $SCHEME = 'http';
1087
+            }
1088 1088
             $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME";
1089 1089
         }
1090 1090
 
@@ -1094,28 +1094,28 @@  discard block
 block discarded – undo
1094 1094
 
1095 1095
         $this->wsdl = new wsdl();
1096 1096
         $this->wsdl->soap_defencoding = $this->soap_defencoding;
1097
-		$this->wsdl->serviceName = $serviceName;
1097
+        $this->wsdl->serviceName = $serviceName;
1098 1098
         $this->wsdl->endpoint = $endpoint;
1099
-		$this->wsdl->namespaces['tns'] = $namespace;
1100
-		$this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
1101
-		$this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
1102
-		if ($schemaTargetNamespace != $namespace) {
1103
-			$this->wsdl->namespaces['types'] = $schemaTargetNamespace;
1104
-		}
1099
+        $this->wsdl->namespaces['tns'] = $namespace;
1100
+        $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
1101
+        $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
1102
+        if ($schemaTargetNamespace != $namespace) {
1103
+            $this->wsdl->namespaces['types'] = $schemaTargetNamespace;
1104
+        }
1105 1105
         $this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namespaces);
1106 1106
         if ($style == 'document') {
1107
-	        $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
1107
+            $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
1108 1108
         }
1109 1109
         $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
1110 1110
         $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array('location' => '', 'loaded' => true);
1111 1111
         $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array('location' => '', 'loaded' => true);
1112 1112
         $this->wsdl->bindings[$serviceName.'Binding'] = array(
1113
-        	'name'=>$serviceName.'Binding',
1113
+            'name'=>$serviceName.'Binding',
1114 1114
             'style'=>$style,
1115 1115
             'transport'=>$transport,
1116 1116
             'portType'=>$serviceName.'PortType');
1117 1117
         $this->wsdl->ports[$serviceName.'Port'] = array(
1118
-        	'binding'=>$serviceName.'Binding',
1118
+            'binding'=>$serviceName.'Binding',
1119 1119
             'location'=>$endpoint,
1120 1120
             'bindingType'=>'http://schemas.xmlsoap.org/wsdl/soap/');
1121 1121
     }
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
169 169
 	* @access   public
170 170
 	*/
171
-	function __construct($wsdl=false)
171
+	function __construct($wsdl = false)
172 172
     {
173 173
 		parent::__construct();
174 174
 		// turn on debugging?
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 			$qs = explode('&', $_SERVER['QUERY_STRING']);
193 193
 			foreach ($qs as $v) {
194 194
 				if (substr($v, 0, 6) == 'debug=') {
195
-					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
195
+					$this->debug("In nusoap_server, set debug_flag=".substr($v, 6)." based on query string #1");
196 196
 					$this->debug_flag = substr($v, 6);
197 197
 				}
198 198
 			}
@@ -200,29 +200,29 @@  discard block
 block discarded – undo
200 200
 			$qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
201 201
 			foreach ($qs as $v) {
202 202
 				if (substr($v, 0, 6) == 'debug=') {
203
-					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
203
+					$this->debug("In nusoap_server, set debug_flag=".substr($v, 6)." based on query string #2");
204 204
 					$this->debug_flag = substr($v, 6);
205 205
 				}
206 206
 			}
207 207
 		}
208 208
 
209 209
 		// wsdl
210
-		if($wsdl){
210
+		if ($wsdl) {
211 211
 			$this->debug("In nusoap_server, WSDL is specified");
212 212
 			if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
213 213
 				$this->wsdl = $wsdl;
214 214
                 $this->wsdl->soap_defencoding = $this->soap_defencoding;
215 215
 				$this->externalWSDLURL = $this->wsdl->wsdl;
216
-				$this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
216
+				$this->debug('Use existing wsdl instance from '.$this->externalWSDLURL);
217 217
 			} else {
218
-				$this->debug('Create wsdl from ' . $wsdl);
218
+				$this->debug('Create wsdl from '.$wsdl);
219 219
 				$this->wsdl = new wsdl($wsdl);
220 220
                 $this->wsdl->soap_defencoding = $this->soap_defencoding;
221 221
 				$this->externalWSDLURL = $wsdl;
222 222
 			}
223 223
 			$this->appendDebug($this->wsdl->getDebug());
224 224
 			$this->wsdl->clearDebug();
225
-			if($err = $this->wsdl->getError()){
225
+			if ($err = $this->wsdl->getError()) {
226 226
 				die('WSDL ERROR: '.$err);
227 227
 			}
228 228
 		}
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	* @param    string $data usually is the value of $HTTP_RAW_POST_DATA
235 235
 	* @access   public
236 236
 	*/
237
-	function service($data){
237
+	function service($data) {
238 238
 		global $HTTP_SERVER_VARS;
239 239
 
240 240
 		if (isset($_SERVER['REQUEST_METHOD'])) {
@@ -252,21 +252,21 @@  discard block
 block discarded – undo
252 252
 		} else {
253 253
 			$qs = '';
254 254
 		}
255
-		$this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
255
+		$this->debug("In service, request method=$rm query string=$qs strlen(\$data)=".strlen($data));
256 256
 
257 257
 		if ($rm == 'POST') {
258 258
 			$this->debug("In service, invoke the request");
259 259
 			$this->parse_request($data);
260
-			if (! $this->fault) {
260
+			if (!$this->fault) {
261 261
 				$this->invoke_method();
262 262
 			}
263
-			if (! $this->fault) {
263
+			if (!$this->fault) {
264 264
 				$this->serialize_return();
265 265
 			}
266 266
 			$this->send_response();
267
-		} elseif (preg_match('/wsdl/', $qs) ){
267
+		} elseif (preg_match('/wsdl/', $qs)) {
268 268
 			$this->debug("In service, this is a request for WSDL");
269
-			if ($this->externalWSDLURL){
269
+			if ($this->externalWSDLURL) {
270 270
               if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
271 271
 				$this->debug("In service, re-direct for WSDL");
272 272
 				header('Location: '.$this->externalWSDLURL);
@@ -323,23 +323,23 @@  discard block
 block discarded – undo
323 323
 
324 324
 		$this->request = '';
325 325
 		$this->SOAPAction = '';
326
-		if(function_exists('getallheaders')){
326
+		if (function_exists('getallheaders')) {
327 327
 			$this->debug("In parse_http_headers, use getallheaders");
328 328
 			$headers = getallheaders();
329
-			foreach($headers as $k=>$v){
329
+			foreach ($headers as $k=>$v) {
330 330
 				$k = strtolower($k);
331 331
 				$this->headers[$k] = $v;
332 332
 				$this->request .= "$k: $v\r\n";
333 333
 				$this->debug("$k: $v");
334 334
 			}
335 335
 			// get SOAPAction header
336
-			if(isset($this->headers['soapaction'])){
337
-				$this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
336
+			if (isset($this->headers['soapaction'])) {
337
+				$this->SOAPAction = str_replace('"', '', $this->headers['soapaction']);
338 338
 			}
339 339
 			// get the character encoding of the incoming request
340
-			if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
341
-				$enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
342
-				if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
340
+			if (isset($this->headers['content-type']) && strpos($this->headers['content-type'], '=')) {
341
+				$enc = str_replace('"', '', substr(strstr($this->headers["content-type"], '='), 1));
342
+				if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
343 343
 					$this->xml_encoding = strtoupper($enc);
344 344
 				} else {
345 345
 					$this->xml_encoding = 'US-ASCII';
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 				// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
349 349
 				$this->xml_encoding = 'ISO-8859-1';
350 350
 			}
351
-		} elseif(isset($_SERVER) && is_array($_SERVER)){
351
+		} elseif (isset($_SERVER) && is_array($_SERVER)) {
352 352
 			$this->debug("In parse_http_headers, use _SERVER");
353 353
 			foreach ($_SERVER as $k => $v) {
354 354
 				if (substr($k, 0, 5) == 'HTTP_') {
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 						$enc = substr(strstr($v, '='), 1);
369 369
 						$enc = str_replace('"', '', $enc);
370 370
 						$enc = str_replace('\\', '', $enc);
371
-						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
371
+						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
372 372
 							$this->xml_encoding = strtoupper($enc);
373 373
 						} else {
374 374
 							$this->xml_encoding = 'US-ASCII';
@@ -386,9 +386,9 @@  discard block
 block discarded – undo
386 386
 			$this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
387 387
 			foreach ($HTTP_SERVER_VARS as $k => $v) {
388 388
 				if (substr($k, 0, 5) == 'HTTP_') {
389
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); 	                                         $k = strtolower(substr($k, 5));
389
+					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); $k = strtolower(substr($k, 5));
390 390
 				} else {
391
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); 	                                         $k = strtolower($k);
391
+					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); $k = strtolower($k);
392 392
 				}
393 393
 				if ($k == 'soapaction') {
394 394
 					// get SOAPAction header
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 						$enc = substr(strstr($v, '='), 1);
403 403
 						$enc = str_replace('"', '', $enc);
404 404
 						$enc = str_replace('\\', '', $enc);
405
-						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
405
+						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
406 406
 							$this->xml_encoding = strtoupper($enc);
407 407
 						} else {
408 408
 							$this->xml_encoding = 'US-ASCII';
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
 	* @param    string $data XML string
445 445
 	* @access   private
446 446
 	*/
447
-	function parse_request($data='') {
447
+	function parse_request($data = '') {
448 448
 		$this->debug('entering parse_request()');
449 449
 		$this->parse_http_headers();
450 450
 		$this->debug('got character encoding: '.$this->xml_encoding);
451 451
 		// uncompress if necessary
452 452
 		if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
453
-			$this->debug('got content encoding: ' . $this->headers['content-encoding']);
453
+			$this->debug('got content encoding: '.$this->headers['content-encoding']);
454 454
 			if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
455 455
 		    	// if decoding works, use it. else assume data wasn't gzencoded
456 456
 				if (function_exists('gzuncompress')) {
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 	* @access   private
493 493
 	*/
494 494
 	function invoke_method() {
495
-		$this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
495
+		$this->debug('in invoke_method, methodname='.$this->methodname.' methodURI='.$this->methodURI.' SOAPAction='.$this->SOAPAction);
496 496
 
497 497
 		//
498 498
 		// if you are debugging in this area of the code, your service uses a class to implement methods,
@@ -507,16 +507,16 @@  discard block
 block discarded – undo
507 507
 		$orig_methodname = $this->methodname;
508 508
 		if ($this->wsdl) {
509 509
 			if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
510
-				$this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
511
-				$this->appendDebug('opData=' . $this->varDump($this->opData));
510
+				$this->debug('in invoke_method, found WSDL operation='.$this->methodname);
511
+				$this->appendDebug('opData='.$this->varDump($this->opData));
512 512
 			} elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
513 513
 				// Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
514
-				$this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
515
-				$this->appendDebug('opData=' . $this->varDump($this->opData));
514
+				$this->debug('in invoke_method, found WSDL soapAction='.$this->SOAPAction.' for operation='.$this->opData['name']);
515
+				$this->appendDebug('opData='.$this->varDump($this->opData));
516 516
 				$this->methodname = $this->opData['name'];
517 517
 			} else {
518
-				$this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
519
-				$this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
518
+				$this->debug('in invoke_method, no WSDL for operation='.$this->methodname);
519
+				$this->fault('SOAP-ENV:Client', "Operation '".$this->methodname."' is not defined in the WSDL for this service");
520 520
 				return;
521 521
 			}
522 522
 		} else {
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 			if (!function_exists($this->methodname)) {
558 558
 				$this->debug("in invoke_method, function '$this->methodname' not found!");
559 559
 				$this->result = 'fault: method not found';
560
-				$this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
560
+				$this->fault('SOAP-ENV:Client', "method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
561 561
 				return;
562 562
 			}
563 563
 		} else {
@@ -565,19 +565,19 @@  discard block
 block discarded – undo
565 565
 			if (!in_array($method_to_compare, get_class_methods($class))) {
566 566
 				$this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
567 567
 				$this->result = 'fault: method not found';
568
-				$this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
568
+				$this->fault('SOAP-ENV:Client', "method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
569 569
 				return;
570 570
 			}
571 571
 		}
572 572
 
573 573
 		// evaluate message, getting back parameters
574 574
 		// verify that request parameters match the method's signature
575
-		if(! $this->verify_method($this->methodname,$this->methodparams)){
575
+		if (!$this->verify_method($this->methodname, $this->methodparams)) {
576 576
 			// debug
577 577
 			$this->debug('ERROR: request not verified against method signature');
578 578
 			$this->result = 'fault: request failed validation against method signature';
579 579
 			// return fault
580
-			$this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
580
+			$this->fault('SOAP-ENV:Client', "Operation '$this->methodname' not defined in service.");
581 581
 			return;
582 582
 		}
583 583
 
@@ -617,13 +617,13 @@  discard block
 block discarded – undo
617 617
 		} else {
618 618
 			if ($class == '') {
619 619
 				$this->debug('in invoke_method, calling function using call_user_func_array()');
620
-				$call_arg = "$this->methodname";	// straight assignment changes $this->methodname to lower case after call_user_func_array()
620
+				$call_arg = "$this->methodname"; // straight assignment changes $this->methodname to lower case after call_user_func_array()
621 621
 			} elseif ($delim == '..') {
622 622
 				$this->debug('in invoke_method, calling class method using call_user_func_array()');
623
-				$call_arg = array ($class, $method);
623
+				$call_arg = array($class, $method);
624 624
 			} else {
625 625
 				$this->debug('in invoke_method, calling instance method using call_user_func_array()');
626
-				$instance = new $class ();
626
+				$instance = new $class();
627 627
 				$call_arg = array(&$instance, $method);
628 628
 			}
629 629
 			if (is_array($this->methodparams)) {
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 	* @access   private
650 650
 	*/
651 651
 	function serialize_return() {
652
-		$this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
652
+		$this->debug('Entering serialize_return methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
653 653
 		// if fault
654 654
 		if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
655 655
 			$this->debug('got a fault object from method');
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 		} else {
662 662
 			$this->debug('got a(n) '.gettype($this->methodreturn).' from method');
663 663
 			$this->debug('serializing return value');
664
-			if($this->wsdl){
664
+			if ($this->wsdl) {
665 665
 				$opParams = "";
666 666
 				if (sizeof($this->opData['output']['parts']) > 1) {
667 667
 					$this->debug('more than one output part, so use the method return unchanged');
@@ -674,10 +674,10 @@  discard block
 block discarded – undo
674 674
 			    	//}
675 675
 			    	$opParams = array($this->methodreturn);
676 676
 			    }
677
-			    $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
677
+			    $return_val = $this->wsdl->serializeRPCParameters($this->methodname, 'output', $opParams);
678 678
 			    $this->appendDebug($this->wsdl->getDebug());
679 679
 			    $this->wsdl->clearDebug();
680
-				if($errstr = $this->wsdl->getError()){
680
+				if ($errstr = $this->wsdl->getError()) {
681 681
 					$this->debug('got wsdl error: '.$errstr);
682 682
 					$this->fault('SOAP-ENV:Server', 'unable to serialize result');
683 683
 					return;
@@ -696,9 +696,9 @@  discard block
 block discarded – undo
696 696
 
697 697
 		$this->debug('serializing response');
698 698
 		if ($this->wsdl) {
699
-			$this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
699
+			$this->debug('have WSDL for serialization: style is '.$this->opData['style']);
700 700
 			if ($this->opData['style'] == 'rpc') {
701
-				$this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
701
+				$this->debug('style is rpc for serialization: use is '.$this->opData['output']['use']);
702 702
 				if ($this->opData['output']['use'] == 'literal') {
703 703
 					// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
704 704
 					if ($this->methodURI) {
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 			$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
723 723
 		}
724 724
 		$this->result = 'successful';
725
-		if($this->wsdl){
725
+		if ($this->wsdl) {
726 726
 			//if($this->debug_flag){
727 727
             	$this->appendDebug($this->wsdl->getDebug());
728 728
             //	}
@@ -732,9 +732,9 @@  discard block
 block discarded – undo
732 732
 				$encodingStyle = '';
733 733
 			}
734 734
 			// Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
735
-			$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
735
+			$this->responseSOAP = $this->serializeEnvelope($payload, $this->responseHeaders, $this->wsdl->usedNamespaces, $this->opData['style'], $this->opData['output']['use'], $encodingStyle);
736 736
 		} else {
737
-			$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
737
+			$this->responseSOAP = $this->serializeEnvelope($payload, $this->responseHeaders);
738 738
 		}
739 739
 		$this->debug("Leaving serialize_return");
740 740
 	}
@@ -764,18 +764,18 @@  discard block
 block discarded – undo
764 764
 			// $this->outgoing_headers[] = "Status: 200 OK";
765 765
 		}
766 766
         // add debug data if in debug mode
767
-		if(isset($this->debug_flag) && $this->debug_flag){
767
+		if (isset($this->debug_flag) && $this->debug_flag) {
768 768
         	$payload .= $this->getDebugAsXMLComment();
769 769
         }
770 770
 		$this->outgoing_headers[] = "Server: $this->title Server v$this->version";
771
-		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
771
+		preg_match('/\$Revisio'.'n: ([^ ]+)/', $this->revision, $rev);
772 772
 		$this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
773 773
 		// Let the Web server decide about this
774 774
 		//$this->outgoing_headers[] = "Connection: Close\r\n";
775 775
 		$payload = $this->getHTTPBody($payload);
776 776
 		$type = $this->getHTTPContentType();
777 777
 		$charset = $this->getHTTPContentTypeCharset();
778
-		$this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
778
+		$this->outgoing_headers[] = "Content-Type: $type".($charset ? '; charset='.$charset : '');
779 779
 		//begin code to compress payload - by John
780 780
 		// NOTE: there is no way to know whether the Web server will also compress
781 781
 		// this data.
@@ -812,11 +812,11 @@  discard block
 block discarded – undo
812 812
 		//end code
813 813
 		$this->outgoing_headers[] = "Content-Length: ".strlen($payload);
814 814
 		reset($this->outgoing_headers);
815
-		foreach($this->outgoing_headers as $hdr){
815
+		foreach ($this->outgoing_headers as $hdr) {
816 816
 			header($hdr, false);
817 817
 		}
818 818
 		print $payload;
819
-		$this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
819
+		$this->response = join("\r\n", $this->outgoing_headers)."\r\n\r\n".$payload;
820 820
 	}
821 821
 
822 822
 	/**
@@ -828,12 +828,12 @@  discard block
 block discarded – undo
828 828
 	* @return	boolean	Whether the operation was found
829 829
 	* @access   private
830 830
 	*/
831
-	function verify_method($operation,$request){
832
-		if(isset($this->wsdl) && is_object($this->wsdl)){
833
-			if($this->wsdl->getOperationData($operation)){
831
+	function verify_method($operation, $request) {
832
+		if (isset($this->wsdl) && is_object($this->wsdl)) {
833
+			if ($this->wsdl->getOperationData($operation)) {
834 834
 				return true;
835 835
 			}
836
-	    } elseif(isset($this->operations[$operation])){
836
+	    } elseif (isset($this->operations[$operation])) {
837 837
 			return true;
838 838
 		}
839 839
 		return false;
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
 	* @access   private
849 849
 	*/
850 850
     function parseRequest($headers, $data) {
851
-		$this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
851
+		$this->debug('Entering parseRequest() for data of length '.strlen($data).' headers:');
852 852
 		$this->appendDebug($this->varDump($headers));
853 853
     	if (!isset($headers['content-type'])) {
854 854
 			$this->setError('Request not of type text/xml (no content-type header)');
@@ -860,8 +860,8 @@  discard block
 block discarded – undo
860 860
 		}
861 861
 		if (strpos($headers['content-type'], '=')) {
862 862
 			$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
863
-			$this->debug('Got response encoding: ' . $enc);
864
-			if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
863
+			$this->debug('Got response encoding: '.$enc);
864
+			if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
865 865
 				$this->xml_encoding = strtoupper($enc);
866 866
 			} else {
867 867
 				$this->xml_encoding = 'US-ASCII';
@@ -870,16 +870,16 @@  discard block
 block discarded – undo
870 870
 			// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
871 871
 			$this->xml_encoding = 'ISO-8859-1';
872 872
 		}
873
-		$this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
873
+		$this->debug('Use encoding: '.$this->xml_encoding.' when creating nusoap_parser');
874 874
 		// parse response, get soap parser obj
875
-		$parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
875
+		$parser = new nusoap_parser($data, $this->xml_encoding, '', $this->decode_utf8);
876 876
 
877 877
 		// parser debug
878 878
 		$this->debug("parser debug: \n".$parser->getDebug());
879 879
 		// if fault occurred during message parsing
880
-		if($err = $parser->getError()){
880
+		if ($err = $parser->getError()) {
881 881
 			$this->result = 'fault: error in msg parsing: '.$err;
882
-			$this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
882
+			$this->fault('SOAP-ENV:Client', "error in msg parsing:\n".$err);
883 883
 		// else successfully parsed request into soapval object
884 884
 		} else {
885 885
 			// get/set methodname
@@ -942,8 +942,8 @@  discard block
 block discarded – undo
942 942
 	* @access   public
943 943
 	* @deprecated
944 944
 	*/
945
-	function add_to_map($methodname,$in,$out){
946
-			$this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
945
+	function add_to_map($methodname, $in, $out) {
946
+			$this->operations[$methodname] = array('name' => $methodname, 'in' => $in, 'out' => $out);
947 947
 	}
948 948
 
949 949
 	/**
@@ -960,13 +960,13 @@  discard block
 block discarded – undo
960 960
 	* @param	string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
961 961
 	* @access   public
962 962
 	*/
963
-	function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
963
+	function register($name, $in = array(), $out = array(), $namespace = false, $soapaction = false, $style = false, $use = false, $documentation = '', $encodingStyle = '') {
964 964
 		global $HTTP_SERVER_VARS;
965 965
 
966
-		if($this->externalWSDLURL){
966
+		if ($this->externalWSDLURL) {
967 967
 			die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
968 968
 		}
969
-		if (! $name) {
969
+		if (!$name) {
970 970
 			die('You must specify a name when you register an operation');
971 971
 		}
972 972
 		if (!is_array($in)) {
@@ -975,9 +975,9 @@  discard block
 block discarded – undo
975 975
 		if (!is_array($out)) {
976 976
 			die('You must provide an array for operation outputs');
977 977
 		}
978
-		if(false == $namespace) {
978
+		if (false == $namespace) {
979 979
 		}
980
-		if(false == $soapaction) {
980
+		if (false == $soapaction) {
981 981
 			if (isset($_SERVER)) {
982 982
 				$SERVER_NAME = $_SERVER['SERVER_NAME'];
983 983
 				$SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
@@ -996,10 +996,10 @@  discard block
 block discarded – undo
996 996
         	}
997 997
 			$soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
998 998
 		}
999
-		if(false == $style) {
999
+		if (false == $style) {
1000 1000
 			$style = "rpc";
1001 1001
 		}
1002
-		if(false == $use) {
1002
+		if (false == $use) {
1003 1003
 			$use = "encoded";
1004 1004
 		}
1005 1005
 		if ($use == 'encoded' && $encodingStyle == '') {
@@ -1013,8 +1013,8 @@  discard block
 block discarded – undo
1013 1013
 	    'namespace' => $namespace,
1014 1014
 	    'soapaction' => $soapaction,
1015 1015
 	    'style' => $style);
1016
-        if($this->wsdl){
1017
-        	$this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
1016
+        if ($this->wsdl) {
1017
+        	$this->wsdl->addOperation($name, $in, $out, $namespace, $soapaction, $style, $use, $documentation, $encodingStyle);
1018 1018
 	    }
1019 1019
 		return true;
1020 1020
 	}
@@ -1029,11 +1029,11 @@  discard block
 block discarded – undo
1029 1029
 	* @param	string $faultdetail
1030 1030
 	* @access   public
1031 1031
 	*/
1032
-	function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
1032
+	function fault($faultcode, $faultstring, $faultactor = '', $faultdetail = '') {
1033 1033
 		if ($faultdetail == '' && $this->debug_flag) {
1034 1034
 			$faultdetail = $this->getDebug();
1035 1035
 		}
1036
-		$this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
1036
+		$this->fault = new nusoap_fault($faultcode, $faultactor, $faultstring, $faultdetail);
1037 1037
 		$this->fault->soap_defencoding = $this->soap_defencoding;
1038 1038
 	}
1039 1039
 
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
     * @param string $transport optional SOAP transport
1049 1049
     * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1050 1050
     */
1051
-    function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
1051
+    function configureWSDL($serviceName, $namespace = false, $endpoint = false, $style = 'rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
1052 1052
     {
1053 1053
     	global $HTTP_SERVER_VARS;
1054 1054
 
@@ -1066,20 +1066,20 @@  discard block
 block discarded – undo
1066 1066
 			$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
1067 1067
 		}
1068 1068
 		// If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
1069
-		$colon = strpos($SERVER_NAME,":");
1069
+		$colon = strpos($SERVER_NAME, ":");
1070 1070
 		if ($colon) {
1071 1071
 		    $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
1072 1072
 		}
1073 1073
 		if ($SERVER_PORT == 80) {
1074 1074
 			$SERVER_PORT = '';
1075 1075
 		} else {
1076
-			$SERVER_PORT = ':' . $SERVER_PORT;
1076
+			$SERVER_PORT = ':'.$SERVER_PORT;
1077 1077
 		}
1078
-        if(false == $namespace) {
1078
+        if (false == $namespace) {
1079 1079
             $namespace = "http://$SERVER_NAME/soap/$serviceName";
1080 1080
         }
1081 1081
 
1082
-        if(false == $endpoint) {
1082
+        if (false == $endpoint) {
1083 1083
         	if ($HTTPS == '1' || $HTTPS == 'on') {
1084 1084
         		$SCHEME = 'https';
1085 1085
         	} else {
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
             $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME";
1089 1089
         }
1090 1090
 
1091
-        if(false == $schemaTargetNamespace) {
1091
+        if (false == $schemaTargetNamespace) {
1092 1092
             $schemaTargetNamespace = $namespace;
1093 1093
         }
1094 1094
 
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soap_transport_http.php 4 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -169,10 +169,6 @@  discard block
 block discarded – undo
169 169
 	/**
170 170
 	* establish an HTTP connection
171 171
 	*
172
-	* @param    integer $timeout set connection timeout in seconds
173
-	* @param	integer $response_timeout set response timeout in seconds
174
-	* @return	boolean true if connected, false if not
175
-	* @access   private
176 172
 	*/
177 173
 	function connect($connection_timeout=0,$response_timeout=30){
178 174
 	  	// For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
@@ -731,7 +727,7 @@  discard block
 block discarded – undo
731 727
 	*
732 728
 	* @param    string $data message data
733 729
 	* @param	array $cookies cookies to send
734
-	* @return	boolean	true if OK, false if problem
730
+	* @return	boolean|null	true if OK, false if problem
735 731
 	* @access   private
736 732
 	*/
737 733
 	function sendRequest($data, $cookies = NULL) {
@@ -1166,7 +1162,7 @@  discard block
 block discarded – undo
1166 1162
 	 * sets the content-type for the SOAP message to be sent
1167 1163
 	 *
1168 1164
 	 * @param	string $type the content type, MIME style
1169
-	 * @param	mixed $charset character set used for encoding (or false)
1165
+	 * @param	string $charset character set used for encoding (or false)
1170 1166
 	 * @access	public
1171 1167
 	 */
1172 1168
 	function setContentType($type, $charset = false) {
@@ -1199,6 +1195,10 @@  discard block
 block discarded – undo
1199 1195
 	/*
1200 1196
 	 * TODO: allow a Set-Cookie string to be parsed into multiple cookies
1201 1197
 	 */
1198
+
1199
+	/**
1200
+	 * @param string $cookie_str
1201
+	 */
1202 1202
 	function parseCookie($cookie_str) {
1203 1203
 		$cookie_str = str_replace('; ', ';', $cookie_str) . ';';
1204 1204
 		$data = preg_split('/;/', $cookie_str);
Please login to merge, or discard this patch.
Braces   +39 added lines, -29 removed lines patch added patch discarded remove patch
@@ -159,10 +159,12 @@  discard block
 block discarded – undo
159 159
 	* @access	private
160 160
 	*/
161 161
 	function io_method() {
162
-		if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm'))
163
-			return 'curl';
164
-		if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm'))
165
-			return 'socket';
162
+		if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) {
163
+					return 'curl';
164
+		}
165
+		if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) {
166
+					return 'socket';
167
+		}
166 168
 		return 'unknown';
167 169
 	}
168 170
 
@@ -246,30 +248,36 @@  discard block
 block discarded – undo
246 248
 			return false;
247 249
 		}
248 250
 		// Avoid warnings when PHP does not have these options
249
-		if (defined('CURLOPT_CONNECTIONTIMEOUT'))
250
-			$CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
251
-		else
252
-			$CURLOPT_CONNECTIONTIMEOUT = 78;
253
-		if (defined('CURLOPT_HTTPAUTH'))
254
-			$CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
255
-		else
256
-			$CURLOPT_HTTPAUTH = 107;
257
-		if (defined('CURLOPT_PROXYAUTH'))
258
-			$CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
259
-		else
260
-			$CURLOPT_PROXYAUTH = 111;
261
-		if (defined('CURLAUTH_BASIC'))
262
-			$CURLAUTH_BASIC = CURLAUTH_BASIC;
263
-		else
264
-			$CURLAUTH_BASIC = 1;
265
-		if (defined('CURLAUTH_DIGEST'))
266
-			$CURLAUTH_DIGEST = CURLAUTH_DIGEST;
267
-		else
268
-			$CURLAUTH_DIGEST = 2;
269
-		if (defined('CURLAUTH_NTLM'))
270
-			$CURLAUTH_NTLM = CURLAUTH_NTLM;
271
-		else
272
-			$CURLAUTH_NTLM = 8;
251
+		if (defined('CURLOPT_CONNECTIONTIMEOUT')) {
252
+					$CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
253
+		} else {
254
+					$CURLOPT_CONNECTIONTIMEOUT = 78;
255
+		}
256
+		if (defined('CURLOPT_HTTPAUTH')) {
257
+					$CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
258
+		} else {
259
+					$CURLOPT_HTTPAUTH = 107;
260
+		}
261
+		if (defined('CURLOPT_PROXYAUTH')) {
262
+					$CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
263
+		} else {
264
+					$CURLOPT_PROXYAUTH = 111;
265
+		}
266
+		if (defined('CURLAUTH_BASIC')) {
267
+					$CURLAUTH_BASIC = CURLAUTH_BASIC;
268
+		} else {
269
+					$CURLAUTH_BASIC = 1;
270
+		}
271
+		if (defined('CURLAUTH_DIGEST')) {
272
+					$CURLAUTH_DIGEST = CURLAUTH_DIGEST;
273
+		} else {
274
+					$CURLAUTH_DIGEST = 2;
275
+		}
276
+		if (defined('CURLAUTH_NTLM')) {
277
+					$CURLAUTH_NTLM = CURLAUTH_NTLM;
278
+		} else {
279
+					$CURLAUTH_NTLM = 8;
280
+		}
273 281
 
274 282
 		$this->debug('connect using cURL');
275 283
 		// init CURL
@@ -612,7 +620,9 @@  discard block
 block discarded – undo
612 620
 								'HTTP/1.0 200 Connection established');
613 621
 		foreach ($skipHeaders as $hd) {
614 622
 			$prefix = substr($data, 0, strlen($hd));
615
-			if ($prefix == $hd) return true;
623
+			if ($prefix == $hd) {
624
+			    return true;
625
+			}
616 626
 		}
617 627
 
618 628
 		return false;
Please login to merge, or discard this patch.
Indentation   +1262 added lines, -1262 removed lines patch added patch discarded remove patch
@@ -11,171 +11,171 @@  discard block
 block discarded – undo
11 11
 */
12 12
 class soap_transport_http extends nusoap_base
13 13
 {
14
-	var $url = '';
15
-	var $uri = '';
16
-	var $digest_uri = '';
17
-	var $scheme = '';
18
-	var $host = '';
19
-	var $port = '';
20
-	var $path = '';
21
-	var $request_method = 'POST';
22
-	var $protocol_version = '1.0';
23
-	var $encoding = '';
24
-	var $outgoing_headers = array();
25
-	var $incoming_headers = array();
26
-	var $incoming_cookies = array();
27
-	var $outgoing_payload = '';
28
-	var $incoming_payload = '';
29
-	var $response_status_line;	// HTTP response status line
30
-	var $useSOAPAction = true;
31
-	var $persistentConnection = false;
32
-	var $ch = false;	// cURL handle
33
-	var $ch_options = array();	// cURL custom options
34
-	var $use_curl = false;		// force cURL use
35
-	var $proxy = null;			// proxy information (associative array)
36
-	var $username = '';
37
-	var $password = '';
38
-	var $authtype = '';
39
-	var $digestRequest = array();
40
-	var $certRequest = array();	// keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional)
41
-								// cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem'
42
-								// sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem'
43
-								// sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem'
44
-								// passphrase: SSL key password/passphrase
45
-								// certpassword: SSL certificate password
46
-								// verifypeer: default is 1
47
-								// verifyhost: default is 1
48
-
49
-	/**
50
-	* constructor
51
-	*
52
-	* @param string $url The URL to which to connect
53
-	* @param array $curl_options User-specified cURL options
54
-	* @param boolean $use_curl Whether to try to force cURL use
55
-	* @access public
56
-	*/
57
-	function __construct($url, $curl_options = NULL, $use_curl = false){
58
-		parent::__construct();
59
-		$this->debug("ctor url=$url use_curl=$use_curl curl_options:");
60
-		$this->appendDebug($this->varDump($curl_options));
61
-		$this->setURL($url);
62
-		if (is_array($curl_options)) {
63
-			$this->ch_options = $curl_options;
64
-		}
65
-		$this->use_curl = $use_curl;
66
-		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
67
-		$this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
68
-	}
69
-
70
-	/**
71
-	* sets a cURL option
72
-	*
73
-	* @param	mixed $option The cURL option (always integer?)
74
-	* @param	mixed $value The cURL option value
75
-	* @access   private
76
-	*/
77
-	function setCurlOption($option, $value) {
78
-		$this->debug("setCurlOption option=$option, value=");
79
-		$this->appendDebug($this->varDump($value));
80
-		curl_setopt($this->ch, $option, $value);
81
-	}
82
-
83
-	/**
84
-	* sets an HTTP header
85
-	*
86
-	* @param string $name The name of the header
87
-	* @param string $value The value of the header
88
-	* @access private
89
-	*/
90
-	function setHeader($name, $value) {
91
-		$this->outgoing_headers[$name] = $value;
92
-		$this->debug("set header $name: $value");
93
-	}
94
-
95
-	/**
96
-	* unsets an HTTP header
97
-	*
98
-	* @param string $name The name of the header
99
-	* @access private
100
-	*/
101
-	function unsetHeader($name) {
102
-		if (isset($this->outgoing_headers[$name])) {
103
-			$this->debug("unset header $name");
104
-			unset($this->outgoing_headers[$name]);
105
-		}
106
-	}
107
-
108
-	/**
109
-	* sets the URL to which to connect
110
-	*
111
-	* @param string $url The URL to which to connect
112
-	* @access private
113
-	*/
114
-	function setURL($url) {
115
-		$this->url = $url;
116
-
117
-		$u = parse_url($url);
118
-		foreach($u as $k => $v){
119
-			$this->debug("parsed URL $k = $v");
120
-			$this->$k = $v;
121
-		}
122
-
123
-		// add any GET params to path
124
-		if(isset($u['query']) && $u['query'] != ''){
14
+    var $url = '';
15
+    var $uri = '';
16
+    var $digest_uri = '';
17
+    var $scheme = '';
18
+    var $host = '';
19
+    var $port = '';
20
+    var $path = '';
21
+    var $request_method = 'POST';
22
+    var $protocol_version = '1.0';
23
+    var $encoding = '';
24
+    var $outgoing_headers = array();
25
+    var $incoming_headers = array();
26
+    var $incoming_cookies = array();
27
+    var $outgoing_payload = '';
28
+    var $incoming_payload = '';
29
+    var $response_status_line;	// HTTP response status line
30
+    var $useSOAPAction = true;
31
+    var $persistentConnection = false;
32
+    var $ch = false;	// cURL handle
33
+    var $ch_options = array();	// cURL custom options
34
+    var $use_curl = false;		// force cURL use
35
+    var $proxy = null;			// proxy information (associative array)
36
+    var $username = '';
37
+    var $password = '';
38
+    var $authtype = '';
39
+    var $digestRequest = array();
40
+    var $certRequest = array();	// keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional)
41
+                                // cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem'
42
+                                // sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem'
43
+                                // sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem'
44
+                                // passphrase: SSL key password/passphrase
45
+                                // certpassword: SSL certificate password
46
+                                // verifypeer: default is 1
47
+                                // verifyhost: default is 1
48
+
49
+    /**
50
+     * constructor
51
+     *
52
+     * @param string $url The URL to which to connect
53
+     * @param array $curl_options User-specified cURL options
54
+     * @param boolean $use_curl Whether to try to force cURL use
55
+     * @access public
56
+     */
57
+    function __construct($url, $curl_options = NULL, $use_curl = false){
58
+        parent::__construct();
59
+        $this->debug("ctor url=$url use_curl=$use_curl curl_options:");
60
+        $this->appendDebug($this->varDump($curl_options));
61
+        $this->setURL($url);
62
+        if (is_array($curl_options)) {
63
+            $this->ch_options = $curl_options;
64
+        }
65
+        $this->use_curl = $use_curl;
66
+        preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
67
+        $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
68
+    }
69
+
70
+    /**
71
+     * sets a cURL option
72
+     *
73
+     * @param	mixed $option The cURL option (always integer?)
74
+     * @param	mixed $value The cURL option value
75
+     * @access   private
76
+     */
77
+    function setCurlOption($option, $value) {
78
+        $this->debug("setCurlOption option=$option, value=");
79
+        $this->appendDebug($this->varDump($value));
80
+        curl_setopt($this->ch, $option, $value);
81
+    }
82
+
83
+    /**
84
+     * sets an HTTP header
85
+     *
86
+     * @param string $name The name of the header
87
+     * @param string $value The value of the header
88
+     * @access private
89
+     */
90
+    function setHeader($name, $value) {
91
+        $this->outgoing_headers[$name] = $value;
92
+        $this->debug("set header $name: $value");
93
+    }
94
+
95
+    /**
96
+     * unsets an HTTP header
97
+     *
98
+     * @param string $name The name of the header
99
+     * @access private
100
+     */
101
+    function unsetHeader($name) {
102
+        if (isset($this->outgoing_headers[$name])) {
103
+            $this->debug("unset header $name");
104
+            unset($this->outgoing_headers[$name]);
105
+        }
106
+    }
107
+
108
+    /**
109
+     * sets the URL to which to connect
110
+     *
111
+     * @param string $url The URL to which to connect
112
+     * @access private
113
+     */
114
+    function setURL($url) {
115
+        $this->url = $url;
116
+
117
+        $u = parse_url($url);
118
+        foreach($u as $k => $v){
119
+            $this->debug("parsed URL $k = $v");
120
+            $this->$k = $v;
121
+        }
122
+
123
+        // add any GET params to path
124
+        if(isset($u['query']) && $u['query'] != ''){
125 125
             $this->path .= '?' . $u['query'];
126
-		}
127
-
128
-		// set default port
129
-		if(!isset($u['port'])){
130
-			if($u['scheme'] == 'https'){
131
-				$this->port = 443;
132
-			} else {
133
-				$this->port = 80;
134
-			}
135
-		}
136
-
137
-		$this->uri = $this->path;
138
-		$this->digest_uri = $this->uri;
139
-
140
-		// build headers
141
-		if (!isset($u['port'])) {
142
-			$this->setHeader('Host', $this->host);
143
-		} else {
144
-			$this->setHeader('Host', $this->host.':'.$this->port);
145
-		}
146
-
147
-		if (isset($u['user']) && $u['user'] != '') {
148
-			$this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
149
-		}
150
-	}
151
-
152
-	/**
153
-	* gets the I/O method to use
154
-	*
155
-	* @return	string	I/O method to use (socket|curl|unknown)
156
-	* @access	private
157
-	*/
158
-	function io_method() {
159
-		if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm'))
160
-			return 'curl';
161
-		if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm'))
162
-			return 'socket';
163
-		return 'unknown';
164
-	}
165
-
166
-	/**
167
-	* establish an HTTP connection
168
-	*
169
-	* @param    integer $timeout set connection timeout in seconds
170
-	* @param	integer $response_timeout set response timeout in seconds
171
-	* @return	boolean true if connected, false if not
172
-	* @access   private
173
-	*/
174
-	function connect($connection_timeout=0,$response_timeout=30){
175
-	  	// For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
176
-	  	// "regular" socket.
177
-	  	// TODO: disabled for now because OpenSSL must be *compiled* in (not just
178
-	  	//       loaded), and until PHP5 stream_get_wrappers is not available.
126
+        }
127
+
128
+        // set default port
129
+        if(!isset($u['port'])){
130
+            if($u['scheme'] == 'https'){
131
+                $this->port = 443;
132
+            } else {
133
+                $this->port = 80;
134
+            }
135
+        }
136
+
137
+        $this->uri = $this->path;
138
+        $this->digest_uri = $this->uri;
139
+
140
+        // build headers
141
+        if (!isset($u['port'])) {
142
+            $this->setHeader('Host', $this->host);
143
+        } else {
144
+            $this->setHeader('Host', $this->host.':'.$this->port);
145
+        }
146
+
147
+        if (isset($u['user']) && $u['user'] != '') {
148
+            $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
149
+        }
150
+    }
151
+
152
+    /**
153
+     * gets the I/O method to use
154
+     *
155
+     * @return	string	I/O method to use (socket|curl|unknown)
156
+     * @access	private
157
+     */
158
+    function io_method() {
159
+        if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm'))
160
+            return 'curl';
161
+        if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm'))
162
+            return 'socket';
163
+        return 'unknown';
164
+    }
165
+
166
+    /**
167
+     * establish an HTTP connection
168
+     *
169
+     * @param    integer $timeout set connection timeout in seconds
170
+     * @param	integer $response_timeout set response timeout in seconds
171
+     * @return	boolean true if connected, false if not
172
+     * @access   private
173
+     */
174
+    function connect($connection_timeout=0,$response_timeout=30){
175
+            // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
176
+            // "regular" socket.
177
+            // TODO: disabled for now because OpenSSL must be *compiled* in (not just
178
+            //       loaded), and until PHP5 stream_get_wrappers is not available.
179 179
 //	  	if ($this->scheme == 'https') {
180 180
 //		  	if (version_compare(phpversion(), '4.3.0') >= 0) {
181 181
 //		  		if (extension_loaded('openssl')) {
@@ -184,1120 +184,1120 @@  discard block
 block discarded – undo
184 184
 //		  		}
185 185
 //		  	}
186 186
 //		}
187
-		$this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
188
-	  if ($this->io_method() == 'socket') {
189
-		if (!is_array($this->proxy)) {
190
-			$host = $this->host;
191
-			$port = $this->port;
192
-		} else {
193
-			$host = $this->proxy['host'];
194
-			$port = $this->proxy['port'];
195
-		}
196
-
197
-		// use persistent connection
198
-		if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
199
-			if (!feof($this->fp)) {
200
-				$this->debug('Re-use persistent connection');
201
-				return true;
202
-			}
203
-			fclose($this->fp);
204
-			$this->debug('Closed persistent connection at EOF');
205
-		}
206
-
207
-		// munge host if using OpenSSL
208
-		if ($this->scheme == 'ssl') {
209
-			$host = 'ssl://' . $host;
210
-		}
211
-		$this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
212
-
213
-		// open socket
214
-		if($connection_timeout > 0){
215
-			$this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout);
216
-		} else {
217
-			$this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str);
218
-		}
219
-
220
-		// test pointer
221
-		if(!$this->fp) {
222
-			$msg = 'Couldn\'t open socket connection to server ' . $this->url;
223
-			if ($this->errno) {
224
-				$msg .= ', Error ('.$this->errno.'): '.$this->error_str;
225
-			} else {
226
-				$msg .= ' prior to connect().  This is often a problem looking up the host name.';
227
-			}
228
-			$this->debug($msg);
229
-			$this->setError($msg);
230
-			return false;
231
-		}
232
-
233
-		// set response timeout
234
-		$this->debug('set response timeout to ' . $response_timeout);
235
-		socket_set_timeout( $this->fp, $response_timeout);
236
-
237
-		$this->debug('socket connected');
238
-		return true;
239
-	  } else if ($this->io_method() == 'curl') {
240
-		if (!extension_loaded('curl')) {
187
+        $this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
188
+        if ($this->io_method() == 'socket') {
189
+        if (!is_array($this->proxy)) {
190
+            $host = $this->host;
191
+            $port = $this->port;
192
+        } else {
193
+            $host = $this->proxy['host'];
194
+            $port = $this->proxy['port'];
195
+        }
196
+
197
+        // use persistent connection
198
+        if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
199
+            if (!feof($this->fp)) {
200
+                $this->debug('Re-use persistent connection');
201
+                return true;
202
+            }
203
+            fclose($this->fp);
204
+            $this->debug('Closed persistent connection at EOF');
205
+        }
206
+
207
+        // munge host if using OpenSSL
208
+        if ($this->scheme == 'ssl') {
209
+            $host = 'ssl://' . $host;
210
+        }
211
+        $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
212
+
213
+        // open socket
214
+        if($connection_timeout > 0){
215
+            $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout);
216
+        } else {
217
+            $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str);
218
+        }
219
+
220
+        // test pointer
221
+        if(!$this->fp) {
222
+            $msg = 'Couldn\'t open socket connection to server ' . $this->url;
223
+            if ($this->errno) {
224
+                $msg .= ', Error ('.$this->errno.'): '.$this->error_str;
225
+            } else {
226
+                $msg .= ' prior to connect().  This is often a problem looking up the host name.';
227
+            }
228
+            $this->debug($msg);
229
+            $this->setError($msg);
230
+            return false;
231
+        }
232
+
233
+        // set response timeout
234
+        $this->debug('set response timeout to ' . $response_timeout);
235
+        socket_set_timeout( $this->fp, $response_timeout);
236
+
237
+        $this->debug('socket connected');
238
+        return true;
239
+        } else if ($this->io_method() == 'curl') {
240
+        if (!extension_loaded('curl')) {
241 241
 //			$this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS');
242
-			$this->setError('The PHP cURL Extension is required for HTTPS or NLTM.  You will need to re-build or update your PHP to include cURL or change php.ini to load the PHP cURL extension.');
243
-			return false;
244
-		}
245
-		// Avoid warnings when PHP does not have these options
246
-		if (defined('CURLOPT_CONNECTIONTIMEOUT'))
247
-			$CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
248
-		else
249
-			$CURLOPT_CONNECTIONTIMEOUT = 78;
250
-		if (defined('CURLOPT_HTTPAUTH'))
251
-			$CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
252
-		else
253
-			$CURLOPT_HTTPAUTH = 107;
254
-		if (defined('CURLOPT_PROXYAUTH'))
255
-			$CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
256
-		else
257
-			$CURLOPT_PROXYAUTH = 111;
258
-		if (defined('CURLAUTH_BASIC'))
259
-			$CURLAUTH_BASIC = CURLAUTH_BASIC;
260
-		else
261
-			$CURLAUTH_BASIC = 1;
262
-		if (defined('CURLAUTH_DIGEST'))
263
-			$CURLAUTH_DIGEST = CURLAUTH_DIGEST;
264
-		else
265
-			$CURLAUTH_DIGEST = 2;
266
-		if (defined('CURLAUTH_NTLM'))
267
-			$CURLAUTH_NTLM = CURLAUTH_NTLM;
268
-		else
269
-			$CURLAUTH_NTLM = 8;
270
-
271
-		$this->debug('connect using cURL');
272
-		// init CURL
273
-		$this->ch = curl_init();
274
-		// set url
275
-		$hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host";
276
-		// add path
277
-		$hostURL .= $this->path;
278
-		$this->setCurlOption(CURLOPT_URL, $hostURL);
279
-		// follow location headers (re-directs)
280
-		if (ini_get('safe_mode') || ini_get('open_basedir')) {
281
-			$this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
282
-			$this->debug('safe_mode = ');
283
-			$this->appendDebug($this->varDump(ini_get('safe_mode')));
284
-			$this->debug('open_basedir = ');
285
-			$this->appendDebug($this->varDump(ini_get('open_basedir')));
286
-		} else {
287
-			$this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1);
288
-		}
289
-		// ask for headers in the response output
290
-		$this->setCurlOption(CURLOPT_HEADER, 1);
291
-		// ask for the response output as the return value
292
-		$this->setCurlOption(CURLOPT_RETURNTRANSFER, 1);
293
-		// encode
294
-		// We manage this ourselves through headers and encoding
242
+            $this->setError('The PHP cURL Extension is required for HTTPS or NLTM.  You will need to re-build or update your PHP to include cURL or change php.ini to load the PHP cURL extension.');
243
+            return false;
244
+        }
245
+        // Avoid warnings when PHP does not have these options
246
+        if (defined('CURLOPT_CONNECTIONTIMEOUT'))
247
+            $CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
248
+        else
249
+            $CURLOPT_CONNECTIONTIMEOUT = 78;
250
+        if (defined('CURLOPT_HTTPAUTH'))
251
+            $CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
252
+        else
253
+            $CURLOPT_HTTPAUTH = 107;
254
+        if (defined('CURLOPT_PROXYAUTH'))
255
+            $CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
256
+        else
257
+            $CURLOPT_PROXYAUTH = 111;
258
+        if (defined('CURLAUTH_BASIC'))
259
+            $CURLAUTH_BASIC = CURLAUTH_BASIC;
260
+        else
261
+            $CURLAUTH_BASIC = 1;
262
+        if (defined('CURLAUTH_DIGEST'))
263
+            $CURLAUTH_DIGEST = CURLAUTH_DIGEST;
264
+        else
265
+            $CURLAUTH_DIGEST = 2;
266
+        if (defined('CURLAUTH_NTLM'))
267
+            $CURLAUTH_NTLM = CURLAUTH_NTLM;
268
+        else
269
+            $CURLAUTH_NTLM = 8;
270
+
271
+        $this->debug('connect using cURL');
272
+        // init CURL
273
+        $this->ch = curl_init();
274
+        // set url
275
+        $hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host";
276
+        // add path
277
+        $hostURL .= $this->path;
278
+        $this->setCurlOption(CURLOPT_URL, $hostURL);
279
+        // follow location headers (re-directs)
280
+        if (ini_get('safe_mode') || ini_get('open_basedir')) {
281
+            $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
282
+            $this->debug('safe_mode = ');
283
+            $this->appendDebug($this->varDump(ini_get('safe_mode')));
284
+            $this->debug('open_basedir = ');
285
+            $this->appendDebug($this->varDump(ini_get('open_basedir')));
286
+        } else {
287
+            $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1);
288
+        }
289
+        // ask for headers in the response output
290
+        $this->setCurlOption(CURLOPT_HEADER, 1);
291
+        // ask for the response output as the return value
292
+        $this->setCurlOption(CURLOPT_RETURNTRANSFER, 1);
293
+        // encode
294
+        // We manage this ourselves through headers and encoding
295 295
 //		if(function_exists('gzuncompress')){
296 296
 //			$this->setCurlOption(CURLOPT_ENCODING, 'deflate');
297 297
 //		}
298
-		// persistent connection
299
-		if ($this->persistentConnection) {
300
-			// I believe the following comment is now bogus, having applied to
301
-			// the code when it used CURLOPT_CUSTOMREQUEST to send the request.
302
-			// The way we send data, we cannot use persistent connections, since
303
-			// there will be some "junk" at the end of our request.
304
-			//$this->setCurlOption(CURL_HTTP_VERSION_1_1, true);
305
-			$this->persistentConnection = false;
306
-			$this->setHeader('Connection', 'close');
307
-		}
308
-		// set timeouts
309
-		if ($connection_timeout != 0) {
310
-			$this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
311
-		}
312
-		if ($response_timeout != 0) {
313
-			$this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout);
314
-		}
315
-
316
-		if ($this->scheme == 'https') {
317
-			$this->debug('set cURL SSL verify options');
318
-			// recent versions of cURL turn on peer/host checking by default,
319
-			// while PHP binaries are not compiled with a default location for the
320
-			// CA cert bundle, so disable peer/host checking.
321
-			//$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt');
322
-			$this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
323
-			$this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
324
-
325
-			// support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo)
326
-			if ($this->authtype == 'certificate') {
327
-				$this->debug('set cURL certificate options');
328
-				if (isset($this->certRequest['cainfofile'])) {
329
-					$this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']);
330
-				}
331
-				if (isset($this->certRequest['verifypeer'])) {
332
-					$this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
333
-				} else {
334
-					$this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
335
-				}
336
-				if (isset($this->certRequest['verifyhost'])) {
337
-					$this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
338
-				} else {
339
-					$this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
340
-				}
341
-				if (isset($this->certRequest['sslcertfile'])) {
342
-					$this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
343
-				}
344
-				if (isset($this->certRequest['sslkeyfile'])) {
345
-					$this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
346
-				}
347
-				if (isset($this->certRequest['passphrase'])) {
348
-					$this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']);
349
-				}
350
-				if (isset($this->certRequest['certpassword'])) {
351
-					$this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']);
352
-				}
353
-			}
354
-		}
355
-		if ($this->authtype && ($this->authtype != 'certificate')) {
356
-			if ($this->username) {
357
-				$this->debug('set cURL username/password');
358
-				$this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password");
359
-			}
360
-			if ($this->authtype == 'basic') {
361
-				$this->debug('set cURL for Basic authentication');
362
-				$this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC);
363
-			}
364
-			if ($this->authtype == 'digest') {
365
-				$this->debug('set cURL for digest authentication');
366
-				$this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST);
367
-			}
368
-			if ($this->authtype == 'ntlm') {
369
-				$this->debug('set cURL for NTLM authentication');
370
-				$this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM);
371
-			}
372
-		}
373
-		if (is_array($this->proxy)) {
374
-			$this->debug('set cURL proxy options');
375
-			if ($this->proxy['port'] != '') {
376
-				$this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'].':'.$this->proxy['port']);
377
-			} else {
378
-				$this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']);
379
-			}
380
-			if ($this->proxy['username'] || $this->proxy['password']) {
381
-				$this->debug('set cURL proxy authentication options');
382
-				$this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'].':'.$this->proxy['password']);
383
-				if ($this->proxy['authtype'] == 'basic') {
384
-					$this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC);
385
-				}
386
-				if ($this->proxy['authtype'] == 'ntlm') {
387
-					$this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM);
388
-				}
389
-			}
390
-		}
391
-		$this->debug('cURL connection set up');
392
-		return true;
393
-	  } else {
394
-		$this->setError('Unknown scheme ' . $this->scheme);
395
-		$this->debug('Unknown scheme ' . $this->scheme);
396
-		return false;
397
-	  }
398
-	}
399
-
400
-	/**
401
-	* sends the SOAP request and gets the SOAP response via HTTP[S]
402
-	*
403
-	* @param    string $data message data
404
-	* @param    integer $timeout set connection timeout in seconds
405
-	* @param	integer $response_timeout set response timeout in seconds
406
-	* @param	array $cookies cookies to send
407
-	* @return	string data
408
-	* @access   public
409
-	*/
410
-	function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) {
411
-
412
-		$this->debug('entered send() with data of length: '.strlen($data));
413
-
414
-		$this->tryagain = true;
415
-		$tries = 0;
416
-		while ($this->tryagain) {
417
-			$this->tryagain = false;
418
-			if ($tries++ < 2) {
419
-				// make connnection
420
-				if (!$this->connect($timeout, $response_timeout)){
421
-					return false;
422
-				}
423
-
424
-				// send request
425
-				if (!$this->sendRequest($data, $cookies)){
426
-					return false;
427
-				}
428
-
429
-				// get response
430
-				$respdata = $this->getResponse();
431
-			} else {
432
-				$this->setError("Too many tries to get an OK response ($this->response_status_line)");
433
-			}
434
-		}
435
-		$this->debug('end of send()');
436
-		return $respdata;
437
-	}
438
-
439
-
440
-	/**
441
-	* sends the SOAP request and gets the SOAP response via HTTPS using CURL
442
-	*
443
-	* @param    string $data message data
444
-	* @param    integer $timeout set connection timeout in seconds
445
-	* @param	integer $response_timeout set response timeout in seconds
446
-	* @param	array $cookies cookies to send
447
-	* @return	string data
448
-	* @access   public
449
-	* @deprecated
450
-	*/
451
-	function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies) {
452
-		return $this->send($data, $timeout, $response_timeout, $cookies);
453
-	}
454
-
455
-	/**
456
-	* if authenticating, set user credentials here
457
-	*
458
-	* @param    string $username
459
-	* @param    string $password
460
-	* @param	string $authtype (basic|digest|certificate|ntlm)
461
-	* @param	array $digestRequest (keys must be nonce, nc, realm, qop)
462
-	* @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
463
-	* @access   public
464
-	*/
465
-	function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) {
466
-		$this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
467
-		$this->appendDebug($this->varDump($digestRequest));
468
-		$this->debug("certRequest=");
469
-		$this->appendDebug($this->varDump($certRequest));
470
-		// cf. RFC 2617
471
-		if ($authtype == 'basic') {
472
-			$this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':','',$username).':'.$password));
473
-		} elseif ($authtype == 'digest') {
474
-			if (isset($digestRequest['nonce'])) {
475
-				$digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
476
-
477
-				// calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
478
-
479
-				// A1 = unq(username-value) ":" unq(realm-value) ":" passwd
480
-				$A1 = $username. ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
481
-
482
-				// H(A1) = MD5(A1)
483
-				$HA1 = md5($A1);
484
-
485
-				// A2 = Method ":" digest-uri-value
486
-				$A2 = $this->request_method . ':' . $this->digest_uri;
487
-
488
-				// H(A2)
489
-				$HA2 =  md5($A2);
490
-
491
-				// KD(secret, data) = H(concat(secret, ":", data))
492
-				// if qop == auth:
493
-				// request-digest  = <"> < KD ( H(A1),     unq(nonce-value)
494
-				//                              ":" nc-value
495
-				//                              ":" unq(cnonce-value)
496
-				//                              ":" unq(qop-value)
497
-				//                              ":" H(A2)
498
-				//                            ) <">
499
-				// if qop is missing,
500
-				// request-digest  = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
501
-
502
-				$unhashedDigest = '';
503
-				$nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : '';
504
-				$cnonce = $nonce;
505
-				if ($digestRequest['qop'] != '') {
506
-					$unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
507
-				} else {
508
-					$unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
509
-				}
510
-
511
-				$hashedDigest = md5($unhashedDigest);
512
-
513
-				$opaque = '';
514
-				if (isset($digestRequest['opaque'])) {
515
-					$opaque = ', opaque="' . $digestRequest['opaque'] . '"';
516
-				}
517
-
518
-				$this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"');
519
-			}
520
-		} elseif ($authtype == 'certificate') {
521
-			$this->certRequest = $certRequest;
522
-			$this->debug('Authorization header not set for certificate');
523
-		} elseif ($authtype == 'ntlm') {
524
-			// do nothing
525
-			$this->debug('Authorization header not set for ntlm');
526
-		}
527
-		$this->username = $username;
528
-		$this->password = $password;
529
-		$this->authtype = $authtype;
530
-		$this->digestRequest = $digestRequest;
531
-	}
532
-
533
-	/**
534
-	* set the soapaction value
535
-	*
536
-	* @param    string $soapaction
537
-	* @access   public
538
-	*/
539
-	function setSOAPAction($soapaction) {
540
-		$this->setHeader('SOAPAction', '"' . $soapaction . '"');
541
-	}
542
-
543
-	/**
544
-	* use http encoding
545
-	*
546
-	* @param    string $enc encoding style. supported values: gzip, deflate, or both
547
-	* @access   public
548
-	*/
549
-	function setEncoding($enc='gzip, deflate') {
550
-		if (function_exists('gzdeflate')) {
551
-			$this->protocol_version = '1.1';
552
-			$this->setHeader('Accept-Encoding', $enc);
553
-			if (!isset($this->outgoing_headers['Connection'])) {
554
-				$this->setHeader('Connection', 'close');
555
-				$this->persistentConnection = false;
556
-			}
557
-			// deprecated as of PHP 5.3.0
558
-			//set_magic_quotes_runtime(0);
559
-			$this->encoding = $enc;
560
-		}
561
-	}
562
-
563
-	/**
564
-	* set proxy info here
565
-	*
566
-	* @param    string $proxyhost use an empty string to remove proxy
567
-	* @param    string $proxyport
568
-	* @param	string $proxyusername
569
-	* @param	string $proxypassword
570
-	* @param	string $proxyauthtype (basic|ntlm)
571
-	* @access   public
572
-	*/
573
-	function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') {
574
-		if ($proxyhost) {
575
-			$this->proxy = array(
576
-				'host' => $proxyhost,
577
-				'port' => $proxyport,
578
-				'username' => $proxyusername,
579
-				'password' => $proxypassword,
580
-				'authtype' => $proxyauthtype
581
-			);
582
-			if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') {
583
-				$this->setHeader('Proxy-Authorization', ' Basic '.base64_encode($proxyusername.':'.$proxypassword));
584
-			}
585
-		} else {
586
-			$this->debug('remove proxy');
587
-			$proxy = null;
588
-			unsetHeader('Proxy-Authorization');
589
-		}
590
-	}
591
-
592
-
593
-	/**
594
-	 * Test if the given string starts with a header that is to be skipped.
595
-	 * Skippable headers result from chunked transfer and proxy requests.
596
-	 *
597
-	 * @param	string $data The string to check.
598
-	 * @returns	boolean	Whether a skippable header was found.
599
-	 * @access	private
600
-	 */
601
-	function isSkippableCurlHeader(&$data) {
602
-		$skipHeaders = array(	'HTTP/1.1 100',
603
-								'HTTP/1.0 301',
604
-								'HTTP/1.1 301',
605
-								'HTTP/1.0 302',
606
-								'HTTP/1.1 302',
607
-								'HTTP/1.0 401',
608
-								'HTTP/1.1 401',
609
-								'HTTP/1.0 200 Connection established');
610
-		foreach ($skipHeaders as $hd) {
611
-			$prefix = substr($data, 0, strlen($hd));
612
-			if ($prefix == $hd) return true;
613
-		}
614
-
615
-		return false;
616
-	}
617
-
618
-	/**
619
-	* decode a string that is encoded w/ "chunked' transfer encoding
620
- 	* as defined in RFC2068 19.4.6
621
-	*
622
-	* @param    string $buffer
623
-	* @param    string $lb
624
-	* @returns	string
625
-	* @access   public
626
-	* @deprecated
627
-	*/
628
-	function decodeChunked($buffer, $lb){
629
-		// length := 0
630
-		$length = 0;
631
-		$new = '';
632
-
633
-		// read chunk-size, chunk-extension (if any) and CRLF
634
-		// get the position of the linebreak
635
-		$chunkend = strpos($buffer, $lb);
636
-		if ($chunkend == FALSE) {
637
-			$this->debug('no linebreak found in decodeChunked');
638
-			return $new;
639
-		}
640
-		$temp = substr($buffer,0,$chunkend);
641
-		$chunk_size = hexdec( trim($temp) );
642
-		$chunkstart = $chunkend + strlen($lb);
643
-		// while (chunk-size > 0) {
644
-		while ($chunk_size > 0) {
645
-			$this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
646
-			$chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size);
647
-
648
-			// Just in case we got a broken connection
649
-		  	if ($chunkend == FALSE) {
650
-		  	    $chunk = substr($buffer,$chunkstart);
651
-				// append chunk-data to entity-body
652
-		    	$new .= $chunk;
653
-		  	    $length += strlen($chunk);
654
-		  	    break;
655
-			}
656
-
657
-		  	// read chunk-data and CRLF
658
-		  	$chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
659
-		  	// append chunk-data to entity-body
660
-		  	$new .= $chunk;
661
-		  	// length := length + chunk-size
662
-		  	$length += strlen($chunk);
663
-		  	// read chunk-size and CRLF
664
-		  	$chunkstart = $chunkend + strlen($lb);
665
-
666
-		  	$chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
667
-			if ($chunkend == FALSE) {
668
-				break; //Just in case we got a broken connection
669
-			}
670
-			$temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
671
-			$chunk_size = hexdec( trim($temp) );
672
-			$chunkstart = $chunkend;
673
-		}
674
-		return $new;
675
-	}
676
-
677
-	/**
678
-	 * Writes the payload, including HTTP headers, to $this->outgoing_payload.
679
-	 *
680
-	 * @param	string $data HTTP body
681
-	 * @param	string $cookie_str data for HTTP Cookie header
682
-	 * @return	void
683
-	 * @access	private
684
-	 */
685
-	function buildPayload($data, $cookie_str = '') {
686
-		// Note: for cURL connections, $this->outgoing_payload is ignored,
687
-		// as is the Content-Length header, but these are still created as
688
-		// debugging guides.
689
-
690
-		// add content-length header
691
-		if ($this->request_method != 'GET') {
692
-			$this->setHeader('Content-Length', strlen($data));
693
-		}
694
-
695
-		// start building outgoing payload:
696
-		if ($this->proxy) {
697
-			$uri = $this->url;
698
-		} else {
699
-			$uri = $this->uri;
700
-		}
701
-		$req = "$this->request_method $uri HTTP/$this->protocol_version";
702
-		$this->debug("HTTP request: $req");
703
-		$this->outgoing_payload = "$req\r\n";
704
-
705
-		// loop thru headers, serializing
706
-		foreach($this->outgoing_headers as $k => $v){
707
-			$hdr = $k.': '.$v;
708
-			$this->debug("HTTP header: $hdr");
709
-			$this->outgoing_payload .= "$hdr\r\n";
710
-		}
711
-
712
-		// add any cookies
713
-		if ($cookie_str != '') {
714
-			$hdr = 'Cookie: '.$cookie_str;
715
-			$this->debug("HTTP header: $hdr");
716
-			$this->outgoing_payload .= "$hdr\r\n";
717
-		}
718
-
719
-		// header/body separator
720
-		$this->outgoing_payload .= "\r\n";
721
-
722
-		// add data
723
-		$this->outgoing_payload .= $data;
724
-	}
725
-
726
-	/**
727
-	* sends the SOAP request via HTTP[S]
728
-	*
729
-	* @param    string $data message data
730
-	* @param	array $cookies cookies to send
731
-	* @return	boolean	true if OK, false if problem
732
-	* @access   private
733
-	*/
734
-	function sendRequest($data, $cookies = NULL) {
735
-		// build cookie string
736
-		$cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));
737
-
738
-		// build payload
739
-		$this->buildPayload($data, $cookie_str);
740
-
741
-	  if ($this->io_method() == 'socket') {
742
-		// send payload
743
-		if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
744
-			$this->setError('couldn\'t write message data to socket');
745
-			$this->debug('couldn\'t write message data to socket');
746
-			return false;
747
-		}
748
-		$this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
749
-		return true;
750
-	  } else if ($this->io_method() == 'curl') {
751
-		// set payload
752
-		// cURL does say this should only be the verb, and in fact it
753
-		// turns out that the URI and HTTP version are appended to this, which
754
-		// some servers refuse to work with (so we no longer use this method!)
755
-		//$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
756
-		$curl_headers = array();
757
-		foreach($this->outgoing_headers as $k => $v){
758
-			if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
759
-				$this->debug("Skip cURL header $k: $v");
760
-			} else {
761
-				$curl_headers[] = "$k: $v";
762
-			}
763
-		}
764
-		if ($cookie_str != '') {
765
-			$curl_headers[] = 'Cookie: ' . $cookie_str;
766
-		}
767
-		$this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
768
-		$this->debug('set cURL HTTP headers');
769
-		if ($this->request_method == "POST") {
770
-	  		$this->setCurlOption(CURLOPT_POST, 1);
771
-	  		$this->setCurlOption(CURLOPT_POSTFIELDS, $data);
772
-			$this->debug('set cURL POST data');
773
-	  	} else {
774
-	  	}
775
-		// insert custom user-set cURL options
776
-		foreach ($this->ch_options as $key => $val) {
777
-			$this->setCurlOption($key, $val);
778
-		}
779
-
780
-		$this->debug('set cURL payload');
781
-		return true;
782
-	  }
783
-	}
784
-
785
-	/**
786
-	* gets the SOAP response via HTTP[S]
787
-	*
788
-	* @return	string the response (also sets member variables like incoming_payload)
789
-	* @access   private
790
-	*/
791
-	function getResponse(){
792
-		$this->incoming_payload = '';
793
-
794
-	  if ($this->io_method() == 'socket') {
795
-	    // loop until headers have been retrieved
796
-	    $data = '';
797
-	    while (!isset($lb)){
798
-
799
-			// We might EOF during header read.
800
-			if(feof($this->fp)) {
801
-				$this->incoming_payload = $data;
802
-				$this->debug('found no headers before EOF after length ' . strlen($data));
803
-				$this->debug("received before EOF:\n" . $data);
804
-				$this->setError('server failed to send headers');
805
-				return false;
806
-			}
807
-
808
-			$tmp = fgets($this->fp, 256);
809
-			$tmplen = strlen($tmp);
810
-			$this->debug("read line of $tmplen bytes: " . trim($tmp));
811
-
812
-			if ($tmplen == 0) {
813
-				$this->incoming_payload = $data;
814
-				$this->debug('socket read of headers timed out after length ' . strlen($data));
815
-				$this->debug("read before timeout: " . $data);
816
-				$this->setError('socket read of headers timed out');
817
-				return false;
818
-			}
819
-
820
-			$data .= $tmp;
821
-			$pos = strpos($data,"\r\n\r\n");
822
-			if($pos > 1){
823
-				$lb = "\r\n";
824
-			} else {
825
-				$pos = strpos($data,"\n\n");
826
-				if($pos > 1){
827
-					$lb = "\n";
828
-				}
829
-			}
830
-			// remove 100 headers
831
-			if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) {
832
-				unset($lb);
833
-				$data = '';
834
-			}//
835
-		}
836
-		// store header data
837
-		$this->incoming_payload .= $data;
838
-		$this->debug('found end of headers after length ' . strlen($data));
839
-		// process headers
840
-		$header_data = trim(substr($data,0,$pos));
841
-		$header_array = explode($lb,$header_data);
842
-		$this->incoming_headers = array();
843
-		$this->incoming_cookies = array();
844
-		foreach($header_array as $header_line){
845
-			$arr = explode(':',$header_line, 2);
846
-			if(count($arr) > 1){
847
-				$header_name = strtolower(trim($arr[0]));
848
-				$this->incoming_headers[$header_name] = trim($arr[1]);
849
-				if ($header_name == 'set-cookie') {
850
-					// TODO: allow multiple cookies from parseCookie
851
-					$cookie = $this->parseCookie(trim($arr[1]));
852
-					if ($cookie) {
853
-						$this->incoming_cookies[] = $cookie;
854
-						$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
855
-					} else {
856
-						$this->debug('did not find cookie in ' . trim($arr[1]));
857
-					}
858
-    			}
859
-			} else if (isset($header_name)) {
860
-				// append continuation line to previous header
861
-				$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
862
-			}
863
-		}
864
-
865
-		// loop until msg has been received
866
-		if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
867
-			$content_length =  2147483647;	// ignore any content-length header
868
-			$chunked = true;
869
-			$this->debug("want to read chunked content");
870
-		} elseif (isset($this->incoming_headers['content-length'])) {
871
-			$content_length = $this->incoming_headers['content-length'];
872
-			$chunked = false;
873
-			$this->debug("want to read content of length $content_length");
874
-		} else {
875
-			$content_length =  2147483647;
876
-			$chunked = false;
877
-			$this->debug("want to read content to EOF");
878
-		}
879
-		$data = '';
880
-		do {
881
-			if ($chunked) {
882
-				$tmp = fgets($this->fp, 256);
883
-				$tmplen = strlen($tmp);
884
-				$this->debug("read chunk line of $tmplen bytes");
885
-				if ($tmplen == 0) {
886
-					$this->incoming_payload = $data;
887
-					$this->debug('socket read of chunk length timed out after length ' . strlen($data));
888
-					$this->debug("read before timeout:\n" . $data);
889
-					$this->setError('socket read of chunk length timed out');
890
-					return false;
891
-				}
892
-				$content_length = hexdec(trim($tmp));
893
-				$this->debug("chunk length $content_length");
894
-			}
895
-			$strlen = 0;
896
-		    while (($strlen < $content_length) && (!feof($this->fp))) {
897
-		    	$readlen = min(8192, $content_length - $strlen);
898
-				$tmp = fread($this->fp, $readlen);
899
-				$tmplen = strlen($tmp);
900
-				$this->debug("read buffer of $tmplen bytes");
901
-				if (($tmplen == 0) && (!feof($this->fp))) {
902
-					$this->incoming_payload = $data;
903
-					$this->debug('socket read of body timed out after length ' . strlen($data));
904
-					$this->debug("read before timeout:\n" . $data);
905
-					$this->setError('socket read of body timed out');
906
-					return false;
907
-				}
908
-				$strlen += $tmplen;
909
-				$data .= $tmp;
910
-			}
911
-			if ($chunked && ($content_length > 0)) {
912
-				$tmp = fgets($this->fp, 256);
913
-				$tmplen = strlen($tmp);
914
-				$this->debug("read chunk terminator of $tmplen bytes");
915
-				if ($tmplen == 0) {
916
-					$this->incoming_payload = $data;
917
-					$this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
918
-					$this->debug("read before timeout:\n" . $data);
919
-					$this->setError('socket read of chunk terminator timed out');
920
-					return false;
921
-				}
922
-			}
923
-		} while ($chunked && ($content_length > 0) && (!feof($this->fp)));
924
-		if (feof($this->fp)) {
925
-			$this->debug('read to EOF');
926
-		}
927
-		$this->debug('read body of length ' . strlen($data));
928
-		$this->incoming_payload .= $data;
929
-		$this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
930
-
931
-		// close filepointer
932
-		if(
933
-			(isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') ||
934
-			(! $this->persistentConnection) || feof($this->fp)){
935
-			fclose($this->fp);
936
-			$this->fp = false;
937
-			$this->debug('closed socket');
938
-		}
939
-
940
-		// connection was closed unexpectedly
941
-		if($this->incoming_payload == ''){
942
-			$this->setError('no response from server');
943
-			return false;
944
-		}
945
-
946
-		// decode transfer-encoding
298
+        // persistent connection
299
+        if ($this->persistentConnection) {
300
+            // I believe the following comment is now bogus, having applied to
301
+            // the code when it used CURLOPT_CUSTOMREQUEST to send the request.
302
+            // The way we send data, we cannot use persistent connections, since
303
+            // there will be some "junk" at the end of our request.
304
+            //$this->setCurlOption(CURL_HTTP_VERSION_1_1, true);
305
+            $this->persistentConnection = false;
306
+            $this->setHeader('Connection', 'close');
307
+        }
308
+        // set timeouts
309
+        if ($connection_timeout != 0) {
310
+            $this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
311
+        }
312
+        if ($response_timeout != 0) {
313
+            $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout);
314
+        }
315
+
316
+        if ($this->scheme == 'https') {
317
+            $this->debug('set cURL SSL verify options');
318
+            // recent versions of cURL turn on peer/host checking by default,
319
+            // while PHP binaries are not compiled with a default location for the
320
+            // CA cert bundle, so disable peer/host checking.
321
+            //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt');
322
+            $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
323
+            $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
324
+
325
+            // support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo)
326
+            if ($this->authtype == 'certificate') {
327
+                $this->debug('set cURL certificate options');
328
+                if (isset($this->certRequest['cainfofile'])) {
329
+                    $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']);
330
+                }
331
+                if (isset($this->certRequest['verifypeer'])) {
332
+                    $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
333
+                } else {
334
+                    $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
335
+                }
336
+                if (isset($this->certRequest['verifyhost'])) {
337
+                    $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
338
+                } else {
339
+                    $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
340
+                }
341
+                if (isset($this->certRequest['sslcertfile'])) {
342
+                    $this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
343
+                }
344
+                if (isset($this->certRequest['sslkeyfile'])) {
345
+                    $this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
346
+                }
347
+                if (isset($this->certRequest['passphrase'])) {
348
+                    $this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']);
349
+                }
350
+                if (isset($this->certRequest['certpassword'])) {
351
+                    $this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']);
352
+                }
353
+            }
354
+        }
355
+        if ($this->authtype && ($this->authtype != 'certificate')) {
356
+            if ($this->username) {
357
+                $this->debug('set cURL username/password');
358
+                $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password");
359
+            }
360
+            if ($this->authtype == 'basic') {
361
+                $this->debug('set cURL for Basic authentication');
362
+                $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC);
363
+            }
364
+            if ($this->authtype == 'digest') {
365
+                $this->debug('set cURL for digest authentication');
366
+                $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST);
367
+            }
368
+            if ($this->authtype == 'ntlm') {
369
+                $this->debug('set cURL for NTLM authentication');
370
+                $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM);
371
+            }
372
+        }
373
+        if (is_array($this->proxy)) {
374
+            $this->debug('set cURL proxy options');
375
+            if ($this->proxy['port'] != '') {
376
+                $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'].':'.$this->proxy['port']);
377
+            } else {
378
+                $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']);
379
+            }
380
+            if ($this->proxy['username'] || $this->proxy['password']) {
381
+                $this->debug('set cURL proxy authentication options');
382
+                $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'].':'.$this->proxy['password']);
383
+                if ($this->proxy['authtype'] == 'basic') {
384
+                    $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC);
385
+                }
386
+                if ($this->proxy['authtype'] == 'ntlm') {
387
+                    $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM);
388
+                }
389
+            }
390
+        }
391
+        $this->debug('cURL connection set up');
392
+        return true;
393
+        } else {
394
+        $this->setError('Unknown scheme ' . $this->scheme);
395
+        $this->debug('Unknown scheme ' . $this->scheme);
396
+        return false;
397
+        }
398
+    }
399
+
400
+    /**
401
+     * sends the SOAP request and gets the SOAP response via HTTP[S]
402
+     *
403
+     * @param    string $data message data
404
+     * @param    integer $timeout set connection timeout in seconds
405
+     * @param	integer $response_timeout set response timeout in seconds
406
+     * @param	array $cookies cookies to send
407
+     * @return	string data
408
+     * @access   public
409
+     */
410
+    function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) {
411
+
412
+        $this->debug('entered send() with data of length: '.strlen($data));
413
+
414
+        $this->tryagain = true;
415
+        $tries = 0;
416
+        while ($this->tryagain) {
417
+            $this->tryagain = false;
418
+            if ($tries++ < 2) {
419
+                // make connnection
420
+                if (!$this->connect($timeout, $response_timeout)){
421
+                    return false;
422
+                }
423
+
424
+                // send request
425
+                if (!$this->sendRequest($data, $cookies)){
426
+                    return false;
427
+                }
428
+
429
+                // get response
430
+                $respdata = $this->getResponse();
431
+            } else {
432
+                $this->setError("Too many tries to get an OK response ($this->response_status_line)");
433
+            }
434
+        }
435
+        $this->debug('end of send()');
436
+        return $respdata;
437
+    }
438
+
439
+
440
+    /**
441
+     * sends the SOAP request and gets the SOAP response via HTTPS using CURL
442
+     *
443
+     * @param    string $data message data
444
+     * @param    integer $timeout set connection timeout in seconds
445
+     * @param	integer $response_timeout set response timeout in seconds
446
+     * @param	array $cookies cookies to send
447
+     * @return	string data
448
+     * @access   public
449
+     * @deprecated
450
+     */
451
+    function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies) {
452
+        return $this->send($data, $timeout, $response_timeout, $cookies);
453
+    }
454
+
455
+    /**
456
+     * if authenticating, set user credentials here
457
+     *
458
+     * @param    string $username
459
+     * @param    string $password
460
+     * @param	string $authtype (basic|digest|certificate|ntlm)
461
+     * @param	array $digestRequest (keys must be nonce, nc, realm, qop)
462
+     * @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
463
+     * @access   public
464
+     */
465
+    function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) {
466
+        $this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
467
+        $this->appendDebug($this->varDump($digestRequest));
468
+        $this->debug("certRequest=");
469
+        $this->appendDebug($this->varDump($certRequest));
470
+        // cf. RFC 2617
471
+        if ($authtype == 'basic') {
472
+            $this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':','',$username).':'.$password));
473
+        } elseif ($authtype == 'digest') {
474
+            if (isset($digestRequest['nonce'])) {
475
+                $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
476
+
477
+                // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
478
+
479
+                // A1 = unq(username-value) ":" unq(realm-value) ":" passwd
480
+                $A1 = $username. ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
481
+
482
+                // H(A1) = MD5(A1)
483
+                $HA1 = md5($A1);
484
+
485
+                // A2 = Method ":" digest-uri-value
486
+                $A2 = $this->request_method . ':' . $this->digest_uri;
487
+
488
+                // H(A2)
489
+                $HA2 =  md5($A2);
490
+
491
+                // KD(secret, data) = H(concat(secret, ":", data))
492
+                // if qop == auth:
493
+                // request-digest  = <"> < KD ( H(A1),     unq(nonce-value)
494
+                //                              ":" nc-value
495
+                //                              ":" unq(cnonce-value)
496
+                //                              ":" unq(qop-value)
497
+                //                              ":" H(A2)
498
+                //                            ) <">
499
+                // if qop is missing,
500
+                // request-digest  = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
501
+
502
+                $unhashedDigest = '';
503
+                $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : '';
504
+                $cnonce = $nonce;
505
+                if ($digestRequest['qop'] != '') {
506
+                    $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
507
+                } else {
508
+                    $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
509
+                }
510
+
511
+                $hashedDigest = md5($unhashedDigest);
512
+
513
+                $opaque = '';
514
+                if (isset($digestRequest['opaque'])) {
515
+                    $opaque = ', opaque="' . $digestRequest['opaque'] . '"';
516
+                }
517
+
518
+                $this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"');
519
+            }
520
+        } elseif ($authtype == 'certificate') {
521
+            $this->certRequest = $certRequest;
522
+            $this->debug('Authorization header not set for certificate');
523
+        } elseif ($authtype == 'ntlm') {
524
+            // do nothing
525
+            $this->debug('Authorization header not set for ntlm');
526
+        }
527
+        $this->username = $username;
528
+        $this->password = $password;
529
+        $this->authtype = $authtype;
530
+        $this->digestRequest = $digestRequest;
531
+    }
532
+
533
+    /**
534
+     * set the soapaction value
535
+     *
536
+     * @param    string $soapaction
537
+     * @access   public
538
+     */
539
+    function setSOAPAction($soapaction) {
540
+        $this->setHeader('SOAPAction', '"' . $soapaction . '"');
541
+    }
542
+
543
+    /**
544
+     * use http encoding
545
+     *
546
+     * @param    string $enc encoding style. supported values: gzip, deflate, or both
547
+     * @access   public
548
+     */
549
+    function setEncoding($enc='gzip, deflate') {
550
+        if (function_exists('gzdeflate')) {
551
+            $this->protocol_version = '1.1';
552
+            $this->setHeader('Accept-Encoding', $enc);
553
+            if (!isset($this->outgoing_headers['Connection'])) {
554
+                $this->setHeader('Connection', 'close');
555
+                $this->persistentConnection = false;
556
+            }
557
+            // deprecated as of PHP 5.3.0
558
+            //set_magic_quotes_runtime(0);
559
+            $this->encoding = $enc;
560
+        }
561
+    }
562
+
563
+    /**
564
+     * set proxy info here
565
+     *
566
+     * @param    string $proxyhost use an empty string to remove proxy
567
+     * @param    string $proxyport
568
+     * @param	string $proxyusername
569
+     * @param	string $proxypassword
570
+     * @param	string $proxyauthtype (basic|ntlm)
571
+     * @access   public
572
+     */
573
+    function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') {
574
+        if ($proxyhost) {
575
+            $this->proxy = array(
576
+                'host' => $proxyhost,
577
+                'port' => $proxyport,
578
+                'username' => $proxyusername,
579
+                'password' => $proxypassword,
580
+                'authtype' => $proxyauthtype
581
+            );
582
+            if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') {
583
+                $this->setHeader('Proxy-Authorization', ' Basic '.base64_encode($proxyusername.':'.$proxypassword));
584
+            }
585
+        } else {
586
+            $this->debug('remove proxy');
587
+            $proxy = null;
588
+            unsetHeader('Proxy-Authorization');
589
+        }
590
+    }
591
+
592
+
593
+    /**
594
+     * Test if the given string starts with a header that is to be skipped.
595
+     * Skippable headers result from chunked transfer and proxy requests.
596
+     *
597
+     * @param	string $data The string to check.
598
+     * @returns	boolean	Whether a skippable header was found.
599
+     * @access	private
600
+     */
601
+    function isSkippableCurlHeader(&$data) {
602
+        $skipHeaders = array(	'HTTP/1.1 100',
603
+                                'HTTP/1.0 301',
604
+                                'HTTP/1.1 301',
605
+                                'HTTP/1.0 302',
606
+                                'HTTP/1.1 302',
607
+                                'HTTP/1.0 401',
608
+                                'HTTP/1.1 401',
609
+                                'HTTP/1.0 200 Connection established');
610
+        foreach ($skipHeaders as $hd) {
611
+            $prefix = substr($data, 0, strlen($hd));
612
+            if ($prefix == $hd) return true;
613
+        }
614
+
615
+        return false;
616
+    }
617
+
618
+    /**
619
+     * decode a string that is encoded w/ "chunked' transfer encoding
620
+     * as defined in RFC2068 19.4.6
621
+     *
622
+     * @param    string $buffer
623
+     * @param    string $lb
624
+     * @returns	string
625
+     * @access   public
626
+     * @deprecated
627
+     */
628
+    function decodeChunked($buffer, $lb){
629
+        // length := 0
630
+        $length = 0;
631
+        $new = '';
632
+
633
+        // read chunk-size, chunk-extension (if any) and CRLF
634
+        // get the position of the linebreak
635
+        $chunkend = strpos($buffer, $lb);
636
+        if ($chunkend == FALSE) {
637
+            $this->debug('no linebreak found in decodeChunked');
638
+            return $new;
639
+        }
640
+        $temp = substr($buffer,0,$chunkend);
641
+        $chunk_size = hexdec( trim($temp) );
642
+        $chunkstart = $chunkend + strlen($lb);
643
+        // while (chunk-size > 0) {
644
+        while ($chunk_size > 0) {
645
+            $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
646
+            $chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size);
647
+
648
+            // Just in case we got a broken connection
649
+                if ($chunkend == FALSE) {
650
+                    $chunk = substr($buffer,$chunkstart);
651
+                // append chunk-data to entity-body
652
+                $new .= $chunk;
653
+                    $length += strlen($chunk);
654
+                    break;
655
+            }
656
+
657
+                // read chunk-data and CRLF
658
+                $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
659
+                // append chunk-data to entity-body
660
+                $new .= $chunk;
661
+                // length := length + chunk-size
662
+                $length += strlen($chunk);
663
+                // read chunk-size and CRLF
664
+                $chunkstart = $chunkend + strlen($lb);
665
+
666
+                $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
667
+            if ($chunkend == FALSE) {
668
+                break; //Just in case we got a broken connection
669
+            }
670
+            $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
671
+            $chunk_size = hexdec( trim($temp) );
672
+            $chunkstart = $chunkend;
673
+        }
674
+        return $new;
675
+    }
676
+
677
+    /**
678
+     * Writes the payload, including HTTP headers, to $this->outgoing_payload.
679
+     *
680
+     * @param	string $data HTTP body
681
+     * @param	string $cookie_str data for HTTP Cookie header
682
+     * @return	void
683
+     * @access	private
684
+     */
685
+    function buildPayload($data, $cookie_str = '') {
686
+        // Note: for cURL connections, $this->outgoing_payload is ignored,
687
+        // as is the Content-Length header, but these are still created as
688
+        // debugging guides.
689
+
690
+        // add content-length header
691
+        if ($this->request_method != 'GET') {
692
+            $this->setHeader('Content-Length', strlen($data));
693
+        }
694
+
695
+        // start building outgoing payload:
696
+        if ($this->proxy) {
697
+            $uri = $this->url;
698
+        } else {
699
+            $uri = $this->uri;
700
+        }
701
+        $req = "$this->request_method $uri HTTP/$this->protocol_version";
702
+        $this->debug("HTTP request: $req");
703
+        $this->outgoing_payload = "$req\r\n";
704
+
705
+        // loop thru headers, serializing
706
+        foreach($this->outgoing_headers as $k => $v){
707
+            $hdr = $k.': '.$v;
708
+            $this->debug("HTTP header: $hdr");
709
+            $this->outgoing_payload .= "$hdr\r\n";
710
+        }
711
+
712
+        // add any cookies
713
+        if ($cookie_str != '') {
714
+            $hdr = 'Cookie: '.$cookie_str;
715
+            $this->debug("HTTP header: $hdr");
716
+            $this->outgoing_payload .= "$hdr\r\n";
717
+        }
718
+
719
+        // header/body separator
720
+        $this->outgoing_payload .= "\r\n";
721
+
722
+        // add data
723
+        $this->outgoing_payload .= $data;
724
+    }
725
+
726
+    /**
727
+     * sends the SOAP request via HTTP[S]
728
+     *
729
+     * @param    string $data message data
730
+     * @param	array $cookies cookies to send
731
+     * @return	boolean	true if OK, false if problem
732
+     * @access   private
733
+     */
734
+    function sendRequest($data, $cookies = NULL) {
735
+        // build cookie string
736
+        $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));
737
+
738
+        // build payload
739
+        $this->buildPayload($data, $cookie_str);
740
+
741
+        if ($this->io_method() == 'socket') {
742
+        // send payload
743
+        if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
744
+            $this->setError('couldn\'t write message data to socket');
745
+            $this->debug('couldn\'t write message data to socket');
746
+            return false;
747
+        }
748
+        $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
749
+        return true;
750
+        } else if ($this->io_method() == 'curl') {
751
+        // set payload
752
+        // cURL does say this should only be the verb, and in fact it
753
+        // turns out that the URI and HTTP version are appended to this, which
754
+        // some servers refuse to work with (so we no longer use this method!)
755
+        //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
756
+        $curl_headers = array();
757
+        foreach($this->outgoing_headers as $k => $v){
758
+            if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
759
+                $this->debug("Skip cURL header $k: $v");
760
+            } else {
761
+                $curl_headers[] = "$k: $v";
762
+            }
763
+        }
764
+        if ($cookie_str != '') {
765
+            $curl_headers[] = 'Cookie: ' . $cookie_str;
766
+        }
767
+        $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
768
+        $this->debug('set cURL HTTP headers');
769
+        if ($this->request_method == "POST") {
770
+                $this->setCurlOption(CURLOPT_POST, 1);
771
+                $this->setCurlOption(CURLOPT_POSTFIELDS, $data);
772
+            $this->debug('set cURL POST data');
773
+            } else {
774
+            }
775
+        // insert custom user-set cURL options
776
+        foreach ($this->ch_options as $key => $val) {
777
+            $this->setCurlOption($key, $val);
778
+        }
779
+
780
+        $this->debug('set cURL payload');
781
+        return true;
782
+        }
783
+    }
784
+
785
+    /**
786
+     * gets the SOAP response via HTTP[S]
787
+     *
788
+     * @return	string the response (also sets member variables like incoming_payload)
789
+     * @access   private
790
+     */
791
+    function getResponse(){
792
+        $this->incoming_payload = '';
793
+
794
+        if ($this->io_method() == 'socket') {
795
+        // loop until headers have been retrieved
796
+        $data = '';
797
+        while (!isset($lb)){
798
+
799
+            // We might EOF during header read.
800
+            if(feof($this->fp)) {
801
+                $this->incoming_payload = $data;
802
+                $this->debug('found no headers before EOF after length ' . strlen($data));
803
+                $this->debug("received before EOF:\n" . $data);
804
+                $this->setError('server failed to send headers');
805
+                return false;
806
+            }
807
+
808
+            $tmp = fgets($this->fp, 256);
809
+            $tmplen = strlen($tmp);
810
+            $this->debug("read line of $tmplen bytes: " . trim($tmp));
811
+
812
+            if ($tmplen == 0) {
813
+                $this->incoming_payload = $data;
814
+                $this->debug('socket read of headers timed out after length ' . strlen($data));
815
+                $this->debug("read before timeout: " . $data);
816
+                $this->setError('socket read of headers timed out');
817
+                return false;
818
+            }
819
+
820
+            $data .= $tmp;
821
+            $pos = strpos($data,"\r\n\r\n");
822
+            if($pos > 1){
823
+                $lb = "\r\n";
824
+            } else {
825
+                $pos = strpos($data,"\n\n");
826
+                if($pos > 1){
827
+                    $lb = "\n";
828
+                }
829
+            }
830
+            // remove 100 headers
831
+            if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) {
832
+                unset($lb);
833
+                $data = '';
834
+            }//
835
+        }
836
+        // store header data
837
+        $this->incoming_payload .= $data;
838
+        $this->debug('found end of headers after length ' . strlen($data));
839
+        // process headers
840
+        $header_data = trim(substr($data,0,$pos));
841
+        $header_array = explode($lb,$header_data);
842
+        $this->incoming_headers = array();
843
+        $this->incoming_cookies = array();
844
+        foreach($header_array as $header_line){
845
+            $arr = explode(':',$header_line, 2);
846
+            if(count($arr) > 1){
847
+                $header_name = strtolower(trim($arr[0]));
848
+                $this->incoming_headers[$header_name] = trim($arr[1]);
849
+                if ($header_name == 'set-cookie') {
850
+                    // TODO: allow multiple cookies from parseCookie
851
+                    $cookie = $this->parseCookie(trim($arr[1]));
852
+                    if ($cookie) {
853
+                        $this->incoming_cookies[] = $cookie;
854
+                        $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
855
+                    } else {
856
+                        $this->debug('did not find cookie in ' . trim($arr[1]));
857
+                    }
858
+                }
859
+            } else if (isset($header_name)) {
860
+                // append continuation line to previous header
861
+                $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
862
+            }
863
+        }
864
+
865
+        // loop until msg has been received
866
+        if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
867
+            $content_length =  2147483647;	// ignore any content-length header
868
+            $chunked = true;
869
+            $this->debug("want to read chunked content");
870
+        } elseif (isset($this->incoming_headers['content-length'])) {
871
+            $content_length = $this->incoming_headers['content-length'];
872
+            $chunked = false;
873
+            $this->debug("want to read content of length $content_length");
874
+        } else {
875
+            $content_length =  2147483647;
876
+            $chunked = false;
877
+            $this->debug("want to read content to EOF");
878
+        }
879
+        $data = '';
880
+        do {
881
+            if ($chunked) {
882
+                $tmp = fgets($this->fp, 256);
883
+                $tmplen = strlen($tmp);
884
+                $this->debug("read chunk line of $tmplen bytes");
885
+                if ($tmplen == 0) {
886
+                    $this->incoming_payload = $data;
887
+                    $this->debug('socket read of chunk length timed out after length ' . strlen($data));
888
+                    $this->debug("read before timeout:\n" . $data);
889
+                    $this->setError('socket read of chunk length timed out');
890
+                    return false;
891
+                }
892
+                $content_length = hexdec(trim($tmp));
893
+                $this->debug("chunk length $content_length");
894
+            }
895
+            $strlen = 0;
896
+            while (($strlen < $content_length) && (!feof($this->fp))) {
897
+                $readlen = min(8192, $content_length - $strlen);
898
+                $tmp = fread($this->fp, $readlen);
899
+                $tmplen = strlen($tmp);
900
+                $this->debug("read buffer of $tmplen bytes");
901
+                if (($tmplen == 0) && (!feof($this->fp))) {
902
+                    $this->incoming_payload = $data;
903
+                    $this->debug('socket read of body timed out after length ' . strlen($data));
904
+                    $this->debug("read before timeout:\n" . $data);
905
+                    $this->setError('socket read of body timed out');
906
+                    return false;
907
+                }
908
+                $strlen += $tmplen;
909
+                $data .= $tmp;
910
+            }
911
+            if ($chunked && ($content_length > 0)) {
912
+                $tmp = fgets($this->fp, 256);
913
+                $tmplen = strlen($tmp);
914
+                $this->debug("read chunk terminator of $tmplen bytes");
915
+                if ($tmplen == 0) {
916
+                    $this->incoming_payload = $data;
917
+                    $this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
918
+                    $this->debug("read before timeout:\n" . $data);
919
+                    $this->setError('socket read of chunk terminator timed out');
920
+                    return false;
921
+                }
922
+            }
923
+        } while ($chunked && ($content_length > 0) && (!feof($this->fp)));
924
+        if (feof($this->fp)) {
925
+            $this->debug('read to EOF');
926
+        }
927
+        $this->debug('read body of length ' . strlen($data));
928
+        $this->incoming_payload .= $data;
929
+        $this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
930
+
931
+        // close filepointer
932
+        if(
933
+            (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') ||
934
+            (! $this->persistentConnection) || feof($this->fp)){
935
+            fclose($this->fp);
936
+            $this->fp = false;
937
+            $this->debug('closed socket');
938
+        }
939
+
940
+        // connection was closed unexpectedly
941
+        if($this->incoming_payload == ''){
942
+            $this->setError('no response from server');
943
+            return false;
944
+        }
945
+
946
+        // decode transfer-encoding
947 947
 //		if(isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked'){
948 948
 //			if(!$data = $this->decodeChunked($data, $lb)){
949 949
 //				$this->setError('Decoding of chunked data failed');
950 950
 //				return false;
951 951
 //			}
952
-			//print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
953
-			// set decoded payload
952
+            //print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
953
+            // set decoded payload
954 954
 //			$this->incoming_payload = $header_data.$lb.$lb.$data;
955 955
 //		}
956 956
 
957
-	  } else if ($this->io_method() == 'curl') {
958
-		// send and receive
959
-		$this->debug('send and receive with cURL');
960
-		$this->incoming_payload = curl_exec($this->ch);
961
-		$data = $this->incoming_payload;
957
+        } else if ($this->io_method() == 'curl') {
958
+        // send and receive
959
+        $this->debug('send and receive with cURL');
960
+        $this->incoming_payload = curl_exec($this->ch);
961
+        $data = $this->incoming_payload;
962 962
 
963 963
         $cErr = curl_error($this->ch);
964
-		if ($cErr != '') {
965
-        	$err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>';
966
-        	// TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
967
-			foreach(curl_getinfo($this->ch) as $k => $v){
968
-				$err .= "$k: $v<br>";
969
-			}
970
-			$this->debug($err);
971
-			$this->setError($err);
972
-			curl_close($this->ch);
973
-	    	return false;
974
-		} else {
975
-			//echo '<pre>';
976
-			//var_dump(curl_getinfo($this->ch));
977
-			//echo '</pre>';
978
-		}
979
-		// close curl
980
-		$this->debug('No cURL error, closing cURL');
981
-		curl_close($this->ch);
982
-
983
-		// try removing skippable headers
984
-		$savedata = $data;
985
-		while ($this->isSkippableCurlHeader($data)) {
986
-			$this->debug("Found HTTP header to skip");
987
-			if ($pos = strpos($data,"\r\n\r\n")) {
988
-				$data = ltrim(substr($data,$pos));
989
-			} elseif($pos = strpos($data,"\n\n") ) {
990
-				$data = ltrim(substr($data,$pos));
991
-			}
992
-		}
993
-
994
-		if ($data == '') {
995
-			// have nothing left; just remove 100 header(s)
996
-			$data = $savedata;
997
-			while (preg_match('/^HTTP\/1.1 100/',$data)) {
998
-				if ($pos = strpos($data,"\r\n\r\n")) {
999
-					$data = ltrim(substr($data,$pos));
1000
-				} elseif($pos = strpos($data,"\n\n") ) {
1001
-					$data = ltrim(substr($data,$pos));
1002
-				}
1003
-			}
1004
-		}
1005
-
1006
-		// separate content from HTTP headers
1007
-		if ($pos = strpos($data,"\r\n\r\n")) {
1008
-			$lb = "\r\n";
1009
-		} elseif( $pos = strpos($data,"\n\n")) {
1010
-			$lb = "\n";
1011
-		} else {
1012
-			$this->debug('no proper separation of headers and document');
1013
-			$this->setError('no proper separation of headers and document');
1014
-			return false;
1015
-		}
1016
-		$header_data = trim(substr($data,0,$pos));
1017
-		$header_array = explode($lb,$header_data);
1018
-		$data = ltrim(substr($data,$pos));
1019
-		$this->debug('found proper separation of headers and document');
1020
-		$this->debug('cleaned data, stringlen: '.strlen($data));
1021
-		// clean headers
1022
-		foreach ($header_array as $header_line) {
1023
-			$arr = explode(':',$header_line,2);
1024
-			if(count($arr) > 1){
1025
-				$header_name = strtolower(trim($arr[0]));
1026
-				$this->incoming_headers[$header_name] = trim($arr[1]);
1027
-				if ($header_name == 'set-cookie') {
1028
-					// TODO: allow multiple cookies from parseCookie
1029
-					$cookie = $this->parseCookie(trim($arr[1]));
1030
-					if ($cookie) {
1031
-						$this->incoming_cookies[] = $cookie;
1032
-						$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
1033
-					} else {
1034
-						$this->debug('did not find cookie in ' . trim($arr[1]));
1035
-					}
1036
-    			}
1037
-			} else if (isset($header_name)) {
1038
-				// append continuation line to previous header
1039
-				$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
1040
-			}
1041
-		}
1042
-	  }
1043
-
1044
-		$this->response_status_line = $header_array[0];
1045
-		$arr = explode(' ', $this->response_status_line, 3);
1046
-		$http_version = $arr[0];
1047
-		$http_status = intval($arr[1]);
1048
-		$http_reason = count($arr) > 2 ? $arr[2] : '';
1049
-
1050
- 		// see if we need to resend the request with http digest authentication
1051
- 		if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
1052
- 			$this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
1053
- 			$this->setURL($this->incoming_headers['location']);
1054
-			$this->tryagain = true;
1055
-			return false;
1056
-		}
1057
-
1058
- 		// see if we need to resend the request with http digest authentication
1059
- 		if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
1060
- 			$this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
1061
- 			if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
1062
- 				$this->debug('Server wants digest authentication');
1063
- 				// remove "Digest " from our elements
1064
- 				$digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
1065
-
1066
- 				// parse elements into array
1067
- 				$digestElements = explode(',', $digestString);
1068
- 				foreach ($digestElements as $val) {
1069
- 					$tempElement = explode('=', trim($val), 2);
1070
- 					$digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]);
1071
- 				}
1072
-
1073
-				// should have (at least) qop, realm, nonce
1074
- 				if (isset($digestRequest['nonce'])) {
1075
- 					$this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
1076
- 					$this->tryagain = true;
1077
- 					return false;
1078
- 				}
1079
- 			}
1080
-			$this->debug('HTTP authentication failed');
1081
-			$this->setError('HTTP authentication failed');
1082
-			return false;
1083
- 		}
1084
-
1085
-		if (
1086
-			($http_status >= 300 && $http_status <= 307) ||
1087
-			($http_status >= 400 && $http_status <= 417) ||
1088
-			($http_status >= 501 && $http_status <= 505)
1089
-		   ) {
1090
-			$this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
1091
-			return false;
1092
-		}
1093
-
1094
-		// decode content-encoding
1095
-		if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != ''){
1096
-			if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip'){
1097
-    			// if decoding works, use it. else assume data wasn't gzencoded
1098
-    			if(function_exists('gzinflate')){
1099
-					//$timer->setMarker('starting decoding of gzip/deflated content');
1100
-					// IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)
1101
-					// this means there are no Zlib headers, although there should be
1102
-					$this->debug('The gzinflate function exists');
1103
-					$datalen = strlen($data);
1104
-					if ($this->incoming_headers['content-encoding'] == 'deflate') {
1105
-						if ($degzdata = @gzinflate($data)) {
1106
-	    					$data = $degzdata;
1107
-	    					$this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
1108
-	    					if (strlen($data) < $datalen) {
1109
-	    						// test for the case that the payload has been compressed twice
1110
-		    					$this->debug('The inflated payload is smaller than the gzipped one; try again');
1111
-								if ($degzdata = @gzinflate($data)) {
1112
-			    					$data = $degzdata;
1113
-			    					$this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
1114
-								}
1115
-	    					}
1116
-	    				} else {
1117
-	    					$this->debug('Error using gzinflate to inflate the payload');
1118
-	    					$this->setError('Error using gzinflate to inflate the payload');
1119
-	    				}
1120
-					} elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
1121
-						if ($degzdata = @gzinflate(substr($data, 10))) {	// do our best
1122
-							$data = $degzdata;
1123
-	    					$this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
1124
-	    					if (strlen($data) < $datalen) {
1125
-	    						// test for the case that the payload has been compressed twice
1126
-		    					$this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
1127
-								if ($degzdata = @gzinflate(substr($data, 10))) {
1128
-			    					$data = $degzdata;
1129
-			    					$this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
1130
-								}
1131
-	    					}
1132
-	    				} else {
1133
-	    					$this->debug('Error using gzinflate to un-gzip the payload');
1134
-							$this->setError('Error using gzinflate to un-gzip the payload');
1135
-	    				}
1136
-					}
1137
-					//$timer->setMarker('finished decoding of gzip/deflated content');
1138
-					//print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
1139
-					// set decoded payload
1140
-					$this->incoming_payload = $header_data.$lb.$lb.$data;
1141
-    			} else {
1142
-					$this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
1143
-					$this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
1144
-				}
1145
-			} else {
1146
-				$this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1147
-				$this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1148
-			}
1149
-		} else {
1150
-			$this->debug('No Content-Encoding header');
1151
-		}
1152
-
1153
-		if(strlen($data) == 0){
1154
-			$this->debug('no data after headers!');
1155
-			$this->setError('no data present after HTTP headers');
1156
-			return false;
1157
-		}
1158
-
1159
-		return $data;
1160
-	}
1161
-
1162
-	/**
1163
-	 * sets the content-type for the SOAP message to be sent
1164
-	 *
1165
-	 * @param	string $type the content type, MIME style
1166
-	 * @param	mixed $charset character set used for encoding (or false)
1167
-	 * @access	public
1168
-	 */
1169
-	function setContentType($type, $charset = false) {
1170
-		$this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
1171
-	}
1172
-
1173
-	/**
1174
-	 * specifies that an HTTP persistent connection should be used
1175
-	 *
1176
-	 * @return	boolean whether the request was honored by this method.
1177
-	 * @access	public
1178
-	 */
1179
-	function usePersistentConnection(){
1180
-		if (isset($this->outgoing_headers['Accept-Encoding'])) {
1181
-			return false;
1182
-		}
1183
-		$this->protocol_version = '1.1';
1184
-		$this->persistentConnection = true;
1185
-		$this->setHeader('Connection', 'Keep-Alive');
1186
-		return true;
1187
-	}
1188
-
1189
-	/**
1190
-	 * parse an incoming Cookie into it's parts
1191
-	 *
1192
-	 * @param	string $cookie_str content of cookie
1193
-	 * @return	array with data of that cookie
1194
-	 * @access	private
1195
-	 */
1196
-	/*
964
+        if ($cErr != '') {
965
+            $err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>';
966
+            // TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
967
+            foreach(curl_getinfo($this->ch) as $k => $v){
968
+                $err .= "$k: $v<br>";
969
+            }
970
+            $this->debug($err);
971
+            $this->setError($err);
972
+            curl_close($this->ch);
973
+            return false;
974
+        } else {
975
+            //echo '<pre>';
976
+            //var_dump(curl_getinfo($this->ch));
977
+            //echo '</pre>';
978
+        }
979
+        // close curl
980
+        $this->debug('No cURL error, closing cURL');
981
+        curl_close($this->ch);
982
+
983
+        // try removing skippable headers
984
+        $savedata = $data;
985
+        while ($this->isSkippableCurlHeader($data)) {
986
+            $this->debug("Found HTTP header to skip");
987
+            if ($pos = strpos($data,"\r\n\r\n")) {
988
+                $data = ltrim(substr($data,$pos));
989
+            } elseif($pos = strpos($data,"\n\n") ) {
990
+                $data = ltrim(substr($data,$pos));
991
+            }
992
+        }
993
+
994
+        if ($data == '') {
995
+            // have nothing left; just remove 100 header(s)
996
+            $data = $savedata;
997
+            while (preg_match('/^HTTP\/1.1 100/',$data)) {
998
+                if ($pos = strpos($data,"\r\n\r\n")) {
999
+                    $data = ltrim(substr($data,$pos));
1000
+                } elseif($pos = strpos($data,"\n\n") ) {
1001
+                    $data = ltrim(substr($data,$pos));
1002
+                }
1003
+            }
1004
+        }
1005
+
1006
+        // separate content from HTTP headers
1007
+        if ($pos = strpos($data,"\r\n\r\n")) {
1008
+            $lb = "\r\n";
1009
+        } elseif( $pos = strpos($data,"\n\n")) {
1010
+            $lb = "\n";
1011
+        } else {
1012
+            $this->debug('no proper separation of headers and document');
1013
+            $this->setError('no proper separation of headers and document');
1014
+            return false;
1015
+        }
1016
+        $header_data = trim(substr($data,0,$pos));
1017
+        $header_array = explode($lb,$header_data);
1018
+        $data = ltrim(substr($data,$pos));
1019
+        $this->debug('found proper separation of headers and document');
1020
+        $this->debug('cleaned data, stringlen: '.strlen($data));
1021
+        // clean headers
1022
+        foreach ($header_array as $header_line) {
1023
+            $arr = explode(':',$header_line,2);
1024
+            if(count($arr) > 1){
1025
+                $header_name = strtolower(trim($arr[0]));
1026
+                $this->incoming_headers[$header_name] = trim($arr[1]);
1027
+                if ($header_name == 'set-cookie') {
1028
+                    // TODO: allow multiple cookies from parseCookie
1029
+                    $cookie = $this->parseCookie(trim($arr[1]));
1030
+                    if ($cookie) {
1031
+                        $this->incoming_cookies[] = $cookie;
1032
+                        $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
1033
+                    } else {
1034
+                        $this->debug('did not find cookie in ' . trim($arr[1]));
1035
+                    }
1036
+                }
1037
+            } else if (isset($header_name)) {
1038
+                // append continuation line to previous header
1039
+                $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
1040
+            }
1041
+        }
1042
+        }
1043
+
1044
+        $this->response_status_line = $header_array[0];
1045
+        $arr = explode(' ', $this->response_status_line, 3);
1046
+        $http_version = $arr[0];
1047
+        $http_status = intval($arr[1]);
1048
+        $http_reason = count($arr) > 2 ? $arr[2] : '';
1049
+
1050
+            // see if we need to resend the request with http digest authentication
1051
+            if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
1052
+                $this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
1053
+                $this->setURL($this->incoming_headers['location']);
1054
+            $this->tryagain = true;
1055
+            return false;
1056
+        }
1057
+
1058
+            // see if we need to resend the request with http digest authentication
1059
+            if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
1060
+                $this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
1061
+                if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
1062
+                    $this->debug('Server wants digest authentication');
1063
+                    // remove "Digest " from our elements
1064
+                    $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
1065
+
1066
+                    // parse elements into array
1067
+                    $digestElements = explode(',', $digestString);
1068
+                    foreach ($digestElements as $val) {
1069
+                        $tempElement = explode('=', trim($val), 2);
1070
+                        $digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]);
1071
+                    }
1072
+
1073
+                // should have (at least) qop, realm, nonce
1074
+                    if (isset($digestRequest['nonce'])) {
1075
+                        $this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
1076
+                        $this->tryagain = true;
1077
+                        return false;
1078
+                    }
1079
+                }
1080
+            $this->debug('HTTP authentication failed');
1081
+            $this->setError('HTTP authentication failed');
1082
+            return false;
1083
+            }
1084
+
1085
+        if (
1086
+            ($http_status >= 300 && $http_status <= 307) ||
1087
+            ($http_status >= 400 && $http_status <= 417) ||
1088
+            ($http_status >= 501 && $http_status <= 505)
1089
+            ) {
1090
+            $this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
1091
+            return false;
1092
+        }
1093
+
1094
+        // decode content-encoding
1095
+        if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != ''){
1096
+            if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip'){
1097
+                // if decoding works, use it. else assume data wasn't gzencoded
1098
+                if(function_exists('gzinflate')){
1099
+                    //$timer->setMarker('starting decoding of gzip/deflated content');
1100
+                    // IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)
1101
+                    // this means there are no Zlib headers, although there should be
1102
+                    $this->debug('The gzinflate function exists');
1103
+                    $datalen = strlen($data);
1104
+                    if ($this->incoming_headers['content-encoding'] == 'deflate') {
1105
+                        if ($degzdata = @gzinflate($data)) {
1106
+                            $data = $degzdata;
1107
+                            $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
1108
+                            if (strlen($data) < $datalen) {
1109
+                                // test for the case that the payload has been compressed twice
1110
+                                $this->debug('The inflated payload is smaller than the gzipped one; try again');
1111
+                                if ($degzdata = @gzinflate($data)) {
1112
+                                    $data = $degzdata;
1113
+                                    $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
1114
+                                }
1115
+                            }
1116
+                        } else {
1117
+                            $this->debug('Error using gzinflate to inflate the payload');
1118
+                            $this->setError('Error using gzinflate to inflate the payload');
1119
+                        }
1120
+                    } elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
1121
+                        if ($degzdata = @gzinflate(substr($data, 10))) {	// do our best
1122
+                            $data = $degzdata;
1123
+                            $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
1124
+                            if (strlen($data) < $datalen) {
1125
+                                // test for the case that the payload has been compressed twice
1126
+                                $this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
1127
+                                if ($degzdata = @gzinflate(substr($data, 10))) {
1128
+                                    $data = $degzdata;
1129
+                                    $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
1130
+                                }
1131
+                            }
1132
+                        } else {
1133
+                            $this->debug('Error using gzinflate to un-gzip the payload');
1134
+                            $this->setError('Error using gzinflate to un-gzip the payload');
1135
+                        }
1136
+                    }
1137
+                    //$timer->setMarker('finished decoding of gzip/deflated content');
1138
+                    //print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
1139
+                    // set decoded payload
1140
+                    $this->incoming_payload = $header_data.$lb.$lb.$data;
1141
+                } else {
1142
+                    $this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
1143
+                    $this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
1144
+                }
1145
+            } else {
1146
+                $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1147
+                $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1148
+            }
1149
+        } else {
1150
+            $this->debug('No Content-Encoding header');
1151
+        }
1152
+
1153
+        if(strlen($data) == 0){
1154
+            $this->debug('no data after headers!');
1155
+            $this->setError('no data present after HTTP headers');
1156
+            return false;
1157
+        }
1158
+
1159
+        return $data;
1160
+    }
1161
+
1162
+    /**
1163
+     * sets the content-type for the SOAP message to be sent
1164
+     *
1165
+     * @param	string $type the content type, MIME style
1166
+     * @param	mixed $charset character set used for encoding (or false)
1167
+     * @access	public
1168
+     */
1169
+    function setContentType($type, $charset = false) {
1170
+        $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
1171
+    }
1172
+
1173
+    /**
1174
+     * specifies that an HTTP persistent connection should be used
1175
+     *
1176
+     * @return	boolean whether the request was honored by this method.
1177
+     * @access	public
1178
+     */
1179
+    function usePersistentConnection(){
1180
+        if (isset($this->outgoing_headers['Accept-Encoding'])) {
1181
+            return false;
1182
+        }
1183
+        $this->protocol_version = '1.1';
1184
+        $this->persistentConnection = true;
1185
+        $this->setHeader('Connection', 'Keep-Alive');
1186
+        return true;
1187
+    }
1188
+
1189
+    /**
1190
+     * parse an incoming Cookie into it's parts
1191
+     *
1192
+     * @param	string $cookie_str content of cookie
1193
+     * @return	array with data of that cookie
1194
+     * @access	private
1195
+     */
1196
+    /*
1197 1197
 	 * TODO: allow a Set-Cookie string to be parsed into multiple cookies
1198 1198
 	 */
1199
-	function parseCookie($cookie_str) {
1200
-		$cookie_str = str_replace('; ', ';', $cookie_str) . ';';
1201
-		$data = preg_split('/;/', $cookie_str);
1202
-		$value_str = $data[0];
1203
-
1204
-		$cookie_param = 'domain=';
1205
-		$start = strpos($cookie_str, $cookie_param);
1206
-		if ($start > 0) {
1207
-			$domain = substr($cookie_str, $start + strlen($cookie_param));
1208
-			$domain = substr($domain, 0, strpos($domain, ';'));
1209
-		} else {
1210
-			$domain = '';
1211
-		}
1212
-
1213
-		$cookie_param = 'expires=';
1214
-		$start = strpos($cookie_str, $cookie_param);
1215
-		if ($start > 0) {
1216
-			$expires = substr($cookie_str, $start + strlen($cookie_param));
1217
-			$expires = substr($expires, 0, strpos($expires, ';'));
1218
-		} else {
1219
-			$expires = '';
1220
-		}
1221
-
1222
-		$cookie_param = 'path=';
1223
-		$start = strpos($cookie_str, $cookie_param);
1224
-		if ( $start > 0 ) {
1225
-			$path = substr($cookie_str, $start + strlen($cookie_param));
1226
-			$path = substr($path, 0, strpos($path, ';'));
1227
-		} else {
1228
-			$path = '/';
1229
-		}
1230
-
1231
-		$cookie_param = ';secure;';
1232
-		if (strpos($cookie_str, $cookie_param) !== FALSE) {
1233
-			$secure = true;
1234
-		} else {
1235
-			$secure = false;
1236
-		}
1237
-
1238
-		$sep_pos = strpos($value_str, '=');
1239
-
1240
-		if ($sep_pos) {
1241
-			$name = substr($value_str, 0, $sep_pos);
1242
-			$value = substr($value_str, $sep_pos + 1);
1243
-			$cookie= array(	'name' => $name,
1244
-			                'value' => $value,
1245
-							'domain' => $domain,
1246
-							'path' => $path,
1247
-							'expires' => $expires,
1248
-							'secure' => $secure
1249
-							);
1250
-			return $cookie;
1251
-		}
1252
-		return false;
1253
-	}
1254
-
1255
-	/**
1256
-	 * sort out cookies for the current request
1257
-	 *
1258
-	 * @param	array $cookies array with all cookies
1259
-	 * @param	boolean $secure is the send-content secure or not?
1260
-	 * @return	string for Cookie-HTTP-Header
1261
-	 * @access	private
1262
-	 */
1263
-	function getCookiesForRequest($cookies, $secure=false) {
1264
-		$cookie_str = '';
1265
-		if ((! is_null($cookies)) && (is_array($cookies))) {
1266
-			foreach ($cookies as $cookie) {
1267
-				if (! is_array($cookie)) {
1268
-					continue;
1269
-				}
1270
-	    		$this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
1271
-				if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
1272
-					if (strtotime($cookie['expires']) <= time()) {
1273
-						$this->debug('cookie has expired');
1274
-						continue;
1275
-					}
1276
-				}
1277
-				if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
1278
-					$domain = preg_quote($cookie['domain']);
1279
-					if (! preg_match("'.*$domain$'i", $this->host)) {
1280
-						$this->debug('cookie has different domain');
1281
-						continue;
1282
-					}
1283
-				}
1284
-				if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
1285
-					$path = preg_quote($cookie['path']);
1286
-					if (! preg_match("'^$path.*'i", $this->path)) {
1287
-						$this->debug('cookie is for a different path');
1288
-						continue;
1289
-					}
1290
-				}
1291
-				if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
1292
-					$this->debug('cookie is secure, transport is not');
1293
-					continue;
1294
-				}
1295
-				$cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
1296
-	    		$this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
1297
-			}
1298
-		}
1299
-		return $cookie_str;
1300
-  }
1199
+    function parseCookie($cookie_str) {
1200
+        $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
1201
+        $data = preg_split('/;/', $cookie_str);
1202
+        $value_str = $data[0];
1203
+
1204
+        $cookie_param = 'domain=';
1205
+        $start = strpos($cookie_str, $cookie_param);
1206
+        if ($start > 0) {
1207
+            $domain = substr($cookie_str, $start + strlen($cookie_param));
1208
+            $domain = substr($domain, 0, strpos($domain, ';'));
1209
+        } else {
1210
+            $domain = '';
1211
+        }
1212
+
1213
+        $cookie_param = 'expires=';
1214
+        $start = strpos($cookie_str, $cookie_param);
1215
+        if ($start > 0) {
1216
+            $expires = substr($cookie_str, $start + strlen($cookie_param));
1217
+            $expires = substr($expires, 0, strpos($expires, ';'));
1218
+        } else {
1219
+            $expires = '';
1220
+        }
1221
+
1222
+        $cookie_param = 'path=';
1223
+        $start = strpos($cookie_str, $cookie_param);
1224
+        if ( $start > 0 ) {
1225
+            $path = substr($cookie_str, $start + strlen($cookie_param));
1226
+            $path = substr($path, 0, strpos($path, ';'));
1227
+        } else {
1228
+            $path = '/';
1229
+        }
1230
+
1231
+        $cookie_param = ';secure;';
1232
+        if (strpos($cookie_str, $cookie_param) !== FALSE) {
1233
+            $secure = true;
1234
+        } else {
1235
+            $secure = false;
1236
+        }
1237
+
1238
+        $sep_pos = strpos($value_str, '=');
1239
+
1240
+        if ($sep_pos) {
1241
+            $name = substr($value_str, 0, $sep_pos);
1242
+            $value = substr($value_str, $sep_pos + 1);
1243
+            $cookie= array(	'name' => $name,
1244
+                            'value' => $value,
1245
+                            'domain' => $domain,
1246
+                            'path' => $path,
1247
+                            'expires' => $expires,
1248
+                            'secure' => $secure
1249
+                            );
1250
+            return $cookie;
1251
+        }
1252
+        return false;
1253
+    }
1254
+
1255
+    /**
1256
+     * sort out cookies for the current request
1257
+     *
1258
+     * @param	array $cookies array with all cookies
1259
+     * @param	boolean $secure is the send-content secure or not?
1260
+     * @return	string for Cookie-HTTP-Header
1261
+     * @access	private
1262
+     */
1263
+    function getCookiesForRequest($cookies, $secure=false) {
1264
+        $cookie_str = '';
1265
+        if ((! is_null($cookies)) && (is_array($cookies))) {
1266
+            foreach ($cookies as $cookie) {
1267
+                if (! is_array($cookie)) {
1268
+                    continue;
1269
+                }
1270
+                $this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
1271
+                if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
1272
+                    if (strtotime($cookie['expires']) <= time()) {
1273
+                        $this->debug('cookie has expired');
1274
+                        continue;
1275
+                    }
1276
+                }
1277
+                if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
1278
+                    $domain = preg_quote($cookie['domain']);
1279
+                    if (! preg_match("'.*$domain$'i", $this->host)) {
1280
+                        $this->debug('cookie has different domain');
1281
+                        continue;
1282
+                    }
1283
+                }
1284
+                if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
1285
+                    $path = preg_quote($cookie['path']);
1286
+                    if (! preg_match("'^$path.*'i", $this->path)) {
1287
+                        $this->debug('cookie is for a different path');
1288
+                        continue;
1289
+                    }
1290
+                }
1291
+                if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
1292
+                    $this->debug('cookie is secure, transport is not');
1293
+                    continue;
1294
+                }
1295
+                $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
1296
+                $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
1297
+            }
1298
+        }
1299
+        return $cookie_str;
1300
+    }
1301 1301
 }
1302 1302
 
1303 1303
 
Please login to merge, or discard this patch.
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -26,18 +26,18 @@  discard block
 block discarded – undo
26 26
 	var $incoming_cookies = array();
27 27
 	var $outgoing_payload = '';
28 28
 	var $incoming_payload = '';
29
-	var $response_status_line;	// HTTP response status line
29
+	var $response_status_line; // HTTP response status line
30 30
 	var $useSOAPAction = true;
31 31
 	var $persistentConnection = false;
32
-	var $ch = false;	// cURL handle
33
-	var $ch_options = array();	// cURL custom options
34
-	var $use_curl = false;		// force cURL use
35
-	var $proxy = null;			// proxy information (associative array)
32
+	var $ch = false; // cURL handle
33
+	var $ch_options = array(); // cURL custom options
34
+	var $use_curl = false; // force cURL use
35
+	var $proxy = null; // proxy information (associative array)
36 36
 	var $username = '';
37 37
 	var $password = '';
38 38
 	var $authtype = '';
39 39
 	var $digestRequest = array();
40
-	var $certRequest = array();	// keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional)
40
+	var $certRequest = array(); // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional)
41 41
 								// cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem'
42 42
 								// sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem'
43 43
 								// sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem'
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	* @param boolean $use_curl Whether to try to force cURL use
55 55
 	* @access public
56 56
 	*/
57
-	function __construct($url, $curl_options = NULL, $use_curl = false){
57
+	function __construct($url, $curl_options = NULL, $use_curl = false) {
58 58
 		parent::__construct();
59 59
 		$this->debug("ctor url=$url use_curl=$use_curl curl_options:");
60 60
 		$this->appendDebug($this->varDump($curl_options));
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			$this->ch_options = $curl_options;
64 64
 		}
65 65
 		$this->use_curl = $use_curl;
66
-		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
66
+		preg_match('/\$Revisio'.'n: ([^ ]+)/', $this->revision, $rev);
67 67
 		$this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
68 68
 	}
69 69
 
@@ -115,19 +115,19 @@  discard block
 block discarded – undo
115 115
 		$this->url = $url;
116 116
 
117 117
 		$u = parse_url($url);
118
-		foreach($u as $k => $v){
118
+		foreach ($u as $k => $v) {
119 119
 			$this->debug("parsed URL $k = $v");
120 120
 			$this->$k = $v;
121 121
 		}
122 122
 
123 123
 		// add any GET params to path
124
-		if(isset($u['query']) && $u['query'] != ''){
125
-            $this->path .= '?' . $u['query'];
124
+		if (isset($u['query']) && $u['query'] != '') {
125
+            $this->path .= '?'.$u['query'];
126 126
 		}
127 127
 
128 128
 		// set default port
129
-		if(!isset($u['port'])){
130
-			if($u['scheme'] == 'https'){
129
+		if (!isset($u['port'])) {
130
+			if ($u['scheme'] == 'https') {
131 131
 				$this->port = 443;
132 132
 			} else {
133 133
 				$this->port = 80;
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	* @return	boolean true if connected, false if not
172 172
 	* @access   private
173 173
 	*/
174
-	function connect($connection_timeout=0,$response_timeout=30){
174
+	function connect($connection_timeout = 0, $response_timeout = 30) {
175 175
 	  	// For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
176 176
 	  	// "regular" socket.
177 177
 	  	// TODO: disabled for now because OpenSSL must be *compiled* in (not just
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		}
196 196
 
197 197
 		// use persistent connection
198
-		if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
198
+		if ($this->persistentConnection && isset($this->fp) && is_resource($this->fp)) {
199 199
 			if (!feof($this->fp)) {
200 200
 				$this->debug('Re-use persistent connection');
201 201
 				return true;
@@ -206,20 +206,20 @@  discard block
 block discarded – undo
206 206
 
207 207
 		// munge host if using OpenSSL
208 208
 		if ($this->scheme == 'ssl') {
209
-			$host = 'ssl://' . $host;
209
+			$host = 'ssl://'.$host;
210 210
 		}
211
-		$this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
211
+		$this->debug('calling fsockopen with host '.$host.' connection_timeout '.$connection_timeout);
212 212
 
213 213
 		// open socket
214
-		if($connection_timeout > 0){
215
-			$this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout);
214
+		if ($connection_timeout > 0) {
215
+			$this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str, $connection_timeout);
216 216
 		} else {
217
-			$this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str);
217
+			$this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str);
218 218
 		}
219 219
 
220 220
 		// test pointer
221
-		if(!$this->fp) {
222
-			$msg = 'Couldn\'t open socket connection to server ' . $this->url;
221
+		if (!$this->fp) {
222
+			$msg = 'Couldn\'t open socket connection to server '.$this->url;
223 223
 			if ($this->errno) {
224 224
 				$msg .= ', Error ('.$this->errno.'): '.$this->error_str;
225 225
 			} else {
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 		}
232 232
 
233 233
 		// set response timeout
234
-		$this->debug('set response timeout to ' . $response_timeout);
235
-		socket_set_timeout( $this->fp, $response_timeout);
234
+		$this->debug('set response timeout to '.$response_timeout);
235
+		socket_set_timeout($this->fp, $response_timeout);
236 236
 
237 237
 		$this->debug('socket connected');
238 238
 		return true;
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
 		$this->debug('cURL connection set up');
392 392
 		return true;
393 393
 	  } else {
394
-		$this->setError('Unknown scheme ' . $this->scheme);
395
-		$this->debug('Unknown scheme ' . $this->scheme);
394
+		$this->setError('Unknown scheme '.$this->scheme);
395
+		$this->debug('Unknown scheme '.$this->scheme);
396 396
 		return false;
397 397
 	  }
398 398
 	}
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	* @return	string data
408 408
 	* @access   public
409 409
 	*/
410
-	function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) {
410
+	function send($data, $timeout = 0, $response_timeout = 30, $cookies = NULL) {
411 411
 
412 412
 		$this->debug('entered send() with data of length: '.strlen($data));
413 413
 
@@ -417,12 +417,12 @@  discard block
 block discarded – undo
417 417
 			$this->tryagain = false;
418 418
 			if ($tries++ < 2) {
419 419
 				// make connnection
420
-				if (!$this->connect($timeout, $response_timeout)){
420
+				if (!$this->connect($timeout, $response_timeout)) {
421 421
 					return false;
422 422
 				}
423 423
 
424 424
 				// send request
425
-				if (!$this->sendRequest($data, $cookies)){
425
+				if (!$this->sendRequest($data, $cookies)) {
426 426
 					return false;
427 427
 				}
428 428
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 	* @access   public
449 449
 	* @deprecated
450 450
 	*/
451
-	function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies) {
451
+	function sendHTTPS($data, $timeout = 0, $response_timeout = 30, $cookies) {
452 452
 		return $this->send($data, $timeout, $response_timeout, $cookies);
453 453
 	}
454 454
 
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 		$this->appendDebug($this->varDump($certRequest));
470 470
 		// cf. RFC 2617
471 471
 		if ($authtype == 'basic') {
472
-			$this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':','',$username).':'.$password));
472
+			$this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':', '', $username).':'.$password));
473 473
 		} elseif ($authtype == 'digest') {
474 474
 			if (isset($digestRequest['nonce'])) {
475 475
 				$digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
@@ -477,16 +477,16 @@  discard block
 block discarded – undo
477 477
 				// calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
478 478
 
479 479
 				// A1 = unq(username-value) ":" unq(realm-value) ":" passwd
480
-				$A1 = $username. ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
480
+				$A1 = $username.':'.(isset($digestRequest['realm']) ? $digestRequest['realm'] : '').':'.$password;
481 481
 
482 482
 				// H(A1) = MD5(A1)
483 483
 				$HA1 = md5($A1);
484 484
 
485 485
 				// A2 = Method ":" digest-uri-value
486
-				$A2 = $this->request_method . ':' . $this->digest_uri;
486
+				$A2 = $this->request_method.':'.$this->digest_uri;
487 487
 
488 488
 				// H(A2)
489
-				$HA2 =  md5($A2);
489
+				$HA2 = md5($A2);
490 490
 
491 491
 				// KD(secret, data) = H(concat(secret, ":", data))
492 492
 				// if qop == auth:
@@ -503,19 +503,19 @@  discard block
 block discarded – undo
503 503
 				$nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : '';
504 504
 				$cnonce = $nonce;
505 505
 				if ($digestRequest['qop'] != '') {
506
-					$unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
506
+					$unhashedDigest = $HA1.':'.$nonce.':'.sprintf("%08d", $digestRequest['nc']).':'.$cnonce.':'.$digestRequest['qop'].':'.$HA2;
507 507
 				} else {
508
-					$unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
508
+					$unhashedDigest = $HA1.':'.$nonce.':'.$HA2;
509 509
 				}
510 510
 
511 511
 				$hashedDigest = md5($unhashedDigest);
512 512
 
513 513
 				$opaque = '';
514 514
 				if (isset($digestRequest['opaque'])) {
515
-					$opaque = ', opaque="' . $digestRequest['opaque'] . '"';
515
+					$opaque = ', opaque="'.$digestRequest['opaque'].'"';
516 516
 				}
517 517
 
518
-				$this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"');
518
+				$this->setHeader('Authorization', 'Digest username="'.$username.'", realm="'.$digestRequest['realm'].'", nonce="'.$nonce.'", uri="'.$this->digest_uri.$opaque.'", cnonce="'.$cnonce.'", nc='.sprintf("%08x", $digestRequest['nc']).', qop="'.$digestRequest['qop'].'", response="'.$hashedDigest.'"');
519 519
 			}
520 520
 		} elseif ($authtype == 'certificate') {
521 521
 			$this->certRequest = $certRequest;
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 	* @access   public
538 538
 	*/
539 539
 	function setSOAPAction($soapaction) {
540
-		$this->setHeader('SOAPAction', '"' . $soapaction . '"');
540
+		$this->setHeader('SOAPAction', '"'.$soapaction.'"');
541 541
 	}
542 542
 
543 543
 	/**
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 	* @param    string $enc encoding style. supported values: gzip, deflate, or both
547 547
 	* @access   public
548 548
 	*/
549
-	function setEncoding($enc='gzip, deflate') {
549
+	function setEncoding($enc = 'gzip, deflate') {
550 550
 		if (function_exists('gzdeflate')) {
551 551
 			$this->protocol_version = '1.1';
552 552
 			$this->setHeader('Accept-Encoding', $enc);
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 	 * @access	private
600 600
 	 */
601 601
 	function isSkippableCurlHeader(&$data) {
602
-		$skipHeaders = array(	'HTTP/1.1 100',
602
+		$skipHeaders = array('HTTP/1.1 100',
603 603
 								'HTTP/1.0 301',
604 604
 								'HTTP/1.1 301',
605 605
 								'HTTP/1.0 302',
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 	* @access   public
626 626
 	* @deprecated
627 627
 	*/
628
-	function decodeChunked($buffer, $lb){
628
+	function decodeChunked($buffer, $lb) {
629 629
 		// length := 0
630 630
 		$length = 0;
631 631
 		$new = '';
@@ -637,17 +637,17 @@  discard block
 block discarded – undo
637 637
 			$this->debug('no linebreak found in decodeChunked');
638 638
 			return $new;
639 639
 		}
640
-		$temp = substr($buffer,0,$chunkend);
641
-		$chunk_size = hexdec( trim($temp) );
640
+		$temp = substr($buffer, 0, $chunkend);
641
+		$chunk_size = hexdec(trim($temp));
642 642
 		$chunkstart = $chunkend + strlen($lb);
643 643
 		// while (chunk-size > 0) {
644 644
 		while ($chunk_size > 0) {
645 645
 			$this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
646
-			$chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size);
646
+			$chunkend = strpos($buffer, $lb, $chunkstart + $chunk_size);
647 647
 
648 648
 			// Just in case we got a broken connection
649 649
 		  	if ($chunkend == FALSE) {
650
-		  	    $chunk = substr($buffer,$chunkstart);
650
+		  	    $chunk = substr($buffer, $chunkstart);
651 651
 				// append chunk-data to entity-body
652 652
 		    	$new .= $chunk;
653 653
 		  	    $length += strlen($chunk);
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 			}
656 656
 
657 657
 		  	// read chunk-data and CRLF
658
-		  	$chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
658
+		  	$chunk = substr($buffer, $chunkstart, $chunkend - $chunkstart);
659 659
 		  	// append chunk-data to entity-body
660 660
 		  	$new .= $chunk;
661 661
 		  	// length := length + chunk-size
@@ -667,8 +667,8 @@  discard block
 block discarded – undo
667 667
 			if ($chunkend == FALSE) {
668 668
 				break; //Just in case we got a broken connection
669 669
 			}
670
-			$temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
671
-			$chunk_size = hexdec( trim($temp) );
670
+			$temp = substr($buffer, $chunkstart, $chunkend - $chunkstart);
671
+			$chunk_size = hexdec(trim($temp));
672 672
 			$chunkstart = $chunkend;
673 673
 		}
674 674
 		return $new;
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 		$this->outgoing_payload = "$req\r\n";
704 704
 
705 705
 		// loop thru headers, serializing
706
-		foreach($this->outgoing_headers as $k => $v){
706
+		foreach ($this->outgoing_headers as $k => $v) {
707 707
 			$hdr = $k.': '.$v;
708 708
 			$this->debug("HTTP header: $hdr");
709 709
 			$this->outgoing_payload .= "$hdr\r\n";
@@ -740,12 +740,12 @@  discard block
 block discarded – undo
740 740
 
741 741
 	  if ($this->io_method() == 'socket') {
742 742
 		// send payload
743
-		if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
743
+		if (!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
744 744
 			$this->setError('couldn\'t write message data to socket');
745 745
 			$this->debug('couldn\'t write message data to socket');
746 746
 			return false;
747 747
 		}
748
-		$this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
748
+		$this->debug('wrote data to socket, length = '.strlen($this->outgoing_payload));
749 749
 		return true;
750 750
 	  } else if ($this->io_method() == 'curl') {
751 751
 		// set payload
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 		// some servers refuse to work with (so we no longer use this method!)
755 755
 		//$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
756 756
 		$curl_headers = array();
757
-		foreach($this->outgoing_headers as $k => $v){
757
+		foreach ($this->outgoing_headers as $k => $v) {
758 758
 			if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
759 759
 				$this->debug("Skip cURL header $k: $v");
760 760
 			} else {
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 			}
763 763
 		}
764 764
 		if ($cookie_str != '') {
765
-			$curl_headers[] = 'Cookie: ' . $cookie_str;
765
+			$curl_headers[] = 'Cookie: '.$cookie_str;
766 766
 		}
767 767
 		$this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
768 768
 		$this->debug('set cURL HTTP headers');
@@ -788,62 +788,62 @@  discard block
 block discarded – undo
788 788
 	* @return	string the response (also sets member variables like incoming_payload)
789 789
 	* @access   private
790 790
 	*/
791
-	function getResponse(){
791
+	function getResponse() {
792 792
 		$this->incoming_payload = '';
793 793
 
794 794
 	  if ($this->io_method() == 'socket') {
795 795
 	    // loop until headers have been retrieved
796 796
 	    $data = '';
797
-	    while (!isset($lb)){
797
+	    while (!isset($lb)) {
798 798
 
799 799
 			// We might EOF during header read.
800
-			if(feof($this->fp)) {
800
+			if (feof($this->fp)) {
801 801
 				$this->incoming_payload = $data;
802
-				$this->debug('found no headers before EOF after length ' . strlen($data));
803
-				$this->debug("received before EOF:\n" . $data);
802
+				$this->debug('found no headers before EOF after length '.strlen($data));
803
+				$this->debug("received before EOF:\n".$data);
804 804
 				$this->setError('server failed to send headers');
805 805
 				return false;
806 806
 			}
807 807
 
808 808
 			$tmp = fgets($this->fp, 256);
809 809
 			$tmplen = strlen($tmp);
810
-			$this->debug("read line of $tmplen bytes: " . trim($tmp));
810
+			$this->debug("read line of $tmplen bytes: ".trim($tmp));
811 811
 
812 812
 			if ($tmplen == 0) {
813 813
 				$this->incoming_payload = $data;
814
-				$this->debug('socket read of headers timed out after length ' . strlen($data));
815
-				$this->debug("read before timeout: " . $data);
814
+				$this->debug('socket read of headers timed out after length '.strlen($data));
815
+				$this->debug("read before timeout: ".$data);
816 816
 				$this->setError('socket read of headers timed out');
817 817
 				return false;
818 818
 			}
819 819
 
820 820
 			$data .= $tmp;
821
-			$pos = strpos($data,"\r\n\r\n");
822
-			if($pos > 1){
821
+			$pos = strpos($data, "\r\n\r\n");
822
+			if ($pos > 1) {
823 823
 				$lb = "\r\n";
824 824
 			} else {
825
-				$pos = strpos($data,"\n\n");
826
-				if($pos > 1){
825
+				$pos = strpos($data, "\n\n");
826
+				if ($pos > 1) {
827 827
 					$lb = "\n";
828 828
 				}
829 829
 			}
830 830
 			// remove 100 headers
831
-			if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) {
831
+			if (isset($lb) && preg_match('/^HTTP\/1.1 100/', $data)) {
832 832
 				unset($lb);
833 833
 				$data = '';
834 834
 			}//
835 835
 		}
836 836
 		// store header data
837 837
 		$this->incoming_payload .= $data;
838
-		$this->debug('found end of headers after length ' . strlen($data));
838
+		$this->debug('found end of headers after length '.strlen($data));
839 839
 		// process headers
840
-		$header_data = trim(substr($data,0,$pos));
841
-		$header_array = explode($lb,$header_data);
840
+		$header_data = trim(substr($data, 0, $pos));
841
+		$header_array = explode($lb, $header_data);
842 842
 		$this->incoming_headers = array();
843 843
 		$this->incoming_cookies = array();
844
-		foreach($header_array as $header_line){
845
-			$arr = explode(':',$header_line, 2);
846
-			if(count($arr) > 1){
844
+		foreach ($header_array as $header_line) {
845
+			$arr = explode(':', $header_line, 2);
846
+			if (count($arr) > 1) {
847 847
 				$header_name = strtolower(trim($arr[0]));
848 848
 				$this->incoming_headers[$header_name] = trim($arr[1]);
849 849
 				if ($header_name == 'set-cookie') {
@@ -851,20 +851,20 @@  discard block
 block discarded – undo
851 851
 					$cookie = $this->parseCookie(trim($arr[1]));
852 852
 					if ($cookie) {
853 853
 						$this->incoming_cookies[] = $cookie;
854
-						$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
854
+						$this->debug('found cookie: '.$cookie['name'].' = '.$cookie['value']);
855 855
 					} else {
856
-						$this->debug('did not find cookie in ' . trim($arr[1]));
856
+						$this->debug('did not find cookie in '.trim($arr[1]));
857 857
 					}
858 858
     			}
859 859
 			} else if (isset($header_name)) {
860 860
 				// append continuation line to previous header
861
-				$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
861
+				$this->incoming_headers[$header_name] .= $lb.' '.$header_line;
862 862
 			}
863 863
 		}
864 864
 
865 865
 		// loop until msg has been received
866 866
 		if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
867
-			$content_length =  2147483647;	// ignore any content-length header
867
+			$content_length = 2147483647; // ignore any content-length header
868 868
 			$chunked = true;
869 869
 			$this->debug("want to read chunked content");
870 870
 		} elseif (isset($this->incoming_headers['content-length'])) {
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
 			$chunked = false;
873 873
 			$this->debug("want to read content of length $content_length");
874 874
 		} else {
875
-			$content_length =  2147483647;
875
+			$content_length = 2147483647;
876 876
 			$chunked = false;
877 877
 			$this->debug("want to read content to EOF");
878 878
 		}
@@ -884,8 +884,8 @@  discard block
 block discarded – undo
884 884
 				$this->debug("read chunk line of $tmplen bytes");
885 885
 				if ($tmplen == 0) {
886 886
 					$this->incoming_payload = $data;
887
-					$this->debug('socket read of chunk length timed out after length ' . strlen($data));
888
-					$this->debug("read before timeout:\n" . $data);
887
+					$this->debug('socket read of chunk length timed out after length '.strlen($data));
888
+					$this->debug("read before timeout:\n".$data);
889 889
 					$this->setError('socket read of chunk length timed out');
890 890
 					return false;
891 891
 				}
@@ -900,8 +900,8 @@  discard block
 block discarded – undo
900 900
 				$this->debug("read buffer of $tmplen bytes");
901 901
 				if (($tmplen == 0) && (!feof($this->fp))) {
902 902
 					$this->incoming_payload = $data;
903
-					$this->debug('socket read of body timed out after length ' . strlen($data));
904
-					$this->debug("read before timeout:\n" . $data);
903
+					$this->debug('socket read of body timed out after length '.strlen($data));
904
+					$this->debug("read before timeout:\n".$data);
905 905
 					$this->setError('socket read of body timed out');
906 906
 					return false;
907 907
 				}
@@ -914,8 +914,8 @@  discard block
 block discarded – undo
914 914
 				$this->debug("read chunk terminator of $tmplen bytes");
915 915
 				if ($tmplen == 0) {
916 916
 					$this->incoming_payload = $data;
917
-					$this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
918
-					$this->debug("read before timeout:\n" . $data);
917
+					$this->debug('socket read of chunk terminator timed out after length '.strlen($data));
918
+					$this->debug("read before timeout:\n".$data);
919 919
 					$this->setError('socket read of chunk terminator timed out');
920 920
 					return false;
921 921
 				}
@@ -924,21 +924,21 @@  discard block
 block discarded – undo
924 924
 		if (feof($this->fp)) {
925 925
 			$this->debug('read to EOF');
926 926
 		}
927
-		$this->debug('read body of length ' . strlen($data));
927
+		$this->debug('read body of length '.strlen($data));
928 928
 		$this->incoming_payload .= $data;
929 929
 		$this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
930 930
 
931 931
 		// close filepointer
932
-		if(
932
+		if (
933 933
 			(isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') ||
934
-			(! $this->persistentConnection) || feof($this->fp)){
934
+			(!$this->persistentConnection) || feof($this->fp)) {
935 935
 			fclose($this->fp);
936 936
 			$this->fp = false;
937 937
 			$this->debug('closed socket');
938 938
 		}
939 939
 
940 940
 		// connection was closed unexpectedly
941
-		if($this->incoming_payload == ''){
941
+		if ($this->incoming_payload == '') {
942 942
 			$this->setError('no response from server');
943 943
 			return false;
944 944
 		}
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 		if ($cErr != '') {
965 965
         	$err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>';
966 966
         	// TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
967
-			foreach(curl_getinfo($this->ch) as $k => $v){
967
+			foreach (curl_getinfo($this->ch) as $k => $v) {
968 968
 				$err .= "$k: $v<br>";
969 969
 			}
970 970
 			$this->debug($err);
@@ -984,44 +984,44 @@  discard block
 block discarded – undo
984 984
 		$savedata = $data;
985 985
 		while ($this->isSkippableCurlHeader($data)) {
986 986
 			$this->debug("Found HTTP header to skip");
987
-			if ($pos = strpos($data,"\r\n\r\n")) {
988
-				$data = ltrim(substr($data,$pos));
989
-			} elseif($pos = strpos($data,"\n\n") ) {
990
-				$data = ltrim(substr($data,$pos));
987
+			if ($pos = strpos($data, "\r\n\r\n")) {
988
+				$data = ltrim(substr($data, $pos));
989
+			} elseif ($pos = strpos($data, "\n\n")) {
990
+				$data = ltrim(substr($data, $pos));
991 991
 			}
992 992
 		}
993 993
 
994 994
 		if ($data == '') {
995 995
 			// have nothing left; just remove 100 header(s)
996 996
 			$data = $savedata;
997
-			while (preg_match('/^HTTP\/1.1 100/',$data)) {
998
-				if ($pos = strpos($data,"\r\n\r\n")) {
999
-					$data = ltrim(substr($data,$pos));
1000
-				} elseif($pos = strpos($data,"\n\n") ) {
1001
-					$data = ltrim(substr($data,$pos));
997
+			while (preg_match('/^HTTP\/1.1 100/', $data)) {
998
+				if ($pos = strpos($data, "\r\n\r\n")) {
999
+					$data = ltrim(substr($data, $pos));
1000
+				} elseif ($pos = strpos($data, "\n\n")) {
1001
+					$data = ltrim(substr($data, $pos));
1002 1002
 				}
1003 1003
 			}
1004 1004
 		}
1005 1005
 
1006 1006
 		// separate content from HTTP headers
1007
-		if ($pos = strpos($data,"\r\n\r\n")) {
1007
+		if ($pos = strpos($data, "\r\n\r\n")) {
1008 1008
 			$lb = "\r\n";
1009
-		} elseif( $pos = strpos($data,"\n\n")) {
1009
+		} elseif ($pos = strpos($data, "\n\n")) {
1010 1010
 			$lb = "\n";
1011 1011
 		} else {
1012 1012
 			$this->debug('no proper separation of headers and document');
1013 1013
 			$this->setError('no proper separation of headers and document');
1014 1014
 			return false;
1015 1015
 		}
1016
-		$header_data = trim(substr($data,0,$pos));
1017
-		$header_array = explode($lb,$header_data);
1018
-		$data = ltrim(substr($data,$pos));
1016
+		$header_data = trim(substr($data, 0, $pos));
1017
+		$header_array = explode($lb, $header_data);
1018
+		$data = ltrim(substr($data, $pos));
1019 1019
 		$this->debug('found proper separation of headers and document');
1020 1020
 		$this->debug('cleaned data, stringlen: '.strlen($data));
1021 1021
 		// clean headers
1022 1022
 		foreach ($header_array as $header_line) {
1023
-			$arr = explode(':',$header_line,2);
1024
-			if(count($arr) > 1){
1023
+			$arr = explode(':', $header_line, 2);
1024
+			if (count($arr) > 1) {
1025 1025
 				$header_name = strtolower(trim($arr[0]));
1026 1026
 				$this->incoming_headers[$header_name] = trim($arr[1]);
1027 1027
 				if ($header_name == 'set-cookie') {
@@ -1029,14 +1029,14 @@  discard block
 block discarded – undo
1029 1029
 					$cookie = $this->parseCookie(trim($arr[1]));
1030 1030
 					if ($cookie) {
1031 1031
 						$this->incoming_cookies[] = $cookie;
1032
-						$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
1032
+						$this->debug('found cookie: '.$cookie['name'].' = '.$cookie['value']);
1033 1033
 					} else {
1034
-						$this->debug('did not find cookie in ' . trim($arr[1]));
1034
+						$this->debug('did not find cookie in '.trim($arr[1]));
1035 1035
 					}
1036 1036
     			}
1037 1037
 			} else if (isset($header_name)) {
1038 1038
 				// append continuation line to previous header
1039
-				$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
1039
+				$this->incoming_headers[$header_name] .= $lb.' '.$header_line;
1040 1040
 			}
1041 1041
 		}
1042 1042
 	  }
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 
1050 1050
  		// see if we need to resend the request with http digest authentication
1051 1051
  		if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
1052
- 			$this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
1052
+ 			$this->debug("Got $http_status $http_reason with Location: ".$this->incoming_headers['location']);
1053 1053
  			$this->setURL($this->incoming_headers['location']);
1054 1054
 			$this->tryagain = true;
1055 1055
 			return false;
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
 
1058 1058
  		// see if we need to resend the request with http digest authentication
1059 1059
  		if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
1060
- 			$this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
1060
+ 			$this->debug("Got 401 $http_reason with WWW-Authenticate: ".$this->incoming_headers['www-authenticate']);
1061 1061
  			if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
1062 1062
  				$this->debug('Server wants digest authentication');
1063 1063
  				// remove "Digest " from our elements
@@ -1092,10 +1092,10 @@  discard block
 block discarded – undo
1092 1092
 		}
1093 1093
 
1094 1094
 		// decode content-encoding
1095
-		if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != ''){
1096
-			if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip'){
1095
+		if (isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != '') {
1096
+			if (strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip') {
1097 1097
     			// if decoding works, use it. else assume data wasn't gzencoded
1098
-    			if(function_exists('gzinflate')){
1098
+    			if (function_exists('gzinflate')) {
1099 1099
 					//$timer->setMarker('starting decoding of gzip/deflated content');
1100 1100
 					// IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)
1101 1101
 					// this means there are no Zlib headers, although there should be
@@ -1104,13 +1104,13 @@  discard block
 block discarded – undo
1104 1104
 					if ($this->incoming_headers['content-encoding'] == 'deflate') {
1105 1105
 						if ($degzdata = @gzinflate($data)) {
1106 1106
 	    					$data = $degzdata;
1107
-	    					$this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
1107
+	    					$this->debug('The payload has been inflated to '.strlen($data).' bytes');
1108 1108
 	    					if (strlen($data) < $datalen) {
1109 1109
 	    						// test for the case that the payload has been compressed twice
1110 1110
 		    					$this->debug('The inflated payload is smaller than the gzipped one; try again');
1111 1111
 								if ($degzdata = @gzinflate($data)) {
1112 1112
 			    					$data = $degzdata;
1113
-			    					$this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
1113
+			    					$this->debug('The payload has been inflated again to '.strlen($data).' bytes');
1114 1114
 								}
1115 1115
 	    					}
1116 1116
 	    				} else {
@@ -1120,13 +1120,13 @@  discard block
 block discarded – undo
1120 1120
 					} elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
1121 1121
 						if ($degzdata = @gzinflate(substr($data, 10))) {	// do our best
1122 1122
 							$data = $degzdata;
1123
-	    					$this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
1123
+	    					$this->debug('The payload has been un-gzipped to '.strlen($data).' bytes');
1124 1124
 	    					if (strlen($data) < $datalen) {
1125 1125
 	    						// test for the case that the payload has been compressed twice
1126 1126
 		    					$this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
1127 1127
 								if ($degzdata = @gzinflate(substr($data, 10))) {
1128 1128
 			    					$data = $degzdata;
1129
-			    					$this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
1129
+			    					$this->debug('The payload has been un-gzipped again to '.strlen($data).' bytes');
1130 1130
 								}
1131 1131
 	    					}
1132 1132
 	    				} else {
@@ -1143,14 +1143,14 @@  discard block
 block discarded – undo
1143 1143
 					$this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
1144 1144
 				}
1145 1145
 			} else {
1146
-				$this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1147
-				$this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1146
+				$this->debug('Unsupported Content-Encoding '.$this->incoming_headers['content-encoding']);
1147
+				$this->setError('Unsupported Content-Encoding '.$this->incoming_headers['content-encoding']);
1148 1148
 			}
1149 1149
 		} else {
1150 1150
 			$this->debug('No Content-Encoding header');
1151 1151
 		}
1152 1152
 
1153
-		if(strlen($data) == 0){
1153
+		if (strlen($data) == 0) {
1154 1154
 			$this->debug('no data after headers!');
1155 1155
 			$this->setError('no data present after HTTP headers');
1156 1156
 			return false;
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
 	 * @access	public
1168 1168
 	 */
1169 1169
 	function setContentType($type, $charset = false) {
1170
-		$this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
1170
+		$this->setHeader('Content-Type', $type.($charset ? '; charset='.$charset : ''));
1171 1171
 	}
1172 1172
 
1173 1173
 	/**
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 	 * @return	boolean whether the request was honored by this method.
1177 1177
 	 * @access	public
1178 1178
 	 */
1179
-	function usePersistentConnection(){
1179
+	function usePersistentConnection() {
1180 1180
 		if (isset($this->outgoing_headers['Accept-Encoding'])) {
1181 1181
 			return false;
1182 1182
 		}
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 	 * TODO: allow a Set-Cookie string to be parsed into multiple cookies
1198 1198
 	 */
1199 1199
 	function parseCookie($cookie_str) {
1200
-		$cookie_str = str_replace('; ', ';', $cookie_str) . ';';
1200
+		$cookie_str = str_replace('; ', ';', $cookie_str).';';
1201 1201
 		$data = preg_split('/;/', $cookie_str);
1202 1202
 		$value_str = $data[0];
1203 1203
 
@@ -1221,7 +1221,7 @@  discard block
 block discarded – undo
1221 1221
 
1222 1222
 		$cookie_param = 'path=';
1223 1223
 		$start = strpos($cookie_str, $cookie_param);
1224
-		if ( $start > 0 ) {
1224
+		if ($start > 0) {
1225 1225
 			$path = substr($cookie_str, $start + strlen($cookie_param));
1226 1226
 			$path = substr($path, 0, strpos($path, ';'));
1227 1227
 		} else {
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
 		if ($sep_pos) {
1241 1241
 			$name = substr($value_str, 0, $sep_pos);
1242 1242
 			$value = substr($value_str, $sep_pos + 1);
1243
-			$cookie= array(	'name' => $name,
1243
+			$cookie = array('name' => $name,
1244 1244
 			                'value' => $value,
1245 1245
 							'domain' => $domain,
1246 1246
 							'path' => $path,
@@ -1260,40 +1260,40 @@  discard block
 block discarded – undo
1260 1260
 	 * @return	string for Cookie-HTTP-Header
1261 1261
 	 * @access	private
1262 1262
 	 */
1263
-	function getCookiesForRequest($cookies, $secure=false) {
1263
+	function getCookiesForRequest($cookies, $secure = false) {
1264 1264
 		$cookie_str = '';
1265
-		if ((! is_null($cookies)) && (is_array($cookies))) {
1265
+		if ((!is_null($cookies)) && (is_array($cookies))) {
1266 1266
 			foreach ($cookies as $cookie) {
1267
-				if (! is_array($cookie)) {
1267
+				if (!is_array($cookie)) {
1268 1268
 					continue;
1269 1269
 				}
1270 1270
 	    		$this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
1271
-				if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
1271
+				if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) {
1272 1272
 					if (strtotime($cookie['expires']) <= time()) {
1273 1273
 						$this->debug('cookie has expired');
1274 1274
 						continue;
1275 1275
 					}
1276 1276
 				}
1277
-				if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
1277
+				if ((isset($cookie['domain'])) && (!empty($cookie['domain']))) {
1278 1278
 					$domain = preg_quote($cookie['domain']);
1279
-					if (! preg_match("'.*$domain$'i", $this->host)) {
1279
+					if (!preg_match("'.*$domain$'i", $this->host)) {
1280 1280
 						$this->debug('cookie has different domain');
1281 1281
 						continue;
1282 1282
 					}
1283 1283
 				}
1284
-				if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
1284
+				if ((isset($cookie['path'])) && (!empty($cookie['path']))) {
1285 1285
 					$path = preg_quote($cookie['path']);
1286
-					if (! preg_match("'^$path.*'i", $this->path)) {
1286
+					if (!preg_match("'^$path.*'i", $this->path)) {
1287 1287
 						$this->debug('cookie is for a different path');
1288 1288
 						continue;
1289 1289
 					}
1290 1290
 				}
1291
-				if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
1291
+				if ((!$secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
1292 1292
 					$this->debug('cookie is secure, transport is not');
1293 1293
 					continue;
1294 1294
 				}
1295
-				$cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
1296
-	    		$this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
1295
+				$cookie_str .= $cookie['name'].'='.$cookie['value'].'; ';
1296
+	    		$this->debug('add cookie to Cookie-String: '.$cookie['name'].'='.$cookie['value']);
1297 1297
 			}
1298 1298
 		}
1299 1299
 		return $cookie_str;
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soap_val.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
 	*
64 64
 	* @param    string $name optional name
65 65
 	* @param    mixed $type optional type name
66
-	* @param	mixed $value optional value
66
+	* @param	integer $value optional value
67 67
 	* @param	mixed $element_ns optional namespace of value
68 68
 	* @param	mixed $type_ns optional namespace of type
69 69
 	* @param	mixed $attributes associative array of attributes to add to element serialization
Please login to merge, or discard this patch.
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -13,90 +13,90 @@
 block discarded – undo
13 13
 */
14 14
 class soapval extends nusoap_base
15 15
 {
16
-	/**
17
-	 * The XML element name
18
-	 *
19
-	 * @var string
20
-	 * @access private
21
-	 */
22
-	var $name;
23
-	/**
24
-	 * The XML type name (string or false)
25
-	 *
26
-	 * @var mixed
27
-	 * @access private
28
-	 */
29
-	var $type;
30
-	/**
31
-	 * The PHP value
32
-	 *
33
-	 * @var mixed
34
-	 * @access private
35
-	 */
36
-	var $value;
37
-	/**
38
-	 * The XML element namespace (string or false)
39
-	 *
40
-	 * @var mixed
41
-	 * @access private
42
-	 */
43
-	var $element_ns;
44
-	/**
45
-	 * The XML type namespace (string or false)
46
-	 *
47
-	 * @var mixed
48
-	 * @access private
49
-	 */
50
-	var $type_ns;
51
-	/**
52
-	 * The XML element attributes (array or false)
53
-	 *
54
-	 * @var mixed
55
-	 * @access private
56
-	 */
57
-	var $attributes;
16
+    /**
17
+     * The XML element name
18
+     *
19
+     * @var string
20
+     * @access private
21
+     */
22
+    var $name;
23
+    /**
24
+     * The XML type name (string or false)
25
+     *
26
+     * @var mixed
27
+     * @access private
28
+     */
29
+    var $type;
30
+    /**
31
+     * The PHP value
32
+     *
33
+     * @var mixed
34
+     * @access private
35
+     */
36
+    var $value;
37
+    /**
38
+     * The XML element namespace (string or false)
39
+     *
40
+     * @var mixed
41
+     * @access private
42
+     */
43
+    var $element_ns;
44
+    /**
45
+     * The XML type namespace (string or false)
46
+     *
47
+     * @var mixed
48
+     * @access private
49
+     */
50
+    var $type_ns;
51
+    /**
52
+     * The XML element attributes (array or false)
53
+     *
54
+     * @var mixed
55
+     * @access private
56
+     */
57
+    var $attributes;
58 58
 
59
-	/**
60
-	* constructor
61
-	*
62
-	* @param    string $name optional name
63
-	* @param    mixed $type optional type name
64
-	* @param	mixed $value optional value
65
-	* @param	mixed $element_ns optional namespace of value
66
-	* @param	mixed $type_ns optional namespace of type
67
-	* @param	mixed $attributes associative array of attributes to add to element serialization
68
-	* @access   public
69
-	*/
70
-  	function __construct($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
71
-		parent::__construct();
72
-		$this->name = $name;
73
-		$this->type = $type;
74
-		$this->value = $value;
75
-		$this->element_ns = $element_ns;
76
-		$this->type_ns = $type_ns;
77
-		$this->attributes = $attributes;
59
+    /**
60
+     * constructor
61
+     *
62
+     * @param    string $name optional name
63
+     * @param    mixed $type optional type name
64
+     * @param	mixed $value optional value
65
+     * @param	mixed $element_ns optional namespace of value
66
+     * @param	mixed $type_ns optional namespace of type
67
+     * @param	mixed $attributes associative array of attributes to add to element serialization
68
+     * @access   public
69
+     */
70
+        function __construct($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
71
+        parent::__construct();
72
+        $this->name = $name;
73
+        $this->type = $type;
74
+        $this->value = $value;
75
+        $this->element_ns = $element_ns;
76
+        $this->type_ns = $type_ns;
77
+        $this->attributes = $attributes;
78 78
     }
79 79
 
80
-	/**
81
-	* return serialized value
82
-	*
83
-	* @param	string $use The WSDL use value (encoded|literal)
84
-	* @return	string XML data
85
-	* @access   public
86
-	*/
87
-	function serialize($use='encoded') {
88
-		return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true);
80
+    /**
81
+     * return serialized value
82
+     *
83
+     * @param	string $use The WSDL use value (encoded|literal)
84
+     * @return	string XML data
85
+     * @access   public
86
+     */
87
+    function serialize($use='encoded') {
88
+        return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true);
89 89
     }
90 90
 
91
-	/**
92
-	* decodes a soapval object into a PHP native type
93
-	*
94
-	* @return	mixed
95
-	* @access   public
96
-	*/
97
-	function decode(){
98
-		return $this->value;
99
-	}
91
+    /**
92
+     * decodes a soapval object into a PHP native type
93
+     *
94
+     * @return	mixed
95
+     * @access   public
96
+     */
97
+    function decode(){
98
+        return $this->value;
99
+    }
100 100
 }
101 101
 
102 102
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	* @param	mixed $attributes associative array of attributes to add to element serialization
68 68
 	* @access   public
69 69
 	*/
70
-  	function __construct($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
70
+  	function __construct($name = 'soapval', $type = false, $value = -1, $element_ns = false, $type_ns = false, $attributes = false) {
71 71
 		parent::__construct();
72 72
 		$this->name = $name;
73 73
 		$this->type = $type;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	* @return	string XML data
85 85
 	* @access   public
86 86
 	*/
87
-	function serialize($use='encoded') {
87
+	function serialize($use = 'encoded') {
88 88
 		return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true);
89 89
     }
90 90
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	* @return	mixed
95 95
 	* @access   public
96 96
 	*/
97
-	function decode(){
97
+	function decode() {
98 98
 		return $this->value;
99 99
 	}
100 100
 }
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soapclient.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -743,6 +743,7 @@
 block discarded – undo
743 743
 	/**
744 744
 	* dynamically creates proxy class code
745 745
 	*
746
+	* @param integer $r
746 747
 	* @return   string PHP/NuSOAP code for the proxy class
747 748
 	* @access   private
748 749
 	*/
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -173,8 +173,9 @@  discard block
 block discarded – undo
173 173
 		}
174 174
 		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
175 175
 			$this->loadWSDL();
176
-			if ($this->getError())
177
-				return false;
176
+			if ($this->getError()) {
177
+							return false;
178
+			}
178 179
 		}
179 180
 		// serialize parameters
180 181
 		if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
@@ -388,8 +389,9 @@  discard block
 block discarded – undo
388 389
 	function getOperationData($operation){
389 390
 		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
390 391
 			$this->loadWSDL();
391
-			if ($this->getError())
392
-				return false;
392
+			if ($this->getError()) {
393
+							return false;
394
+			}
393 395
 		}
394 396
 		if(isset($this->operations[$operation])){
395 397
 			return $this->operations[$operation];
Please login to merge, or discard this patch.
Indentation   +903 added lines, -903 removed lines patch added patch discarded remove patch
@@ -22,967 +22,967 @@
 block discarded – undo
22 22
 */
23 23
 class nusoap_client extends nusoap_base
24 24
 {
25
-	var $username = '';				// Username for HTTP authentication
26
-	var $password = '';				// Password for HTTP authentication
27
-	var $authtype = '';				// Type of HTTP authentication
28
-	var $certRequest = array();		// Certificate for HTTP SSL authentication
29
-	var $requestHeaders = false;	// SOAP headers in request (text)
30
-	var $responseHeaders = '';		// SOAP headers from response (incomplete namespace resolution) (text)
31
-	var $responseHeader = NULL;		// SOAP Header from response (parsed)
32
-	var $document = '';				// SOAP body response portion (incomplete namespace resolution) (text)
33
-	var $endpoint;
34
-	var $forceEndpoint = '';		// overrides WSDL endpoint
25
+    var $username = '';				// Username for HTTP authentication
26
+    var $password = '';				// Password for HTTP authentication
27
+    var $authtype = '';				// Type of HTTP authentication
28
+    var $certRequest = array();		// Certificate for HTTP SSL authentication
29
+    var $requestHeaders = false;	// SOAP headers in request (text)
30
+    var $responseHeaders = '';		// SOAP headers from response (incomplete namespace resolution) (text)
31
+    var $responseHeader = NULL;		// SOAP Header from response (parsed)
32
+    var $document = '';				// SOAP body response portion (incomplete namespace resolution) (text)
33
+    var $endpoint;
34
+    var $forceEndpoint = '';		// overrides WSDL endpoint
35 35
     var $proxyhost = '';
36 36
     var $proxyport = '';
37
-	var $proxyusername = '';
38
-	var $proxypassword = '';
39
-	var $portName = '';				// port name to use in WSDL
37
+    var $proxyusername = '';
38
+    var $proxypassword = '';
39
+    var $portName = '';				// port name to use in WSDL
40 40
     var $xml_encoding = '';			// character set encoding of incoming (response) messages
41
-	var $http_encoding = false;
42
-	var $timeout = 0;				// HTTP connection timeout
43
-	var $response_timeout = 30;		// HTTP response timeout
44
-	var $endpointType = '';			// soap|wsdl, empty for WSDL initialization error
45
-	var $persistentConnection = false;
46
-	var $defaultRpcParams = false;	// This is no longer used
47
-	var $request = '';				// HTTP request
48
-	var $response = '';				// HTTP response
49
-	var $responseData = '';			// SOAP payload of response
50
-	var $cookies = array();			// Cookies from response or for request
41
+    var $http_encoding = false;
42
+    var $timeout = 0;				// HTTP connection timeout
43
+    var $response_timeout = 30;		// HTTP response timeout
44
+    var $endpointType = '';			// soap|wsdl, empty for WSDL initialization error
45
+    var $persistentConnection = false;
46
+    var $defaultRpcParams = false;	// This is no longer used
47
+    var $request = '';				// HTTP request
48
+    var $response = '';				// HTTP response
49
+    var $responseData = '';			// SOAP payload of response
50
+    var $cookies = array();			// Cookies from response or for request
51 51
     var $decode_utf8 = true;		// toggles whether the parser decodes element content w/ utf8_decode()
52
-	var $operations = array();		// WSDL operations, empty for WSDL initialization error
53
-	var $curl_options = array();	// User-specified cURL options
54
-	var $bindingType = '';			// WSDL operation binding type
55
-	var $use_curl = false;			// whether to always try to use cURL
52
+    var $operations = array();		// WSDL operations, empty for WSDL initialization error
53
+    var $curl_options = array();	// User-specified cURL options
54
+    var $bindingType = '';			// WSDL operation binding type
55
+    var $use_curl = false;			// whether to always try to use cURL
56 56
 
57
-	/*
57
+    /*
58 58
 	 * fault related variables
59 59
 	 */
60
-	/**
61
-	 * @var      fault
62
-	 * @access   public
63
-	 */
64
-	var $fault;
65
-	/**
66
-	 * @var      faultcode
67
-	 * @access   public
68
-	 */
69
-	var $faultcode;
70
-	/**
71
-	 * @var      faultstring
72
-	 * @access   public
73
-	 */
74
-	var $faultstring;
75
-	/**
76
-	 * @var      faultdetail
77
-	 * @access   public
78
-	 */
79
-	var $faultdetail;
80
-
81
-	/**
82
-	* constructor
83
-	*
84
-	* @param    mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object)
85
-	* @param    mixed $wsdl optional, set to 'wsdl' or true if using WSDL
86
-	* @param    string $proxyhost optional
87
-	* @param    string $proxyport optional
88
-	* @param	string $proxyusername optional
89
-	* @param	string $proxypassword optional
90
-	* @param	integer $timeout set the connection timeout
91
-	* @param	integer $response_timeout set the response timeout
92
-	* @param	string $portName optional portName in WSDL document
93
-	* @access   public
94
-	*/
95
-	function __construct($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
96
-		parent::__construct();
97
-		$this->endpoint = $endpoint;
98
-		$this->proxyhost = $proxyhost;
99
-		$this->proxyport = $proxyport;
100
-		$this->proxyusername = $proxyusername;
101
-		$this->proxypassword = $proxypassword;
102
-		$this->timeout = $timeout;
103
-		$this->response_timeout = $response_timeout;
104
-		$this->portName = $portName;
105
-
106
-		$this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
107
-		$this->appendDebug('endpoint=' . $this->varDump($endpoint));
108
-
109
-		// make values
110
-		if($wsdl){
111
-			if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) {
112
-				$this->wsdl = $endpoint;
113
-				$this->endpoint = $this->wsdl->wsdl;
114
-				$this->wsdlFile = $this->endpoint;
115
-				$this->debug('existing wsdl instance created from ' . $this->endpoint);
116
-				$this->checkWSDL();
117
-			} else {
118
-				$this->wsdlFile = $this->endpoint;
119
-				$this->wsdl = null;
120
-				$this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
121
-			}
122
-			$this->endpointType = 'wsdl';
123
-		} else {
124
-			$this->debug("instantiate SOAP with endpoint at $endpoint");
125
-			$this->endpointType = 'soap';
126
-		}
127
-	}
60
+    /**
61
+     * @var      fault
62
+     * @access   public
63
+     */
64
+    var $fault;
65
+    /**
66
+     * @var      faultcode
67
+     * @access   public
68
+     */
69
+    var $faultcode;
70
+    /**
71
+     * @var      faultstring
72
+     * @access   public
73
+     */
74
+    var $faultstring;
75
+    /**
76
+     * @var      faultdetail
77
+     * @access   public
78
+     */
79
+    var $faultdetail;
128 80
 
129
-	/**
130
-	* calls method, returns PHP native type
131
-	*
132
-	* @param    string $operation SOAP server URL or path
133
-	* @param    mixed $params An array, associative or simple, of the parameters
134
-	*			              for the method call, or a string that is the XML
135
-	*			              for the call.  For rpc style, this call will
136
-	*			              wrap the XML in a tag named after the method, as
137
-	*			              well as the SOAP Envelope and Body.  For document
138
-	*			              style, this will only wrap with the Envelope and Body.
139
-	*			              IMPORTANT: when using an array with document style,
140
-	*			              in which case there
141
-	*                         is really one parameter, the root of the fragment
142
-	*                         used in the call, which encloses what programmers
143
-	*                         normally think of parameters.  A parameter array
144
-	*                         *must* include the wrapper.
145
-	* @param	string $namespace optional method namespace (WSDL can override)
146
-	* @param	string $soapAction optional SOAPAction value (WSDL can override)
147
-	* @param	mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
148
-	* @param	boolean $rpcParams optional (no longer used)
149
-	* @param	string	$style optional (rpc|document) the style to use when serializing parameters (WSDL can override)
150
-	* @param	string	$use optional (encoded|literal) the use when serializing parameters (WSDL can override)
151
-	* @return	mixed	response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors
152
-	* @access   public
153
-	*/
154
-	function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
155
-		$this->operation = $operation;
156
-		$this->fault = false;
157
-		$this->setError('');
158
-		$this->request = '';
159
-		$this->response = '';
160
-		$this->responseData = '';
161
-		$this->faultstring = '';
162
-		$this->faultcode = '';
163
-		$this->opData = array();
164
-
165
-		$this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
166
-		$this->appendDebug('params=' . $this->varDump($params));
167
-		$this->appendDebug('headers=' . $this->varDump($headers));
168
-		if ($headers) {
169
-			$this->requestHeaders = $headers;
170
-		}
171
-		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
172
-			$this->loadWSDL();
173
-			if ($this->getError())
174
-				return false;
175
-		}
176
-		// serialize parameters
177
-		if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
178
-			// use WSDL for operation
179
-			$this->opData = $opData;
180
-			$this->debug("found operation");
181
-			$this->appendDebug('opData=' . $this->varDump($opData));
182
-			if (isset($opData['soapAction'])) {
183
-				$soapAction = $opData['soapAction'];
184
-			}
185
-			if (! $this->forceEndpoint) {
186
-				$this->endpoint = $opData['endpoint'];
187
-			} else {
188
-				$this->endpoint = $this->forceEndpoint;
189
-			}
190
-			$namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] :	$namespace;
191
-			$style = $opData['style'];
192
-			$use = $opData['input']['use'];
193
-			// add ns to ns array
194
-			if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
195
-				$nsPrefix = 'ns' . rand(1000, 9999);
196
-				$this->wsdl->namespaces[$nsPrefix] = $namespace;
197
-			}
81
+    /**
82
+     * constructor
83
+     *
84
+     * @param    mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object)
85
+     * @param    mixed $wsdl optional, set to 'wsdl' or true if using WSDL
86
+     * @param    string $proxyhost optional
87
+     * @param    string $proxyport optional
88
+     * @param	string $proxyusername optional
89
+     * @param	string $proxypassword optional
90
+     * @param	integer $timeout set the connection timeout
91
+     * @param	integer $response_timeout set the response timeout
92
+     * @param	string $portName optional portName in WSDL document
93
+     * @access   public
94
+     */
95
+    function __construct($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
96
+        parent::__construct();
97
+        $this->endpoint = $endpoint;
98
+        $this->proxyhost = $proxyhost;
99
+        $this->proxyport = $proxyport;
100
+        $this->proxyusername = $proxyusername;
101
+        $this->proxypassword = $proxypassword;
102
+        $this->timeout = $timeout;
103
+        $this->response_timeout = $response_timeout;
104
+        $this->portName = $portName;
105
+
106
+        $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
107
+        $this->appendDebug('endpoint=' . $this->varDump($endpoint));
108
+
109
+        // make values
110
+        if($wsdl){
111
+            if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) {
112
+                $this->wsdl = $endpoint;
113
+                $this->endpoint = $this->wsdl->wsdl;
114
+                $this->wsdlFile = $this->endpoint;
115
+                $this->debug('existing wsdl instance created from ' . $this->endpoint);
116
+                $this->checkWSDL();
117
+            } else {
118
+                $this->wsdlFile = $this->endpoint;
119
+                $this->wsdl = null;
120
+                $this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
121
+            }
122
+            $this->endpointType = 'wsdl';
123
+        } else {
124
+            $this->debug("instantiate SOAP with endpoint at $endpoint");
125
+            $this->endpointType = 'soap';
126
+        }
127
+    }
128
+
129
+    /**
130
+     * calls method, returns PHP native type
131
+     *
132
+     * @param    string $operation SOAP server URL or path
133
+     * @param    mixed $params An array, associative or simple, of the parameters
134
+     *			              for the method call, or a string that is the XML
135
+     *			              for the call.  For rpc style, this call will
136
+     *			              wrap the XML in a tag named after the method, as
137
+     *			              well as the SOAP Envelope and Body.  For document
138
+     *			              style, this will only wrap with the Envelope and Body.
139
+     *			              IMPORTANT: when using an array with document style,
140
+     *			              in which case there
141
+     *                         is really one parameter, the root of the fragment
142
+     *                         used in the call, which encloses what programmers
143
+     *                         normally think of parameters.  A parameter array
144
+     *                         *must* include the wrapper.
145
+     * @param	string $namespace optional method namespace (WSDL can override)
146
+     * @param	string $soapAction optional SOAPAction value (WSDL can override)
147
+     * @param	mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
148
+     * @param	boolean $rpcParams optional (no longer used)
149
+     * @param	string	$style optional (rpc|document) the style to use when serializing parameters (WSDL can override)
150
+     * @param	string	$use optional (encoded|literal) the use when serializing parameters (WSDL can override)
151
+     * @return	mixed	response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors
152
+     * @access   public
153
+     */
154
+    function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
155
+        $this->operation = $operation;
156
+        $this->fault = false;
157
+        $this->setError('');
158
+        $this->request = '';
159
+        $this->response = '';
160
+        $this->responseData = '';
161
+        $this->faultstring = '';
162
+        $this->faultcode = '';
163
+        $this->opData = array();
164
+
165
+        $this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
166
+        $this->appendDebug('params=' . $this->varDump($params));
167
+        $this->appendDebug('headers=' . $this->varDump($headers));
168
+        if ($headers) {
169
+            $this->requestHeaders = $headers;
170
+        }
171
+        if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
172
+            $this->loadWSDL();
173
+            if ($this->getError())
174
+                return false;
175
+        }
176
+        // serialize parameters
177
+        if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
178
+            // use WSDL for operation
179
+            $this->opData = $opData;
180
+            $this->debug("found operation");
181
+            $this->appendDebug('opData=' . $this->varDump($opData));
182
+            if (isset($opData['soapAction'])) {
183
+                $soapAction = $opData['soapAction'];
184
+            }
185
+            if (! $this->forceEndpoint) {
186
+                $this->endpoint = $opData['endpoint'];
187
+            } else {
188
+                $this->endpoint = $this->forceEndpoint;
189
+            }
190
+            $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] :	$namespace;
191
+            $style = $opData['style'];
192
+            $use = $opData['input']['use'];
193
+            // add ns to ns array
194
+            if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
195
+                $nsPrefix = 'ns' . rand(1000, 9999);
196
+                $this->wsdl->namespaces[$nsPrefix] = $namespace;
197
+            }
198 198
             $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace);
199
-			// serialize payload
200
-			if (is_string($params)) {
201
-				$this->debug("serializing param string for WSDL operation $operation");
202
-				$payload = $params;
203
-			} elseif (is_array($params)) {
204
-				$this->debug("serializing param array for WSDL operation $operation");
205
-				$payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType);
206
-			} else {
207
-				$this->debug('params must be array or string');
208
-				$this->setError('params must be array or string');
209
-				return false;
210
-			}
199
+            // serialize payload
200
+            if (is_string($params)) {
201
+                $this->debug("serializing param string for WSDL operation $operation");
202
+                $payload = $params;
203
+            } elseif (is_array($params)) {
204
+                $this->debug("serializing param array for WSDL operation $operation");
205
+                $payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType);
206
+            } else {
207
+                $this->debug('params must be array or string');
208
+                $this->setError('params must be array or string');
209
+                return false;
210
+            }
211 211
             $usedNamespaces = $this->wsdl->usedNamespaces;
212
-			if (isset($opData['input']['encodingStyle'])) {
213
-				$encodingStyle = $opData['input']['encodingStyle'];
214
-			} else {
215
-				$encodingStyle = '';
216
-			}
217
-			$this->appendDebug($this->wsdl->getDebug());
218
-			$this->wsdl->clearDebug();
219
-			if ($errstr = $this->wsdl->getError()) {
220
-				$this->debug('got wsdl error: '.$errstr);
221
-				$this->setError('wsdl error: '.$errstr);
222
-				return false;
223
-			}
224
-		} elseif($this->endpointType == 'wsdl') {
225
-			// operation not in WSDL
226
-			$this->appendDebug($this->wsdl->getDebug());
227
-			$this->wsdl->clearDebug();
228
-			$this->setError('operation '.$operation.' not present in WSDL.');
229
-			$this->debug("operation '$operation' not present in WSDL.");
230
-			return false;
231
-		} else {
232
-			// no WSDL
233
-			//$this->namespaces['ns1'] = $namespace;
234
-			$nsPrefix = 'ns' . rand(1000, 9999);
235
-			// serialize
236
-			$payload = '';
237
-			if (is_string($params)) {
238
-				$this->debug("serializing param string for operation $operation");
239
-				$payload = $params;
240
-			} elseif (is_array($params)) {
241
-				$this->debug("serializing param array for operation $operation");
242
-				foreach($params as $k => $v){
243
-					$payload .= $this->serialize_val($v,$k,false,false,false,false,$use);
244
-				}
245
-			} else {
246
-				$this->debug('params must be array or string');
247
-				$this->setError('params must be array or string');
248
-				return false;
249
-			}
250
-			$usedNamespaces = array();
251
-			if ($use == 'encoded') {
252
-				$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
253
-			} else {
254
-				$encodingStyle = '';
255
-			}
256
-		}
257
-		// wrap RPC calls with method element
258
-		if ($style == 'rpc') {
259
-			if ($use == 'literal') {
260
-				$this->debug("wrapping RPC request with literal method element");
261
-				if ($namespace) {
262
-					// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
263
-					$payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
264
-								$payload .
265
-								"</$nsPrefix:$operation>";
266
-				} else {
267
-					$payload = "<$operation>" . $payload . "</$operation>";
268
-				}
269
-			} else {
270
-				$this->debug("wrapping RPC request with encoded method element");
271
-				if ($namespace) {
272
-					$payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
273
-								$payload .
274
-								"</$nsPrefix:$operation>";
275
-				} else {
276
-					$payload = "<$operation>" .
277
-								$payload .
278
-								"</$operation>";
279
-				}
280
-			}
281
-		}
282
-		// serialize envelope
283
-		$soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle);
284
-		$this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
285
-		$this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
286
-		// send
287
-		$return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout);
288
-		if($errstr = $this->getError()){
289
-			$this->debug('Error: '.$errstr);
290
-			return false;
291
-		} else {
292
-			$this->return = $return;
293
-			$this->debug('sent message successfully and got a(n) '.gettype($return));
294
-           	$this->appendDebug('return=' . $this->varDump($return));
295
-
296
-			// fault?
297
-			if(is_array($return) && isset($return['faultcode'])){
298
-				$this->debug('got fault');
299
-				$this->setError($return['faultcode'].': '.$return['faultstring']);
300
-				$this->fault = true;
301
-				foreach($return as $k => $v){
302
-					$this->$k = $v;
303
-					$this->debug("$k = $v<br>");
304
-				}
305
-				return $return;
306
-			} elseif ($style == 'document') {
307
-				// NOTE: if the response is defined to have multiple parts (i.e. unwrapped),
308
-				// we are only going to return the first part here...sorry about that
309
-				return $return;
310
-			} else {
311
-				// array of return values
312
-				if(is_array($return)){
313
-					// multiple 'out' parameters, which we return wrapped up
314
-					// in the array
315
-					if(sizeof($return) > 1){
316
-						return $return;
317
-					}
318
-					// single 'out' parameter (normally the return value)
319
-					$return = array_shift($return);
320
-					$this->debug('return shifted value: ');
321
-					$this->appendDebug($this->varDump($return));
322
-           			return $return;
323
-				// nothing returned (ie, echoVoid)
324
-				} else {
325
-					return "";
326
-				}
327
-			}
328
-		}
329
-	}
212
+            if (isset($opData['input']['encodingStyle'])) {
213
+                $encodingStyle = $opData['input']['encodingStyle'];
214
+            } else {
215
+                $encodingStyle = '';
216
+            }
217
+            $this->appendDebug($this->wsdl->getDebug());
218
+            $this->wsdl->clearDebug();
219
+            if ($errstr = $this->wsdl->getError()) {
220
+                $this->debug('got wsdl error: '.$errstr);
221
+                $this->setError('wsdl error: '.$errstr);
222
+                return false;
223
+            }
224
+        } elseif($this->endpointType == 'wsdl') {
225
+            // operation not in WSDL
226
+            $this->appendDebug($this->wsdl->getDebug());
227
+            $this->wsdl->clearDebug();
228
+            $this->setError('operation '.$operation.' not present in WSDL.');
229
+            $this->debug("operation '$operation' not present in WSDL.");
230
+            return false;
231
+        } else {
232
+            // no WSDL
233
+            //$this->namespaces['ns1'] = $namespace;
234
+            $nsPrefix = 'ns' . rand(1000, 9999);
235
+            // serialize
236
+            $payload = '';
237
+            if (is_string($params)) {
238
+                $this->debug("serializing param string for operation $operation");
239
+                $payload = $params;
240
+            } elseif (is_array($params)) {
241
+                $this->debug("serializing param array for operation $operation");
242
+                foreach($params as $k => $v){
243
+                    $payload .= $this->serialize_val($v,$k,false,false,false,false,$use);
244
+                }
245
+            } else {
246
+                $this->debug('params must be array or string');
247
+                $this->setError('params must be array or string');
248
+                return false;
249
+            }
250
+            $usedNamespaces = array();
251
+            if ($use == 'encoded') {
252
+                $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
253
+            } else {
254
+                $encodingStyle = '';
255
+            }
256
+        }
257
+        // wrap RPC calls with method element
258
+        if ($style == 'rpc') {
259
+            if ($use == 'literal') {
260
+                $this->debug("wrapping RPC request with literal method element");
261
+                if ($namespace) {
262
+                    // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
263
+                    $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
264
+                                $payload .
265
+                                "</$nsPrefix:$operation>";
266
+                } else {
267
+                    $payload = "<$operation>" . $payload . "</$operation>";
268
+                }
269
+            } else {
270
+                $this->debug("wrapping RPC request with encoded method element");
271
+                if ($namespace) {
272
+                    $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
273
+                                $payload .
274
+                                "</$nsPrefix:$operation>";
275
+                } else {
276
+                    $payload = "<$operation>" .
277
+                                $payload .
278
+                                "</$operation>";
279
+                }
280
+            }
281
+        }
282
+        // serialize envelope
283
+        $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle);
284
+        $this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
285
+        $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
286
+        // send
287
+        $return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout);
288
+        if($errstr = $this->getError()){
289
+            $this->debug('Error: '.$errstr);
290
+            return false;
291
+        } else {
292
+            $this->return = $return;
293
+            $this->debug('sent message successfully and got a(n) '.gettype($return));
294
+                $this->appendDebug('return=' . $this->varDump($return));
295
+
296
+            // fault?
297
+            if(is_array($return) && isset($return['faultcode'])){
298
+                $this->debug('got fault');
299
+                $this->setError($return['faultcode'].': '.$return['faultstring']);
300
+                $this->fault = true;
301
+                foreach($return as $k => $v){
302
+                    $this->$k = $v;
303
+                    $this->debug("$k = $v<br>");
304
+                }
305
+                return $return;
306
+            } elseif ($style == 'document') {
307
+                // NOTE: if the response is defined to have multiple parts (i.e. unwrapped),
308
+                // we are only going to return the first part here...sorry about that
309
+                return $return;
310
+            } else {
311
+                // array of return values
312
+                if(is_array($return)){
313
+                    // multiple 'out' parameters, which we return wrapped up
314
+                    // in the array
315
+                    if(sizeof($return) > 1){
316
+                        return $return;
317
+                    }
318
+                    // single 'out' parameter (normally the return value)
319
+                    $return = array_shift($return);
320
+                    $this->debug('return shifted value: ');
321
+                    $this->appendDebug($this->varDump($return));
322
+                        return $return;
323
+                // nothing returned (ie, echoVoid)
324
+                } else {
325
+                    return "";
326
+                }
327
+            }
328
+        }
329
+    }
330 330
 
331
-	/**
332
-	* check WSDL passed as an instance or pulled from an endpoint
333
-	*
334
-	* @access   private
335
-	*/
336
-	function checkWSDL() {
337
-		$this->appendDebug($this->wsdl->getDebug());
338
-		$this->wsdl->clearDebug();
339
-		$this->debug('checkWSDL');
340
-		// catch errors
341
-		if ($errstr = $this->wsdl->getError()) {
342
-			$this->appendDebug($this->wsdl->getDebug());
343
-			$this->wsdl->clearDebug();
344
-			$this->debug('got wsdl error: '.$errstr);
345
-			$this->setError('wsdl error: '.$errstr);
346
-		} elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap')) {
347
-			$this->appendDebug($this->wsdl->getDebug());
348
-			$this->wsdl->clearDebug();
349
-			$this->bindingType = 'soap';
350
-			$this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
351
-		} elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) {
352
-			$this->appendDebug($this->wsdl->getDebug());
353
-			$this->wsdl->clearDebug();
354
-			$this->bindingType = 'soap12';
355
-			$this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
356
-			$this->debug('**************** WARNING: SOAP 1.2 BINDING *****************');
357
-		} else {
358
-			$this->appendDebug($this->wsdl->getDebug());
359
-			$this->wsdl->clearDebug();
360
-			$this->debug('getOperations returned false');
361
-			$this->setError('no operations defined in the WSDL document!');
362
-		}
363
-	}
331
+    /**
332
+     * check WSDL passed as an instance or pulled from an endpoint
333
+     *
334
+     * @access   private
335
+     */
336
+    function checkWSDL() {
337
+        $this->appendDebug($this->wsdl->getDebug());
338
+        $this->wsdl->clearDebug();
339
+        $this->debug('checkWSDL');
340
+        // catch errors
341
+        if ($errstr = $this->wsdl->getError()) {
342
+            $this->appendDebug($this->wsdl->getDebug());
343
+            $this->wsdl->clearDebug();
344
+            $this->debug('got wsdl error: '.$errstr);
345
+            $this->setError('wsdl error: '.$errstr);
346
+        } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap')) {
347
+            $this->appendDebug($this->wsdl->getDebug());
348
+            $this->wsdl->clearDebug();
349
+            $this->bindingType = 'soap';
350
+            $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
351
+        } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) {
352
+            $this->appendDebug($this->wsdl->getDebug());
353
+            $this->wsdl->clearDebug();
354
+            $this->bindingType = 'soap12';
355
+            $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
356
+            $this->debug('**************** WARNING: SOAP 1.2 BINDING *****************');
357
+        } else {
358
+            $this->appendDebug($this->wsdl->getDebug());
359
+            $this->wsdl->clearDebug();
360
+            $this->debug('getOperations returned false');
361
+            $this->setError('no operations defined in the WSDL document!');
362
+        }
363
+    }
364 364
 
365
-	/**
366
-	 * instantiate wsdl object and parse wsdl file
367
-	 *
368
-	 * @access	public
369
-	 */
370
-	function loadWSDL() {
371
-		$this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
372
-		$this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
373
-		$this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest);
374
-		$this->wsdl->fetchWSDL($this->wsdlFile);
375
-		$this->checkWSDL();
376
-	}
365
+    /**
366
+     * instantiate wsdl object and parse wsdl file
367
+     *
368
+     * @access	public
369
+     */
370
+    function loadWSDL() {
371
+        $this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
372
+        $this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
373
+        $this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest);
374
+        $this->wsdl->fetchWSDL($this->wsdlFile);
375
+        $this->checkWSDL();
376
+    }
377 377
 
378
-	/**
379
-	* get available data pertaining to an operation
380
-	*
381
-	* @param    string $operation operation name
382
-	* @return	array array of data pertaining to the operation
383
-	* @access   public
384
-	*/
385
-	function getOperationData($operation){
386
-		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
387
-			$this->loadWSDL();
388
-			if ($this->getError())
389
-				return false;
390
-		}
391
-		if(isset($this->operations[$operation])){
392
-			return $this->operations[$operation];
393
-		}
394
-		$this->debug("No data for operation: $operation");
395
-	}
378
+    /**
379
+     * get available data pertaining to an operation
380
+     *
381
+     * @param    string $operation operation name
382
+     * @return	array array of data pertaining to the operation
383
+     * @access   public
384
+     */
385
+    function getOperationData($operation){
386
+        if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
387
+            $this->loadWSDL();
388
+            if ($this->getError())
389
+                return false;
390
+        }
391
+        if(isset($this->operations[$operation])){
392
+            return $this->operations[$operation];
393
+        }
394
+        $this->debug("No data for operation: $operation");
395
+    }
396 396
 
397 397
     /**
398
-    * send the SOAP message
399
-    *
400
-    * Note: if the operation has multiple return values
401
-    * the return value of this method will be an array
402
-    * of those values.
403
-    *
404
-	* @param    string $msg a SOAPx4 soapmsg object
405
-	* @param    string $soapaction SOAPAction value
406
-	* @param    integer $timeout set connection timeout in seconds
407
-	* @param	integer $response_timeout set response timeout in seconds
408
-	* @return	mixed native PHP types.
409
-	* @access   private
410
-	*/
411
-	function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
412
-		$this->checkCookies();
413
-		// detect transport
414
-		switch(true){
415
-			// http(s)
416
-			case preg_match('/^http/',$this->endpoint):
417
-				$this->debug('transporting via HTTP');
418
-				if($this->persistentConnection == true && is_object($this->persistentConnection)){
419
-					$http =& $this->persistentConnection;
420
-				} else {
421
-					$http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl);
422
-					if ($this->persistentConnection) {
423
-						$http->usePersistentConnection();
424
-					}
425
-				}
426
-				$http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset());
427
-				$http->setSOAPAction($soapaction);
428
-				if($this->proxyhost && $this->proxyport){
429
-					$http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
430
-				}
398
+     * send the SOAP message
399
+     *
400
+     * Note: if the operation has multiple return values
401
+     * the return value of this method will be an array
402
+     * of those values.
403
+     *
404
+     * @param    string $msg a SOAPx4 soapmsg object
405
+     * @param    string $soapaction SOAPAction value
406
+     * @param    integer $timeout set connection timeout in seconds
407
+     * @param	integer $response_timeout set response timeout in seconds
408
+     * @return	mixed native PHP types.
409
+     * @access   private
410
+     */
411
+    function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
412
+        $this->checkCookies();
413
+        // detect transport
414
+        switch(true){
415
+            // http(s)
416
+            case preg_match('/^http/',$this->endpoint):
417
+                $this->debug('transporting via HTTP');
418
+                if($this->persistentConnection == true && is_object($this->persistentConnection)){
419
+                    $http =& $this->persistentConnection;
420
+                } else {
421
+                    $http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl);
422
+                    if ($this->persistentConnection) {
423
+                        $http->usePersistentConnection();
424
+                    }
425
+                }
426
+                $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset());
427
+                $http->setSOAPAction($soapaction);
428
+                if($this->proxyhost && $this->proxyport){
429
+                    $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
430
+                }
431 431
                 if($this->authtype != '') {
432
-					$http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
433
-				}
434
-				if($this->http_encoding != ''){
435
-					$http->setEncoding($this->http_encoding);
436
-				}
437
-				$this->debug('sending message, length='.strlen($msg));
438
-				if(preg_match('/^http:/',$this->endpoint)){
439
-				//if(strpos($this->endpoint,'http:')){
440
-					$this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies);
441
-				} elseif(preg_match('/^https/',$this->endpoint)){
442
-				//} elseif(strpos($this->endpoint,'https:')){
443
-					//if(phpversion() == '4.3.0-dev'){
444
-						//$response = $http->send($msg,$timeout,$response_timeout);
445
-                   		//$this->request = $http->outgoing_payload;
446
-						//$this->response = $http->incoming_payload;
447
-					//} else
448
-					$this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies);
449
-				} else {
450
-					$this->setError('no http/s in endpoint url');
451
-				}
452
-				$this->request = $http->outgoing_payload;
453
-				$this->response = $http->incoming_payload;
454
-				$this->appendDebug($http->getDebug());
455
-				$this->UpdateCookies($http->incoming_cookies);
456
-
457
-				// save transport object if using persistent connections
458
-				if ($this->persistentConnection) {
459
-					$http->clearDebug();
460
-					if (!is_object($this->persistentConnection)) {
461
-						$this->persistentConnection = $http;
462
-					}
463
-				}
464
-
465
-				if($err = $http->getError()){
466
-					$this->setError('HTTP Error: '.$err);
467
-					return false;
468
-				} elseif($this->getError()){
469
-					return false;
470
-				} else {
471
-					$this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
472
-					return $this->parseResponse($http->incoming_headers, $this->responseData);
473
-				}
474
-			break;
475
-			default:
476
-				$this->setError('no transport found, or selected transport is not yet supported!');
477
-			return false;
478
-			break;
479
-		}
480
-	}
432
+                    $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
433
+                }
434
+                if($this->http_encoding != ''){
435
+                    $http->setEncoding($this->http_encoding);
436
+                }
437
+                $this->debug('sending message, length='.strlen($msg));
438
+                if(preg_match('/^http:/',$this->endpoint)){
439
+                //if(strpos($this->endpoint,'http:')){
440
+                    $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies);
441
+                } elseif(preg_match('/^https/',$this->endpoint)){
442
+                //} elseif(strpos($this->endpoint,'https:')){
443
+                    //if(phpversion() == '4.3.0-dev'){
444
+                        //$response = $http->send($msg,$timeout,$response_timeout);
445
+                            //$this->request = $http->outgoing_payload;
446
+                        //$this->response = $http->incoming_payload;
447
+                    //} else
448
+                    $this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies);
449
+                } else {
450
+                    $this->setError('no http/s in endpoint url');
451
+                }
452
+                $this->request = $http->outgoing_payload;
453
+                $this->response = $http->incoming_payload;
454
+                $this->appendDebug($http->getDebug());
455
+                $this->UpdateCookies($http->incoming_cookies);
456
+
457
+                // save transport object if using persistent connections
458
+                if ($this->persistentConnection) {
459
+                    $http->clearDebug();
460
+                    if (!is_object($this->persistentConnection)) {
461
+                        $this->persistentConnection = $http;
462
+                    }
463
+                }
464
+
465
+                if($err = $http->getError()){
466
+                    $this->setError('HTTP Error: '.$err);
467
+                    return false;
468
+                } elseif($this->getError()){
469
+                    return false;
470
+                } else {
471
+                    $this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
472
+                    return $this->parseResponse($http->incoming_headers, $this->responseData);
473
+                }
474
+            break;
475
+            default:
476
+                $this->setError('no transport found, or selected transport is not yet supported!');
477
+            return false;
478
+            break;
479
+        }
480
+    }
481 481
 
482
-	/**
483
-	* processes SOAP message returned from server
484
-	*
485
-	* @param	array	$headers	The HTTP headers
486
-	* @param	string	$data		unprocessed response data from server
487
-	* @return	mixed	value of the message, decoded into a PHP type
488
-	* @access   private
489
-	*/
482
+    /**
483
+     * processes SOAP message returned from server
484
+     *
485
+     * @param	array	$headers	The HTTP headers
486
+     * @param	string	$data		unprocessed response data from server
487
+     * @return	mixed	value of the message, decoded into a PHP type
488
+     * @access   private
489
+     */
490 490
     function parseResponse($headers, $data) {
491
-		$this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
492
-		$this->appendDebug($this->varDump($headers));
493
-    	if (!isset($headers['content-type'])) {
494
-			$this->setError('Response not of type text/xml (no content-type header)');
495
-			return false;
496
-    	}
497
-		if (!strstr($headers['content-type'], 'text/xml')) {
498
-			$this->setError('Response not of type text/xml: ' . $headers['content-type']);
499
-			return false;
500
-		}
501
-		if (strpos($headers['content-type'], '=')) {
502
-			$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
503
-			$this->debug('Got response encoding: ' . $enc);
504
-			if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
505
-				$this->xml_encoding = strtoupper($enc);
506
-			} else {
507
-				$this->xml_encoding = 'US-ASCII';
508
-			}
509
-		} else {
510
-			// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
511
-			$this->xml_encoding = 'ISO-8859-1';
512
-		}
513
-		$this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
514
-		$parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8);
515
-		// add parser debug data to our debug
516
-		$this->appendDebug($parser->getDebug());
517
-		// if parse errors
518
-		if($errstr = $parser->getError()){
519
-			$this->setError( $errstr);
520
-			// destroy the parser object
521
-			unset($parser);
522
-			return false;
523
-		} else {
524
-			// get SOAP headers
525
-			$this->responseHeaders = $parser->getHeaders();
526
-			// get SOAP headers
527
-			$this->responseHeader = $parser->get_soapheader();
528
-			// get decoded message
529
-			$return = $parser->get_soapbody();
491
+        $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
492
+        $this->appendDebug($this->varDump($headers));
493
+        if (!isset($headers['content-type'])) {
494
+            $this->setError('Response not of type text/xml (no content-type header)');
495
+            return false;
496
+        }
497
+        if (!strstr($headers['content-type'], 'text/xml')) {
498
+            $this->setError('Response not of type text/xml: ' . $headers['content-type']);
499
+            return false;
500
+        }
501
+        if (strpos($headers['content-type'], '=')) {
502
+            $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
503
+            $this->debug('Got response encoding: ' . $enc);
504
+            if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
505
+                $this->xml_encoding = strtoupper($enc);
506
+            } else {
507
+                $this->xml_encoding = 'US-ASCII';
508
+            }
509
+        } else {
510
+            // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
511
+            $this->xml_encoding = 'ISO-8859-1';
512
+        }
513
+        $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
514
+        $parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8);
515
+        // add parser debug data to our debug
516
+        $this->appendDebug($parser->getDebug());
517
+        // if parse errors
518
+        if($errstr = $parser->getError()){
519
+            $this->setError( $errstr);
520
+            // destroy the parser object
521
+            unset($parser);
522
+            return false;
523
+        } else {
524
+            // get SOAP headers
525
+            $this->responseHeaders = $parser->getHeaders();
526
+            // get SOAP headers
527
+            $this->responseHeader = $parser->get_soapheader();
528
+            // get decoded message
529
+            $return = $parser->get_soapbody();
530 530
             // add document for doclit support
531 531
             $this->document = $parser->document;
532
-			// destroy the parser object
533
-			unset($parser);
534
-			// return decode message
535
-			return $return;
536
-		}
537
-	 }
538
-
539
-	/**
540
-	* sets user-specified cURL options
541
-	*
542
-	* @param	mixed $option The cURL option (always integer?)
543
-	* @param	mixed $value The cURL option value
544
-	* @access   public
545
-	*/
546
-	function setCurlOption($option, $value) {
547
-		$this->debug("setCurlOption option=$option, value=");
548
-		$this->appendDebug($this->varDump($value));
549
-		$this->curl_options[$option] = $value;
550
-	}
532
+            // destroy the parser object
533
+            unset($parser);
534
+            // return decode message
535
+            return $return;
536
+        }
537
+        }
551 538
 
552
-	/**
553
-	* sets the SOAP endpoint, which can override WSDL
554
-	*
555
-	* @param	string $endpoint The endpoint URL to use, or empty string or false to prevent override
556
-	* @access   public
557
-	*/
558
-	function setEndpoint($endpoint) {
559
-		$this->debug("setEndpoint(\"$endpoint\")");
560
-		$this->forceEndpoint = $endpoint;
561
-	}
539
+    /**
540
+     * sets user-specified cURL options
541
+     *
542
+     * @param	mixed $option The cURL option (always integer?)
543
+     * @param	mixed $value The cURL option value
544
+     * @access   public
545
+     */
546
+    function setCurlOption($option, $value) {
547
+        $this->debug("setCurlOption option=$option, value=");
548
+        $this->appendDebug($this->varDump($value));
549
+        $this->curl_options[$option] = $value;
550
+    }
562 551
 
563
-	/**
564
-	* set the SOAP headers
565
-	*
566
-	* @param	mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers
567
-	* @access   public
568
-	*/
569
-	function setHeaders($headers){
570
-		$this->debug("setHeaders headers=");
571
-		$this->appendDebug($this->varDump($headers));
572
-		$this->requestHeaders = $headers;
573
-	}
552
+    /**
553
+     * sets the SOAP endpoint, which can override WSDL
554
+     *
555
+     * @param	string $endpoint The endpoint URL to use, or empty string or false to prevent override
556
+     * @access   public
557
+     */
558
+    function setEndpoint($endpoint) {
559
+        $this->debug("setEndpoint(\"$endpoint\")");
560
+        $this->forceEndpoint = $endpoint;
561
+    }
574 562
 
575
-	/**
576
-	* get the SOAP response headers (namespace resolution incomplete)
577
-	*
578
-	* @return	string
579
-	* @access   public
580
-	*/
581
-	function getHeaders(){
582
-		return $this->responseHeaders;
583
-	}
563
+    /**
564
+     * set the SOAP headers
565
+     *
566
+     * @param	mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers
567
+     * @access   public
568
+     */
569
+    function setHeaders($headers){
570
+        $this->debug("setHeaders headers=");
571
+        $this->appendDebug($this->varDump($headers));
572
+        $this->requestHeaders = $headers;
573
+    }
584 574
 
585
-	/**
586
-	* get the SOAP response Header (parsed)
587
-	*
588
-	* @return	mixed
589
-	* @access   public
590
-	*/
591
-	function getHeader(){
592
-		return $this->responseHeader;
593
-	}
575
+    /**
576
+     * get the SOAP response headers (namespace resolution incomplete)
577
+     *
578
+     * @return	string
579
+     * @access   public
580
+     */
581
+    function getHeaders(){
582
+        return $this->responseHeaders;
583
+    }
594 584
 
595
-	/**
596
-	* set proxy info here
597
-	*
598
-	* @param    string $proxyhost
599
-	* @param    string $proxyport
600
-	* @param	string $proxyusername
601
-	* @param	string $proxypassword
602
-	* @access   public
603
-	*/
604
-	function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '') {
605
-		$this->proxyhost = $proxyhost;
606
-		$this->proxyport = $proxyport;
607
-		$this->proxyusername = $proxyusername;
608
-		$this->proxypassword = $proxypassword;
609
-	}
585
+    /**
586
+     * get the SOAP response Header (parsed)
587
+     *
588
+     * @return	mixed
589
+     * @access   public
590
+     */
591
+    function getHeader(){
592
+        return $this->responseHeader;
593
+    }
610 594
 
611
-	/**
612
-	* if authenticating, set user credentials here
613
-	*
614
-	* @param    string $username
615
-	* @param    string $password
616
-	* @param	string $authtype (basic|digest|certificate|ntlm)
617
-	* @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
618
-	* @access   public
619
-	*/
620
-	function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
621
-		$this->debug("setCredentials username=$username authtype=$authtype certRequest=");
622
-		$this->appendDebug($this->varDump($certRequest));
623
-		$this->username = $username;
624
-		$this->password = $password;
625
-		$this->authtype = $authtype;
626
-		$this->certRequest = $certRequest;
627
-	}
595
+    /**
596
+     * set proxy info here
597
+     *
598
+     * @param    string $proxyhost
599
+     * @param    string $proxyport
600
+     * @param	string $proxyusername
601
+     * @param	string $proxypassword
602
+     * @access   public
603
+     */
604
+    function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '') {
605
+        $this->proxyhost = $proxyhost;
606
+        $this->proxyport = $proxyport;
607
+        $this->proxyusername = $proxyusername;
608
+        $this->proxypassword = $proxypassword;
609
+    }
628 610
 
629
-	/**
630
-	* use HTTP encoding
631
-	*
632
-	* @param    string $enc HTTP encoding
633
-	* @access   public
634
-	*/
635
-	function setHTTPEncoding($enc='gzip, deflate'){
636
-		$this->debug("setHTTPEncoding(\"$enc\")");
637
-		$this->http_encoding = $enc;
638
-	}
611
+    /**
612
+     * if authenticating, set user credentials here
613
+     *
614
+     * @param    string $username
615
+     * @param    string $password
616
+     * @param	string $authtype (basic|digest|certificate|ntlm)
617
+     * @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
618
+     * @access   public
619
+     */
620
+    function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
621
+        $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
622
+        $this->appendDebug($this->varDump($certRequest));
623
+        $this->username = $username;
624
+        $this->password = $password;
625
+        $this->authtype = $authtype;
626
+        $this->certRequest = $certRequest;
627
+    }
639 628
 
640
-	/**
641
-	* Set whether to try to use cURL connections if possible
642
-	*
643
-	* @param	boolean $use Whether to try to use cURL
644
-	* @access   public
645
-	*/
646
-	function setUseCURL($use) {
647
-		$this->debug("setUseCURL($use)");
648
-		$this->use_curl = $use;
649
-	}
629
+    /**
630
+     * use HTTP encoding
631
+     *
632
+     * @param    string $enc HTTP encoding
633
+     * @access   public
634
+     */
635
+    function setHTTPEncoding($enc='gzip, deflate'){
636
+        $this->debug("setHTTPEncoding(\"$enc\")");
637
+        $this->http_encoding = $enc;
638
+    }
650 639
 
651
-	/**
652
-	* use HTTP persistent connections if possible
653
-	*
654
-	* @access   public
655
-	*/
656
-	function useHTTPPersistentConnection(){
657
-		$this->debug("useHTTPPersistentConnection");
658
-		$this->persistentConnection = true;
659
-	}
640
+    /**
641
+     * Set whether to try to use cURL connections if possible
642
+     *
643
+     * @param	boolean $use Whether to try to use cURL
644
+     * @access   public
645
+     */
646
+    function setUseCURL($use) {
647
+        $this->debug("setUseCURL($use)");
648
+        $this->use_curl = $use;
649
+    }
660 650
 
661
-	/**
662
-	* gets the default RPC parameter setting.
663
-	* If true, default is that call params are like RPC even for document style.
664
-	* Each call() can override this value.
665
-	*
666
-	* This is no longer used.
667
-	*
668
-	* @return boolean
669
-	* @access public
670
-	* @deprecated
671
-	*/
672
-	function getDefaultRpcParams() {
673
-		return $this->defaultRpcParams;
674
-	}
651
+    /**
652
+     * use HTTP persistent connections if possible
653
+     *
654
+     * @access   public
655
+     */
656
+    function useHTTPPersistentConnection(){
657
+        $this->debug("useHTTPPersistentConnection");
658
+        $this->persistentConnection = true;
659
+    }
675 660
 
676
-	/**
677
-	* sets the default RPC parameter setting.
678
-	* If true, default is that call params are like RPC even for document style
679
-	* Each call() can override this value.
680
-	*
681
-	* This is no longer used.
682
-	*
683
-	* @param    boolean $rpcParams
684
-	* @access public
685
-	* @deprecated
686
-	*/
687
-	function setDefaultRpcParams($rpcParams) {
688
-		$this->defaultRpcParams = $rpcParams;
689
-	}
661
+    /**
662
+     * gets the default RPC parameter setting.
663
+     * If true, default is that call params are like RPC even for document style.
664
+     * Each call() can override this value.
665
+     *
666
+     * This is no longer used.
667
+     *
668
+     * @return boolean
669
+     * @access public
670
+     * @deprecated
671
+     */
672
+    function getDefaultRpcParams() {
673
+        return $this->defaultRpcParams;
674
+    }
690 675
 
691
-	/**
692
-	* dynamically creates an instance of a proxy class,
693
-	* allowing user to directly call methods from wsdl
694
-	*
695
-	* @return   object soap_proxy object
696
-	* @access   public
697
-	*/
698
-	function getProxy() {
699
-		$r = rand();
700
-		$evalStr = $this->_getProxyClassCode($r);
701
-		//$this->debug("proxy class: $evalStr");
702
-		if ($this->getError()) {
703
-			$this->debug("Error from _getProxyClassCode, so return NULL");
704
-			return null;
705
-		}
706
-		// eval the class
707
-		eval($evalStr);
708
-		// instantiate proxy object
709
-		eval("\$proxy = new nusoap_proxy_$r('');");
710
-		// transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice
711
-		$proxy->endpointType = 'wsdl';
712
-		$proxy->wsdlFile = $this->wsdlFile;
713
-		$proxy->wsdl = $this->wsdl;
714
-		$proxy->operations = $this->operations;
715
-		$proxy->defaultRpcParams = $this->defaultRpcParams;
716
-		// transfer other state
717
-		$proxy->soap_defencoding = $this->soap_defencoding;
718
-		$proxy->username = $this->username;
719
-		$proxy->password = $this->password;
720
-		$proxy->authtype = $this->authtype;
721
-		$proxy->certRequest = $this->certRequest;
722
-		$proxy->requestHeaders = $this->requestHeaders;
723
-		$proxy->endpoint = $this->endpoint;
724
-		$proxy->forceEndpoint = $this->forceEndpoint;
725
-		$proxy->proxyhost = $this->proxyhost;
726
-		$proxy->proxyport = $this->proxyport;
727
-		$proxy->proxyusername = $this->proxyusername;
728
-		$proxy->proxypassword = $this->proxypassword;
729
-		$proxy->http_encoding = $this->http_encoding;
730
-		$proxy->timeout = $this->timeout;
731
-		$proxy->response_timeout = $this->response_timeout;
732
-		$proxy->persistentConnection = &$this->persistentConnection;
733
-		$proxy->decode_utf8 = $this->decode_utf8;
734
-		$proxy->curl_options = $this->curl_options;
735
-		$proxy->bindingType = $this->bindingType;
736
-		$proxy->use_curl = $this->use_curl;
737
-		return $proxy;
738
-	}
676
+    /**
677
+     * sets the default RPC parameter setting.
678
+     * If true, default is that call params are like RPC even for document style
679
+     * Each call() can override this value.
680
+     *
681
+     * This is no longer used.
682
+     *
683
+     * @param    boolean $rpcParams
684
+     * @access public
685
+     * @deprecated
686
+     */
687
+    function setDefaultRpcParams($rpcParams) {
688
+        $this->defaultRpcParams = $rpcParams;
689
+    }
690
+
691
+    /**
692
+     * dynamically creates an instance of a proxy class,
693
+     * allowing user to directly call methods from wsdl
694
+     *
695
+     * @return   object soap_proxy object
696
+     * @access   public
697
+     */
698
+    function getProxy() {
699
+        $r = rand();
700
+        $evalStr = $this->_getProxyClassCode($r);
701
+        //$this->debug("proxy class: $evalStr");
702
+        if ($this->getError()) {
703
+            $this->debug("Error from _getProxyClassCode, so return NULL");
704
+            return null;
705
+        }
706
+        // eval the class
707
+        eval($evalStr);
708
+        // instantiate proxy object
709
+        eval("\$proxy = new nusoap_proxy_$r('');");
710
+        // transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice
711
+        $proxy->endpointType = 'wsdl';
712
+        $proxy->wsdlFile = $this->wsdlFile;
713
+        $proxy->wsdl = $this->wsdl;
714
+        $proxy->operations = $this->operations;
715
+        $proxy->defaultRpcParams = $this->defaultRpcParams;
716
+        // transfer other state
717
+        $proxy->soap_defencoding = $this->soap_defencoding;
718
+        $proxy->username = $this->username;
719
+        $proxy->password = $this->password;
720
+        $proxy->authtype = $this->authtype;
721
+        $proxy->certRequest = $this->certRequest;
722
+        $proxy->requestHeaders = $this->requestHeaders;
723
+        $proxy->endpoint = $this->endpoint;
724
+        $proxy->forceEndpoint = $this->forceEndpoint;
725
+        $proxy->proxyhost = $this->proxyhost;
726
+        $proxy->proxyport = $this->proxyport;
727
+        $proxy->proxyusername = $this->proxyusername;
728
+        $proxy->proxypassword = $this->proxypassword;
729
+        $proxy->http_encoding = $this->http_encoding;
730
+        $proxy->timeout = $this->timeout;
731
+        $proxy->response_timeout = $this->response_timeout;
732
+        $proxy->persistentConnection = &$this->persistentConnection;
733
+        $proxy->decode_utf8 = $this->decode_utf8;
734
+        $proxy->curl_options = $this->curl_options;
735
+        $proxy->bindingType = $this->bindingType;
736
+        $proxy->use_curl = $this->use_curl;
737
+        return $proxy;
738
+    }
739 739
 
740
-	/**
741
-	* dynamically creates proxy class code
742
-	*
743
-	* @return   string PHP/NuSOAP code for the proxy class
744
-	* @access   private
745
-	*/
746
-	function _getProxyClassCode($r) {
747
-		$this->debug("in getProxy endpointType=$this->endpointType");
748
-		$this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
749
-		if ($this->endpointType != 'wsdl') {
750
-			$evalStr = 'A proxy can only be created for a WSDL client';
751
-			$this->setError($evalStr);
752
-			$evalStr = "echo \"$evalStr\";";
753
-			return $evalStr;
754
-		}
755
-		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
756
-			$this->loadWSDL();
757
-			if ($this->getError()) {
758
-				return "echo \"" . $this->getError() . "\";";
759
-			}
760
-		}
761
-		$evalStr = '';
762
-		foreach ($this->operations as $operation => $opData) {
763
-			if ($operation != '') {
764
-				// create param string and param comment string
765
-				if (sizeof($opData['input']['parts']) > 0) {
766
-					$paramStr = '';
767
-					$paramArrayStr = '';
768
-					$paramCommentStr = '';
769
-					foreach ($opData['input']['parts'] as $name => $type) {
770
-						$paramStr .= "\$$name, ";
771
-						$paramArrayStr .= "'$name' => \$$name, ";
772
-						$paramCommentStr .= "$type \$$name, ";
773
-					}
774
-					$paramStr = substr($paramStr, 0, strlen($paramStr)-2);
775
-					$paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2);
776
-					$paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2);
777
-				} else {
778
-					$paramStr = '';
779
-					$paramArrayStr = '';
780
-					$paramCommentStr = 'void';
781
-				}
782
-				$opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace'];
783
-				$evalStr .= "// $paramCommentStr
740
+    /**
741
+     * dynamically creates proxy class code
742
+     *
743
+     * @return   string PHP/NuSOAP code for the proxy class
744
+     * @access   private
745
+     */
746
+    function _getProxyClassCode($r) {
747
+        $this->debug("in getProxy endpointType=$this->endpointType");
748
+        $this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
749
+        if ($this->endpointType != 'wsdl') {
750
+            $evalStr = 'A proxy can only be created for a WSDL client';
751
+            $this->setError($evalStr);
752
+            $evalStr = "echo \"$evalStr\";";
753
+            return $evalStr;
754
+        }
755
+        if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
756
+            $this->loadWSDL();
757
+            if ($this->getError()) {
758
+                return "echo \"" . $this->getError() . "\";";
759
+            }
760
+        }
761
+        $evalStr = '';
762
+        foreach ($this->operations as $operation => $opData) {
763
+            if ($operation != '') {
764
+                // create param string and param comment string
765
+                if (sizeof($opData['input']['parts']) > 0) {
766
+                    $paramStr = '';
767
+                    $paramArrayStr = '';
768
+                    $paramCommentStr = '';
769
+                    foreach ($opData['input']['parts'] as $name => $type) {
770
+                        $paramStr .= "\$$name, ";
771
+                        $paramArrayStr .= "'$name' => \$$name, ";
772
+                        $paramCommentStr .= "$type \$$name, ";
773
+                    }
774
+                    $paramStr = substr($paramStr, 0, strlen($paramStr)-2);
775
+                    $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2);
776
+                    $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2);
777
+                } else {
778
+                    $paramStr = '';
779
+                    $paramArrayStr = '';
780
+                    $paramCommentStr = 'void';
781
+                }
782
+                $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace'];
783
+                $evalStr .= "// $paramCommentStr
784 784
 	function " . str_replace('.', '__', $operation) . "($paramStr) {
785 785
 		\$params = array($paramArrayStr);
786 786
 		return \$this->call('$operation', \$params, '".$opData['namespace']."', '".(isset($opData['soapAction']) ? $opData['soapAction'] : '')."');
787 787
 	}
788 788
 	";
789
-				unset($paramStr);
790
-				unset($paramCommentStr);
791
-			}
792
-		}
793
-		$evalStr = 'class nusoap_proxy_'.$r.' extends nusoap_client {
789
+                unset($paramStr);
790
+                unset($paramCommentStr);
791
+            }
792
+        }
793
+        $evalStr = 'class nusoap_proxy_'.$r.' extends nusoap_client {
794 794
 	'.$evalStr.'
795 795
 }';
796
-		return $evalStr;
797
-	}
796
+        return $evalStr;
797
+    }
798 798
 
799
-	/**
800
-	* dynamically creates proxy class code
801
-	*
802
-	* @return   string PHP/NuSOAP code for the proxy class
803
-	* @access   public
804
-	*/
805
-	function getProxyClassCode() {
806
-		$r = rand();
807
-		return $this->_getProxyClassCode($r);
808
-	}
799
+    /**
800
+     * dynamically creates proxy class code
801
+     *
802
+     * @return   string PHP/NuSOAP code for the proxy class
803
+     * @access   public
804
+     */
805
+    function getProxyClassCode() {
806
+        $r = rand();
807
+        return $this->_getProxyClassCode($r);
808
+    }
809 809
 
810
-	/**
811
-	* gets the HTTP body for the current request.
812
-	*
813
-	* @param string $soapmsg The SOAP payload
814
-	* @return string The HTTP body, which includes the SOAP payload
815
-	* @access private
816
-	*/
817
-	function getHTTPBody($soapmsg) {
818
-		return $soapmsg;
819
-	}
810
+    /**
811
+     * gets the HTTP body for the current request.
812
+     *
813
+     * @param string $soapmsg The SOAP payload
814
+     * @return string The HTTP body, which includes the SOAP payload
815
+     * @access private
816
+     */
817
+    function getHTTPBody($soapmsg) {
818
+        return $soapmsg;
819
+    }
820 820
 
821
-	/**
822
-	* gets the HTTP content type for the current request.
823
-	*
824
-	* Note: getHTTPBody must be called before this.
825
-	*
826
-	* @return string the HTTP content type for the current request.
827
-	* @access private
828
-	*/
829
-	function getHTTPContentType() {
830
-		return 'text/xml';
831
-	}
821
+    /**
822
+     * gets the HTTP content type for the current request.
823
+     *
824
+     * Note: getHTTPBody must be called before this.
825
+     *
826
+     * @return string the HTTP content type for the current request.
827
+     * @access private
828
+     */
829
+    function getHTTPContentType() {
830
+        return 'text/xml';
831
+    }
832 832
 
833
-	/**
834
-	* gets the HTTP content type charset for the current request.
835
-	* returns false for non-text content types.
836
-	*
837
-	* Note: getHTTPBody must be called before this.
838
-	*
839
-	* @return string the HTTP content type charset for the current request.
840
-	* @access private
841
-	*/
842
-	function getHTTPContentTypeCharset() {
843
-		return $this->soap_defencoding;
844
-	}
833
+    /**
834
+     * gets the HTTP content type charset for the current request.
835
+     * returns false for non-text content types.
836
+     *
837
+     * Note: getHTTPBody must be called before this.
838
+     *
839
+     * @return string the HTTP content type charset for the current request.
840
+     * @access private
841
+     */
842
+    function getHTTPContentTypeCharset() {
843
+        return $this->soap_defencoding;
844
+    }
845 845
 
846
-	/*
846
+    /*
847 847
 	* whether or not parser should decode utf8 element content
848 848
     *
849 849
     * @return   always returns true
850 850
     * @access   public
851 851
     */
852 852
     function decodeUTF8($bool){
853
-		$this->decode_utf8 = $bool;
854
-		return true;
853
+        $this->decode_utf8 = $bool;
854
+        return true;
855 855
     }
856 856
 
857
-	/**
858
-	 * adds a new Cookie into $this->cookies array
859
-	 *
860
-	 * @param	string $name Cookie Name
861
-	 * @param	string $value Cookie Value
862
-	 * @return	boolean if cookie-set was successful returns true, else false
863
-	 * @access	public
864
-	 */
865
-	function setCookie($name, $value) {
866
-		if (strlen($name) == 0) {
867
-			return false;
868
-		}
869
-		$this->cookies[] = array('name' => $name, 'value' => $value);
870
-		return true;
871
-	}
857
+    /**
858
+     * adds a new Cookie into $this->cookies array
859
+     *
860
+     * @param	string $name Cookie Name
861
+     * @param	string $value Cookie Value
862
+     * @return	boolean if cookie-set was successful returns true, else false
863
+     * @access	public
864
+     */
865
+    function setCookie($name, $value) {
866
+        if (strlen($name) == 0) {
867
+            return false;
868
+        }
869
+        $this->cookies[] = array('name' => $name, 'value' => $value);
870
+        return true;
871
+    }
872 872
 
873
-	/**
874
-	 * gets all Cookies
875
-	 *
876
-	 * @return   array with all internal cookies
877
-	 * @access   public
878
-	 */
879
-	function getCookies() {
880
-		return $this->cookies;
881
-	}
873
+    /**
874
+     * gets all Cookies
875
+     *
876
+     * @return   array with all internal cookies
877
+     * @access   public
878
+     */
879
+    function getCookies() {
880
+        return $this->cookies;
881
+    }
882 882
 
883
-	/**
884
-	 * checks all Cookies and delete those which are expired
885
-	 *
886
-	 * @return   boolean always return true
887
-	 * @access   private
888
-	 */
889
-	function checkCookies() {
890
-		if (sizeof($this->cookies) == 0) {
891
-			return true;
892
-		}
893
-		$this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
894
-		$curr_cookies = $this->cookies;
895
-		$this->cookies = array();
896
-		foreach ($curr_cookies as $cookie) {
897
-			if (! is_array($cookie)) {
898
-				$this->debug('Remove cookie that is not an array');
899
-				continue;
900
-			}
901
-			if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
902
-				if (strtotime($cookie['expires']) > time()) {
903
-					$this->cookies[] = $cookie;
904
-				} else {
905
-					$this->debug('Remove expired cookie ' . $cookie['name']);
906
-				}
907
-			} else {
908
-				$this->cookies[] = $cookie;
909
-			}
910
-		}
911
-		$this->debug('checkCookie: '.sizeof($this->cookies).' cookies left in array');
912
-		return true;
913
-	}
883
+    /**
884
+     * checks all Cookies and delete those which are expired
885
+     *
886
+     * @return   boolean always return true
887
+     * @access   private
888
+     */
889
+    function checkCookies() {
890
+        if (sizeof($this->cookies) == 0) {
891
+            return true;
892
+        }
893
+        $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
894
+        $curr_cookies = $this->cookies;
895
+        $this->cookies = array();
896
+        foreach ($curr_cookies as $cookie) {
897
+            if (! is_array($cookie)) {
898
+                $this->debug('Remove cookie that is not an array');
899
+                continue;
900
+            }
901
+            if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
902
+                if (strtotime($cookie['expires']) > time()) {
903
+                    $this->cookies[] = $cookie;
904
+                } else {
905
+                    $this->debug('Remove expired cookie ' . $cookie['name']);
906
+                }
907
+            } else {
908
+                $this->cookies[] = $cookie;
909
+            }
910
+        }
911
+        $this->debug('checkCookie: '.sizeof($this->cookies).' cookies left in array');
912
+        return true;
913
+    }
914 914
 
915
-	/**
916
-	 * updates the current cookies with a new set
917
-	 *
918
-	 * @param	array $cookies new cookies with which to update current ones
919
-	 * @return	boolean always return true
920
-	 * @access	private
921
-	 */
922
-	function UpdateCookies($cookies) {
923
-		if (sizeof($this->cookies) == 0) {
924
-			// no existing cookies: take whatever is new
925
-			if (sizeof($cookies) > 0) {
926
-				$this->debug('Setting new cookie(s)');
927
-				$this->cookies = $cookies;
928
-			}
929
-			return true;
930
-		}
931
-		if (sizeof($cookies) == 0) {
932
-			// no new cookies: keep what we've got
933
-			return true;
934
-		}
935
-		// merge
936
-		foreach ($cookies as $newCookie) {
937
-			if (!is_array($newCookie)) {
938
-				continue;
939
-			}
940
-			if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) {
941
-				continue;
942
-			}
943
-			$newName = $newCookie['name'];
944
-
945
-			$found = false;
946
-			for ($i = 0; $i < count($this->cookies); $i++) {
947
-				$cookie = $this->cookies[$i];
948
-				if (!is_array($cookie)) {
949
-					continue;
950
-				}
951
-				if (!isset($cookie['name'])) {
952
-					continue;
953
-				}
954
-				if ($newName != $cookie['name']) {
955
-					continue;
956
-				}
957
-				$newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN';
958
-				$domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN';
959
-				if ($newDomain != $domain) {
960
-					continue;
961
-				}
962
-				$newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH';
963
-				$path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH';
964
-				if ($newPath != $path) {
965
-					continue;
966
-				}
967
-				$this->cookies[$i] = $newCookie;
968
-				$found = true;
969
-				$this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
970
-				break;
971
-			}
972
-			if (! $found) {
973
-				$this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
974
-				$this->cookies[] = $newCookie;
975
-			}
976
-		}
977
-		return true;
978
-	}
915
+    /**
916
+     * updates the current cookies with a new set
917
+     *
918
+     * @param	array $cookies new cookies with which to update current ones
919
+     * @return	boolean always return true
920
+     * @access	private
921
+     */
922
+    function UpdateCookies($cookies) {
923
+        if (sizeof($this->cookies) == 0) {
924
+            // no existing cookies: take whatever is new
925
+            if (sizeof($cookies) > 0) {
926
+                $this->debug('Setting new cookie(s)');
927
+                $this->cookies = $cookies;
928
+            }
929
+            return true;
930
+        }
931
+        if (sizeof($cookies) == 0) {
932
+            // no new cookies: keep what we've got
933
+            return true;
934
+        }
935
+        // merge
936
+        foreach ($cookies as $newCookie) {
937
+            if (!is_array($newCookie)) {
938
+                continue;
939
+            }
940
+            if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) {
941
+                continue;
942
+            }
943
+            $newName = $newCookie['name'];
944
+
945
+            $found = false;
946
+            for ($i = 0; $i < count($this->cookies); $i++) {
947
+                $cookie = $this->cookies[$i];
948
+                if (!is_array($cookie)) {
949
+                    continue;
950
+                }
951
+                if (!isset($cookie['name'])) {
952
+                    continue;
953
+                }
954
+                if ($newName != $cookie['name']) {
955
+                    continue;
956
+                }
957
+                $newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN';
958
+                $domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN';
959
+                if ($newDomain != $domain) {
960
+                    continue;
961
+                }
962
+                $newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH';
963
+                $path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH';
964
+                if ($newPath != $path) {
965
+                    continue;
966
+                }
967
+                $this->cookies[$i] = $newCookie;
968
+                $found = true;
969
+                $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
970
+                break;
971
+            }
972
+            if (! $found) {
973
+                $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
974
+                $this->cookies[] = $newCookie;
975
+            }
976
+        }
977
+        return true;
978
+    }
979 979
 }
980 980
 
981 981
 if (!extension_loaded('soap')) {
982
-	/**
983
-	 *	For backwards compatiblity, define soapclient unless the PHP SOAP extension is loaded.
984
-	 */
985
-	class soapclient extends nusoap_client {
986
-	}
982
+    /**
983
+     *	For backwards compatiblity, define soapclient unless the PHP SOAP extension is loaded.
984
+     */
985
+    class soapclient extends nusoap_client {
986
+    }
987 987
 }
988 988
 ?>
Please login to merge, or discard this patch.
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -22,37 +22,37 @@  discard block
 block discarded – undo
22 22
 */
23 23
 class nusoap_client extends nusoap_base
24 24
 {
25
-	var $username = '';				// Username for HTTP authentication
26
-	var $password = '';				// Password for HTTP authentication
27
-	var $authtype = '';				// Type of HTTP authentication
28
-	var $certRequest = array();		// Certificate for HTTP SSL authentication
29
-	var $requestHeaders = false;	// SOAP headers in request (text)
30
-	var $responseHeaders = '';		// SOAP headers from response (incomplete namespace resolution) (text)
31
-	var $responseHeader = NULL;		// SOAP Header from response (parsed)
32
-	var $document = '';				// SOAP body response portion (incomplete namespace resolution) (text)
25
+	var $username = ''; // Username for HTTP authentication
26
+	var $password = ''; // Password for HTTP authentication
27
+	var $authtype = ''; // Type of HTTP authentication
28
+	var $certRequest = array(); // Certificate for HTTP SSL authentication
29
+	var $requestHeaders = false; // SOAP headers in request (text)
30
+	var $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text)
31
+	var $responseHeader = NULL; // SOAP Header from response (parsed)
32
+	var $document = ''; // SOAP body response portion (incomplete namespace resolution) (text)
33 33
 	var $endpoint;
34
-	var $forceEndpoint = '';		// overrides WSDL endpoint
34
+	var $forceEndpoint = ''; // overrides WSDL endpoint
35 35
     var $proxyhost = '';
36 36
     var $proxyport = '';
37 37
 	var $proxyusername = '';
38 38
 	var $proxypassword = '';
39
-	var $portName = '';				// port name to use in WSDL
40
-    var $xml_encoding = '';			// character set encoding of incoming (response) messages
39
+	var $portName = ''; // port name to use in WSDL
40
+    var $xml_encoding = ''; // character set encoding of incoming (response) messages
41 41
 	var $http_encoding = false;
42
-	var $timeout = 0;				// HTTP connection timeout
43
-	var $response_timeout = 30;		// HTTP response timeout
44
-	var $endpointType = '';			// soap|wsdl, empty for WSDL initialization error
42
+	var $timeout = 0; // HTTP connection timeout
43
+	var $response_timeout = 30; // HTTP response timeout
44
+	var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error
45 45
 	var $persistentConnection = false;
46
-	var $defaultRpcParams = false;	// This is no longer used
47
-	var $request = '';				// HTTP request
48
-	var $response = '';				// HTTP response
49
-	var $responseData = '';			// SOAP payload of response
50
-	var $cookies = array();			// Cookies from response or for request
51
-    var $decode_utf8 = true;		// toggles whether the parser decodes element content w/ utf8_decode()
52
-	var $operations = array();		// WSDL operations, empty for WSDL initialization error
53
-	var $curl_options = array();	// User-specified cURL options
54
-	var $bindingType = '';			// WSDL operation binding type
55
-	var $use_curl = false;			// whether to always try to use cURL
46
+	var $defaultRpcParams = false; // This is no longer used
47
+	var $request = ''; // HTTP request
48
+	var $response = ''; // HTTP response
49
+	var $responseData = ''; // SOAP payload of response
50
+	var $cookies = array(); // Cookies from response or for request
51
+    var $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode()
52
+	var $operations = array(); // WSDL operations, empty for WSDL initialization error
53
+	var $curl_options = array(); // User-specified cURL options
54
+	var $bindingType = ''; // WSDL operation binding type
55
+	var $use_curl = false; // whether to always try to use cURL
56 56
 
57 57
 	/*
58 58
 	 * fault related variables
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	* @param	string $portName optional portName in WSDL document
93 93
 	* @access   public
94 94
 	*/
95
-	function __construct($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
95
+	function __construct($endpoint, $wsdl = false, $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = '') {
96 96
 		parent::__construct();
97 97
 		$this->endpoint = $endpoint;
98 98
 		$this->proxyhost = $proxyhost;
@@ -104,20 +104,20 @@  discard block
 block discarded – undo
104 104
 		$this->portName = $portName;
105 105
 
106 106
 		$this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
107
-		$this->appendDebug('endpoint=' . $this->varDump($endpoint));
107
+		$this->appendDebug('endpoint='.$this->varDump($endpoint));
108 108
 
109 109
 		// make values
110
-		if($wsdl){
110
+		if ($wsdl) {
111 111
 			if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) {
112 112
 				$this->wsdl = $endpoint;
113 113
 				$this->endpoint = $this->wsdl->wsdl;
114 114
 				$this->wsdlFile = $this->endpoint;
115
-				$this->debug('existing wsdl instance created from ' . $this->endpoint);
115
+				$this->debug('existing wsdl instance created from '.$this->endpoint);
116 116
 				$this->checkWSDL();
117 117
 			} else {
118 118
 				$this->wsdlFile = $this->endpoint;
119 119
 				$this->wsdl = null;
120
-				$this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
120
+				$this->debug('will use lazy evaluation of wsdl from '.$this->endpoint);
121 121
 			}
122 122
 			$this->endpointType = 'wsdl';
123 123
 		} else {
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	* @return	mixed	response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors
152 152
 	* @access   public
153 153
 	*/
154
-	function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
154
+	function call($operation, $params = array(), $namespace = 'http://tempuri.org', $soapAction = '', $headers = false, $rpcParams = null, $style = 'rpc', $use = 'encoded') {
155 155
 		$this->operation = $operation;
156 156
 		$this->fault = false;
157 157
 		$this->setError('');
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 		$this->opData = array();
164 164
 
165 165
 		$this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
166
-		$this->appendDebug('params=' . $this->varDump($params));
167
-		$this->appendDebug('headers=' . $this->varDump($headers));
166
+		$this->appendDebug('params='.$this->varDump($params));
167
+		$this->appendDebug('headers='.$this->varDump($headers));
168 168
 		if ($headers) {
169 169
 			$this->requestHeaders = $headers;
170 170
 		}
@@ -174,25 +174,25 @@  discard block
 block discarded – undo
174 174
 				return false;
175 175
 		}
176 176
 		// serialize parameters
177
-		if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
177
+		if ($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)) {
178 178
 			// use WSDL for operation
179 179
 			$this->opData = $opData;
180 180
 			$this->debug("found operation");
181
-			$this->appendDebug('opData=' . $this->varDump($opData));
181
+			$this->appendDebug('opData='.$this->varDump($opData));
182 182
 			if (isset($opData['soapAction'])) {
183 183
 				$soapAction = $opData['soapAction'];
184 184
 			}
185
-			if (! $this->forceEndpoint) {
185
+			if (!$this->forceEndpoint) {
186 186
 				$this->endpoint = $opData['endpoint'];
187 187
 			} else {
188 188
 				$this->endpoint = $this->forceEndpoint;
189 189
 			}
190
-			$namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] :	$namespace;
190
+			$namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace;
191 191
 			$style = $opData['style'];
192 192
 			$use = $opData['input']['use'];
193 193
 			// add ns to ns array
194
-			if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
195
-				$nsPrefix = 'ns' . rand(1000, 9999);
194
+			if ($namespace != '' && !isset($this->wsdl->namespaces[$namespace])) {
195
+				$nsPrefix = 'ns'.rand(1000, 9999);
196 196
 				$this->wsdl->namespaces[$nsPrefix] = $namespace;
197 197
 			}
198 198
             $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace);
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 				$payload = $params;
203 203
 			} elseif (is_array($params)) {
204 204
 				$this->debug("serializing param array for WSDL operation $operation");
205
-				$payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType);
205
+				$payload = $this->wsdl->serializeRPCParameters($operation, 'input', $params, $this->bindingType);
206 206
 			} else {
207 207
 				$this->debug('params must be array or string');
208 208
 				$this->setError('params must be array or string');
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 				$this->setError('wsdl error: '.$errstr);
222 222
 				return false;
223 223
 			}
224
-		} elseif($this->endpointType == 'wsdl') {
224
+		} elseif ($this->endpointType == 'wsdl') {
225 225
 			// operation not in WSDL
226 226
 			$this->appendDebug($this->wsdl->getDebug());
227 227
 			$this->wsdl->clearDebug();
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		} else {
232 232
 			// no WSDL
233 233
 			//$this->namespaces['ns1'] = $namespace;
234
-			$nsPrefix = 'ns' . rand(1000, 9999);
234
+			$nsPrefix = 'ns'.rand(1000, 9999);
235 235
 			// serialize
236 236
 			$payload = '';
237 237
 			if (is_string($params)) {
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 				$payload = $params;
240 240
 			} elseif (is_array($params)) {
241 241
 				$this->debug("serializing param array for operation $operation");
242
-				foreach($params as $k => $v){
243
-					$payload .= $this->serialize_val($v,$k,false,false,false,false,$use);
242
+				foreach ($params as $k => $v) {
243
+					$payload .= $this->serialize_val($v, $k, false, false, false, false, $use);
244 244
 				}
245 245
 			} else {
246 246
 				$this->debug('params must be array or string');
@@ -260,45 +260,45 @@  discard block
 block discarded – undo
260 260
 				$this->debug("wrapping RPC request with literal method element");
261 261
 				if ($namespace) {
262 262
 					// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
263
-					$payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
264
-								$payload .
263
+					$payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">".
264
+								$payload.
265 265
 								"</$nsPrefix:$operation>";
266 266
 				} else {
267
-					$payload = "<$operation>" . $payload . "</$operation>";
267
+					$payload = "<$operation>".$payload."</$operation>";
268 268
 				}
269 269
 			} else {
270 270
 				$this->debug("wrapping RPC request with encoded method element");
271 271
 				if ($namespace) {
272
-					$payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
273
-								$payload .
272
+					$payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">".
273
+								$payload.
274 274
 								"</$nsPrefix:$operation>";
275 275
 				} else {
276
-					$payload = "<$operation>" .
277
-								$payload .
276
+					$payload = "<$operation>".
277
+								$payload.
278 278
 								"</$operation>";
279 279
 				}
280 280
 			}
281 281
 		}
282 282
 		// serialize envelope
283
-		$soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle);
283
+		$soapmsg = $this->serializeEnvelope($payload, $this->requestHeaders, $usedNamespaces, $style, $use, $encodingStyle);
284 284
 		$this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
285
-		$this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
285
+		$this->debug('SOAP message length='.strlen($soapmsg).' contents (max 1000 bytes)='.substr($soapmsg, 0, 1000));
286 286
 		// send
287
-		$return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout);
288
-		if($errstr = $this->getError()){
287
+		$return = $this->send($this->getHTTPBody($soapmsg), $soapAction, $this->timeout, $this->response_timeout);
288
+		if ($errstr = $this->getError()) {
289 289
 			$this->debug('Error: '.$errstr);
290 290
 			return false;
291 291
 		} else {
292 292
 			$this->return = $return;
293 293
 			$this->debug('sent message successfully and got a(n) '.gettype($return));
294
-           	$this->appendDebug('return=' . $this->varDump($return));
294
+           	$this->appendDebug('return='.$this->varDump($return));
295 295
 
296 296
 			// fault?
297
-			if(is_array($return) && isset($return['faultcode'])){
297
+			if (is_array($return) && isset($return['faultcode'])) {
298 298
 				$this->debug('got fault');
299 299
 				$this->setError($return['faultcode'].': '.$return['faultstring']);
300 300
 				$this->fault = true;
301
-				foreach($return as $k => $v){
301
+				foreach ($return as $k => $v) {
302 302
 					$this->$k = $v;
303 303
 					$this->debug("$k = $v<br>");
304 304
 				}
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
 				return $return;
310 310
 			} else {
311 311
 				// array of return values
312
-				if(is_array($return)){
312
+				if (is_array($return)) {
313 313
 					// multiple 'out' parameters, which we return wrapped up
314 314
 					// in the array
315
-					if(sizeof($return) > 1){
315
+					if (sizeof($return) > 1) {
316 316
 						return $return;
317 317
 					}
318 318
 					// single 'out' parameter (normally the return value)
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 */
370 370
 	function loadWSDL() {
371 371
 		$this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
372
-		$this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
372
+		$this->wsdl = new wsdl('', $this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword, $this->timeout, $this->response_timeout, $this->curl_options, $this->use_curl);
373 373
 		$this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest);
374 374
 		$this->wsdl->fetchWSDL($this->wsdlFile);
375 375
 		$this->checkWSDL();
@@ -382,13 +382,13 @@  discard block
 block discarded – undo
382 382
 	* @return	array array of data pertaining to the operation
383 383
 	* @access   public
384 384
 	*/
385
-	function getOperationData($operation){
385
+	function getOperationData($operation) {
386 386
 		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
387 387
 			$this->loadWSDL();
388 388
 			if ($this->getError())
389 389
 				return false;
390 390
 		}
391
-		if(isset($this->operations[$operation])){
391
+		if (isset($this->operations[$operation])) {
392 392
 			return $this->operations[$operation];
393 393
 		}
394 394
 		$this->debug("No data for operation: $operation");
@@ -408,15 +408,15 @@  discard block
 block discarded – undo
408 408
 	* @return	mixed native PHP types.
409 409
 	* @access   private
410 410
 	*/
411
-	function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
411
+	function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30) {
412 412
 		$this->checkCookies();
413 413
 		// detect transport
414
-		switch(true){
414
+		switch (true) {
415 415
 			// http(s)
416
-			case preg_match('/^http/',$this->endpoint):
416
+			case preg_match('/^http/', $this->endpoint):
417 417
 				$this->debug('transporting via HTTP');
418
-				if($this->persistentConnection == true && is_object($this->persistentConnection)){
419
-					$http =& $this->persistentConnection;
418
+				if ($this->persistentConnection == true && is_object($this->persistentConnection)) {
419
+					$http = & $this->persistentConnection;
420 420
 				} else {
421 421
 					$http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl);
422 422
 					if ($this->persistentConnection) {
@@ -425,27 +425,27 @@  discard block
 block discarded – undo
425 425
 				}
426 426
 				$http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset());
427 427
 				$http->setSOAPAction($soapaction);
428
-				if($this->proxyhost && $this->proxyport){
429
-					$http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
428
+				if ($this->proxyhost && $this->proxyport) {
429
+					$http->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword);
430 430
 				}
431
-                if($this->authtype != '') {
431
+                if ($this->authtype != '') {
432 432
 					$http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
433 433
 				}
434
-				if($this->http_encoding != ''){
434
+				if ($this->http_encoding != '') {
435 435
 					$http->setEncoding($this->http_encoding);
436 436
 				}
437 437
 				$this->debug('sending message, length='.strlen($msg));
438
-				if(preg_match('/^http:/',$this->endpoint)){
438
+				if (preg_match('/^http:/', $this->endpoint)) {
439 439
 				//if(strpos($this->endpoint,'http:')){
440
-					$this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies);
441
-				} elseif(preg_match('/^https/',$this->endpoint)){
440
+					$this->responseData = $http->send($msg, $timeout, $response_timeout, $this->cookies);
441
+				} elseif (preg_match('/^https/', $this->endpoint)) {
442 442
 				//} elseif(strpos($this->endpoint,'https:')){
443 443
 					//if(phpversion() == '4.3.0-dev'){
444 444
 						//$response = $http->send($msg,$timeout,$response_timeout);
445 445
                    		//$this->request = $http->outgoing_payload;
446 446
 						//$this->response = $http->incoming_payload;
447 447
 					//} else
448
-					$this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies);
448
+					$this->responseData = $http->sendHTTPS($msg, $timeout, $response_timeout, $this->cookies);
449 449
 				} else {
450 450
 					$this->setError('no http/s in endpoint url');
451 451
 				}
@@ -462,13 +462,13 @@  discard block
 block discarded – undo
462 462
 					}
463 463
 				}
464 464
 
465
-				if($err = $http->getError()){
465
+				if ($err = $http->getError()) {
466 466
 					$this->setError('HTTP Error: '.$err);
467 467
 					return false;
468
-				} elseif($this->getError()){
468
+				} elseif ($this->getError()) {
469 469
 					return false;
470 470
 				} else {
471
-					$this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
471
+					$this->debug('got response, length='.strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
472 472
 					return $this->parseResponse($http->incoming_headers, $this->responseData);
473 473
 				}
474 474
 			break;
@@ -488,20 +488,20 @@  discard block
 block discarded – undo
488 488
 	* @access   private
489 489
 	*/
490 490
     function parseResponse($headers, $data) {
491
-		$this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
491
+		$this->debug('Entering parseResponse() for data of length '.strlen($data).' headers:');
492 492
 		$this->appendDebug($this->varDump($headers));
493 493
     	if (!isset($headers['content-type'])) {
494 494
 			$this->setError('Response not of type text/xml (no content-type header)');
495 495
 			return false;
496 496
     	}
497 497
 		if (!strstr($headers['content-type'], 'text/xml')) {
498
-			$this->setError('Response not of type text/xml: ' . $headers['content-type']);
498
+			$this->setError('Response not of type text/xml: '.$headers['content-type']);
499 499
 			return false;
500 500
 		}
501 501
 		if (strpos($headers['content-type'], '=')) {
502 502
 			$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
503
-			$this->debug('Got response encoding: ' . $enc);
504
-			if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
503
+			$this->debug('Got response encoding: '.$enc);
504
+			if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
505 505
 				$this->xml_encoding = strtoupper($enc);
506 506
 			} else {
507 507
 				$this->xml_encoding = 'US-ASCII';
@@ -510,13 +510,13 @@  discard block
 block discarded – undo
510 510
 			// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
511 511
 			$this->xml_encoding = 'ISO-8859-1';
512 512
 		}
513
-		$this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
514
-		$parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8);
513
+		$this->debug('Use encoding: '.$this->xml_encoding.' when creating nusoap_parser');
514
+		$parser = new nusoap_parser($data, $this->xml_encoding, $this->operation, $this->decode_utf8);
515 515
 		// add parser debug data to our debug
516 516
 		$this->appendDebug($parser->getDebug());
517 517
 		// if parse errors
518
-		if($errstr = $parser->getError()){
519
-			$this->setError( $errstr);
518
+		if ($errstr = $parser->getError()) {
519
+			$this->setError($errstr);
520 520
 			// destroy the parser object
521 521
 			unset($parser);
522 522
 			return false;
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	* @param	mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers
567 567
 	* @access   public
568 568
 	*/
569
-	function setHeaders($headers){
569
+	function setHeaders($headers) {
570 570
 		$this->debug("setHeaders headers=");
571 571
 		$this->appendDebug($this->varDump($headers));
572 572
 		$this->requestHeaders = $headers;
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 	* @return	string
579 579
 	* @access   public
580 580
 	*/
581
-	function getHeaders(){
581
+	function getHeaders() {
582 582
 		return $this->responseHeaders;
583 583
 	}
584 584
 
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 	* @return	mixed
589 589
 	* @access   public
590 590
 	*/
591
-	function getHeader(){
591
+	function getHeader() {
592 592
 		return $this->responseHeader;
593 593
 	}
594 594
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 	* @param    string $enc HTTP encoding
633 633
 	* @access   public
634 634
 	*/
635
-	function setHTTPEncoding($enc='gzip, deflate'){
635
+	function setHTTPEncoding($enc = 'gzip, deflate') {
636 636
 		$this->debug("setHTTPEncoding(\"$enc\")");
637 637
 		$this->http_encoding = $enc;
638 638
 	}
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 	*
654 654
 	* @access   public
655 655
 	*/
656
-	function useHTTPPersistentConnection(){
656
+	function useHTTPPersistentConnection() {
657 657
 		$this->debug("useHTTPPersistentConnection");
658 658
 		$this->persistentConnection = true;
659 659
 	}
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 	*/
746 746
 	function _getProxyClassCode($r) {
747 747
 		$this->debug("in getProxy endpointType=$this->endpointType");
748
-		$this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
748
+		$this->appendDebug("wsdl=".$this->varDump($this->wsdl));
749 749
 		if ($this->endpointType != 'wsdl') {
750 750
 			$evalStr = 'A proxy can only be created for a WSDL client';
751 751
 			$this->setError($evalStr);
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
756 756
 			$this->loadWSDL();
757 757
 			if ($this->getError()) {
758
-				return "echo \"" . $this->getError() . "\";";
758
+				return "echo \"".$this->getError()."\";";
759 759
 			}
760 760
 		}
761 761
 		$evalStr = '';
@@ -771,9 +771,9 @@  discard block
 block discarded – undo
771 771
 						$paramArrayStr .= "'$name' => \$$name, ";
772 772
 						$paramCommentStr .= "$type \$$name, ";
773 773
 					}
774
-					$paramStr = substr($paramStr, 0, strlen($paramStr)-2);
775
-					$paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2);
776
-					$paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2);
774
+					$paramStr = substr($paramStr, 0, strlen($paramStr) - 2);
775
+					$paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr) - 2);
776
+					$paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr) - 2);
777 777
 				} else {
778 778
 					$paramStr = '';
779 779
 					$paramArrayStr = '';
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 				}
782 782
 				$opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace'];
783 783
 				$evalStr .= "// $paramCommentStr
784
-	function " . str_replace('.', '__', $operation) . "($paramStr) {
784
+	function ".str_replace('.', '__', $operation)."($paramStr) {
785 785
 		\$params = array($paramArrayStr);
786 786
 		return \$this->call('$operation', \$params, '".$opData['namespace']."', '".(isset($opData['soapAction']) ? $opData['soapAction'] : '')."');
787 787
 	}
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
     * @return   always returns true
850 850
     * @access   public
851 851
     */
852
-    function decodeUTF8($bool){
852
+    function decodeUTF8($bool) {
853 853
 		$this->decode_utf8 = $bool;
854 854
 		return true;
855 855
     }
@@ -890,19 +890,19 @@  discard block
 block discarded – undo
890 890
 		if (sizeof($this->cookies) == 0) {
891 891
 			return true;
892 892
 		}
893
-		$this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
893
+		$this->debug('checkCookie: check '.sizeof($this->cookies).' cookies');
894 894
 		$curr_cookies = $this->cookies;
895 895
 		$this->cookies = array();
896 896
 		foreach ($curr_cookies as $cookie) {
897
-			if (! is_array($cookie)) {
897
+			if (!is_array($cookie)) {
898 898
 				$this->debug('Remove cookie that is not an array');
899 899
 				continue;
900 900
 			}
901
-			if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
901
+			if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) {
902 902
 				if (strtotime($cookie['expires']) > time()) {
903 903
 					$this->cookies[] = $cookie;
904 904
 				} else {
905
-					$this->debug('Remove expired cookie ' . $cookie['name']);
905
+					$this->debug('Remove expired cookie '.$cookie['name']);
906 906
 				}
907 907
 			} else {
908 908
 				$this->cookies[] = $cookie;
@@ -966,11 +966,11 @@  discard block
 block discarded – undo
966 966
 				}
967 967
 				$this->cookies[$i] = $newCookie;
968 968
 				$found = true;
969
-				$this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
969
+				$this->debug('Update cookie '.$newName.'='.$newCookie['value']);
970 970
 				break;
971 971
 			}
972
-			if (! $found) {
973
-				$this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
972
+			if (!$found) {
973
+				$this->debug('Add cookie '.$newName.'='.$newCookie['value']);
974 974
 				$this->cookies[] = $newCookie;
975 975
 			}
976 976
 		}
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.wsdl.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 	/**
884 884
 	* serialize the parsed wsdl
885 885
 	*
886
-	* @param mixed $debug whether to put debug=1 in endpoint URL
886
+	* @param integer $debug whether to put debug=1 in endpoint URL
887 887
 	* @return string serialization of WSDL
888 888
 	* @access public
889 889
 	*/
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 	 * @param string $direction (input|output)
1107 1107
 	 * @param mixed $parameters parameter value(s)
1108 1108
 	 * @param string $bindingType (soap|soap12)
1109
-	 * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1109
+	 * @return false|string parameters serialized as XML or false on error (e.g. operation not found)
1110 1110
 	 * @access public
1111 1111
 	 */
1112 1112
 	function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
 	 * @param string $operation operation name
1207 1207
 	 * @param string $direction (input|output)
1208 1208
 	 * @param mixed $parameters parameter value(s)
1209
-	 * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1209
+	 * @return false|string parameters serialized as XML or false on error (e.g. operation not found)
1210 1210
 	 * @access public
1211 1211
 	 * @deprecated
1212 1212
 	 */
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,8 +78,9 @@
 block discarded – undo
78 78
 		$this->proxypassword = $proxypassword;
79 79
 		$this->timeout = $timeout;
80 80
 		$this->response_timeout = $response_timeout;
81
-		if (is_array($curl_options))
82
-			$this->curl_options = $curl_options;
81
+		if (is_array($curl_options)) {
82
+					$this->curl_options = $curl_options;
83
+		}
83 84
 		$this->use_curl = $use_curl;
84 85
 		$this->fetchWSDL($wsdl);
85 86
     }
Please login to merge, or discard this patch.
Indentation   +1576 added lines, -1576 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 */
12 12
 class wsdl extends nusoap_base
13 13
 {
14
-	// URL or filename of the root of this WSDL
14
+    // URL or filename of the root of this WSDL
15 15
     var $wsdl;
16 16
     // define internal arrays of bindings, ports, operations, messages, etc.
17 17
     var $schemas = array();
@@ -38,142 +38,142 @@  discard block
 block discarded – undo
38 38
     var $position = 0;
39 39
     var $depth = 0;
40 40
     var $depth_array = array();
41
-	// for getting wsdl
42
-	var $proxyhost = '';
41
+    // for getting wsdl
42
+    var $proxyhost = '';
43 43
     var $proxyport = '';
44
-	var $proxyusername = '';
45
-	var $proxypassword = '';
46
-	var $timeout = 0;
47
-	var $response_timeout = 30;
48
-	var $curl_options = array();	// User-specified cURL options
49
-	var $use_curl = false;			// whether to always try to use cURL
50
-	// for HTTP authentication
51
-	var $username = '';				// Username for HTTP authentication
52
-	var $password = '';				// Password for HTTP authentication
53
-	var $authtype = '';				// Type of HTTP authentication
54
-	var $certRequest = array();		// Certificate for HTTP SSL authentication
44
+    var $proxyusername = '';
45
+    var $proxypassword = '';
46
+    var $timeout = 0;
47
+    var $response_timeout = 30;
48
+    var $curl_options = array();	// User-specified cURL options
49
+    var $use_curl = false;			// whether to always try to use cURL
50
+    // for HTTP authentication
51
+    var $username = '';				// Username for HTTP authentication
52
+    var $password = '';				// Password for HTTP authentication
53
+    var $authtype = '';				// Type of HTTP authentication
54
+    var $certRequest = array();		// Certificate for HTTP SSL authentication
55 55
 
56 56
     /**
57 57
      * constructor
58 58
      *
59 59
      * @param string $wsdl WSDL document URL
60
-	 * @param string $proxyhost
61
-	 * @param string $proxyport
62
-	 * @param string $proxyusername
63
-	 * @param string $proxypassword
64
-	 * @param integer $timeout set the connection timeout
65
-	 * @param integer $response_timeout set the response timeout
66
-	 * @param array $curl_options user-specified cURL options
67
-	 * @param boolean $use_curl try to use cURL
60
+     * @param string $proxyhost
61
+     * @param string $proxyport
62
+     * @param string $proxyusername
63
+     * @param string $proxypassword
64
+     * @param integer $timeout set the connection timeout
65
+     * @param integer $response_timeout set the response timeout
66
+     * @param array $curl_options user-specified cURL options
67
+     * @param boolean $use_curl try to use cURL
68 68
      * @access public
69 69
      */
70 70
     function __construct($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){
71
-		parent::__construct();
72
-		$this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
71
+        parent::__construct();
72
+        $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
73 73
         $this->proxyhost = $proxyhost;
74 74
         $this->proxyport = $proxyport;
75
-		$this->proxyusername = $proxyusername;
76
-		$this->proxypassword = $proxypassword;
77
-		$this->timeout = $timeout;
78
-		$this->response_timeout = $response_timeout;
79
-		if (is_array($curl_options))
80
-			$this->curl_options = $curl_options;
81
-		$this->use_curl = $use_curl;
82
-		$this->fetchWSDL($wsdl);
75
+        $this->proxyusername = $proxyusername;
76
+        $this->proxypassword = $proxypassword;
77
+        $this->timeout = $timeout;
78
+        $this->response_timeout = $response_timeout;
79
+        if (is_array($curl_options))
80
+            $this->curl_options = $curl_options;
81
+        $this->use_curl = $use_curl;
82
+        $this->fetchWSDL($wsdl);
83 83
     }
84 84
 
85
-	/**
86
-	 * fetches the WSDL document and parses it
87
-	 *
88
-	 * @access public
89
-	 */
90
-	function fetchWSDL($wsdl) {
91
-		$this->debug("parse and process WSDL path=$wsdl");
92
-		$this->wsdl = $wsdl;
85
+    /**
86
+     * fetches the WSDL document and parses it
87
+     *
88
+     * @access public
89
+     */
90
+    function fetchWSDL($wsdl) {
91
+        $this->debug("parse and process WSDL path=$wsdl");
92
+        $this->wsdl = $wsdl;
93 93
         // parse wsdl file
94 94
         if ($this->wsdl != "") {
95 95
             $this->parseWSDL($this->wsdl);
96 96
         }
97 97
         // imports
98 98
         // TODO: handle imports more properly, grabbing them in-line and nesting them
99
-    	$imported_urls = array();
100
-    	$imported = 1;
101
-    	while ($imported > 0) {
102
-    		$imported = 0;
103
-    		// Schema imports
104
-    		foreach ($this->schemas as $ns => $list) {
105
-    			foreach ($list as $xs) {
106
-					$wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
107
-		            foreach ($xs->imports as $ns2 => $list2) {
108
-		                for ($ii = 0; $ii < count($list2); $ii++) {
109
-		                	if (! $list2[$ii]['loaded']) {
110
-		                		$this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
111
-		                		$url = $list2[$ii]['location'];
112
-								if ($url != '') {
113
-									$urlparts = parse_url($url);
114
-									if (!isset($urlparts['host'])) {
115
-										$url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') .
116
-												substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
117
-									}
118
-									if (! in_array($url, $imported_urls)) {
119
-					                	$this->parseWSDL($url);
120
-				                		$imported++;
121
-				                		$imported_urls[] = $url;
122
-				                	}
123
-								} else {
124
-									$this->debug("Unexpected scenario: empty URL for unloaded import");
125
-								}
126
-							}
127
-						}
128
-		            }
129
-    			}
130
-    		}
131
-    		// WSDL imports
132
-			$wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
99
+        $imported_urls = array();
100
+        $imported = 1;
101
+        while ($imported > 0) {
102
+            $imported = 0;
103
+            // Schema imports
104
+            foreach ($this->schemas as $ns => $list) {
105
+                foreach ($list as $xs) {
106
+                    $wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
107
+                    foreach ($xs->imports as $ns2 => $list2) {
108
+                        for ($ii = 0; $ii < count($list2); $ii++) {
109
+                            if (! $list2[$ii]['loaded']) {
110
+                                $this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
111
+                                $url = $list2[$ii]['location'];
112
+                                if ($url != '') {
113
+                                    $urlparts = parse_url($url);
114
+                                    if (!isset($urlparts['host'])) {
115
+                                        $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') .
116
+                                                substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
117
+                                    }
118
+                                    if (! in_array($url, $imported_urls)) {
119
+                                        $this->parseWSDL($url);
120
+                                        $imported++;
121
+                                        $imported_urls[] = $url;
122
+                                    }
123
+                                } else {
124
+                                    $this->debug("Unexpected scenario: empty URL for unloaded import");
125
+                                }
126
+                            }
127
+                        }
128
+                    }
129
+                }
130
+            }
131
+            // WSDL imports
132
+            $wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
133 133
             foreach ($this->import as $ns => $list) {
134 134
                 for ($ii = 0; $ii < count($list); $ii++) {
135
-                	if (! $list[$ii]['loaded']) {
136
-                		$this->import[$ns][$ii]['loaded'] = true;
137
-                		$url = $list[$ii]['location'];
138
-						if ($url != '') {
139
-							$urlparts = parse_url($url);
140
-							if (!isset($urlparts['host'])) {
141
-								$url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
142
-										substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
143
-							}
144
-							if (! in_array($url, $imported_urls)) {
145
-			                	$this->parseWSDL($url);
146
-		                		$imported++;
147
-		                		$imported_urls[] = $url;
148
-		                	}
149
-						} else {
150
-							$this->debug("Unexpected scenario: empty URL for unloaded import");
151
-						}
152
-					}
153
-				}
135
+                    if (! $list[$ii]['loaded']) {
136
+                        $this->import[$ns][$ii]['loaded'] = true;
137
+                        $url = $list[$ii]['location'];
138
+                        if ($url != '') {
139
+                            $urlparts = parse_url($url);
140
+                            if (!isset($urlparts['host'])) {
141
+                                $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
142
+                                        substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
143
+                            }
144
+                            if (! in_array($url, $imported_urls)) {
145
+                                $this->parseWSDL($url);
146
+                                $imported++;
147
+                                $imported_urls[] = $url;
148
+                            }
149
+                        } else {
150
+                            $this->debug("Unexpected scenario: empty URL for unloaded import");
151
+                        }
152
+                    }
153
+                }
154 154
             }
155
-		}
155
+        }
156 156
         // add new data to operation data
157 157
         foreach($this->bindings as $binding => $bindingData) {
158 158
             if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
159 159
                 foreach($bindingData['operations'] as $operation => $data) {
160 160
                     $this->debug('post-parse data gathering for ' . $operation);
161 161
                     $this->bindings[$binding]['operations'][$operation]['input'] =
162
-						isset($this->bindings[$binding]['operations'][$operation]['input']) ?
163
-						array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) :
164
-						$this->portTypes[ $bindingData['portType'] ][$operation]['input'];
162
+                        isset($this->bindings[$binding]['operations'][$operation]['input']) ?
163
+                        array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) :
164
+                        $this->portTypes[ $bindingData['portType'] ][$operation]['input'];
165 165
                     $this->bindings[$binding]['operations'][$operation]['output'] =
166
-						isset($this->bindings[$binding]['operations'][$operation]['output']) ?
167
-						array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) :
168
-						$this->portTypes[ $bindingData['portType'] ][$operation]['output'];
166
+                        isset($this->bindings[$binding]['operations'][$operation]['output']) ?
167
+                        array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) :
168
+                        $this->portTypes[ $bindingData['portType'] ][$operation]['output'];
169 169
                     if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){
170
-						$this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ];
171
-					}
172
-					if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){
173
-                   		$this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ];
170
+                        $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ];
171
+                    }
172
+                    if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){
173
+                            $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ];
174 174
                     }
175 175
                     // Set operation style if necessary, but do not override one already provided
176
-					if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
176
+                    if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
177 177
                         $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style'];
178 178
                     }
179 179
                     $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : '';
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
                 }
183 183
             }
184 184
         }
185
-	}
185
+    }
186 186
 
187 187
     /**
188 188
      * parses the wsdl document
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      * @access private
192 192
      */
193 193
     function parseWSDL($wsdl = '') {
194
-		$this->debug("parse WSDL at path=$wsdl");
194
+        $this->debug("parse WSDL at path=$wsdl");
195 195
 
196 196
         if ($wsdl == '') {
197 197
             $this->debug('no wsdl passed to parseWSDL()!!');
@@ -204,38 +204,38 @@  discard block
 block discarded – undo
204 204
 
205 205
         if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) {
206 206
             $this->debug('getting WSDL http(s) URL ' . $wsdl);
207
-        	// get wsdl
208
-	        $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl);
209
-			$tr->request_method = 'GET';
210
-			$tr->useSOAPAction = false;
211
-			if($this->proxyhost && $this->proxyport){
212
-				$tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
213
-			}
214
-			if ($this->authtype != '') {
215
-				$tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
216
-			}
217
-			$tr->setEncoding('gzip, deflate');
218
-			$wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
219
-			//$this->debug("WSDL request\n" . $tr->outgoing_payload);
220
-			//$this->debug("WSDL response\n" . $tr->incoming_payload);
221
-			$this->appendDebug($tr->getDebug());
222
-			// catch errors
223
-			if($err = $tr->getError() ){
224
-				$errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err;
225
-				$this->debug($errstr);
226
-	            $this->setError($errstr);
227
-				unset($tr);
228
-	            return false;
229
-			}
230
-			unset($tr);
231
-			$this->debug("got WSDL URL");
207
+            // get wsdl
208
+            $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl);
209
+            $tr->request_method = 'GET';
210
+            $tr->useSOAPAction = false;
211
+            if($this->proxyhost && $this->proxyport){
212
+                $tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
213
+            }
214
+            if ($this->authtype != '') {
215
+                $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
216
+            }
217
+            $tr->setEncoding('gzip, deflate');
218
+            $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
219
+            //$this->debug("WSDL request\n" . $tr->outgoing_payload);
220
+            //$this->debug("WSDL response\n" . $tr->incoming_payload);
221
+            $this->appendDebug($tr->getDebug());
222
+            // catch errors
223
+            if($err = $tr->getError() ){
224
+                $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err;
225
+                $this->debug($errstr);
226
+                $this->setError($errstr);
227
+                unset($tr);
228
+                return false;
229
+            }
230
+            unset($tr);
231
+            $this->debug("got WSDL URL");
232 232
         } else {
233 233
             // $wsdl is not http(s), so treat it as a file URL or plain file path
234
-        	if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
235
-        		$path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path'];
236
-        	} else {
237
-        		$path = $wsdl;
238
-        	}
234
+            if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
235
+                $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path'];
236
+            } else {
237
+                $path = $wsdl;
238
+            }
239 239
             $this->debug('getting WSDL file ' . $path);
240 240
             if ($fp = @fopen($path, 'r')) {
241 241
                 $wsdl_string = '';
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
                 }
245 245
                 fclose($fp);
246 246
             } else {
247
-            	$errstr = "Bad path to WSDL file $path";
248
-            	$this->debug($errstr);
247
+                $errstr = "Bad path to WSDL file $path";
248
+                $this->debug($errstr);
249 249
                 $this->setError($errstr);
250 250
                 return false;
251 251
             }
@@ -266,23 +266,23 @@  discard block
 block discarded – undo
266 266
         if (!xml_parse($this->parser, $wsdl_string, true)) {
267 267
             // Display an error message.
268 268
             $errstr = sprintf(
269
-				'XML error parsing WSDL from %s on line %d: %s',
270
-				$wsdl,
269
+                'XML error parsing WSDL from %s on line %d: %s',
270
+                $wsdl,
271 271
                 xml_get_current_line_number($this->parser),
272 272
                 xml_error_string(xml_get_error_code($this->parser))
273 273
                 );
274 274
             $this->debug($errstr);
275
-			$this->debug("XML payload:\n" . $wsdl_string);
275
+            $this->debug("XML payload:\n" . $wsdl_string);
276 276
             $this->setError($errstr);
277 277
             return false;
278 278
         }
279
-		// free the parser
279
+        // free the parser
280 280
         xml_parser_free($this->parser);
281 281
         $this->debug('Parsing WSDL done');
282
-		// catch wsdl parse errors
283
-		if($this->getError()){
284
-			return false;
285
-		}
282
+        // catch wsdl parse errors
283
+        if($this->getError()){
284
+            return false;
285
+        }
286 286
         return true;
287 287
     }
288 288
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
             $this->appendDebug($this->currentSchema->getDebug());
302 302
             $this->currentSchema->clearDebug();
303 303
         } elseif (preg_match('/schema$/', $name)) {
304
-        	$this->debug('Parsing WSDL schema');
304
+            $this->debug('Parsing WSDL schema');
305 305
             // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")");
306 306
             $this->status = 'schema';
307 307
             $this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces);
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
             $this->message[$pos] = array('cdata' => '');
318 318
             // process attributes
319 319
             if (count($attrs) > 0) {
320
-				// register namespace declarations
320
+                // register namespace declarations
321 321
                 foreach($attrs as $k => $v) {
322 322
                     if (preg_match('/^xmlns/',$k)) {
323 323
                         if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
@@ -352,417 +352,417 @@  discard block
 block discarded – undo
352 352
                 // get unqualified name
353 353
                 $name = substr(strstr($name, ':'), 1);
354 354
             }
355
-			// process attributes, expanding any prefixes to namespaces
355
+            // process attributes, expanding any prefixes to namespaces
356 356
             // find status, register data
357 357
             switch ($this->status) {
358 358
                 case 'message':
359 359
                     if ($name == 'part') {
360
-			            if (isset($attrs['type'])) {
361
-		                    $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
362
-		                    $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
363
-            			}
364
-			            if (isset($attrs['element'])) {
365
-		                    $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
366
-			                $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
367
-			            }
368
-        			}
369
-        			break;
370
-			    case 'portType':
371
-			        switch ($name) {
372
-			            case 'operation':
373
-			                $this->currentPortOperation = $attrs['name'];
374
-			                $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
375
-			                if (isset($attrs['parameterOrder'])) {
376
-			                	$this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
377
-			        		}
378
-			        		break;
379
-					    case 'documentation':
380
-					        $this->documentation = true;
381
-					        break;
382
-					    // merge input/output data
383
-					    default:
384
-					        $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
385
-					        $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
386
-					        break;
387
-					}
388
-			    	break;
389
-				case 'binding':
390
-				    switch ($name) {
391
-				        case 'binding':
392
-				            // get ns prefix
393
-				            if (isset($attrs['style'])) {
394
-				            $this->bindings[$this->currentBinding]['prefix'] = $prefix;
395
-					    	}
396
-					    	$this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
397
-					    	break;
398
-						case 'header':
399
-						    $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs;
400
-						    break;
401
-						case 'operation':
402
-						    if (isset($attrs['soapAction'])) {
403
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction'];
404
-						    }
405
-						    if (isset($attrs['style'])) {
406
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style'];
407
-						    }
408
-						    if (isset($attrs['name'])) {
409
-						        $this->currentOperation = $attrs['name'];
410
-						        $this->debug("current binding operation: $this->currentOperation");
411
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name'];
412
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding;
413
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : '';
414
-						    }
415
-						    break;
416
-						case 'input':
417
-						    $this->opStatus = 'input';
418
-						    break;
419
-						case 'output':
420
-						    $this->opStatus = 'output';
421
-						    break;
422
-						case 'body':
423
-						    if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
424
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs);
425
-						    } else {
426
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs;
427
-						    }
428
-						    break;
429
-					}
430
-					break;
431
-				case 'service':
432
-					switch ($name) {
433
-					    case 'port':
434
-					        $this->currentPort = $attrs['name'];
435
-					        $this->debug('current port: ' . $this->currentPort);
436
-					        $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
360
+                        if (isset($attrs['type'])) {
361
+                            $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
362
+                            $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
363
+                        }
364
+                        if (isset($attrs['element'])) {
365
+                            $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
366
+                            $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
367
+                        }
368
+                    }
369
+                    break;
370
+                case 'portType':
371
+                    switch ($name) {
372
+                        case 'operation':
373
+                            $this->currentPortOperation = $attrs['name'];
374
+                            $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
375
+                            if (isset($attrs['parameterOrder'])) {
376
+                                $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
377
+                            }
378
+                            break;
379
+                        case 'documentation':
380
+                            $this->documentation = true;
381
+                            break;
382
+                        // merge input/output data
383
+                        default:
384
+                            $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
385
+                            $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
386
+                            break;
387
+                    }
388
+                    break;
389
+                case 'binding':
390
+                    switch ($name) {
391
+                        case 'binding':
392
+                            // get ns prefix
393
+                            if (isset($attrs['style'])) {
394
+                            $this->bindings[$this->currentBinding]['prefix'] = $prefix;
395
+                            }
396
+                            $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
397
+                            break;
398
+                        case 'header':
399
+                            $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs;
400
+                            break;
401
+                        case 'operation':
402
+                            if (isset($attrs['soapAction'])) {
403
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction'];
404
+                            }
405
+                            if (isset($attrs['style'])) {
406
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style'];
407
+                            }
408
+                            if (isset($attrs['name'])) {
409
+                                $this->currentOperation = $attrs['name'];
410
+                                $this->debug("current binding operation: $this->currentOperation");
411
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name'];
412
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding;
413
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : '';
414
+                            }
415
+                            break;
416
+                        case 'input':
417
+                            $this->opStatus = 'input';
418
+                            break;
419
+                        case 'output':
420
+                            $this->opStatus = 'output';
421
+                            break;
422
+                        case 'body':
423
+                            if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
424
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs);
425
+                            } else {
426
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs;
427
+                            }
428
+                            break;
429
+                    }
430
+                    break;
431
+                case 'service':
432
+                    switch ($name) {
433
+                        case 'port':
434
+                            $this->currentPort = $attrs['name'];
435
+                            $this->debug('current port: ' . $this->currentPort);
436
+                            $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
437 437
 
438
-					        break;
439
-					    case 'address':
440
-					        $this->ports[$this->currentPort]['location'] = $attrs['location'];
441
-					        $this->ports[$this->currentPort]['bindingType'] = $namespace;
442
-					        $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
443
-					        $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
444
-					        break;
445
-					}
446
-					break;
447
-			}
448
-		// set status
449
-		switch ($name) {
450
-			case 'import':
451
-			    if (isset($attrs['location'])) {
438
+                            break;
439
+                        case 'address':
440
+                            $this->ports[$this->currentPort]['location'] = $attrs['location'];
441
+                            $this->ports[$this->currentPort]['bindingType'] = $namespace;
442
+                            $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
443
+                            $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
444
+                            break;
445
+                    }
446
+                    break;
447
+            }
448
+        // set status
449
+        switch ($name) {
450
+            case 'import':
451
+                if (isset($attrs['location'])) {
452 452
                     $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
453 453
                     $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')');
454
-				} else {
454
+                } else {
455 455
                     $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
456
-					if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
457
-						$this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
458
-					}
456
+                    if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
457
+                        $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
458
+                    }
459 459
                     $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')');
460
-				}
461
-				break;
462
-			//wait for schema
463
-			//case 'types':
464
-			//	$this->status = 'schema';
465
-			//	break;
466
-			case 'message':
467
-				$this->status = 'message';
468
-				$this->messages[$attrs['name']] = array();
469
-				$this->currentMessage = $attrs['name'];
470
-				break;
471
-			case 'portType':
472
-				$this->status = 'portType';
473
-				$this->portTypes[$attrs['name']] = array();
474
-				$this->currentPortType = $attrs['name'];
475
-				break;
476
-			case "binding":
477
-				if (isset($attrs['name'])) {
478
-				// get binding name
479
-					if (strpos($attrs['name'], ':')) {
480
-			    		$this->currentBinding = $this->getLocalPart($attrs['name']);
481
-					} else {
482
-			    		$this->currentBinding = $attrs['name'];
483
-					}
484
-					$this->status = 'binding';
485
-					$this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
486
-					$this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
487
-				}
488
-				break;
489
-			case 'service':
490
-				$this->serviceName = $attrs['name'];
491
-				$this->status = 'service';
492
-				$this->debug('current service: ' . $this->serviceName);
493
-				break;
494
-			case 'definitions':
495
-				foreach ($attrs as $name => $value) {
496
-					$this->wsdl_info[$name] = $value;
497
-				}
498
-				break;
499
-			}
500
-		}
501
-	}
460
+                }
461
+                break;
462
+            //wait for schema
463
+            //case 'types':
464
+            //	$this->status = 'schema';
465
+            //	break;
466
+            case 'message':
467
+                $this->status = 'message';
468
+                $this->messages[$attrs['name']] = array();
469
+                $this->currentMessage = $attrs['name'];
470
+                break;
471
+            case 'portType':
472
+                $this->status = 'portType';
473
+                $this->portTypes[$attrs['name']] = array();
474
+                $this->currentPortType = $attrs['name'];
475
+                break;
476
+            case "binding":
477
+                if (isset($attrs['name'])) {
478
+                // get binding name
479
+                    if (strpos($attrs['name'], ':')) {
480
+                        $this->currentBinding = $this->getLocalPart($attrs['name']);
481
+                    } else {
482
+                        $this->currentBinding = $attrs['name'];
483
+                    }
484
+                    $this->status = 'binding';
485
+                    $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
486
+                    $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
487
+                }
488
+                break;
489
+            case 'service':
490
+                $this->serviceName = $attrs['name'];
491
+                $this->status = 'service';
492
+                $this->debug('current service: ' . $this->serviceName);
493
+                break;
494
+            case 'definitions':
495
+                foreach ($attrs as $name => $value) {
496
+                    $this->wsdl_info[$name] = $value;
497
+                }
498
+                break;
499
+            }
500
+        }
501
+    }
502 502
 
503
-	/**
504
-	* end-element handler
505
-	*
506
-	* @param string $parser XML parser object
507
-	* @param string $name element name
508
-	* @access private
509
-	*/
510
-	function end_element($parser, $name){
511
-		// unset schema status
512
-		if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
513
-			$this->status = "";
503
+    /**
504
+     * end-element handler
505
+     *
506
+     * @param string $parser XML parser object
507
+     * @param string $name element name
508
+     * @access private
509
+     */
510
+    function end_element($parser, $name){
511
+        // unset schema status
512
+        if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
513
+            $this->status = "";
514 514
             $this->appendDebug($this->currentSchema->getDebug());
515 515
             $this->currentSchema->clearDebug();
516
-			$this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
517
-        	$this->debug('Parsing WSDL schema done');
518
-		}
519
-		if ($this->status == 'schema') {
520
-			$this->currentSchema->schemaEndElement($parser, $name);
521
-		} else {
522
-			// bring depth down a notch
523
-			$this->depth--;
524
-		}
525
-		// end documentation
526
-		if ($this->documentation) {
527
-			//TODO: track the node to which documentation should be assigned; it can be a part, message, etc.
528
-			//$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation;
529
-			$this->documentation = false;
530
-		}
531
-	}
516
+            $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
517
+            $this->debug('Parsing WSDL schema done');
518
+        }
519
+        if ($this->status == 'schema') {
520
+            $this->currentSchema->schemaEndElement($parser, $name);
521
+        } else {
522
+            // bring depth down a notch
523
+            $this->depth--;
524
+        }
525
+        // end documentation
526
+        if ($this->documentation) {
527
+            //TODO: track the node to which documentation should be assigned; it can be a part, message, etc.
528
+            //$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation;
529
+            $this->documentation = false;
530
+        }
531
+    }
532 532
 
533
-	/**
534
-	 * element content handler
535
-	 *
536
-	 * @param string $parser XML parser object
537
-	 * @param string $data element content
538
-	 * @access private
539
-	 */
540
-	function character_data($parser, $data)
541
-	{
542
-		$pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
543
-		if (isset($this->message[$pos]['cdata'])) {
544
-			$this->message[$pos]['cdata'] .= $data;
545
-		}
546
-		if ($this->documentation) {
547
-			$this->documentation .= $data;
548
-		}
549
-	}
533
+    /**
534
+     * element content handler
535
+     *
536
+     * @param string $parser XML parser object
537
+     * @param string $data element content
538
+     * @access private
539
+     */
540
+    function character_data($parser, $data)
541
+    {
542
+        $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
543
+        if (isset($this->message[$pos]['cdata'])) {
544
+            $this->message[$pos]['cdata'] .= $data;
545
+        }
546
+        if ($this->documentation) {
547
+            $this->documentation .= $data;
548
+        }
549
+    }
550 550
 
551
-	/**
552
-	* if authenticating, set user credentials here
553
-	*
554
-	* @param    string $username
555
-	* @param    string $password
556
-	* @param	string $authtype (basic|digest|certificate|ntlm)
557
-	* @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
558
-	* @access   public
559
-	*/
560
-	function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
561
-		$this->debug("setCredentials username=$username authtype=$authtype certRequest=");
562
-		$this->appendDebug($this->varDump($certRequest));
563
-		$this->username = $username;
564
-		$this->password = $password;
565
-		$this->authtype = $authtype;
566
-		$this->certRequest = $certRequest;
567
-	}
551
+    /**
552
+     * if authenticating, set user credentials here
553
+     *
554
+     * @param    string $username
555
+     * @param    string $password
556
+     * @param	string $authtype (basic|digest|certificate|ntlm)
557
+     * @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
558
+     * @access   public
559
+     */
560
+    function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
561
+        $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
562
+        $this->appendDebug($this->varDump($certRequest));
563
+        $this->username = $username;
564
+        $this->password = $password;
565
+        $this->authtype = $authtype;
566
+        $this->certRequest = $certRequest;
567
+    }
568 568
 
569
-	function getBindingData($binding)
570
-	{
571
-		if (is_array($this->bindings[$binding])) {
572
-			return $this->bindings[$binding];
573
-		}
574
-	}
569
+    function getBindingData($binding)
570
+    {
571
+        if (is_array($this->bindings[$binding])) {
572
+            return $this->bindings[$binding];
573
+        }
574
+    }
575 575
 
576
-	/**
577
-	 * returns an assoc array of operation names => operation data
578
-	 *
579
-	 * @param string $portName WSDL port name
580
-	 * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported)
581
-	 * @return array
582
-	 * @access public
583
-	 */
584
-	function getOperations($portName = '', $bindingType = 'soap') {
585
-		$ops = array();
586
-		if ($bindingType == 'soap') {
587
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
588
-		} elseif ($bindingType == 'soap12') {
589
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
590
-		} else {
591
-			$this->debug("getOperations bindingType $bindingType may not be supported");
592
-		}
593
-		$this->debug("getOperations for port '$portName' bindingType $bindingType");
594
-		// loop thru ports
595
-		foreach($this->ports as $port => $portData) {
596
-			$this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
597
-			if ($portName == '' || $port == $portName) {
598
-				// binding type of port matches parameter
599
-				if ($portData['bindingType'] == $bindingType) {
600
-					$this->debug("getOperations found port $port bindingType $bindingType");
601
-					//$this->debug("port data: " . $this->varDump($portData));
602
-					//$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
603
-					// merge bindings
604
-					if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
605
-						$ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']);
606
-					}
607
-				}
608
-			}
609
-		}
610
-		if (count($ops) == 0) {
611
-			$this->debug("getOperations found no operations for port '$portName' bindingType $bindingType");
612
-		}
613
-		return $ops;
614
-	}
576
+    /**
577
+     * returns an assoc array of operation names => operation data
578
+     *
579
+     * @param string $portName WSDL port name
580
+     * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported)
581
+     * @return array
582
+     * @access public
583
+     */
584
+    function getOperations($portName = '', $bindingType = 'soap') {
585
+        $ops = array();
586
+        if ($bindingType == 'soap') {
587
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
588
+        } elseif ($bindingType == 'soap12') {
589
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
590
+        } else {
591
+            $this->debug("getOperations bindingType $bindingType may not be supported");
592
+        }
593
+        $this->debug("getOperations for port '$portName' bindingType $bindingType");
594
+        // loop thru ports
595
+        foreach($this->ports as $port => $portData) {
596
+            $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
597
+            if ($portName == '' || $port == $portName) {
598
+                // binding type of port matches parameter
599
+                if ($portData['bindingType'] == $bindingType) {
600
+                    $this->debug("getOperations found port $port bindingType $bindingType");
601
+                    //$this->debug("port data: " . $this->varDump($portData));
602
+                    //$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
603
+                    // merge bindings
604
+                    if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
605
+                        $ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']);
606
+                    }
607
+                }
608
+            }
609
+        }
610
+        if (count($ops) == 0) {
611
+            $this->debug("getOperations found no operations for port '$portName' bindingType $bindingType");
612
+        }
613
+        return $ops;
614
+    }
615 615
 
616
-	/**
617
-	 * returns an associative array of data necessary for calling an operation
618
-	 *
619
-	 * @param string $operation name of operation
620
-	 * @param string $bindingType type of binding eg: soap, soap12
621
-	 * @return array
622
-	 * @access public
623
-	 */
624
-	function getOperationData($operation, $bindingType = 'soap')
625
-	{
626
-		if ($bindingType == 'soap') {
627
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
628
-		} elseif ($bindingType == 'soap12') {
629
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
630
-		}
631
-		// loop thru ports
632
-		foreach($this->ports as $port => $portData) {
633
-			// binding type of port matches parameter
634
-			if ($portData['bindingType'] == $bindingType) {
635
-				// get binding
636
-				//foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
637
-				foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
638
-					// note that we could/should also check the namespace here
639
-					if ($operation == $bOperation) {
640
-						$opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
641
-					    return $opData;
642
-					}
643
-				}
644
-			}
645
-		}
646
-	}
616
+    /**
617
+     * returns an associative array of data necessary for calling an operation
618
+     *
619
+     * @param string $operation name of operation
620
+     * @param string $bindingType type of binding eg: soap, soap12
621
+     * @return array
622
+     * @access public
623
+     */
624
+    function getOperationData($operation, $bindingType = 'soap')
625
+    {
626
+        if ($bindingType == 'soap') {
627
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
628
+        } elseif ($bindingType == 'soap12') {
629
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
630
+        }
631
+        // loop thru ports
632
+        foreach($this->ports as $port => $portData) {
633
+            // binding type of port matches parameter
634
+            if ($portData['bindingType'] == $bindingType) {
635
+                // get binding
636
+                //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
637
+                foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
638
+                    // note that we could/should also check the namespace here
639
+                    if ($operation == $bOperation) {
640
+                        $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
641
+                        return $opData;
642
+                    }
643
+                }
644
+            }
645
+        }
646
+    }
647 647
 
648
-	/**
649
-	 * returns an associative array of data necessary for calling an operation
650
-	 *
651
-	 * @param string $soapAction soapAction for operation
652
-	 * @param string $bindingType type of binding eg: soap, soap12
653
-	 * @return array
654
-	 * @access public
655
-	 */
656
-	function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') {
657
-		if ($bindingType == 'soap') {
658
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
659
-		} elseif ($bindingType == 'soap12') {
660
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
661
-		}
662
-		// loop thru ports
663
-		foreach($this->ports as $port => $portData) {
664
-			// binding type of port matches parameter
665
-			if ($portData['bindingType'] == $bindingType) {
666
-				// loop through operations for the binding
667
-				foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
668
-					if ($opData['soapAction'] == $soapAction) {
669
-					    return $opData;
670
-					}
671
-				}
672
-			}
673
-		}
674
-	}
648
+    /**
649
+     * returns an associative array of data necessary for calling an operation
650
+     *
651
+     * @param string $soapAction soapAction for operation
652
+     * @param string $bindingType type of binding eg: soap, soap12
653
+     * @return array
654
+     * @access public
655
+     */
656
+    function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') {
657
+        if ($bindingType == 'soap') {
658
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
659
+        } elseif ($bindingType == 'soap12') {
660
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
661
+        }
662
+        // loop thru ports
663
+        foreach($this->ports as $port => $portData) {
664
+            // binding type of port matches parameter
665
+            if ($portData['bindingType'] == $bindingType) {
666
+                // loop through operations for the binding
667
+                foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
668
+                    if ($opData['soapAction'] == $soapAction) {
669
+                        return $opData;
670
+                    }
671
+                }
672
+            }
673
+        }
674
+    }
675 675
 
676
-	/**
677
-    * returns an array of information about a given type
678
-    * returns false if no type exists by the given name
679
-    *
680
-	*	 typeDef = array(
681
-	*	 'elements' => array(), // refs to elements array
682
-	*	'restrictionBase' => '',
683
-	*	'phpType' => '',
684
-	*	'order' => '(sequence|all)',
685
-	*	'attrs' => array() // refs to attributes array
686
-	*	)
687
-    *
688
-    * @param string $type the type
689
-    * @param string $ns namespace (not prefix) of the type
690
-    * @return mixed
691
-    * @access public
692
-    * @see nusoap_xmlschema
693
-    */
694
-	function getTypeDef($type, $ns) {
695
-		$this->debug("in getTypeDef: type=$type, ns=$ns");
696
-		if ((! $ns) && isset($this->namespaces['tns'])) {
697
-			$ns = $this->namespaces['tns'];
698
-			$this->debug("in getTypeDef: type namespace forced to $ns");
699
-		}
700
-		if (!isset($this->schemas[$ns])) {
701
-			foreach ($this->schemas as $ns0 => $schema0) {
702
-				if (strcasecmp($ns, $ns0) == 0) {
703
-					$this->debug("in getTypeDef: replacing schema namespace $ns with $ns0");
704
-					$ns = $ns0;
705
-					break;
706
-				}
707
-			}
708
-		}
709
-		if (isset($this->schemas[$ns])) {
710
-			$this->debug("in getTypeDef: have schema for namespace $ns");
711
-			for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
712
-				$xs = &$this->schemas[$ns][$i];
713
-				$t = $xs->getTypeDef($type);
714
-				$this->appendDebug($xs->getDebug());
715
-				$xs->clearDebug();
716
-				if ($t) {
717
-					$this->debug("in getTypeDef: found type $type");
718
-					if (!isset($t['phpType'])) {
719
-						// get info for type to tack onto the element
720
-						$uqType = substr($t['type'], strrpos($t['type'], ':') + 1);
721
-						$ns = substr($t['type'], 0, strrpos($t['type'], ':'));
722
-						$etype = $this->getTypeDef($uqType, $ns);
723
-						if ($etype) {
724
-							$this->debug("found type for [element] $type:");
725
-							$this->debug($this->varDump($etype));
726
-							if (isset($etype['phpType'])) {
727
-								$t['phpType'] = $etype['phpType'];
728
-							}
729
-							if (isset($etype['elements'])) {
730
-								$t['elements'] = $etype['elements'];
731
-							}
732
-							if (isset($etype['attrs'])) {
733
-								$t['attrs'] = $etype['attrs'];
734
-							}
735
-						} else {
736
-							$this->debug("did not find type for [element] $type");
737
-						}
738
-					}
739
-					return $t;
740
-				}
741
-			}
742
-			$this->debug("in getTypeDef: did not find type $type");
743
-		} else {
744
-			$this->debug("in getTypeDef: do not have schema for namespace $ns");
745
-		}
746
-		return false;
747
-	}
676
+    /**
677
+     * returns an array of information about a given type
678
+     * returns false if no type exists by the given name
679
+     *
680
+     *	 typeDef = array(
681
+     *	 'elements' => array(), // refs to elements array
682
+     *	'restrictionBase' => '',
683
+     *	'phpType' => '',
684
+     *	'order' => '(sequence|all)',
685
+     *	'attrs' => array() // refs to attributes array
686
+     *	)
687
+     *
688
+     * @param string $type the type
689
+     * @param string $ns namespace (not prefix) of the type
690
+     * @return mixed
691
+     * @access public
692
+     * @see nusoap_xmlschema
693
+     */
694
+    function getTypeDef($type, $ns) {
695
+        $this->debug("in getTypeDef: type=$type, ns=$ns");
696
+        if ((! $ns) && isset($this->namespaces['tns'])) {
697
+            $ns = $this->namespaces['tns'];
698
+            $this->debug("in getTypeDef: type namespace forced to $ns");
699
+        }
700
+        if (!isset($this->schemas[$ns])) {
701
+            foreach ($this->schemas as $ns0 => $schema0) {
702
+                if (strcasecmp($ns, $ns0) == 0) {
703
+                    $this->debug("in getTypeDef: replacing schema namespace $ns with $ns0");
704
+                    $ns = $ns0;
705
+                    break;
706
+                }
707
+            }
708
+        }
709
+        if (isset($this->schemas[$ns])) {
710
+            $this->debug("in getTypeDef: have schema for namespace $ns");
711
+            for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
712
+                $xs = &$this->schemas[$ns][$i];
713
+                $t = $xs->getTypeDef($type);
714
+                $this->appendDebug($xs->getDebug());
715
+                $xs->clearDebug();
716
+                if ($t) {
717
+                    $this->debug("in getTypeDef: found type $type");
718
+                    if (!isset($t['phpType'])) {
719
+                        // get info for type to tack onto the element
720
+                        $uqType = substr($t['type'], strrpos($t['type'], ':') + 1);
721
+                        $ns = substr($t['type'], 0, strrpos($t['type'], ':'));
722
+                        $etype = $this->getTypeDef($uqType, $ns);
723
+                        if ($etype) {
724
+                            $this->debug("found type for [element] $type:");
725
+                            $this->debug($this->varDump($etype));
726
+                            if (isset($etype['phpType'])) {
727
+                                $t['phpType'] = $etype['phpType'];
728
+                            }
729
+                            if (isset($etype['elements'])) {
730
+                                $t['elements'] = $etype['elements'];
731
+                            }
732
+                            if (isset($etype['attrs'])) {
733
+                                $t['attrs'] = $etype['attrs'];
734
+                            }
735
+                        } else {
736
+                            $this->debug("did not find type for [element] $type");
737
+                        }
738
+                    }
739
+                    return $t;
740
+                }
741
+            }
742
+            $this->debug("in getTypeDef: did not find type $type");
743
+        } else {
744
+            $this->debug("in getTypeDef: do not have schema for namespace $ns");
745
+        }
746
+        return false;
747
+    }
748 748
 
749 749
     /**
750
-    * prints html description of services
751
-    *
752
-    * @access private
753
-    */
750
+     * prints html description of services
751
+     *
752
+     * @access private
753
+     */
754 754
     function webDescription(){
755
-    	global $HTTP_SERVER_VARS;
755
+        global $HTTP_SERVER_VARS;
756 756
 
757
-		if (isset($_SERVER)) {
758
-			$PHP_SELF = $_SERVER['PHP_SELF'];
759
-		} elseif (isset($HTTP_SERVER_VARS)) {
760
-			$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
761
-		} else {
762
-			$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
763
-		}
757
+        if (isset($_SERVER)) {
758
+            $PHP_SELF = $_SERVER['PHP_SELF'];
759
+        } elseif (isset($HTTP_SERVER_VARS)) {
760
+            $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
761
+        } else {
762
+            $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
763
+        }
764 764
 
765
-		$b = '
765
+        $b = '
766 766
 		<html><head><title>NuSOAP: '.$this->serviceName.'</title>
767 767
 		<style type="text/css">
768 768
 		    body    { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
@@ -845,1092 +845,1092 @@  discard block
 block discarded – undo
845 845
 				<p>View the <a href="'.$PHP_SELF.'?wsdl">WSDL</a> for the service.
846 846
 				Click on an operation name to view it&apos;s details.</p>
847 847
 				<ul>';
848
-				foreach($this->getOperations() as $op => $data){
849
-				    $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
850
-				    // create hidden div
851
-				    $b .= "<div id='$op' class='hidden'>
848
+                foreach($this->getOperations() as $op => $data){
849
+                    $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
850
+                    // create hidden div
851
+                    $b .= "<div id='$op' class='hidden'>
852 852
 				    <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
853
-				    foreach($data as $donnie => $marie){ // loop through opdata
854
-						if($donnie == 'input' || $donnie == 'output'){ // show input/output data
855
-						    $b .= "<font color='white'>".ucfirst($donnie).':</font><br>';
856
-						    foreach($marie as $captain => $tenille){ // loop through data
857
-								if($captain == 'parts'){ // loop thru parts
858
-								    $b .= "&nbsp;&nbsp;$captain:<br>";
859
-					                //if(is_array($tenille)){
860
-								    	foreach($tenille as $joanie => $chachi){
861
-											$b .= "&nbsp;&nbsp;&nbsp;&nbsp;$joanie: $chachi<br>";
862
-								    	}
863
-					        		//}
864
-								} else {
865
-								    $b .= "&nbsp;&nbsp;$captain: $tenille<br>";
866
-								}
867
-						    }
868
-						} else {
869
-						    $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>";
870
-						}
871
-				    }
872
-					$b .= '</div>';
873
-				}
874
-				$b .= '
853
+                    foreach($data as $donnie => $marie){ // loop through opdata
854
+                        if($donnie == 'input' || $donnie == 'output'){ // show input/output data
855
+                            $b .= "<font color='white'>".ucfirst($donnie).':</font><br>';
856
+                            foreach($marie as $captain => $tenille){ // loop through data
857
+                                if($captain == 'parts'){ // loop thru parts
858
+                                    $b .= "&nbsp;&nbsp;$captain:<br>";
859
+                                    //if(is_array($tenille)){
860
+                                        foreach($tenille as $joanie => $chachi){
861
+                                            $b .= "&nbsp;&nbsp;&nbsp;&nbsp;$joanie: $chachi<br>";
862
+                                        }
863
+                                    //}
864
+                                } else {
865
+                                    $b .= "&nbsp;&nbsp;$captain: $tenille<br>";
866
+                                }
867
+                            }
868
+                        } else {
869
+                            $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>";
870
+                        }
871
+                    }
872
+                    $b .= '</div>';
873
+                }
874
+                $b .= '
875 875
 				<ul>
876 876
 			</div>
877 877
 		</div></body></html>';
878
-		return $b;
878
+        return $b;
879 879
     }
880 880
 
881
-	/**
882
-	* serialize the parsed wsdl
883
-	*
884
-	* @param mixed $debug whether to put debug=1 in endpoint URL
885
-	* @return string serialization of WSDL
886
-	* @access public
887
-	*/
888
-	function serialize($debug = 0)
889
-	{
890
-		$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
891
-		$xml .= "\n<definitions";
892
-		foreach($this->namespaces as $k => $v) {
893
-			$xml .= " xmlns:$k=\"$v\"";
894
-		}
895
-		// 10.9.02 - add poulter fix for wsdl and tns declarations
896
-		if (isset($this->namespaces['wsdl'])) {
897
-			$xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
898
-		}
899
-		if (isset($this->namespaces['tns'])) {
900
-			$xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
901
-		}
902
-		$xml .= '>';
903
-		// imports
904
-		if (sizeof($this->import) > 0) {
905
-			foreach($this->import as $ns => $list) {
906
-				foreach ($list as $ii) {
907
-					if ($ii['location'] != '') {
908
-						$xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />';
909
-					} else {
910
-						$xml .= '<import namespace="' . $ns . '" />';
911
-					}
912
-				}
913
-			}
914
-		}
915
-		// types
916
-		if (count($this->schemas)>=1) {
917
-			$xml .= "\n<types>\n";
918
-			foreach ($this->schemas as $ns => $list) {
919
-				foreach ($list as $xs) {
920
-					$xml .= $xs->serializeSchema();
921
-				}
922
-			}
923
-			$xml .= '</types>';
924
-		}
925
-		// messages
926
-		if (count($this->messages) >= 1) {
927
-			foreach($this->messages as $msgName => $msgParts) {
928
-				$xml .= "\n<message name=\"" . $msgName . '">';
929
-				if(is_array($msgParts)){
930
-					foreach($msgParts as $partName => $partType) {
931
-						// print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
932
-						if (strpos($partType, ':')) {
933
-						    $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
934
-						} elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
935
-						    // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
936
-						    $typePrefix = 'xsd';
937
-						} else {
938
-						    foreach($this->typemap as $ns => $types) {
939
-						        if (isset($types[$partType])) {
940
-						            $typePrefix = $this->getPrefixFromNamespace($ns);
941
-						        }
942
-						    }
943
-						    if (!isset($typePrefix)) {
944
-						        die("$partType has no namespace!");
945
-						    }
946
-						}
947
-						$ns = $this->getNamespaceFromPrefix($typePrefix);
948
-						$localPart = $this->getLocalPart($partType);
949
-						$typeDef = $this->getTypeDef($localPart, $ns);
950
-						if ($typeDef['typeClass'] == 'element') {
951
-							$elementortype = 'element';
952
-							if (substr($localPart, -1) == '^') {
953
-								$localPart = substr($localPart, 0, -1);
954
-							}
955
-						} else {
956
-							$elementortype = 'type';
957
-						}
958
-						$xml .= "\n" . '  <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />';
959
-					}
960
-				}
961
-				$xml .= '</message>';
962
-			}
963
-		}
964
-		// bindings & porttypes
965
-		if (count($this->bindings) >= 1) {
966
-			$binding_xml = '';
967
-			$portType_xml = '';
968
-			foreach($this->bindings as $bindingName => $attrs) {
969
-				$binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
970
-				$binding_xml .= "\n" . '  <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
971
-				$portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
972
-				foreach($attrs['operations'] as $opName => $opParts) {
973
-					$binding_xml .= "\n" . '  <operation name="' . $opName . '">';
974
-					$binding_xml .= "\n" . '    <soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>';
975
-					if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
976
-						$enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
977
-					} else {
978
-						$enc_style = '';
979
-					}
980
-					$binding_xml .= "\n" . '    <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
981
-					if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
982
-						$enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
983
-					} else {
984
-						$enc_style = '';
985
-					}
986
-					$binding_xml .= "\n" . '    <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
987
-					$binding_xml .= "\n" . '  </operation>';
988
-					$portType_xml .= "\n" . '  <operation name="' . $opParts['name'] . '"';
989
-					if (isset($opParts['parameterOrder'])) {
990
-					    $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
991
-					}
992
-					$portType_xml .= '>';
993
-					if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
994
-						$portType_xml .= "\n" . '    <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
995
-					}
996
-					$portType_xml .= "\n" . '    <input message="tns:' . $opParts['input']['message'] . '"/>';
997
-					$portType_xml .= "\n" . '    <output message="tns:' . $opParts['output']['message'] . '"/>';
998
-					$portType_xml .= "\n" . '  </operation>';
999
-				}
1000
-				$portType_xml .= "\n" . '</portType>';
1001
-				$binding_xml .= "\n" . '</binding>';
1002
-			}
1003
-			$xml .= $portType_xml . $binding_xml;
1004
-		}
1005
-		// services
1006
-		$xml .= "\n<service name=\"" . $this->serviceName . '">';
1007
-		if (count($this->ports) >= 1) {
1008
-			foreach($this->ports as $pName => $attrs) {
1009
-				$xml .= "\n" . '  <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
1010
-				$xml .= "\n" . '    <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
1011
-				$xml .= "\n" . '  </port>';
1012
-			}
1013
-		}
1014
-		$xml .= "\n" . '</service>';
1015
-		return $xml . "\n</definitions>";
1016
-	}
881
+    /**
882
+     * serialize the parsed wsdl
883
+     *
884
+     * @param mixed $debug whether to put debug=1 in endpoint URL
885
+     * @return string serialization of WSDL
886
+     * @access public
887
+     */
888
+    function serialize($debug = 0)
889
+    {
890
+        $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
891
+        $xml .= "\n<definitions";
892
+        foreach($this->namespaces as $k => $v) {
893
+            $xml .= " xmlns:$k=\"$v\"";
894
+        }
895
+        // 10.9.02 - add poulter fix for wsdl and tns declarations
896
+        if (isset($this->namespaces['wsdl'])) {
897
+            $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
898
+        }
899
+        if (isset($this->namespaces['tns'])) {
900
+            $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
901
+        }
902
+        $xml .= '>';
903
+        // imports
904
+        if (sizeof($this->import) > 0) {
905
+            foreach($this->import as $ns => $list) {
906
+                foreach ($list as $ii) {
907
+                    if ($ii['location'] != '') {
908
+                        $xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />';
909
+                    } else {
910
+                        $xml .= '<import namespace="' . $ns . '" />';
911
+                    }
912
+                }
913
+            }
914
+        }
915
+        // types
916
+        if (count($this->schemas)>=1) {
917
+            $xml .= "\n<types>\n";
918
+            foreach ($this->schemas as $ns => $list) {
919
+                foreach ($list as $xs) {
920
+                    $xml .= $xs->serializeSchema();
921
+                }
922
+            }
923
+            $xml .= '</types>';
924
+        }
925
+        // messages
926
+        if (count($this->messages) >= 1) {
927
+            foreach($this->messages as $msgName => $msgParts) {
928
+                $xml .= "\n<message name=\"" . $msgName . '">';
929
+                if(is_array($msgParts)){
930
+                    foreach($msgParts as $partName => $partType) {
931
+                        // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
932
+                        if (strpos($partType, ':')) {
933
+                            $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
934
+                        } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
935
+                            // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
936
+                            $typePrefix = 'xsd';
937
+                        } else {
938
+                            foreach($this->typemap as $ns => $types) {
939
+                                if (isset($types[$partType])) {
940
+                                    $typePrefix = $this->getPrefixFromNamespace($ns);
941
+                                }
942
+                            }
943
+                            if (!isset($typePrefix)) {
944
+                                die("$partType has no namespace!");
945
+                            }
946
+                        }
947
+                        $ns = $this->getNamespaceFromPrefix($typePrefix);
948
+                        $localPart = $this->getLocalPart($partType);
949
+                        $typeDef = $this->getTypeDef($localPart, $ns);
950
+                        if ($typeDef['typeClass'] == 'element') {
951
+                            $elementortype = 'element';
952
+                            if (substr($localPart, -1) == '^') {
953
+                                $localPart = substr($localPart, 0, -1);
954
+                            }
955
+                        } else {
956
+                            $elementortype = 'type';
957
+                        }
958
+                        $xml .= "\n" . '  <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />';
959
+                    }
960
+                }
961
+                $xml .= '</message>';
962
+            }
963
+        }
964
+        // bindings & porttypes
965
+        if (count($this->bindings) >= 1) {
966
+            $binding_xml = '';
967
+            $portType_xml = '';
968
+            foreach($this->bindings as $bindingName => $attrs) {
969
+                $binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
970
+                $binding_xml .= "\n" . '  <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
971
+                $portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
972
+                foreach($attrs['operations'] as $opName => $opParts) {
973
+                    $binding_xml .= "\n" . '  <operation name="' . $opName . '">';
974
+                    $binding_xml .= "\n" . '    <soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>';
975
+                    if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
976
+                        $enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
977
+                    } else {
978
+                        $enc_style = '';
979
+                    }
980
+                    $binding_xml .= "\n" . '    <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
981
+                    if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
982
+                        $enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
983
+                    } else {
984
+                        $enc_style = '';
985
+                    }
986
+                    $binding_xml .= "\n" . '    <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
987
+                    $binding_xml .= "\n" . '  </operation>';
988
+                    $portType_xml .= "\n" . '  <operation name="' . $opParts['name'] . '"';
989
+                    if (isset($opParts['parameterOrder'])) {
990
+                        $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
991
+                    }
992
+                    $portType_xml .= '>';
993
+                    if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
994
+                        $portType_xml .= "\n" . '    <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
995
+                    }
996
+                    $portType_xml .= "\n" . '    <input message="tns:' . $opParts['input']['message'] . '"/>';
997
+                    $portType_xml .= "\n" . '    <output message="tns:' . $opParts['output']['message'] . '"/>';
998
+                    $portType_xml .= "\n" . '  </operation>';
999
+                }
1000
+                $portType_xml .= "\n" . '</portType>';
1001
+                $binding_xml .= "\n" . '</binding>';
1002
+            }
1003
+            $xml .= $portType_xml . $binding_xml;
1004
+        }
1005
+        // services
1006
+        $xml .= "\n<service name=\"" . $this->serviceName . '">';
1007
+        if (count($this->ports) >= 1) {
1008
+            foreach($this->ports as $pName => $attrs) {
1009
+                $xml .= "\n" . '  <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
1010
+                $xml .= "\n" . '    <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
1011
+                $xml .= "\n" . '  </port>';
1012
+            }
1013
+        }
1014
+        $xml .= "\n" . '</service>';
1015
+        return $xml . "\n</definitions>";
1016
+    }
1017 1017
 
1018
-	/**
1019
-	 * determine whether a set of parameters are unwrapped
1020
-	 * when they are expect to be wrapped, Microsoft-style.
1021
-	 *
1022
-	 * @param string $type the type (element name) of the wrapper
1023
-	 * @param array $parameters the parameter values for the SOAP call
1024
-	 * @return boolean whether they parameters are unwrapped (and should be wrapped)
1025
-	 * @access private
1026
-	 */
1027
-	function parametersMatchWrapped($type, &$parameters) {
1028
-		$this->debug("in parametersMatchWrapped type=$type, parameters=");
1029
-		$this->appendDebug($this->varDump($parameters));
1018
+    /**
1019
+     * determine whether a set of parameters are unwrapped
1020
+     * when they are expect to be wrapped, Microsoft-style.
1021
+     *
1022
+     * @param string $type the type (element name) of the wrapper
1023
+     * @param array $parameters the parameter values for the SOAP call
1024
+     * @return boolean whether they parameters are unwrapped (and should be wrapped)
1025
+     * @access private
1026
+     */
1027
+    function parametersMatchWrapped($type, &$parameters) {
1028
+        $this->debug("in parametersMatchWrapped type=$type, parameters=");
1029
+        $this->appendDebug($this->varDump($parameters));
1030 1030
 
1031
-		// split type into namespace:unqualified-type
1032
-		if (strpos($type, ':')) {
1033
-			$uqType = substr($type, strrpos($type, ':') + 1);
1034
-			$ns = substr($type, 0, strrpos($type, ':'));
1035
-			$this->debug("in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
1036
-			if ($this->getNamespaceFromPrefix($ns)) {
1037
-				$ns = $this->getNamespaceFromPrefix($ns);
1038
-				$this->debug("in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
1039
-			}
1040
-		} else {
1041
-			// TODO: should the type be compared to types in XSD, and the namespace
1042
-			// set to XSD if the type matches?
1043
-			$this->debug("in parametersMatchWrapped: No namespace for type $type");
1044
-			$ns = '';
1045
-			$uqType = $type;
1046
-		}
1031
+        // split type into namespace:unqualified-type
1032
+        if (strpos($type, ':')) {
1033
+            $uqType = substr($type, strrpos($type, ':') + 1);
1034
+            $ns = substr($type, 0, strrpos($type, ':'));
1035
+            $this->debug("in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
1036
+            if ($this->getNamespaceFromPrefix($ns)) {
1037
+                $ns = $this->getNamespaceFromPrefix($ns);
1038
+                $this->debug("in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
1039
+            }
1040
+        } else {
1041
+            // TODO: should the type be compared to types in XSD, and the namespace
1042
+            // set to XSD if the type matches?
1043
+            $this->debug("in parametersMatchWrapped: No namespace for type $type");
1044
+            $ns = '';
1045
+            $uqType = $type;
1046
+        }
1047 1047
 
1048
-		// get the type information
1049
-		if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
1050
-			$this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type.");
1051
-			return false;
1052
-		}
1053
-		$this->debug("in parametersMatchWrapped: found typeDef=");
1054
-		$this->appendDebug($this->varDump($typeDef));
1055
-		if (substr($uqType, -1) == '^') {
1056
-			$uqType = substr($uqType, 0, -1);
1057
-		}
1058
-		$phpType = $typeDef['phpType'];
1059
-		$arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '');
1060
-		$this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
1048
+        // get the type information
1049
+        if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
1050
+            $this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type.");
1051
+            return false;
1052
+        }
1053
+        $this->debug("in parametersMatchWrapped: found typeDef=");
1054
+        $this->appendDebug($this->varDump($typeDef));
1055
+        if (substr($uqType, -1) == '^') {
1056
+            $uqType = substr($uqType, 0, -1);
1057
+        }
1058
+        $phpType = $typeDef['phpType'];
1059
+        $arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '');
1060
+        $this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
1061 1061
 
1062
-		// we expect a complexType or element of complexType
1063
-		if ($phpType != 'struct') {
1064
-			$this->debug("in parametersMatchWrapped: not a struct");
1065
-			return false;
1066
-		}
1062
+        // we expect a complexType or element of complexType
1063
+        if ($phpType != 'struct') {
1064
+            $this->debug("in parametersMatchWrapped: not a struct");
1065
+            return false;
1066
+        }
1067 1067
 
1068
-		// see whether the parameter names match the elements
1069
-		if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1070
-			$elements = 0;
1071
-			$matches = 0;
1072
-			foreach ($typeDef['elements'] as $name => $attrs) {
1073
-				if (isset($parameters[$name])) {
1074
-					$this->debug("in parametersMatchWrapped: have parameter named $name");
1075
-					$matches++;
1076
-				} else {
1077
-					$this->debug("in parametersMatchWrapped: do not have parameter named $name");
1078
-				}
1079
-				$elements++;
1080
-			}
1068
+        // see whether the parameter names match the elements
1069
+        if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1070
+            $elements = 0;
1071
+            $matches = 0;
1072
+            foreach ($typeDef['elements'] as $name => $attrs) {
1073
+                if (isset($parameters[$name])) {
1074
+                    $this->debug("in parametersMatchWrapped: have parameter named $name");
1075
+                    $matches++;
1076
+                } else {
1077
+                    $this->debug("in parametersMatchWrapped: do not have parameter named $name");
1078
+                }
1079
+                $elements++;
1080
+            }
1081 1081
 
1082
-			$this->debug("in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names");
1083
-			if ($matches == 0) {
1084
-				return false;
1085
-			}
1086
-			return true;
1087
-		}
1082
+            $this->debug("in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names");
1083
+            if ($matches == 0) {
1084
+                return false;
1085
+            }
1086
+            return true;
1087
+        }
1088 1088
 
1089
-		// since there are no elements for the type, if the user passed no
1090
-		// parameters, the parameters match wrapped.
1091
-		$this->debug("in parametersMatchWrapped: no elements type $ns:$uqType");
1092
-		return count($parameters) == 0;
1093
-	}
1089
+        // since there are no elements for the type, if the user passed no
1090
+        // parameters, the parameters match wrapped.
1091
+        $this->debug("in parametersMatchWrapped: no elements type $ns:$uqType");
1092
+        return count($parameters) == 0;
1093
+    }
1094 1094
 
1095
-	/**
1096
-	 * serialize PHP values according to a WSDL message definition
1097
-	 * contrary to the method name, this is not limited to RPC
1098
-	 *
1099
-	 * TODO
1100
-	 * - multi-ref serialization
1101
-	 * - validate PHP values against type definitions, return errors if invalid
1102
-	 *
1103
-	 * @param string $operation operation name
1104
-	 * @param string $direction (input|output)
1105
-	 * @param mixed $parameters parameter value(s)
1106
-	 * @param string $bindingType (soap|soap12)
1107
-	 * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1108
-	 * @access public
1109
-	 */
1110
-	function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
1111
-		$this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
1112
-		$this->appendDebug('parameters=' . $this->varDump($parameters));
1095
+    /**
1096
+     * serialize PHP values according to a WSDL message definition
1097
+     * contrary to the method name, this is not limited to RPC
1098
+     *
1099
+     * TODO
1100
+     * - multi-ref serialization
1101
+     * - validate PHP values against type definitions, return errors if invalid
1102
+     *
1103
+     * @param string $operation operation name
1104
+     * @param string $direction (input|output)
1105
+     * @param mixed $parameters parameter value(s)
1106
+     * @param string $bindingType (soap|soap12)
1107
+     * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1108
+     * @access public
1109
+     */
1110
+    function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
1111
+        $this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
1112
+        $this->appendDebug('parameters=' . $this->varDump($parameters));
1113 1113
 
1114
-		if ($direction != 'input' && $direction != 'output') {
1115
-			$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1116
-			$this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1117
-			return false;
1118
-		}
1119
-		if (!$opData = $this->getOperationData($operation, $bindingType)) {
1120
-			$this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1121
-			$this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1122
-			return false;
1123
-		}
1124
-		$this->debug('in serializeRPCParameters: opData:');
1125
-		$this->appendDebug($this->varDump($opData));
1114
+        if ($direction != 'input' && $direction != 'output') {
1115
+            $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1116
+            $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1117
+            return false;
1118
+        }
1119
+        if (!$opData = $this->getOperationData($operation, $bindingType)) {
1120
+            $this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1121
+            $this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1122
+            return false;
1123
+        }
1124
+        $this->debug('in serializeRPCParameters: opData:');
1125
+        $this->appendDebug($this->varDump($opData));
1126 1126
 
1127
-		// Get encoding style for output and set to current
1128
-		$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1129
-		if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1130
-			$encodingStyle = $opData['output']['encodingStyle'];
1131
-			$enc_style = $encodingStyle;
1132
-		}
1127
+        // Get encoding style for output and set to current
1128
+        $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1129
+        if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1130
+            $encodingStyle = $opData['output']['encodingStyle'];
1131
+            $enc_style = $encodingStyle;
1132
+        }
1133 1133
 
1134
-		// set input params
1135
-		$xml = '';
1136
-		if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1137
-			$parts = &$opData[$direction]['parts'];
1138
-			$part_count = sizeof($parts);
1139
-			$style = $opData['style'];
1140
-			$use = $opData[$direction]['use'];
1141
-			$this->debug("have $part_count part(s) to serialize using $style/$use");
1142
-			if (is_array($parameters)) {
1143
-				$parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1144
-				$parameter_count = count($parameters);
1145
-				$this->debug("have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
1146
-				// check for Microsoft-style wrapped parameters
1147
-				if ($style == 'document' && $use == 'literal' && $part_count == 1 && isset($parts['parameters'])) {
1148
-					$this->debug('check whether the caller has wrapped the parameters');
1149
-					if ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1) {
1150
-						// TODO: consider checking here for double-wrapping, when
1151
-						// service function wraps, then NuSOAP wraps again
1152
-						$this->debug("change simple array to associative with 'parameters' element");
1153
-						$parameters['parameters'] = $parameters[0];
1154
-						unset($parameters[0]);
1155
-					}
1156
-					if (($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) {
1157
-						$this->debug('check whether caller\'s parameters match the wrapped ones');
1158
-						if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) {
1159
-							$this->debug('wrap the parameters for the caller');
1160
-							$parameters = array('parameters' => $parameters);
1161
-							$parameter_count = 1;
1162
-						}
1163
-					}
1164
-				}
1165
-				foreach ($parts as $name => $type) {
1166
-					$this->debug("serializing part $name of type $type");
1167
-					// Track encoding style
1168
-					if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1169
-						$encodingStyle = $opData[$direction]['encodingStyle'];
1170
-						$enc_style = $encodingStyle;
1171
-					} else {
1172
-						$enc_style = false;
1173
-					}
1174
-					// NOTE: add error handling here
1175
-					// if serializeType returns false, then catch global error and fault
1176
-					if ($parametersArrayType == 'arraySimple') {
1177
-						$p = array_shift($parameters);
1178
-						$this->debug('calling serializeType w/indexed param');
1179
-						$xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1180
-					} elseif (isset($parameters[$name])) {
1181
-						$this->debug('calling serializeType w/named param');
1182
-						$xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1183
-					} else {
1184
-						// TODO: only send nillable
1185
-						$this->debug('calling serializeType w/null param');
1186
-						$xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1187
-					}
1188
-				}
1189
-			} else {
1190
-				$this->debug('no parameters passed.');
1191
-			}
1192
-		}
1193
-		$this->debug("serializeRPCParameters returning: $xml");
1194
-		return $xml;
1195
-	}
1134
+        // set input params
1135
+        $xml = '';
1136
+        if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1137
+            $parts = &$opData[$direction]['parts'];
1138
+            $part_count = sizeof($parts);
1139
+            $style = $opData['style'];
1140
+            $use = $opData[$direction]['use'];
1141
+            $this->debug("have $part_count part(s) to serialize using $style/$use");
1142
+            if (is_array($parameters)) {
1143
+                $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1144
+                $parameter_count = count($parameters);
1145
+                $this->debug("have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
1146
+                // check for Microsoft-style wrapped parameters
1147
+                if ($style == 'document' && $use == 'literal' && $part_count == 1 && isset($parts['parameters'])) {
1148
+                    $this->debug('check whether the caller has wrapped the parameters');
1149
+                    if ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1) {
1150
+                        // TODO: consider checking here for double-wrapping, when
1151
+                        // service function wraps, then NuSOAP wraps again
1152
+                        $this->debug("change simple array to associative with 'parameters' element");
1153
+                        $parameters['parameters'] = $parameters[0];
1154
+                        unset($parameters[0]);
1155
+                    }
1156
+                    if (($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) {
1157
+                        $this->debug('check whether caller\'s parameters match the wrapped ones');
1158
+                        if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) {
1159
+                            $this->debug('wrap the parameters for the caller');
1160
+                            $parameters = array('parameters' => $parameters);
1161
+                            $parameter_count = 1;
1162
+                        }
1163
+                    }
1164
+                }
1165
+                foreach ($parts as $name => $type) {
1166
+                    $this->debug("serializing part $name of type $type");
1167
+                    // Track encoding style
1168
+                    if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1169
+                        $encodingStyle = $opData[$direction]['encodingStyle'];
1170
+                        $enc_style = $encodingStyle;
1171
+                    } else {
1172
+                        $enc_style = false;
1173
+                    }
1174
+                    // NOTE: add error handling here
1175
+                    // if serializeType returns false, then catch global error and fault
1176
+                    if ($parametersArrayType == 'arraySimple') {
1177
+                        $p = array_shift($parameters);
1178
+                        $this->debug('calling serializeType w/indexed param');
1179
+                        $xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1180
+                    } elseif (isset($parameters[$name])) {
1181
+                        $this->debug('calling serializeType w/named param');
1182
+                        $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1183
+                    } else {
1184
+                        // TODO: only send nillable
1185
+                        $this->debug('calling serializeType w/null param');
1186
+                        $xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1187
+                    }
1188
+                }
1189
+            } else {
1190
+                $this->debug('no parameters passed.');
1191
+            }
1192
+        }
1193
+        $this->debug("serializeRPCParameters returning: $xml");
1194
+        return $xml;
1195
+    }
1196 1196
 
1197
-	/**
1198
-	 * serialize a PHP value according to a WSDL message definition
1199
-	 *
1200
-	 * TODO
1201
-	 * - multi-ref serialization
1202
-	 * - validate PHP values against type definitions, return errors if invalid
1203
-	 *
1204
-	 * @param string $operation operation name
1205
-	 * @param string $direction (input|output)
1206
-	 * @param mixed $parameters parameter value(s)
1207
-	 * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1208
-	 * @access public
1209
-	 * @deprecated
1210
-	 */
1211
-	function serializeParameters($operation, $direction, $parameters)
1212
-	{
1213
-		$this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
1214
-		$this->appendDebug('parameters=' . $this->varDump($parameters));
1197
+    /**
1198
+     * serialize a PHP value according to a WSDL message definition
1199
+     *
1200
+     * TODO
1201
+     * - multi-ref serialization
1202
+     * - validate PHP values against type definitions, return errors if invalid
1203
+     *
1204
+     * @param string $operation operation name
1205
+     * @param string $direction (input|output)
1206
+     * @param mixed $parameters parameter value(s)
1207
+     * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1208
+     * @access public
1209
+     * @deprecated
1210
+     */
1211
+    function serializeParameters($operation, $direction, $parameters)
1212
+    {
1213
+        $this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
1214
+        $this->appendDebug('parameters=' . $this->varDump($parameters));
1215 1215
 
1216
-		if ($direction != 'input' && $direction != 'output') {
1217
-			$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1218
-			$this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1219
-			return false;
1220
-		}
1221
-		if (!$opData = $this->getOperationData($operation)) {
1222
-			$this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
1223
-			$this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
1224
-			return false;
1225
-		}
1226
-		$this->debug('opData:');
1227
-		$this->appendDebug($this->varDump($opData));
1216
+        if ($direction != 'input' && $direction != 'output') {
1217
+            $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1218
+            $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1219
+            return false;
1220
+        }
1221
+        if (!$opData = $this->getOperationData($operation)) {
1222
+            $this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
1223
+            $this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
1224
+            return false;
1225
+        }
1226
+        $this->debug('opData:');
1227
+        $this->appendDebug($this->varDump($opData));
1228 1228
 
1229
-		// Get encoding style for output and set to current
1230
-		$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1231
-		if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1232
-			$encodingStyle = $opData['output']['encodingStyle'];
1233
-			$enc_style = $encodingStyle;
1234
-		}
1229
+        // Get encoding style for output and set to current
1230
+        $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1231
+        if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1232
+            $encodingStyle = $opData['output']['encodingStyle'];
1233
+            $enc_style = $encodingStyle;
1234
+        }
1235 1235
 
1236
-		// set input params
1237
-		$xml = '';
1238
-		if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1236
+        // set input params
1237
+        $xml = '';
1238
+        if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1239 1239
 
1240
-			$use = $opData[$direction]['use'];
1241
-			$this->debug("use=$use");
1242
-			$this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
1243
-			if (is_array($parameters)) {
1244
-				$parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1245
-				$this->debug('have ' . $parametersArrayType . ' parameters');
1246
-				foreach($opData[$direction]['parts'] as $name => $type) {
1247
-					$this->debug('serializing part "'.$name.'" of type "'.$type.'"');
1248
-					// Track encoding style
1249
-					if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1250
-						$encodingStyle = $opData[$direction]['encodingStyle'];
1251
-						$enc_style = $encodingStyle;
1252
-					} else {
1253
-						$enc_style = false;
1254
-					}
1255
-					// NOTE: add error handling here
1256
-					// if serializeType returns false, then catch global error and fault
1257
-					if ($parametersArrayType == 'arraySimple') {
1258
-						$p = array_shift($parameters);
1259
-						$this->debug('calling serializeType w/indexed param');
1260
-						$xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1261
-					} elseif (isset($parameters[$name])) {
1262
-						$this->debug('calling serializeType w/named param');
1263
-						$xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1264
-					} else {
1265
-						// TODO: only send nillable
1266
-						$this->debug('calling serializeType w/null param');
1267
-						$xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1268
-					}
1269
-				}
1270
-			} else {
1271
-				$this->debug('no parameters passed.');
1272
-			}
1273
-		}
1274
-		$this->debug("serializeParameters returning: $xml");
1275
-		return $xml;
1276
-	}
1240
+            $use = $opData[$direction]['use'];
1241
+            $this->debug("use=$use");
1242
+            $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
1243
+            if (is_array($parameters)) {
1244
+                $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1245
+                $this->debug('have ' . $parametersArrayType . ' parameters');
1246
+                foreach($opData[$direction]['parts'] as $name => $type) {
1247
+                    $this->debug('serializing part "'.$name.'" of type "'.$type.'"');
1248
+                    // Track encoding style
1249
+                    if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1250
+                        $encodingStyle = $opData[$direction]['encodingStyle'];
1251
+                        $enc_style = $encodingStyle;
1252
+                    } else {
1253
+                        $enc_style = false;
1254
+                    }
1255
+                    // NOTE: add error handling here
1256
+                    // if serializeType returns false, then catch global error and fault
1257
+                    if ($parametersArrayType == 'arraySimple') {
1258
+                        $p = array_shift($parameters);
1259
+                        $this->debug('calling serializeType w/indexed param');
1260
+                        $xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1261
+                    } elseif (isset($parameters[$name])) {
1262
+                        $this->debug('calling serializeType w/named param');
1263
+                        $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1264
+                    } else {
1265
+                        // TODO: only send nillable
1266
+                        $this->debug('calling serializeType w/null param');
1267
+                        $xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1268
+                    }
1269
+                }
1270
+            } else {
1271
+                $this->debug('no parameters passed.');
1272
+            }
1273
+        }
1274
+        $this->debug("serializeParameters returning: $xml");
1275
+        return $xml;
1276
+    }
1277 1277
 
1278
-	/**
1279
-	 * serializes a PHP value according a given type definition
1280
-	 *
1281
-	 * @param string $name name of value (part or element)
1282
-	 * @param string $type XML schema type of value (type or element)
1283
-	 * @param mixed $value a native PHP value (parameter value)
1284
-	 * @param string $use use for part (encoded|literal)
1285
-	 * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1286
-	 * @param boolean $unqualified a kludge for what should be XML namespace form handling
1287
-	 * @return string value serialized as an XML string
1288
-	 * @access private
1289
-	 */
1290
-	function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false)
1291
-	{
1292
-		$this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
1293
-		$this->appendDebug("value=" . $this->varDump($value));
1294
-		if($use == 'encoded' && $encodingStyle) {
1295
-			$encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
1296
-		}
1278
+    /**
1279
+     * serializes a PHP value according a given type definition
1280
+     *
1281
+     * @param string $name name of value (part or element)
1282
+     * @param string $type XML schema type of value (type or element)
1283
+     * @param mixed $value a native PHP value (parameter value)
1284
+     * @param string $use use for part (encoded|literal)
1285
+     * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1286
+     * @param boolean $unqualified a kludge for what should be XML namespace form handling
1287
+     * @return string value serialized as an XML string
1288
+     * @access private
1289
+     */
1290
+    function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false)
1291
+    {
1292
+        $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
1293
+        $this->appendDebug("value=" . $this->varDump($value));
1294
+        if($use == 'encoded' && $encodingStyle) {
1295
+            $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
1296
+        }
1297 1297
 
1298
-		// if a soapval has been supplied, let its type override the WSDL
1299
-    	if (is_object($value) && get_class($value) == 'soapval') {
1300
-    		if ($value->type_ns) {
1301
-    			$type = $value->type_ns . ':' . $value->type;
1302
-		    	$forceType = true;
1303
-		    	$this->debug("in serializeType: soapval overrides type to $type");
1304
-    		} elseif ($value->type) {
1305
-	    		$type = $value->type;
1306
-		    	$forceType = true;
1307
-		    	$this->debug("in serializeType: soapval overrides type to $type");
1308
-	    	} else {
1309
-	    		$forceType = false;
1310
-		    	$this->debug("in serializeType: soapval does not override type");
1311
-	    	}
1312
-	    	$attrs = $value->attributes;
1313
-	    	$value = $value->value;
1314
-	    	$this->debug("in serializeType: soapval overrides value to $value");
1315
-	    	if ($attrs) {
1316
-	    		if (!is_array($value)) {
1317
-	    			$value['!'] = $value;
1318
-	    		}
1319
-	    		foreach ($attrs as $n => $v) {
1320
-	    			$value['!' . $n] = $v;
1321
-	    		}
1322
-		    	$this->debug("in serializeType: soapval provides attributes");
1323
-		    }
1298
+        // if a soapval has been supplied, let its type override the WSDL
1299
+        if (is_object($value) && get_class($value) == 'soapval') {
1300
+            if ($value->type_ns) {
1301
+                $type = $value->type_ns . ':' . $value->type;
1302
+                $forceType = true;
1303
+                $this->debug("in serializeType: soapval overrides type to $type");
1304
+            } elseif ($value->type) {
1305
+                $type = $value->type;
1306
+                $forceType = true;
1307
+                $this->debug("in serializeType: soapval overrides type to $type");
1308
+            } else {
1309
+                $forceType = false;
1310
+                $this->debug("in serializeType: soapval does not override type");
1311
+            }
1312
+            $attrs = $value->attributes;
1313
+            $value = $value->value;
1314
+            $this->debug("in serializeType: soapval overrides value to $value");
1315
+            if ($attrs) {
1316
+                if (!is_array($value)) {
1317
+                    $value['!'] = $value;
1318
+                }
1319
+                foreach ($attrs as $n => $v) {
1320
+                    $value['!' . $n] = $v;
1321
+                }
1322
+                $this->debug("in serializeType: soapval provides attributes");
1323
+            }
1324 1324
         } else {
1325
-        	$forceType = false;
1325
+            $forceType = false;
1326 1326
         }
1327 1327
 
1328
-		$xml = '';
1329
-		if (strpos($type, ':')) {
1330
-			$uqType = substr($type, strrpos($type, ':') + 1);
1331
-			$ns = substr($type, 0, strrpos($type, ':'));
1332
-			$this->debug("in serializeType: got a prefixed type: $uqType, $ns");
1333
-			if ($this->getNamespaceFromPrefix($ns)) {
1334
-				$ns = $this->getNamespaceFromPrefix($ns);
1335
-				$this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
1336
-			}
1328
+        $xml = '';
1329
+        if (strpos($type, ':')) {
1330
+            $uqType = substr($type, strrpos($type, ':') + 1);
1331
+            $ns = substr($type, 0, strrpos($type, ':'));
1332
+            $this->debug("in serializeType: got a prefixed type: $uqType, $ns");
1333
+            if ($this->getNamespaceFromPrefix($ns)) {
1334
+                $ns = $this->getNamespaceFromPrefix($ns);
1335
+                $this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
1336
+            }
1337 1337
 
1338
-			if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
1339
-				$this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
1340
-				if ($unqualified && $use == 'literal') {
1341
-					$elementNS = " xmlns=\"\"";
1342
-				} else {
1343
-					$elementNS = '';
1344
-				}
1345
-				if (is_null($value)) {
1346
-					if ($use == 'literal') {
1347
-						// TODO: depends on minOccurs
1348
-						$xml = "<$name$elementNS/>";
1349
-					} else {
1350
-						// TODO: depends on nillable, which should be checked before calling this method
1351
-						$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1352
-					}
1353
-					$this->debug("in serializeType: returning: $xml");
1354
-					return $xml;
1355
-				}
1356
-				if ($uqType == 'Array') {
1357
-					// JBoss/Axis does this sometimes
1358
-					return $this->serialize_val($value, $name, false, false, false, false, $use);
1359
-				}
1360
-		    	if ($uqType == 'boolean') {
1361
-		    		if ((is_string($value) && $value == 'false') || (! $value)) {
1362
-						$value = 'false';
1363
-					} else {
1364
-						$value = 'true';
1365
-					}
1366
-				}
1367
-				if ($uqType == 'string' && gettype($value) == 'string') {
1368
-					$value = $this->expandEntities($value);
1369
-				}
1370
-				if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') {
1371
-					$value = sprintf("%.0lf", $value);
1372
-				}
1373
-				// it's a scalar
1374
-				// TODO: what about null/nil values?
1375
-				// check type isn't a custom type extending xmlschema namespace
1376
-				if (!$this->getTypeDef($uqType, $ns)) {
1377
-					if ($use == 'literal') {
1378
-						if ($forceType) {
1379
-							$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1380
-						} else {
1381
-							$xml = "<$name$elementNS>$value</$name>";
1382
-						}
1383
-					} else {
1384
-						$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1385
-					}
1386
-					$this->debug("in serializeType: returning: $xml");
1387
-					return $xml;
1388
-				}
1389
-				$this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
1390
-			} else if ($ns == 'http://xml.apache.org/xml-soap') {
1391
-				$this->debug('in serializeType: appears to be Apache SOAP type');
1392
-				if ($uqType == 'Map') {
1393
-					$tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1394
-					if (! $tt_prefix) {
1395
-						$this->debug('in serializeType: Add namespace for Apache SOAP type');
1396
-						$tt_prefix = 'ns' . rand(1000, 9999);
1397
-						$this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
1398
-						// force this to be added to usedNamespaces
1399
-						$tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1400
-					}
1401
-					$contents = '';
1402
-					foreach($value as $k => $v) {
1403
-						$this->debug("serializing map element: key $k, value $v");
1404
-						$contents .= '<item>';
1405
-						$contents .= $this->serialize_val($k,'key',false,false,false,false,$use);
1406
-						$contents .= $this->serialize_val($v,'value',false,false,false,false,$use);
1407
-						$contents .= '</item>';
1408
-					}
1409
-					if ($use == 'literal') {
1410
-						if ($forceType) {
1411
-							$xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>";
1412
-						} else {
1413
-							$xml = "<$name>$contents</$name>";
1414
-						}
1415
-					} else {
1416
-						$xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>";
1417
-					}
1418
-					$this->debug("in serializeType: returning: $xml");
1419
-					return $xml;
1420
-				}
1421
-				$this->debug('in serializeType: Apache SOAP type, but only support Map');
1422
-			}
1423
-		} else {
1424
-			// TODO: should the type be compared to types in XSD, and the namespace
1425
-			// set to XSD if the type matches?
1426
-			$this->debug("in serializeType: No namespace for type $type");
1427
-			$ns = '';
1428
-			$uqType = $type;
1429
-		}
1430
-		if(!$typeDef = $this->getTypeDef($uqType, $ns)){
1431
-			$this->setError("$type ($uqType) is not a supported type.");
1432
-			$this->debug("in serializeType: $type ($uqType) is not a supported type.");
1433
-			return false;
1434
-		} else {
1435
-			$this->debug("in serializeType: found typeDef");
1436
-			$this->appendDebug('typeDef=' . $this->varDump($typeDef));
1437
-			if (substr($uqType, -1) == '^') {
1438
-				$uqType = substr($uqType, 0, -1);
1439
-			}
1440
-		}
1441
-		if (!isset($typeDef['phpType'])) {
1442
-			$this->setError("$type ($uqType) has no phpType.");
1443
-			$this->debug("in serializeType: $type ($uqType) has no phpType.");
1444
-			return false;
1445
-		}
1446
-		$phpType = $typeDef['phpType'];
1447
-		$this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
1448
-		// if php type == struct, map value to the <all> element names
1449
-		if ($phpType == 'struct') {
1450
-			if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
1451
-				$elementName = $uqType;
1452
-				if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1453
-					$elementNS = " xmlns=\"$ns\"";
1454
-				} else {
1455
-					$elementNS = " xmlns=\"\"";
1456
-				}
1457
-			} else {
1458
-				$elementName = $name;
1459
-				if ($unqualified) {
1460
-					$elementNS = " xmlns=\"\"";
1461
-				} else {
1462
-					$elementNS = '';
1463
-				}
1464
-			}
1465
-			if (is_null($value)) {
1466
-				if ($use == 'literal') {
1467
-					// TODO: depends on minOccurs and nillable
1468
-					$xml = "<$elementName$elementNS/>";
1469
-				} else {
1470
-					$xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1471
-				}
1472
-				$this->debug("in serializeType: returning: $xml");
1473
-				return $xml;
1474
-			}
1475
-			if (is_object($value)) {
1476
-				$value = get_object_vars($value);
1477
-			}
1478
-			if (is_array($value)) {
1479
-				$elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
1480
-				if ($use == 'literal') {
1481
-					if ($forceType) {
1482
-						$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
1483
-					} else {
1484
-						$xml = "<$elementName$elementNS$elementAttrs>";
1485
-					}
1486
-				} else {
1487
-					$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
1488
-				}
1338
+            if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
1339
+                $this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
1340
+                if ($unqualified && $use == 'literal') {
1341
+                    $elementNS = " xmlns=\"\"";
1342
+                } else {
1343
+                    $elementNS = '';
1344
+                }
1345
+                if (is_null($value)) {
1346
+                    if ($use == 'literal') {
1347
+                        // TODO: depends on minOccurs
1348
+                        $xml = "<$name$elementNS/>";
1349
+                    } else {
1350
+                        // TODO: depends on nillable, which should be checked before calling this method
1351
+                        $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1352
+                    }
1353
+                    $this->debug("in serializeType: returning: $xml");
1354
+                    return $xml;
1355
+                }
1356
+                if ($uqType == 'Array') {
1357
+                    // JBoss/Axis does this sometimes
1358
+                    return $this->serialize_val($value, $name, false, false, false, false, $use);
1359
+                }
1360
+                if ($uqType == 'boolean') {
1361
+                    if ((is_string($value) && $value == 'false') || (! $value)) {
1362
+                        $value = 'false';
1363
+                    } else {
1364
+                        $value = 'true';
1365
+                    }
1366
+                }
1367
+                if ($uqType == 'string' && gettype($value) == 'string') {
1368
+                    $value = $this->expandEntities($value);
1369
+                }
1370
+                if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') {
1371
+                    $value = sprintf("%.0lf", $value);
1372
+                }
1373
+                // it's a scalar
1374
+                // TODO: what about null/nil values?
1375
+                // check type isn't a custom type extending xmlschema namespace
1376
+                if (!$this->getTypeDef($uqType, $ns)) {
1377
+                    if ($use == 'literal') {
1378
+                        if ($forceType) {
1379
+                            $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1380
+                        } else {
1381
+                            $xml = "<$name$elementNS>$value</$name>";
1382
+                        }
1383
+                    } else {
1384
+                        $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1385
+                    }
1386
+                    $this->debug("in serializeType: returning: $xml");
1387
+                    return $xml;
1388
+                }
1389
+                $this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
1390
+            } else if ($ns == 'http://xml.apache.org/xml-soap') {
1391
+                $this->debug('in serializeType: appears to be Apache SOAP type');
1392
+                if ($uqType == 'Map') {
1393
+                    $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1394
+                    if (! $tt_prefix) {
1395
+                        $this->debug('in serializeType: Add namespace for Apache SOAP type');
1396
+                        $tt_prefix = 'ns' . rand(1000, 9999);
1397
+                        $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
1398
+                        // force this to be added to usedNamespaces
1399
+                        $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1400
+                    }
1401
+                    $contents = '';
1402
+                    foreach($value as $k => $v) {
1403
+                        $this->debug("serializing map element: key $k, value $v");
1404
+                        $contents .= '<item>';
1405
+                        $contents .= $this->serialize_val($k,'key',false,false,false,false,$use);
1406
+                        $contents .= $this->serialize_val($v,'value',false,false,false,false,$use);
1407
+                        $contents .= '</item>';
1408
+                    }
1409
+                    if ($use == 'literal') {
1410
+                        if ($forceType) {
1411
+                            $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>";
1412
+                        } else {
1413
+                            $xml = "<$name>$contents</$name>";
1414
+                        }
1415
+                    } else {
1416
+                        $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>";
1417
+                    }
1418
+                    $this->debug("in serializeType: returning: $xml");
1419
+                    return $xml;
1420
+                }
1421
+                $this->debug('in serializeType: Apache SOAP type, but only support Map');
1422
+            }
1423
+        } else {
1424
+            // TODO: should the type be compared to types in XSD, and the namespace
1425
+            // set to XSD if the type matches?
1426
+            $this->debug("in serializeType: No namespace for type $type");
1427
+            $ns = '';
1428
+            $uqType = $type;
1429
+        }
1430
+        if(!$typeDef = $this->getTypeDef($uqType, $ns)){
1431
+            $this->setError("$type ($uqType) is not a supported type.");
1432
+            $this->debug("in serializeType: $type ($uqType) is not a supported type.");
1433
+            return false;
1434
+        } else {
1435
+            $this->debug("in serializeType: found typeDef");
1436
+            $this->appendDebug('typeDef=' . $this->varDump($typeDef));
1437
+            if (substr($uqType, -1) == '^') {
1438
+                $uqType = substr($uqType, 0, -1);
1439
+            }
1440
+        }
1441
+        if (!isset($typeDef['phpType'])) {
1442
+            $this->setError("$type ($uqType) has no phpType.");
1443
+            $this->debug("in serializeType: $type ($uqType) has no phpType.");
1444
+            return false;
1445
+        }
1446
+        $phpType = $typeDef['phpType'];
1447
+        $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
1448
+        // if php type == struct, map value to the <all> element names
1449
+        if ($phpType == 'struct') {
1450
+            if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
1451
+                $elementName = $uqType;
1452
+                if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1453
+                    $elementNS = " xmlns=\"$ns\"";
1454
+                } else {
1455
+                    $elementNS = " xmlns=\"\"";
1456
+                }
1457
+            } else {
1458
+                $elementName = $name;
1459
+                if ($unqualified) {
1460
+                    $elementNS = " xmlns=\"\"";
1461
+                } else {
1462
+                    $elementNS = '';
1463
+                }
1464
+            }
1465
+            if (is_null($value)) {
1466
+                if ($use == 'literal') {
1467
+                    // TODO: depends on minOccurs and nillable
1468
+                    $xml = "<$elementName$elementNS/>";
1469
+                } else {
1470
+                    $xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1471
+                }
1472
+                $this->debug("in serializeType: returning: $xml");
1473
+                return $xml;
1474
+            }
1475
+            if (is_object($value)) {
1476
+                $value = get_object_vars($value);
1477
+            }
1478
+            if (is_array($value)) {
1479
+                $elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
1480
+                if ($use == 'literal') {
1481
+                    if ($forceType) {
1482
+                        $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
1483
+                    } else {
1484
+                        $xml = "<$elementName$elementNS$elementAttrs>";
1485
+                    }
1486
+                } else {
1487
+                    $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
1488
+                }
1489 1489
 
1490
-				if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
1491
-					if (isset($value['!'])) {
1492
-						$xml .= $value['!'];
1493
-						$this->debug("in serializeType: serialized simpleContent for type $type");
1494
-					} else {
1495
-						$this->debug("in serializeType: no simpleContent to serialize for type $type");
1496
-					}
1497
-				} else {
1498
-					// complexContent
1499
-					$xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
1500
-				}
1501
-				$xml .= "</$elementName>";
1502
-			} else {
1503
-				$this->debug("in serializeType: phpType is struct, but value is not an array");
1504
-				$this->setError("phpType is struct, but value is not an array: see debug output for details");
1505
-				$xml = '';
1506
-			}
1507
-		} elseif ($phpType == 'array') {
1508
-			if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1509
-				$elementNS = " xmlns=\"$ns\"";
1510
-			} else {
1511
-				if ($unqualified) {
1512
-					$elementNS = " xmlns=\"\"";
1513
-				} else {
1514
-					$elementNS = '';
1515
-				}
1516
-			}
1517
-			if (is_null($value)) {
1518
-				if ($use == 'literal') {
1519
-					// TODO: depends on minOccurs
1520
-					$xml = "<$name$elementNS/>";
1521
-				} else {
1522
-					$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
1523
-						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1524
-						":Array\" " .
1525
-						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1526
-						':arrayType="' .
1527
-						$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
1528
-						':' .
1529
-						$this->getLocalPart($typeDef['arrayType'])."[0]\"/>";
1530
-				}
1531
-				$this->debug("in serializeType: returning: $xml");
1532
-				return $xml;
1533
-			}
1534
-			if (isset($typeDef['multidimensional'])) {
1535
-				$nv = array();
1536
-				foreach($value as $v) {
1537
-					$cols = ',' . sizeof($v);
1538
-					$nv = array_merge($nv, $v);
1539
-				}
1540
-				$value = $nv;
1541
-			} else {
1542
-				$cols = '';
1543
-			}
1544
-			if (is_array($value) && sizeof($value) >= 1) {
1545
-				$rows = sizeof($value);
1546
-				$contents = '';
1547
-				foreach($value as $k => $v) {
1548
-					//$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
1549
-					//if (strpos($typeDef['arrayType'], ':') ) {
1550
-					if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
1551
-					    $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
1552
-					} else {
1553
-					    $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
1554
-					}
1555
-				}
1556
-			} else {
1557
-				$rows = 0;
1558
-				$contents = null;
1559
-			}
1560
-			// TODO: for now, an empty value will be serialized as a zero element
1561
-			// array.  Revisit this when coding the handling of null/nil values.
1562
-			if ($use == 'literal') {
1563
-				$xml = "<$name$elementNS>"
1564
-					.$contents
1565
-					."</$name>";
1566
-			} else {
1567
-				$xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '.
1568
-					$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
1569
-					.':arrayType="'
1570
-					.$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
1571
-					.":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">"
1572
-					.$contents
1573
-					."</$name>";
1574
-			}
1575
-		} elseif ($phpType == 'scalar') {
1576
-			if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1577
-				$elementNS = " xmlns=\"$ns\"";
1578
-			} else {
1579
-				if ($unqualified) {
1580
-					$elementNS = " xmlns=\"\"";
1581
-				} else {
1582
-					$elementNS = '';
1583
-				}
1584
-			}
1585
-			if ($use == 'literal') {
1586
-				if ($forceType) {
1587
-					$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1588
-				} else {
1589
-					$xml = "<$name$elementNS>$value</$name>";
1590
-				}
1591
-			} else {
1592
-				$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1593
-			}
1594
-		}
1595
-		$this->debug("in serializeType: returning: $xml");
1596
-		return $xml;
1597
-	}
1490
+                if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
1491
+                    if (isset($value['!'])) {
1492
+                        $xml .= $value['!'];
1493
+                        $this->debug("in serializeType: serialized simpleContent for type $type");
1494
+                    } else {
1495
+                        $this->debug("in serializeType: no simpleContent to serialize for type $type");
1496
+                    }
1497
+                } else {
1498
+                    // complexContent
1499
+                    $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
1500
+                }
1501
+                $xml .= "</$elementName>";
1502
+            } else {
1503
+                $this->debug("in serializeType: phpType is struct, but value is not an array");
1504
+                $this->setError("phpType is struct, but value is not an array: see debug output for details");
1505
+                $xml = '';
1506
+            }
1507
+        } elseif ($phpType == 'array') {
1508
+            if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1509
+                $elementNS = " xmlns=\"$ns\"";
1510
+            } else {
1511
+                if ($unqualified) {
1512
+                    $elementNS = " xmlns=\"\"";
1513
+                } else {
1514
+                    $elementNS = '';
1515
+                }
1516
+            }
1517
+            if (is_null($value)) {
1518
+                if ($use == 'literal') {
1519
+                    // TODO: depends on minOccurs
1520
+                    $xml = "<$name$elementNS/>";
1521
+                } else {
1522
+                    $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
1523
+                        $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1524
+                        ":Array\" " .
1525
+                        $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1526
+                        ':arrayType="' .
1527
+                        $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
1528
+                        ':' .
1529
+                        $this->getLocalPart($typeDef['arrayType'])."[0]\"/>";
1530
+                }
1531
+                $this->debug("in serializeType: returning: $xml");
1532
+                return $xml;
1533
+            }
1534
+            if (isset($typeDef['multidimensional'])) {
1535
+                $nv = array();
1536
+                foreach($value as $v) {
1537
+                    $cols = ',' . sizeof($v);
1538
+                    $nv = array_merge($nv, $v);
1539
+                }
1540
+                $value = $nv;
1541
+            } else {
1542
+                $cols = '';
1543
+            }
1544
+            if (is_array($value) && sizeof($value) >= 1) {
1545
+                $rows = sizeof($value);
1546
+                $contents = '';
1547
+                foreach($value as $k => $v) {
1548
+                    //$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
1549
+                    //if (strpos($typeDef['arrayType'], ':') ) {
1550
+                    if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
1551
+                        $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
1552
+                    } else {
1553
+                        $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
1554
+                    }
1555
+                }
1556
+            } else {
1557
+                $rows = 0;
1558
+                $contents = null;
1559
+            }
1560
+            // TODO: for now, an empty value will be serialized as a zero element
1561
+            // array.  Revisit this when coding the handling of null/nil values.
1562
+            if ($use == 'literal') {
1563
+                $xml = "<$name$elementNS>"
1564
+                    .$contents
1565
+                    ."</$name>";
1566
+            } else {
1567
+                $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '.
1568
+                    $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
1569
+                    .':arrayType="'
1570
+                    .$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
1571
+                    .":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">"
1572
+                    .$contents
1573
+                    ."</$name>";
1574
+            }
1575
+        } elseif ($phpType == 'scalar') {
1576
+            if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1577
+                $elementNS = " xmlns=\"$ns\"";
1578
+            } else {
1579
+                if ($unqualified) {
1580
+                    $elementNS = " xmlns=\"\"";
1581
+                } else {
1582
+                    $elementNS = '';
1583
+                }
1584
+            }
1585
+            if ($use == 'literal') {
1586
+                if ($forceType) {
1587
+                    $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1588
+                } else {
1589
+                    $xml = "<$name$elementNS>$value</$name>";
1590
+                }
1591
+            } else {
1592
+                $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1593
+            }
1594
+        }
1595
+        $this->debug("in serializeType: returning: $xml");
1596
+        return $xml;
1597
+    }
1598 1598
 
1599
-	/**
1600
-	 * serializes the attributes for a complexType
1601
-	 *
1602
-	 * @param array $typeDef our internal representation of an XML schema type (or element)
1603
-	 * @param mixed $value a native PHP value (parameter value)
1604
-	 * @param string $ns the namespace of the type
1605
-	 * @param string $uqType the local part of the type
1606
-	 * @return string value serialized as an XML string
1607
-	 * @access private
1608
-	 */
1609
-	function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
1610
-		$this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType");
1611
-		$xml = '';
1612
-		if (isset($typeDef['extensionBase'])) {
1613
-			$nsx = $this->getPrefix($typeDef['extensionBase']);
1614
-			$uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1615
-			if ($this->getNamespaceFromPrefix($nsx)) {
1616
-				$nsx = $this->getNamespaceFromPrefix($nsx);
1617
-			}
1618
-			if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1619
-				$this->debug("serialize attributes for extension base $nsx:$uqTypex");
1620
-				$xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex);
1621
-			} else {
1622
-				$this->debug("extension base $nsx:$uqTypex is not a supported type");
1623
-			}
1624
-		}
1625
-		if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
1626
-			$this->debug("serialize attributes for XML Schema type $ns:$uqType");
1627
-			if (is_array($value)) {
1628
-				$xvalue = $value;
1629
-			} elseif (is_object($value)) {
1630
-				$xvalue = get_object_vars($value);
1631
-			} else {
1632
-				$this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1633
-				$xvalue = array();
1634
-			}
1635
-			foreach ($typeDef['attrs'] as $aName => $attrs) {
1636
-				if (isset($xvalue['!' . $aName])) {
1637
-					$xname = '!' . $aName;
1638
-					$this->debug("value provided for attribute $aName with key $xname");
1639
-				} elseif (isset($xvalue[$aName])) {
1640
-					$xname = $aName;
1641
-					$this->debug("value provided for attribute $aName with key $xname");
1642
-				} elseif (isset($attrs['default'])) {
1643
-					$xname = '!' . $aName;
1644
-					$xvalue[$xname] = $attrs['default'];
1645
-					$this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
1646
-				} else {
1647
-					$xname = '';
1648
-					$this->debug("no value provided for attribute $aName");
1649
-				}
1650
-				if ($xname) {
1651
-					$xml .=  " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
1652
-				}
1653
-			}
1654
-		} else {
1655
-			$this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
1656
-		}
1657
-		return $xml;
1658
-	}
1599
+    /**
1600
+     * serializes the attributes for a complexType
1601
+     *
1602
+     * @param array $typeDef our internal representation of an XML schema type (or element)
1603
+     * @param mixed $value a native PHP value (parameter value)
1604
+     * @param string $ns the namespace of the type
1605
+     * @param string $uqType the local part of the type
1606
+     * @return string value serialized as an XML string
1607
+     * @access private
1608
+     */
1609
+    function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
1610
+        $this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType");
1611
+        $xml = '';
1612
+        if (isset($typeDef['extensionBase'])) {
1613
+            $nsx = $this->getPrefix($typeDef['extensionBase']);
1614
+            $uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1615
+            if ($this->getNamespaceFromPrefix($nsx)) {
1616
+                $nsx = $this->getNamespaceFromPrefix($nsx);
1617
+            }
1618
+            if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1619
+                $this->debug("serialize attributes for extension base $nsx:$uqTypex");
1620
+                $xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex);
1621
+            } else {
1622
+                $this->debug("extension base $nsx:$uqTypex is not a supported type");
1623
+            }
1624
+        }
1625
+        if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
1626
+            $this->debug("serialize attributes for XML Schema type $ns:$uqType");
1627
+            if (is_array($value)) {
1628
+                $xvalue = $value;
1629
+            } elseif (is_object($value)) {
1630
+                $xvalue = get_object_vars($value);
1631
+            } else {
1632
+                $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1633
+                $xvalue = array();
1634
+            }
1635
+            foreach ($typeDef['attrs'] as $aName => $attrs) {
1636
+                if (isset($xvalue['!' . $aName])) {
1637
+                    $xname = '!' . $aName;
1638
+                    $this->debug("value provided for attribute $aName with key $xname");
1639
+                } elseif (isset($xvalue[$aName])) {
1640
+                    $xname = $aName;
1641
+                    $this->debug("value provided for attribute $aName with key $xname");
1642
+                } elseif (isset($attrs['default'])) {
1643
+                    $xname = '!' . $aName;
1644
+                    $xvalue[$xname] = $attrs['default'];
1645
+                    $this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
1646
+                } else {
1647
+                    $xname = '';
1648
+                    $this->debug("no value provided for attribute $aName");
1649
+                }
1650
+                if ($xname) {
1651
+                    $xml .=  " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
1652
+                }
1653
+            }
1654
+        } else {
1655
+            $this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
1656
+        }
1657
+        return $xml;
1658
+    }
1659 1659
 
1660
-	/**
1661
-	 * serializes the elements for a complexType
1662
-	 *
1663
-	 * @param array $typeDef our internal representation of an XML schema type (or element)
1664
-	 * @param mixed $value a native PHP value (parameter value)
1665
-	 * @param string $ns the namespace of the type
1666
-	 * @param string $uqType the local part of the type
1667
-	 * @param string $use use for part (encoded|literal)
1668
-	 * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1669
-	 * @return string value serialized as an XML string
1670
-	 * @access private
1671
-	 */
1672
-	function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
1673
-		$this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
1674
-		$xml = '';
1675
-		if (isset($typeDef['extensionBase'])) {
1676
-			$nsx = $this->getPrefix($typeDef['extensionBase']);
1677
-			$uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1678
-			if ($this->getNamespaceFromPrefix($nsx)) {
1679
-				$nsx = $this->getNamespaceFromPrefix($nsx);
1680
-			}
1681
-			if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1682
-				$this->debug("serialize elements for extension base $nsx:$uqTypex");
1683
-				$xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle);
1684
-			} else {
1685
-				$this->debug("extension base $nsx:$uqTypex is not a supported type");
1686
-			}
1687
-		}
1688
-		if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1689
-			$this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
1690
-			if (is_array($value)) {
1691
-				$xvalue = $value;
1692
-			} elseif (is_object($value)) {
1693
-				$xvalue = get_object_vars($value);
1694
-			} else {
1695
-				$this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1696
-				$xvalue = array();
1697
-			}
1698
-			// toggle whether all elements are present - ideally should validate against schema
1699
-			if (count($typeDef['elements']) != count($xvalue)){
1700
-				$optionals = true;
1701
-			}
1702
-			foreach ($typeDef['elements'] as $eName => $attrs) {
1703
-				if (!isset($xvalue[$eName])) {
1704
-					if (isset($attrs['default'])) {
1705
-						$xvalue[$eName] = $attrs['default'];
1706
-						$this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
1707
-					}
1708
-				}
1709
-				// if user took advantage of a minOccurs=0, then only serialize named parameters
1710
-				if (isset($optionals)
1711
-				    && (!isset($xvalue[$eName]))
1712
-					&& ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
1713
-					){
1714
-					if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
1715
-						$this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
1716
-					}
1717
-					// do nothing
1718
-					$this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
1719
-				} else {
1720
-					// get value
1721
-					if (isset($xvalue[$eName])) {
1722
-					    $v = $xvalue[$eName];
1723
-					} else {
1724
-					    $v = null;
1725
-					}
1726
-					if (isset($attrs['form'])) {
1727
-						$unqualified = ($attrs['form'] == 'unqualified');
1728
-					} else {
1729
-						$unqualified = false;
1730
-					}
1731
-					if (isset($attrs['maxOccurs']) && ($attrs['maxOccurs'] == 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruct($v) == 'arraySimple') {
1732
-						$vv = $v;
1733
-						foreach ($vv as $k => $v) {
1734
-							if (isset($attrs['type']) || isset($attrs['ref'])) {
1735
-								// serialize schema-defined type
1736
-							    $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1737
-							} else {
1738
-								// serialize generic type (can this ever really happen?)
1739
-							    $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1740
-							    $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1741
-							}
1742
-						}
1743
-					} else {
1744
-						if (is_null($v) && isset($attrs['minOccurs']) && $attrs['minOccurs'] == '0') {
1745
-							// do nothing
1746
-						} elseif (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true') {
1747
-							// TODO: serialize a nil correctly, but for now serialize schema-defined type
1748
-						    $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1749
-						} elseif (isset($attrs['type']) || isset($attrs['ref'])) {
1750
-							// serialize schema-defined type
1751
-						    $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1752
-						} else {
1753
-							// serialize generic type (can this ever really happen?)
1754
-						    $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1755
-						    $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1756
-						}
1757
-					}
1758
-				}
1759
-			}
1760
-		} else {
1761
-			$this->debug("no elements to serialize for XML Schema type $ns:$uqType");
1762
-		}
1763
-		return $xml;
1764
-	}
1660
+    /**
1661
+     * serializes the elements for a complexType
1662
+     *
1663
+     * @param array $typeDef our internal representation of an XML schema type (or element)
1664
+     * @param mixed $value a native PHP value (parameter value)
1665
+     * @param string $ns the namespace of the type
1666
+     * @param string $uqType the local part of the type
1667
+     * @param string $use use for part (encoded|literal)
1668
+     * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1669
+     * @return string value serialized as an XML string
1670
+     * @access private
1671
+     */
1672
+    function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
1673
+        $this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
1674
+        $xml = '';
1675
+        if (isset($typeDef['extensionBase'])) {
1676
+            $nsx = $this->getPrefix($typeDef['extensionBase']);
1677
+            $uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1678
+            if ($this->getNamespaceFromPrefix($nsx)) {
1679
+                $nsx = $this->getNamespaceFromPrefix($nsx);
1680
+            }
1681
+            if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1682
+                $this->debug("serialize elements for extension base $nsx:$uqTypex");
1683
+                $xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle);
1684
+            } else {
1685
+                $this->debug("extension base $nsx:$uqTypex is not a supported type");
1686
+            }
1687
+        }
1688
+        if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1689
+            $this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
1690
+            if (is_array($value)) {
1691
+                $xvalue = $value;
1692
+            } elseif (is_object($value)) {
1693
+                $xvalue = get_object_vars($value);
1694
+            } else {
1695
+                $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1696
+                $xvalue = array();
1697
+            }
1698
+            // toggle whether all elements are present - ideally should validate against schema
1699
+            if (count($typeDef['elements']) != count($xvalue)){
1700
+                $optionals = true;
1701
+            }
1702
+            foreach ($typeDef['elements'] as $eName => $attrs) {
1703
+                if (!isset($xvalue[$eName])) {
1704
+                    if (isset($attrs['default'])) {
1705
+                        $xvalue[$eName] = $attrs['default'];
1706
+                        $this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
1707
+                    }
1708
+                }
1709
+                // if user took advantage of a minOccurs=0, then only serialize named parameters
1710
+                if (isset($optionals)
1711
+                    && (!isset($xvalue[$eName]))
1712
+                    && ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
1713
+                    ){
1714
+                    if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
1715
+                        $this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
1716
+                    }
1717
+                    // do nothing
1718
+                    $this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
1719
+                } else {
1720
+                    // get value
1721
+                    if (isset($xvalue[$eName])) {
1722
+                        $v = $xvalue[$eName];
1723
+                    } else {
1724
+                        $v = null;
1725
+                    }
1726
+                    if (isset($attrs['form'])) {
1727
+                        $unqualified = ($attrs['form'] == 'unqualified');
1728
+                    } else {
1729
+                        $unqualified = false;
1730
+                    }
1731
+                    if (isset($attrs['maxOccurs']) && ($attrs['maxOccurs'] == 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruct($v) == 'arraySimple') {
1732
+                        $vv = $v;
1733
+                        foreach ($vv as $k => $v) {
1734
+                            if (isset($attrs['type']) || isset($attrs['ref'])) {
1735
+                                // serialize schema-defined type
1736
+                                $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1737
+                            } else {
1738
+                                // serialize generic type (can this ever really happen?)
1739
+                                $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1740
+                                $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1741
+                            }
1742
+                        }
1743
+                    } else {
1744
+                        if (is_null($v) && isset($attrs['minOccurs']) && $attrs['minOccurs'] == '0') {
1745
+                            // do nothing
1746
+                        } elseif (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true') {
1747
+                            // TODO: serialize a nil correctly, but for now serialize schema-defined type
1748
+                            $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1749
+                        } elseif (isset($attrs['type']) || isset($attrs['ref'])) {
1750
+                            // serialize schema-defined type
1751
+                            $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1752
+                        } else {
1753
+                            // serialize generic type (can this ever really happen?)
1754
+                            $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1755
+                            $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1756
+                        }
1757
+                    }
1758
+                }
1759
+            }
1760
+        } else {
1761
+            $this->debug("no elements to serialize for XML Schema type $ns:$uqType");
1762
+        }
1763
+        return $xml;
1764
+    }
1765 1765
 
1766
-	/**
1767
-	* adds an XML Schema complex type to the WSDL types
1768
-	*
1769
-	* @param string	$name
1770
-	* @param string $typeClass (complexType|simpleType|attribute)
1771
-	* @param string $phpType currently supported are array and struct (php assoc array)
1772
-	* @param string $compositor (all|sequence|choice)
1773
-	* @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1774
-	* @param array $elements e.g. array ( name => array(name=>'',type=>'') )
1775
-	* @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
1776
-	* @param string $arrayType as namespace:name (xsd:string)
1777
-	* @see nusoap_xmlschema
1778
-	* @access public
1779
-	*/
1780
-	function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') {
1781
-		if (count($elements) > 0) {
1782
-			$eElements = array();
1783
-	    	foreach($elements as $n => $e){
1784
-	            // expand each element
1785
-	            $ee = array();
1786
-	            foreach ($e as $k => $v) {
1787
-		            $k = strpos($k,':') ? $this->expandQname($k) : $k;
1788
-		            $v = strpos($v,':') ? $this->expandQname($v) : $v;
1789
-		            $ee[$k] = $v;
1790
-		    	}
1791
-	    		$eElements[$n] = $ee;
1792
-	    	}
1793
-	    	$elements = $eElements;
1794
-		}
1766
+    /**
1767
+     * adds an XML Schema complex type to the WSDL types
1768
+     *
1769
+     * @param string	$name
1770
+     * @param string $typeClass (complexType|simpleType|attribute)
1771
+     * @param string $phpType currently supported are array and struct (php assoc array)
1772
+     * @param string $compositor (all|sequence|choice)
1773
+     * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1774
+     * @param array $elements e.g. array ( name => array(name=>'',type=>'') )
1775
+     * @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
1776
+     * @param string $arrayType as namespace:name (xsd:string)
1777
+     * @see nusoap_xmlschema
1778
+     * @access public
1779
+     */
1780
+    function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') {
1781
+        if (count($elements) > 0) {
1782
+            $eElements = array();
1783
+            foreach($elements as $n => $e){
1784
+                // expand each element
1785
+                $ee = array();
1786
+                foreach ($e as $k => $v) {
1787
+                    $k = strpos($k,':') ? $this->expandQname($k) : $k;
1788
+                    $v = strpos($v,':') ? $this->expandQname($v) : $v;
1789
+                    $ee[$k] = $v;
1790
+                }
1791
+                $eElements[$n] = $ee;
1792
+            }
1793
+            $elements = $eElements;
1794
+        }
1795 1795
 
1796
-		if (count($attrs) > 0) {
1797
-	    	foreach($attrs as $n => $a){
1798
-	            // expand each attribute
1799
-	            foreach ($a as $k => $v) {
1800
-		            $k = strpos($k,':') ? $this->expandQname($k) : $k;
1801
-		            $v = strpos($v,':') ? $this->expandQname($v) : $v;
1802
-		            $aa[$k] = $v;
1803
-		    	}
1804
-	    		$eAttrs[$n] = $aa;
1805
-	    	}
1806
-	    	$attrs = $eAttrs;
1807
-		}
1796
+        if (count($attrs) > 0) {
1797
+            foreach($attrs as $n => $a){
1798
+                // expand each attribute
1799
+                foreach ($a as $k => $v) {
1800
+                    $k = strpos($k,':') ? $this->expandQname($k) : $k;
1801
+                    $v = strpos($v,':') ? $this->expandQname($v) : $v;
1802
+                    $aa[$k] = $v;
1803
+                }
1804
+                $eAttrs[$n] = $aa;
1805
+            }
1806
+            $attrs = $eAttrs;
1807
+        }
1808 1808
 
1809
-		$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1810
-		$arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType;
1809
+        $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1810
+        $arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType;
1811 1811
 
1812
-		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1813
-		$this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType);
1814
-	}
1812
+        $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1813
+        $this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType);
1814
+    }
1815 1815
 
1816
-	/**
1817
-	* adds an XML Schema simple type to the WSDL types
1818
-	*
1819
-	* @param string $name
1820
-	* @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1821
-	* @param string $typeClass (should always be simpleType)
1822
-	* @param string $phpType (should always be scalar)
1823
-	* @param array $enumeration array of values
1824
-	* @see nusoap_xmlschema
1825
-	* @access public
1826
-	*/
1827
-	function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
1828
-		$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1816
+    /**
1817
+     * adds an XML Schema simple type to the WSDL types
1818
+     *
1819
+     * @param string $name
1820
+     * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1821
+     * @param string $typeClass (should always be simpleType)
1822
+     * @param string $phpType (should always be scalar)
1823
+     * @param array $enumeration array of values
1824
+     * @see nusoap_xmlschema
1825
+     * @access public
1826
+     */
1827
+    function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
1828
+        $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1829 1829
 
1830
-		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1831
-		$this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration);
1832
-	}
1830
+        $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1831
+        $this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration);
1832
+    }
1833 1833
 
1834
-	/**
1835
-	* adds an element to the WSDL types
1836
-	*
1837
-	* @param array $attrs attributes that must include name and type
1838
-	* @see nusoap_xmlschema
1839
-	* @access public
1840
-	*/
1841
-	function addElement($attrs) {
1842
-		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1843
-		$this->schemas[$typens][0]->addElement($attrs);
1844
-	}
1834
+    /**
1835
+     * adds an element to the WSDL types
1836
+     *
1837
+     * @param array $attrs attributes that must include name and type
1838
+     * @see nusoap_xmlschema
1839
+     * @access public
1840
+     */
1841
+    function addElement($attrs) {
1842
+        $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1843
+        $this->schemas[$typens][0]->addElement($attrs);
1844
+    }
1845 1845
 
1846
-	/**
1847
-	* register an operation with the server
1848
-	*
1849
-	* @param string $name operation (method) name
1850
-	* @param array $in assoc array of input values: key = param name, value = param type
1851
-	* @param array $out assoc array of output values: key = param name, value = param type
1852
-	* @param string $namespace optional The namespace for the operation
1853
-	* @param string $soapaction optional The soapaction for the operation
1854
-	* @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically
1855
-	* @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now)
1856
-	* @param string $documentation optional The description to include in the WSDL
1857
-	* @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
1858
-	* @access public
1859
-	*/
1860
-	function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
1861
-		if ($use == 'encoded' && $encodingStyle == '') {
1862
-			$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1863
-		}
1846
+    /**
1847
+     * register an operation with the server
1848
+     *
1849
+     * @param string $name operation (method) name
1850
+     * @param array $in assoc array of input values: key = param name, value = param type
1851
+     * @param array $out assoc array of output values: key = param name, value = param type
1852
+     * @param string $namespace optional The namespace for the operation
1853
+     * @param string $soapaction optional The soapaction for the operation
1854
+     * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically
1855
+     * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now)
1856
+     * @param string $documentation optional The description to include in the WSDL
1857
+     * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
1858
+     * @access public
1859
+     */
1860
+    function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
1861
+        if ($use == 'encoded' && $encodingStyle == '') {
1862
+            $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1863
+        }
1864 1864
 
1865
-		if ($style == 'document') {
1866
-			$elements = array();
1867
-			foreach ($in as $n => $t) {
1868
-				$elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1869
-			}
1870
-			$this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
1871
-			$this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
1872
-			$in = array('parameters' => 'tns:' . $name . '^');
1865
+        if ($style == 'document') {
1866
+            $elements = array();
1867
+            foreach ($in as $n => $t) {
1868
+                $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1869
+            }
1870
+            $this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
1871
+            $this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
1872
+            $in = array('parameters' => 'tns:' . $name . '^');
1873 1873
 
1874
-			$elements = array();
1875
-			foreach ($out as $n => $t) {
1876
-				$elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1877
-			}
1878
-			$this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
1879
-			$this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified'));
1880
-			$out = array('parameters' => 'tns:' . $name . 'Response' . '^');
1881
-		}
1874
+            $elements = array();
1875
+            foreach ($out as $n => $t) {
1876
+                $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1877
+            }
1878
+            $this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
1879
+            $this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified'));
1880
+            $out = array('parameters' => 'tns:' . $name . 'Response' . '^');
1881
+        }
1882 1882
 
1883
-		// get binding
1884
-		$this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] =
1885
-		array(
1886
-		'name' => $name,
1887
-		'binding' => $this->serviceName . 'Binding',
1888
-		'endpoint' => $this->endpoint,
1889
-		'soapAction' => $soapaction,
1890
-		'style' => $style,
1891
-		'input' => array(
1892
-			'use' => $use,
1893
-			'namespace' => $namespace,
1894
-			'encodingStyle' => $encodingStyle,
1895
-			'message' => $name . 'Request',
1896
-			'parts' => $in),
1897
-		'output' => array(
1898
-			'use' => $use,
1899
-			'namespace' => $namespace,
1900
-			'encodingStyle' => $encodingStyle,
1901
-			'message' => $name . 'Response',
1902
-			'parts' => $out),
1903
-		'namespace' => $namespace,
1904
-		'transport' => 'http://schemas.xmlsoap.org/soap/http',
1905
-		'documentation' => $documentation);
1906
-		// add portTypes
1907
-		// add messages
1908
-		if($in)
1909
-		{
1910
-			foreach($in as $pName => $pType)
1911
-			{
1912
-				if(strpos($pType,':')) {
1913
-					$pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1914
-				}
1915
-				$this->messages[$name.'Request'][$pName] = $pType;
1916
-			}
1917
-		} else {
1883
+        // get binding
1884
+        $this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] =
1885
+        array(
1886
+        'name' => $name,
1887
+        'binding' => $this->serviceName . 'Binding',
1888
+        'endpoint' => $this->endpoint,
1889
+        'soapAction' => $soapaction,
1890
+        'style' => $style,
1891
+        'input' => array(
1892
+            'use' => $use,
1893
+            'namespace' => $namespace,
1894
+            'encodingStyle' => $encodingStyle,
1895
+            'message' => $name . 'Request',
1896
+            'parts' => $in),
1897
+        'output' => array(
1898
+            'use' => $use,
1899
+            'namespace' => $namespace,
1900
+            'encodingStyle' => $encodingStyle,
1901
+            'message' => $name . 'Response',
1902
+            'parts' => $out),
1903
+        'namespace' => $namespace,
1904
+        'transport' => 'http://schemas.xmlsoap.org/soap/http',
1905
+        'documentation' => $documentation);
1906
+        // add portTypes
1907
+        // add messages
1908
+        if($in)
1909
+        {
1910
+            foreach($in as $pName => $pType)
1911
+            {
1912
+                if(strpos($pType,':')) {
1913
+                    $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1914
+                }
1915
+                $this->messages[$name.'Request'][$pName] = $pType;
1916
+            }
1917
+        } else {
1918 1918
             $this->messages[$name.'Request']= '0';
1919 1919
         }
1920
-		if($out)
1921
-		{
1922
-			foreach($out as $pName => $pType)
1923
-			{
1924
-				if(strpos($pType,':')) {
1925
-					$pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1926
-				}
1927
-				$this->messages[$name.'Response'][$pName] = $pType;
1928
-			}
1929
-		} else {
1920
+        if($out)
1921
+        {
1922
+            foreach($out as $pName => $pType)
1923
+            {
1924
+                if(strpos($pType,':')) {
1925
+                    $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1926
+                }
1927
+                $this->messages[$name.'Response'][$pName] = $pType;
1928
+            }
1929
+        } else {
1930 1930
             $this->messages[$name.'Response']= '0';
1931 1931
         }
1932
-		return true;
1933
-	}
1932
+        return true;
1933
+    }
1934 1934
 }
1935 1935
 
1936 1936
 ?>
Please login to merge, or discard this patch.
Spacing   +205 added lines, -207 removed lines patch added patch discarded remove patch
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
 	var $proxypassword = '';
46 46
 	var $timeout = 0;
47 47
 	var $response_timeout = 30;
48
-	var $curl_options = array();	// User-specified cURL options
49
-	var $use_curl = false;			// whether to always try to use cURL
48
+	var $curl_options = array(); // User-specified cURL options
49
+	var $use_curl = false; // whether to always try to use cURL
50 50
 	// for HTTP authentication
51
-	var $username = '';				// Username for HTTP authentication
52
-	var $password = '';				// Password for HTTP authentication
53
-	var $authtype = '';				// Type of HTTP authentication
54
-	var $certRequest = array();		// Certificate for HTTP SSL authentication
51
+	var $username = ''; // Username for HTTP authentication
52
+	var $password = ''; // Password for HTTP authentication
53
+	var $authtype = ''; // Type of HTTP authentication
54
+	var $certRequest = array(); // Certificate for HTTP SSL authentication
55 55
 
56 56
     /**
57 57
      * constructor
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @param boolean $use_curl try to use cURL
68 68
      * @access public
69 69
      */
70
-    function __construct($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){
70
+    function __construct($wsdl = '', $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $curl_options = null, $use_curl = false) {
71 71
 		parent::__construct();
72 72
 		$this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
73 73
         $this->proxyhost = $proxyhost;
@@ -103,19 +103,19 @@  discard block
 block discarded – undo
103 103
     		// Schema imports
104 104
     		foreach ($this->schemas as $ns => $list) {
105 105
     			foreach ($list as $xs) {
106
-					$wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
106
+					$wsdlparts = parse_url($this->wsdl); // this is bogusly simple!
107 107
 		            foreach ($xs->imports as $ns2 => $list2) {
108 108
 		                for ($ii = 0; $ii < count($list2); $ii++) {
109
-		                	if (! $list2[$ii]['loaded']) {
109
+		                	if (!$list2[$ii]['loaded']) {
110 110
 		                		$this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
111 111
 		                		$url = $list2[$ii]['location'];
112 112
 								if ($url != '') {
113 113
 									$urlparts = parse_url($url);
114 114
 									if (!isset($urlparts['host'])) {
115
-										$url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') .
116
-												substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
115
+										$url = $wsdlparts['scheme'].'://'.$wsdlparts['host'].(isset($wsdlparts['port']) ? ':'.$wsdlparts['port'] : '').
116
+												substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1).$urlparts['path'];
117 117
 									}
118
-									if (! in_array($url, $imported_urls)) {
118
+									if (!in_array($url, $imported_urls)) {
119 119
 					                	$this->parseWSDL($url);
120 120
 				                		$imported++;
121 121
 				                		$imported_urls[] = $url;
@@ -129,19 +129,19 @@  discard block
 block discarded – undo
129 129
     			}
130 130
     		}
131 131
     		// WSDL imports
132
-			$wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
132
+			$wsdlparts = parse_url($this->wsdl); // this is bogusly simple!
133 133
             foreach ($this->import as $ns => $list) {
134 134
                 for ($ii = 0; $ii < count($list); $ii++) {
135
-                	if (! $list[$ii]['loaded']) {
135
+                	if (!$list[$ii]['loaded']) {
136 136
                 		$this->import[$ns][$ii]['loaded'] = true;
137 137
                 		$url = $list[$ii]['location'];
138 138
 						if ($url != '') {
139 139
 							$urlparts = parse_url($url);
140 140
 							if (!isset($urlparts['host'])) {
141
-								$url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
142
-										substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
141
+								$url = $wsdlparts['scheme'].'://'.$wsdlparts['host'].(isset($wsdlparts['port']) ? ':'.$wsdlparts['port'] : '').
142
+										substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1).$urlparts['path'];
143 143
 							}
144
-							if (! in_array($url, $imported_urls)) {
144
+							if (!in_array($url, $imported_urls)) {
145 145
 			                	$this->parseWSDL($url);
146 146
 		                		$imported++;
147 147
 		                		$imported_urls[] = $url;
@@ -154,30 +154,28 @@  discard block
 block discarded – undo
154 154
             }
155 155
 		}
156 156
         // add new data to operation data
157
-        foreach($this->bindings as $binding => $bindingData) {
157
+        foreach ($this->bindings as $binding => $bindingData) {
158 158
             if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
159
-                foreach($bindingData['operations'] as $operation => $data) {
160
-                    $this->debug('post-parse data gathering for ' . $operation);
159
+                foreach ($bindingData['operations'] as $operation => $data) {
160
+                    $this->debug('post-parse data gathering for '.$operation);
161 161
                     $this->bindings[$binding]['operations'][$operation]['input'] =
162 162
 						isset($this->bindings[$binding]['operations'][$operation]['input']) ?
163
-						array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) :
164
-						$this->portTypes[ $bindingData['portType'] ][$operation]['input'];
163
+						array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[$bindingData['portType']][$operation]['input']) : $this->portTypes[$bindingData['portType']][$operation]['input'];
165 164
                     $this->bindings[$binding]['operations'][$operation]['output'] =
166 165
 						isset($this->bindings[$binding]['operations'][$operation]['output']) ?
167
-						array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) :
168
-						$this->portTypes[ $bindingData['portType'] ][$operation]['output'];
169
-                    if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){
170
-						$this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ];
166
+						array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[$bindingData['portType']][$operation]['output']) : $this->portTypes[$bindingData['portType']][$operation]['output'];
167
+                    if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']])) {
168
+						$this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']];
171 169
 					}
172
-					if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){
173
-                   		$this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ];
170
+					if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']])) {
171
+                   		$this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']];
174 172
                     }
175 173
                     // Set operation style if necessary, but do not override one already provided
176 174
 					if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
177 175
                         $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style'];
178 176
                     }
179 177
                     $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : '';
180
-                    $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : '';
178
+                    $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[$bindingData['portType']][$operation]['documentation']) ? $this->portTypes[$bindingData['portType']][$operation]['documentation'] : '';
181 179
                     $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : '';
182 180
                 }
183 181
             }
@@ -203,13 +201,13 @@  discard block
 block discarded – undo
203 201
         $wsdl_props = parse_url($wsdl);
204 202
 
205 203
         if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) {
206
-            $this->debug('getting WSDL http(s) URL ' . $wsdl);
204
+            $this->debug('getting WSDL http(s) URL '.$wsdl);
207 205
         	// get wsdl
208 206
 	        $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl);
209 207
 			$tr->request_method = 'GET';
210 208
 			$tr->useSOAPAction = false;
211
-			if($this->proxyhost && $this->proxyport){
212
-				$tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
209
+			if ($this->proxyhost && $this->proxyport) {
210
+				$tr->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword);
213 211
 			}
214 212
 			if ($this->authtype != '') {
215 213
 				$tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
@@ -220,8 +218,8 @@  discard block
 block discarded – undo
220 218
 			//$this->debug("WSDL response\n" . $tr->incoming_payload);
221 219
 			$this->appendDebug($tr->getDebug());
222 220
 			// catch errors
223
-			if($err = $tr->getError() ){
224
-				$errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err;
221
+			if ($err = $tr->getError()) {
222
+				$errstr = 'Getting '.$wsdl.' - HTTP ERROR: '.$err;
225 223
 				$this->debug($errstr);
226 224
 	            $this->setError($errstr);
227 225
 				unset($tr);
@@ -232,11 +230,11 @@  discard block
 block discarded – undo
232 230
         } else {
233 231
             // $wsdl is not http(s), so treat it as a file URL or plain file path
234 232
         	if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
235
-        		$path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path'];
233
+        		$path = isset($wsdl_props['host']) ? ($wsdl_props['host'].':'.$wsdl_props['path']) : $wsdl_props['path'];
236 234
         	} else {
237 235
         		$path = $wsdl;
238 236
         	}
239
-            $this->debug('getting WSDL file ' . $path);
237
+            $this->debug('getting WSDL file '.$path);
240 238
             if ($fp = @fopen($path, 'r')) {
241 239
                 $wsdl_string = '';
242 240
                 while ($data = fread($fp, 32768)) {
@@ -272,7 +270,7 @@  discard block
 block discarded – undo
272 270
                 xml_error_string(xml_get_error_code($this->parser))
273 271
                 );
274 272
             $this->debug($errstr);
275
-			$this->debug("XML payload:\n" . $wsdl_string);
273
+			$this->debug("XML payload:\n".$wsdl_string);
276 274
             $this->setError($errstr);
277 275
             return false;
278 276
         }
@@ -280,7 +278,7 @@  discard block
 block discarded – undo
280 278
         xml_parser_free($this->parser);
281 279
         $this->debug('Parsing WSDL done');
282 280
 		// catch wsdl parse errors
283
-		if($this->getError()){
281
+		if ($this->getError()) {
284 282
 			return false;
285 283
 		}
286 284
         return true;
@@ -318,21 +316,21 @@  discard block
 block discarded – undo
318 316
             // process attributes
319 317
             if (count($attrs) > 0) {
320 318
 				// register namespace declarations
321
-                foreach($attrs as $k => $v) {
322
-                    if (preg_match('/^xmlns/',$k)) {
319
+                foreach ($attrs as $k => $v) {
320
+                    if (preg_match('/^xmlns/', $k)) {
323 321
                         if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
324 322
                             $this->namespaces[$ns_prefix] = $v;
325 323
                         } else {
326
-                            $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
324
+                            $this->namespaces['ns'.(count($this->namespaces) + 1)] = $v;
327 325
                         }
328 326
                         if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
329 327
                             $this->XMLSchemaVersion = $v;
330
-                            $this->namespaces['xsi'] = $v . '-instance';
328
+                            $this->namespaces['xsi'] = $v.'-instance';
331 329
                         }
332 330
                     }
333 331
                 }
334 332
                 // expand each attribute prefix to its namespace
335
-                foreach($attrs as $k => $v) {
333
+                foreach ($attrs as $k => $v) {
336 334
                     $k = strpos($k, ':') ? $this->expandQname($k) : $k;
337 335
                     if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') {
338 336
                         $v = strpos($v, ':') ? $this->expandQname($v) : $v;
@@ -358,12 +356,12 @@  discard block
 block discarded – undo
358 356
                 case 'message':
359 357
                     if ($name == 'part') {
360 358
 			            if (isset($attrs['type'])) {
361
-		                    $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
359
+		                    $this->debug("msg ".$this->currentMessage.": found part (with type) $attrs[name]: ".implode(',', $attrs));
362 360
 		                    $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
363 361
             			}
364 362
 			            if (isset($attrs['element'])) {
365
-		                    $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
366
-			                $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
363
+		                    $this->debug("msg ".$this->currentMessage.": found part (with element) $attrs[name]: ".implode(',', $attrs));
364
+			                $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'].'^';
367 365
 			            }
368 366
         			}
369 367
         			break;
@@ -432,15 +430,15 @@  discard block
 block discarded – undo
432 430
 					switch ($name) {
433 431
 					    case 'port':
434 432
 					        $this->currentPort = $attrs['name'];
435
-					        $this->debug('current port: ' . $this->currentPort);
433
+					        $this->debug('current port: '.$this->currentPort);
436 434
 					        $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
437 435
 
438 436
 					        break;
439 437
 					    case 'address':
440 438
 					        $this->ports[$this->currentPort]['location'] = $attrs['location'];
441 439
 					        $this->ports[$this->currentPort]['bindingType'] = $namespace;
442
-					        $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
443
-					        $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
440
+					        $this->bindings[$this->ports[$this->currentPort]['binding']]['bindingType'] = $namespace;
441
+					        $this->bindings[$this->ports[$this->currentPort]['binding']]['endpoint'] = $attrs['location'];
444 442
 					        break;
445 443
 					}
446 444
 					break;
@@ -450,13 +448,13 @@  discard block
 block discarded – undo
450 448
 			case 'import':
451 449
 			    if (isset($attrs['location'])) {
452 450
                     $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
453
-                    $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')');
451
+                    $this->debug('parsing import '.$attrs['namespace'].' - '.$attrs['location'].' ('.count($this->import[$attrs['namespace']]).')');
454 452
 				} else {
455 453
                     $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
456
-					if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
457
-						$this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
454
+					if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
455
+						$this->namespaces['ns'.(count($this->namespaces) + 1)] = $attrs['namespace'];
458 456
 					}
459
-                    $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')');
457
+                    $this->debug('parsing import '.$attrs['namespace'].' - [no location] ('.count($this->import[$attrs['namespace']]).')');
460 458
 				}
461 459
 				break;
462 460
 			//wait for schema
@@ -483,13 +481,13 @@  discard block
 block discarded – undo
483 481
 					}
484 482
 					$this->status = 'binding';
485 483
 					$this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
486
-					$this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
484
+					$this->debug("current binding: $this->currentBinding of portType: ".$attrs['type']);
487 485
 				}
488 486
 				break;
489 487
 			case 'service':
490 488
 				$this->serviceName = $attrs['name'];
491 489
 				$this->status = 'service';
492
-				$this->debug('current service: ' . $this->serviceName);
490
+				$this->debug('current service: '.$this->serviceName);
493 491
 				break;
494 492
 			case 'definitions':
495 493
 				foreach ($attrs as $name => $value) {
@@ -507,7 +505,7 @@  discard block
 block discarded – undo
507 505
 	* @param string $name element name
508 506
 	* @access private
509 507
 	*/
510
-	function end_element($parser, $name){
508
+	function end_element($parser, $name) {
511 509
 		// unset schema status
512 510
 		if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
513 511
 			$this->status = "";
@@ -592,8 +590,8 @@  discard block
 block discarded – undo
592 590
 		}
593 591
 		$this->debug("getOperations for port '$portName' bindingType $bindingType");
594 592
 		// loop thru ports
595
-		foreach($this->ports as $port => $portData) {
596
-			$this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
593
+		foreach ($this->ports as $port => $portData) {
594
+			$this->debug("getOperations checking port $port bindingType ".$portData['bindingType']);
597 595
 			if ($portName == '' || $port == $portName) {
598 596
 				// binding type of port matches parameter
599 597
 				if ($portData['bindingType'] == $bindingType) {
@@ -601,8 +599,8 @@  discard block
 block discarded – undo
601 599
 					//$this->debug("port data: " . $this->varDump($portData));
602 600
 					//$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
603 601
 					// merge bindings
604
-					if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
605
-						$ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']);
602
+					if (isset($this->bindings[$portData['binding']]['operations'])) {
603
+						$ops = array_merge($ops, $this->bindings[$portData['binding']]['operations']);
606 604
 					}
607 605
 				}
608 606
 			}
@@ -629,15 +627,15 @@  discard block
 block discarded – undo
629 627
 			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
630 628
 		}
631 629
 		// loop thru ports
632
-		foreach($this->ports as $port => $portData) {
630
+		foreach ($this->ports as $port => $portData) {
633 631
 			// binding type of port matches parameter
634 632
 			if ($portData['bindingType'] == $bindingType) {
635 633
 				// get binding
636 634
 				//foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
637
-				foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
635
+				foreach (array_keys($this->bindings[$portData['binding']]['operations']) as $bOperation) {
638 636
 					// note that we could/should also check the namespace here
639 637
 					if ($operation == $bOperation) {
640
-						$opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
638
+						$opData = $this->bindings[$portData['binding']]['operations'][$operation];
641 639
 					    return $opData;
642 640
 					}
643 641
 				}
@@ -660,11 +658,11 @@  discard block
 block discarded – undo
660 658
 			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
661 659
 		}
662 660
 		// loop thru ports
663
-		foreach($this->ports as $port => $portData) {
661
+		foreach ($this->ports as $port => $portData) {
664 662
 			// binding type of port matches parameter
665 663
 			if ($portData['bindingType'] == $bindingType) {
666 664
 				// loop through operations for the binding
667
-				foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
665
+				foreach ($this->bindings[$portData['binding']]['operations'] as $bOperation => $opData) {
668 666
 					if ($opData['soapAction'] == $soapAction) {
669 667
 					    return $opData;
670 668
 					}
@@ -693,7 +691,7 @@  discard block
 block discarded – undo
693 691
     */
694 692
 	function getTypeDef($type, $ns) {
695 693
 		$this->debug("in getTypeDef: type=$type, ns=$ns");
696
-		if ((! $ns) && isset($this->namespaces['tns'])) {
694
+		if ((!$ns) && isset($this->namespaces['tns'])) {
697 695
 			$ns = $this->namespaces['tns'];
698 696
 			$this->debug("in getTypeDef: type namespace forced to $ns");
699 697
 		}
@@ -751,7 +749,7 @@  discard block
 block discarded – undo
751 749
     *
752 750
     * @access private
753 751
     */
754
-    function webDescription(){
752
+    function webDescription() {
755 753
     	global $HTTP_SERVER_VARS;
756 754
 
757 755
 		if (isset($_SERVER)) {
@@ -845,19 +843,19 @@  discard block
 block discarded – undo
845 843
 				<p>View the <a href="'.$PHP_SELF.'?wsdl">WSDL</a> for the service.
846 844
 				Click on an operation name to view it&apos;s details.</p>
847 845
 				<ul>';
848
-				foreach($this->getOperations() as $op => $data){
846
+				foreach ($this->getOperations() as $op => $data) {
849 847
 				    $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
850 848
 				    // create hidden div
851 849
 				    $b .= "<div id='$op' class='hidden'>
852 850
 				    <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
853
-				    foreach($data as $donnie => $marie){ // loop through opdata
854
-						if($donnie == 'input' || $donnie == 'output'){ // show input/output data
851
+				    foreach ($data as $donnie => $marie) { // loop through opdata
852
+						if ($donnie == 'input' || $donnie == 'output') { // show input/output data
855 853
 						    $b .= "<font color='white'>".ucfirst($donnie).':</font><br>';
856
-						    foreach($marie as $captain => $tenille){ // loop through data
857
-								if($captain == 'parts'){ // loop thru parts
854
+						    foreach ($marie as $captain => $tenille) { // loop through data
855
+								if ($captain == 'parts') { // loop thru parts
858 856
 								    $b .= "&nbsp;&nbsp;$captain:<br>";
859 857
 					                //if(is_array($tenille)){
860
-								    	foreach($tenille as $joanie => $chachi){
858
+								    	foreach ($tenille as $joanie => $chachi) {
861 859
 											$b .= "&nbsp;&nbsp;&nbsp;&nbsp;$joanie: $chachi<br>";
862 860
 								    	}
863 861
 					        		//}
@@ -889,31 +887,31 @@  discard block
 block discarded – undo
889 887
 	{
890 888
 		$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
891 889
 		$xml .= "\n<definitions";
892
-		foreach($this->namespaces as $k => $v) {
890
+		foreach ($this->namespaces as $k => $v) {
893 891
 			$xml .= " xmlns:$k=\"$v\"";
894 892
 		}
895 893
 		// 10.9.02 - add poulter fix for wsdl and tns declarations
896 894
 		if (isset($this->namespaces['wsdl'])) {
897
-			$xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
895
+			$xml .= " xmlns=\"".$this->namespaces['wsdl']."\"";
898 896
 		}
899 897
 		if (isset($this->namespaces['tns'])) {
900
-			$xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
898
+			$xml .= " targetNamespace=\"".$this->namespaces['tns']."\"";
901 899
 		}
902 900
 		$xml .= '>';
903 901
 		// imports
904 902
 		if (sizeof($this->import) > 0) {
905
-			foreach($this->import as $ns => $list) {
903
+			foreach ($this->import as $ns => $list) {
906 904
 				foreach ($list as $ii) {
907 905
 					if ($ii['location'] != '') {
908
-						$xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />';
906
+						$xml .= '<import location="'.$ii['location'].'" namespace="'.$ns.'" />';
909 907
 					} else {
910
-						$xml .= '<import namespace="' . $ns . '" />';
908
+						$xml .= '<import namespace="'.$ns.'" />';
911 909
 					}
912 910
 				}
913 911
 			}
914 912
 		}
915 913
 		// types
916
-		if (count($this->schemas)>=1) {
914
+		if (count($this->schemas) >= 1) {
917 915
 			$xml .= "\n<types>\n";
918 916
 			foreach ($this->schemas as $ns => $list) {
919 917
 				foreach ($list as $xs) {
@@ -924,10 +922,10 @@  discard block
 block discarded – undo
924 922
 		}
925 923
 		// messages
926 924
 		if (count($this->messages) >= 1) {
927
-			foreach($this->messages as $msgName => $msgParts) {
928
-				$xml .= "\n<message name=\"" . $msgName . '">';
929
-				if(is_array($msgParts)){
930
-					foreach($msgParts as $partName => $partType) {
925
+			foreach ($this->messages as $msgName => $msgParts) {
926
+				$xml .= "\n<message name=\"".$msgName.'">';
927
+				if (is_array($msgParts)) {
928
+					foreach ($msgParts as $partName => $partType) {
931 929
 						// print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
932 930
 						if (strpos($partType, ':')) {
933 931
 						    $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
@@ -935,7 +933,7 @@  discard block
 block discarded – undo
935 933
 						    // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
936 934
 						    $typePrefix = 'xsd';
937 935
 						} else {
938
-						    foreach($this->typemap as $ns => $types) {
936
+						    foreach ($this->typemap as $ns => $types) {
939 937
 						        if (isset($types[$partType])) {
940 938
 						            $typePrefix = $this->getPrefixFromNamespace($ns);
941 939
 						        }
@@ -955,7 +953,7 @@  discard block
 block discarded – undo
955 953
 						} else {
956 954
 							$elementortype = 'type';
957 955
 						}
958
-						$xml .= "\n" . '  <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />';
956
+						$xml .= "\n".'  <part name="'.$partName.'" '.$elementortype.'="'.$typePrefix.':'.$localPart.'" />';
959 957
 					}
960 958
 				}
961 959
 				$xml .= '</message>';
@@ -965,54 +963,54 @@  discard block
 block discarded – undo
965 963
 		if (count($this->bindings) >= 1) {
966 964
 			$binding_xml = '';
967 965
 			$portType_xml = '';
968
-			foreach($this->bindings as $bindingName => $attrs) {
969
-				$binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
970
-				$binding_xml .= "\n" . '  <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
971
-				$portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
972
-				foreach($attrs['operations'] as $opName => $opParts) {
973
-					$binding_xml .= "\n" . '  <operation name="' . $opName . '">';
974
-					$binding_xml .= "\n" . '    <soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>';
966
+			foreach ($this->bindings as $bindingName => $attrs) {
967
+				$binding_xml .= "\n<binding name=\"".$bindingName.'" type="tns:'.$attrs['portType'].'">';
968
+				$binding_xml .= "\n".'  <soap:binding style="'.$attrs['style'].'" transport="'.$attrs['transport'].'"/>';
969
+				$portType_xml .= "\n<portType name=\"".$attrs['portType'].'">';
970
+				foreach ($attrs['operations'] as $opName => $opParts) {
971
+					$binding_xml .= "\n".'  <operation name="'.$opName.'">';
972
+					$binding_xml .= "\n".'    <soap:operation soapAction="'.$opParts['soapAction'].'" style="'.$opParts['style'].'"/>';
975 973
 					if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
976
-						$enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
974
+						$enc_style = ' encodingStyle="'.$opParts['input']['encodingStyle'].'"';
977 975
 					} else {
978 976
 						$enc_style = '';
979 977
 					}
980
-					$binding_xml .= "\n" . '    <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
978
+					$binding_xml .= "\n".'    <input><soap:body use="'.$opParts['input']['use'].'" namespace="'.$opParts['input']['namespace'].'"'.$enc_style.'/></input>';
981 979
 					if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
982
-						$enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
980
+						$enc_style = ' encodingStyle="'.$opParts['output']['encodingStyle'].'"';
983 981
 					} else {
984 982
 						$enc_style = '';
985 983
 					}
986
-					$binding_xml .= "\n" . '    <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
987
-					$binding_xml .= "\n" . '  </operation>';
988
-					$portType_xml .= "\n" . '  <operation name="' . $opParts['name'] . '"';
984
+					$binding_xml .= "\n".'    <output><soap:body use="'.$opParts['output']['use'].'" namespace="'.$opParts['output']['namespace'].'"'.$enc_style.'/></output>';
985
+					$binding_xml .= "\n".'  </operation>';
986
+					$portType_xml .= "\n".'  <operation name="'.$opParts['name'].'"';
989 987
 					if (isset($opParts['parameterOrder'])) {
990
-					    $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
988
+					    $portType_xml .= ' parameterOrder="'.$opParts['parameterOrder'].'"';
991 989
 					}
992 990
 					$portType_xml .= '>';
993
-					if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
994
-						$portType_xml .= "\n" . '    <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
991
+					if (isset($opParts['documentation']) && $opParts['documentation'] != '') {
992
+						$portType_xml .= "\n".'    <documentation>'.htmlspecialchars($opParts['documentation']).'</documentation>';
995 993
 					}
996
-					$portType_xml .= "\n" . '    <input message="tns:' . $opParts['input']['message'] . '"/>';
997
-					$portType_xml .= "\n" . '    <output message="tns:' . $opParts['output']['message'] . '"/>';
998
-					$portType_xml .= "\n" . '  </operation>';
994
+					$portType_xml .= "\n".'    <input message="tns:'.$opParts['input']['message'].'"/>';
995
+					$portType_xml .= "\n".'    <output message="tns:'.$opParts['output']['message'].'"/>';
996
+					$portType_xml .= "\n".'  </operation>';
999 997
 				}
1000
-				$portType_xml .= "\n" . '</portType>';
1001
-				$binding_xml .= "\n" . '</binding>';
998
+				$portType_xml .= "\n".'</portType>';
999
+				$binding_xml .= "\n".'</binding>';
1002 1000
 			}
1003
-			$xml .= $portType_xml . $binding_xml;
1001
+			$xml .= $portType_xml.$binding_xml;
1004 1002
 		}
1005 1003
 		// services
1006
-		$xml .= "\n<service name=\"" . $this->serviceName . '">';
1004
+		$xml .= "\n<service name=\"".$this->serviceName.'">';
1007 1005
 		if (count($this->ports) >= 1) {
1008
-			foreach($this->ports as $pName => $attrs) {
1009
-				$xml .= "\n" . '  <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
1010
-				$xml .= "\n" . '    <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
1011
-				$xml .= "\n" . '  </port>';
1006
+			foreach ($this->ports as $pName => $attrs) {
1007
+				$xml .= "\n".'  <port name="'.$pName.'" binding="tns:'.$attrs['binding'].'">';
1008
+				$xml .= "\n".'    <soap:address location="'.$attrs['location'].($debug ? '?debug=1' : '').'"/>';
1009
+				$xml .= "\n".'  </port>';
1012 1010
 			}
1013 1011
 		}
1014
-		$xml .= "\n" . '</service>';
1015
-		return $xml . "\n</definitions>";
1012
+		$xml .= "\n".'</service>';
1013
+		return $xml."\n</definitions>";
1016 1014
 	}
1017 1015
 
1018 1016
 	/**
@@ -1109,7 +1107,7 @@  discard block
 block discarded – undo
1109 1107
 	 */
1110 1108
 	function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
1111 1109
 		$this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
1112
-		$this->appendDebug('parameters=' . $this->varDump($parameters));
1110
+		$this->appendDebug('parameters='.$this->varDump($parameters));
1113 1111
 
1114 1112
 		if ($direction != 'input' && $direction != 'output') {
1115 1113
 			$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
@@ -1117,8 +1115,8 @@  discard block
 block discarded – undo
1117 1115
 			return false;
1118 1116
 		}
1119 1117
 		if (!$opData = $this->getOperationData($operation, $bindingType)) {
1120
-			$this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1121
-			$this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1118
+			$this->debug('Unable to retrieve WSDL data for operation: '.$operation.' bindingType: '.$bindingType);
1119
+			$this->setError('Unable to retrieve WSDL data for operation: '.$operation.' bindingType: '.$bindingType);
1122 1120
 			return false;
1123 1121
 		}
1124 1122
 		$this->debug('in serializeRPCParameters: opData:');
@@ -1126,7 +1124,7 @@  discard block
 block discarded – undo
1126 1124
 
1127 1125
 		// Get encoding style for output and set to current
1128 1126
 		$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1129
-		if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1127
+		if (($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1130 1128
 			$encodingStyle = $opData['output']['encodingStyle'];
1131 1129
 			$enc_style = $encodingStyle;
1132 1130
 		}
@@ -1211,7 +1209,7 @@  discard block
 block discarded – undo
1211 1209
 	function serializeParameters($operation, $direction, $parameters)
1212 1210
 	{
1213 1211
 		$this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
1214
-		$this->appendDebug('parameters=' . $this->varDump($parameters));
1212
+		$this->appendDebug('parameters='.$this->varDump($parameters));
1215 1213
 
1216 1214
 		if ($direction != 'input' && $direction != 'output') {
1217 1215
 			$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
@@ -1219,8 +1217,8 @@  discard block
 block discarded – undo
1219 1217
 			return false;
1220 1218
 		}
1221 1219
 		if (!$opData = $this->getOperationData($operation)) {
1222
-			$this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
1223
-			$this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
1220
+			$this->debug('Unable to retrieve WSDL data for operation: '.$operation);
1221
+			$this->setError('Unable to retrieve WSDL data for operation: '.$operation);
1224 1222
 			return false;
1225 1223
 		}
1226 1224
 		$this->debug('opData:');
@@ -1228,7 +1226,7 @@  discard block
 block discarded – undo
1228 1226
 
1229 1227
 		// Get encoding style for output and set to current
1230 1228
 		$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1231
-		if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1229
+		if (($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1232 1230
 			$encodingStyle = $opData['output']['encodingStyle'];
1233 1231
 			$enc_style = $encodingStyle;
1234 1232
 		}
@@ -1239,14 +1237,14 @@  discard block
 block discarded – undo
1239 1237
 
1240 1238
 			$use = $opData[$direction]['use'];
1241 1239
 			$this->debug("use=$use");
1242
-			$this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
1240
+			$this->debug('got '.count($opData[$direction]['parts']).' part(s)');
1243 1241
 			if (is_array($parameters)) {
1244 1242
 				$parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1245
-				$this->debug('have ' . $parametersArrayType . ' parameters');
1246
-				foreach($opData[$direction]['parts'] as $name => $type) {
1243
+				$this->debug('have '.$parametersArrayType.' parameters');
1244
+				foreach ($opData[$direction]['parts'] as $name => $type) {
1247 1245
 					$this->debug('serializing part "'.$name.'" of type "'.$type.'"');
1248 1246
 					// Track encoding style
1249
-					if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1247
+					if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1250 1248
 						$encodingStyle = $opData[$direction]['encodingStyle'];
1251 1249
 						$enc_style = $encodingStyle;
1252 1250
 					} else {
@@ -1287,18 +1285,18 @@  discard block
 block discarded – undo
1287 1285
 	 * @return string value serialized as an XML string
1288 1286
 	 * @access private
1289 1287
 	 */
1290
-	function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false)
1288
+	function serializeType($name, $type, $value, $use = 'encoded', $encodingStyle = false, $unqualified = false)
1291 1289
 	{
1292
-		$this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
1293
-		$this->appendDebug("value=" . $this->varDump($value));
1294
-		if($use == 'encoded' && $encodingStyle) {
1295
-			$encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
1290
+		$this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=".($unqualified ? "unqualified" : "qualified"));
1291
+		$this->appendDebug("value=".$this->varDump($value));
1292
+		if ($use == 'encoded' && $encodingStyle) {
1293
+			$encodingStyle = ' SOAP-ENV:encodingStyle="'.$encodingStyle.'"';
1296 1294
 		}
1297 1295
 
1298 1296
 		// if a soapval has been supplied, let its type override the WSDL
1299 1297
     	if (is_object($value) && get_class($value) == 'soapval') {
1300 1298
     		if ($value->type_ns) {
1301
-    			$type = $value->type_ns . ':' . $value->type;
1299
+    			$type = $value->type_ns.':'.$value->type;
1302 1300
 		    	$forceType = true;
1303 1301
 		    	$this->debug("in serializeType: soapval overrides type to $type");
1304 1302
     		} elseif ($value->type) {
@@ -1317,7 +1315,7 @@  discard block
 block discarded – undo
1317 1315
 	    			$value['!'] = $value;
1318 1316
 	    		}
1319 1317
 	    		foreach ($attrs as $n => $v) {
1320
-	    			$value['!' . $n] = $v;
1318
+	    			$value['!'.$n] = $v;
1321 1319
 	    		}
1322 1320
 		    	$this->debug("in serializeType: soapval provides attributes");
1323 1321
 		    }
@@ -1335,7 +1333,7 @@  discard block
 block discarded – undo
1335 1333
 				$this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
1336 1334
 			}
1337 1335
 
1338
-			if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
1336
+			if ($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/') {
1339 1337
 				$this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
1340 1338
 				if ($unqualified && $use == 'literal') {
1341 1339
 					$elementNS = " xmlns=\"\"";
@@ -1348,7 +1346,7 @@  discard block
 block discarded – undo
1348 1346
 						$xml = "<$name$elementNS/>";
1349 1347
 					} else {
1350 1348
 						// TODO: depends on nillable, which should be checked before calling this method
1351
-						$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1349
+						$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"/>";
1352 1350
 					}
1353 1351
 					$this->debug("in serializeType: returning: $xml");
1354 1352
 					return $xml;
@@ -1358,7 +1356,7 @@  discard block
 block discarded – undo
1358 1356
 					return $this->serialize_val($value, $name, false, false, false, false, $use);
1359 1357
 				}
1360 1358
 		    	if ($uqType == 'boolean') {
1361
-		    		if ((is_string($value) && $value == 'false') || (! $value)) {
1359
+		    		if ((is_string($value) && $value == 'false') || (!$value)) {
1362 1360
 						$value = 'false';
1363 1361
 					} else {
1364 1362
 						$value = 'true';
@@ -1376,12 +1374,12 @@  discard block
 block discarded – undo
1376 1374
 				if (!$this->getTypeDef($uqType, $ns)) {
1377 1375
 					if ($use == 'literal') {
1378 1376
 						if ($forceType) {
1379
-							$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1377
+							$xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\">$value</$name>";
1380 1378
 						} else {
1381 1379
 							$xml = "<$name$elementNS>$value</$name>";
1382 1380
 						}
1383 1381
 					} else {
1384
-						$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1382
+						$xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"$encodingStyle>$value</$name>";
1385 1383
 					}
1386 1384
 					$this->debug("in serializeType: returning: $xml");
1387 1385
 					return $xml;
@@ -1391,29 +1389,29 @@  discard block
 block discarded – undo
1391 1389
 				$this->debug('in serializeType: appears to be Apache SOAP type');
1392 1390
 				if ($uqType == 'Map') {
1393 1391
 					$tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1394
-					if (! $tt_prefix) {
1392
+					if (!$tt_prefix) {
1395 1393
 						$this->debug('in serializeType: Add namespace for Apache SOAP type');
1396
-						$tt_prefix = 'ns' . rand(1000, 9999);
1394
+						$tt_prefix = 'ns'.rand(1000, 9999);
1397 1395
 						$this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
1398 1396
 						// force this to be added to usedNamespaces
1399 1397
 						$tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1400 1398
 					}
1401 1399
 					$contents = '';
1402
-					foreach($value as $k => $v) {
1400
+					foreach ($value as $k => $v) {
1403 1401
 						$this->debug("serializing map element: key $k, value $v");
1404 1402
 						$contents .= '<item>';
1405
-						$contents .= $this->serialize_val($k,'key',false,false,false,false,$use);
1406
-						$contents .= $this->serialize_val($v,'value',false,false,false,false,$use);
1403
+						$contents .= $this->serialize_val($k, 'key', false, false, false, false, $use);
1404
+						$contents .= $this->serialize_val($v, 'value', false, false, false, false, $use);
1407 1405
 						$contents .= '</item>';
1408 1406
 					}
1409 1407
 					if ($use == 'literal') {
1410 1408
 						if ($forceType) {
1411
-							$xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>";
1409
+							$xml = "<$name xsi:type=\"".$tt_prefix.":$uqType\">$contents</$name>";
1412 1410
 						} else {
1413 1411
 							$xml = "<$name>$contents</$name>";
1414 1412
 						}
1415 1413
 					} else {
1416
-						$xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>";
1414
+						$xml = "<$name xsi:type=\"".$tt_prefix.":$uqType\"$encodingStyle>$contents</$name>";
1417 1415
 					}
1418 1416
 					$this->debug("in serializeType: returning: $xml");
1419 1417
 					return $xml;
@@ -1427,13 +1425,13 @@  discard block
 block discarded – undo
1427 1425
 			$ns = '';
1428 1426
 			$uqType = $type;
1429 1427
 		}
1430
-		if(!$typeDef = $this->getTypeDef($uqType, $ns)){
1428
+		if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
1431 1429
 			$this->setError("$type ($uqType) is not a supported type.");
1432 1430
 			$this->debug("in serializeType: $type ($uqType) is not a supported type.");
1433 1431
 			return false;
1434 1432
 		} else {
1435 1433
 			$this->debug("in serializeType: found typeDef");
1436
-			$this->appendDebug('typeDef=' . $this->varDump($typeDef));
1434
+			$this->appendDebug('typeDef='.$this->varDump($typeDef));
1437 1435
 			if (substr($uqType, -1) == '^') {
1438 1436
 				$uqType = substr($uqType, 0, -1);
1439 1437
 			}
@@ -1444,7 +1442,7 @@  discard block
 block discarded – undo
1444 1442
 			return false;
1445 1443
 		}
1446 1444
 		$phpType = $typeDef['phpType'];
1447
-		$this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
1445
+		$this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: ".(isset($typeDef['arrayType']) ? $typeDef['arrayType'] : ''));
1448 1446
 		// if php type == struct, map value to the <all> element names
1449 1447
 		if ($phpType == 'struct') {
1450 1448
 			if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
@@ -1467,7 +1465,7 @@  discard block
 block discarded – undo
1467 1465
 					// TODO: depends on minOccurs and nillable
1468 1466
 					$xml = "<$elementName$elementNS/>";
1469 1467
 				} else {
1470
-					$xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1468
+					$xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"/>";
1471 1469
 				}
1472 1470
 				$this->debug("in serializeType: returning: $xml");
1473 1471
 				return $xml;
@@ -1479,12 +1477,12 @@  discard block
 block discarded – undo
1479 1477
 				$elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
1480 1478
 				if ($use == 'literal') {
1481 1479
 					if ($forceType) {
1482
-						$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
1480
+						$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\">";
1483 1481
 					} else {
1484 1482
 						$xml = "<$elementName$elementNS$elementAttrs>";
1485 1483
 					}
1486 1484
 				} else {
1487
-					$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
1485
+					$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"$encodingStyle>";
1488 1486
 				}
1489 1487
 
1490 1488
 				if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
@@ -1519,13 +1517,13 @@  discard block
 block discarded – undo
1519 1517
 					// TODO: depends on minOccurs
1520 1518
 					$xml = "<$name$elementNS/>";
1521 1519
 				} else {
1522
-					$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
1523
-						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1524
-						":Array\" " .
1525
-						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1526
-						':arrayType="' .
1527
-						$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
1528
-						':' .
1520
+					$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"".
1521
+						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').
1522
+						":Array\" ".
1523
+						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').
1524
+						':arrayType="'.
1525
+						$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])).
1526
+						':'.
1529 1527
 						$this->getLocalPart($typeDef['arrayType'])."[0]\"/>";
1530 1528
 				}
1531 1529
 				$this->debug("in serializeType: returning: $xml");
@@ -1533,8 +1531,8 @@  discard block
 block discarded – undo
1533 1531
 			}
1534 1532
 			if (isset($typeDef['multidimensional'])) {
1535 1533
 				$nv = array();
1536
-				foreach($value as $v) {
1537
-					$cols = ',' . sizeof($v);
1534
+				foreach ($value as $v) {
1535
+					$cols = ','.sizeof($v);
1538 1536
 					$nv = array_merge($nv, $v);
1539 1537
 				}
1540 1538
 				$value = $nv;
@@ -1544,10 +1542,10 @@  discard block
 block discarded – undo
1544 1542
 			if (is_array($value) && sizeof($value) >= 1) {
1545 1543
 				$rows = sizeof($value);
1546 1544
 				$contents = '';
1547
-				foreach($value as $k => $v) {
1545
+				foreach ($value as $k => $v) {
1548 1546
 					//$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
1549 1547
 					//if (strpos($typeDef['arrayType'], ':') ) {
1550
-					if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
1548
+					if (!in_array($typeDef['arrayType'], $this->typemap['http://www.w3.org/2001/XMLSchema'])) {
1551 1549
 					    $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
1552 1550
 					} else {
1553 1551
 					    $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
@@ -1584,12 +1582,12 @@  discard block
 block discarded – undo
1584 1582
 			}
1585 1583
 			if ($use == 'literal') {
1586 1584
 				if ($forceType) {
1587
-					$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1585
+					$xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\">$value</$name>";
1588 1586
 				} else {
1589 1587
 					$xml = "<$name$elementNS>$value</$name>";
1590 1588
 				}
1591 1589
 			} else {
1592
-				$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1590
+				$xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"$encodingStyle>$value</$name>";
1593 1591
 			}
1594 1592
 		}
1595 1593
 		$this->debug("in serializeType: returning: $xml");
@@ -1633,22 +1631,22 @@  discard block
 block discarded – undo
1633 1631
 				$xvalue = array();
1634 1632
 			}
1635 1633
 			foreach ($typeDef['attrs'] as $aName => $attrs) {
1636
-				if (isset($xvalue['!' . $aName])) {
1637
-					$xname = '!' . $aName;
1634
+				if (isset($xvalue['!'.$aName])) {
1635
+					$xname = '!'.$aName;
1638 1636
 					$this->debug("value provided for attribute $aName with key $xname");
1639 1637
 				} elseif (isset($xvalue[$aName])) {
1640 1638
 					$xname = $aName;
1641 1639
 					$this->debug("value provided for attribute $aName with key $xname");
1642 1640
 				} elseif (isset($attrs['default'])) {
1643
-					$xname = '!' . $aName;
1641
+					$xname = '!'.$aName;
1644 1642
 					$xvalue[$xname] = $attrs['default'];
1645
-					$this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
1643
+					$this->debug('use default value of '.$xvalue[$aName].' for attribute '.$aName);
1646 1644
 				} else {
1647 1645
 					$xname = '';
1648 1646
 					$this->debug("no value provided for attribute $aName");
1649 1647
 				}
1650 1648
 				if ($xname) {
1651
-					$xml .=  " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
1649
+					$xml .= " $aName=\"".$this->expandEntities($xvalue[$xname])."\"";
1652 1650
 				}
1653 1651
 			}
1654 1652
 		} else {
@@ -1669,7 +1667,7 @@  discard block
 block discarded – undo
1669 1667
 	 * @return string value serialized as an XML string
1670 1668
 	 * @access private
1671 1669
 	 */
1672
-	function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
1670
+	function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use = 'encoded', $encodingStyle = false) {
1673 1671
 		$this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
1674 1672
 		$xml = '';
1675 1673
 		if (isset($typeDef['extensionBase'])) {
@@ -1696,23 +1694,23 @@  discard block
 block discarded – undo
1696 1694
 				$xvalue = array();
1697 1695
 			}
1698 1696
 			// toggle whether all elements are present - ideally should validate against schema
1699
-			if (count($typeDef['elements']) != count($xvalue)){
1697
+			if (count($typeDef['elements']) != count($xvalue)) {
1700 1698
 				$optionals = true;
1701 1699
 			}
1702 1700
 			foreach ($typeDef['elements'] as $eName => $attrs) {
1703 1701
 				if (!isset($xvalue[$eName])) {
1704 1702
 					if (isset($attrs['default'])) {
1705 1703
 						$xvalue[$eName] = $attrs['default'];
1706
-						$this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
1704
+						$this->debug('use default value of '.$xvalue[$eName].' for element '.$eName);
1707 1705
 					}
1708 1706
 				}
1709 1707
 				// if user took advantage of a minOccurs=0, then only serialize named parameters
1710 1708
 				if (isset($optionals)
1711 1709
 				    && (!isset($xvalue[$eName]))
1712
-					&& ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
1713
-					){
1710
+					&& ((!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
1711
+					) {
1714 1712
 					if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
1715
-						$this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
1713
+						$this->debug("apparent error: no value provided for element $eName with minOccurs=".$attrs['minOccurs']);
1716 1714
 					}
1717 1715
 					// do nothing
1718 1716
 					$this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
@@ -1777,15 +1775,15 @@  discard block
 block discarded – undo
1777 1775
 	* @see nusoap_xmlschema
1778 1776
 	* @access public
1779 1777
 	*/
1780
-	function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') {
1778
+	function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') {
1781 1779
 		if (count($elements) > 0) {
1782 1780
 			$eElements = array();
1783
-	    	foreach($elements as $n => $e){
1781
+	    	foreach ($elements as $n => $e) {
1784 1782
 	            // expand each element
1785 1783
 	            $ee = array();
1786 1784
 	            foreach ($e as $k => $v) {
1787
-		            $k = strpos($k,':') ? $this->expandQname($k) : $k;
1788
-		            $v = strpos($v,':') ? $this->expandQname($v) : $v;
1785
+		            $k = strpos($k, ':') ? $this->expandQname($k) : $k;
1786
+		            $v = strpos($v, ':') ? $this->expandQname($v) : $v;
1789 1787
 		            $ee[$k] = $v;
1790 1788
 		    	}
1791 1789
 	    		$eElements[$n] = $ee;
@@ -1794,11 +1792,11 @@  discard block
 block discarded – undo
1794 1792
 		}
1795 1793
 
1796 1794
 		if (count($attrs) > 0) {
1797
-	    	foreach($attrs as $n => $a){
1795
+	    	foreach ($attrs as $n => $a) {
1798 1796
 	            // expand each attribute
1799 1797
 	            foreach ($a as $k => $v) {
1800
-		            $k = strpos($k,':') ? $this->expandQname($k) : $k;
1801
-		            $v = strpos($v,':') ? $this->expandQname($v) : $v;
1798
+		            $k = strpos($k, ':') ? $this->expandQname($k) : $k;
1799
+		            $v = strpos($v, ':') ? $this->expandQname($v) : $v;
1802 1800
 		            $aa[$k] = $v;
1803 1801
 		    	}
1804 1802
 	    		$eAttrs[$n] = $aa;
@@ -1806,11 +1804,11 @@  discard block
 block discarded – undo
1806 1804
 	    	$attrs = $eAttrs;
1807 1805
 		}
1808 1806
 
1809
-		$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1810
-		$arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType;
1807
+		$restrictionBase = strpos($restrictionBase, ':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1808
+		$arrayType = strpos($arrayType, ':') ? $this->expandQname($arrayType) : $arrayType;
1811 1809
 
1812 1810
 		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1813
-		$this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType);
1811
+		$this->schemas[$typens][0]->addComplexType($name, $typeClass, $phpType, $compositor, $restrictionBase, $elements, $attrs, $arrayType);
1814 1812
 	}
1815 1813
 
1816 1814
 	/**
@@ -1824,8 +1822,8 @@  discard block
 block discarded – undo
1824 1822
 	* @see nusoap_xmlschema
1825 1823
 	* @access public
1826 1824
 	*/
1827
-	function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
1828
-		$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1825
+	function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) {
1826
+		$restrictionBase = strpos($restrictionBase, ':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1829 1827
 
1830 1828
 		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1831 1829
 		$this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration);
@@ -1857,7 +1855,7 @@  discard block
 block discarded – undo
1857 1855
 	* @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
1858 1856
 	* @access public
1859 1857
 	*/
1860
-	function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
1858
+	function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = '') {
1861 1859
 		if ($use == 'encoded' && $encodingStyle == '') {
1862 1860
 			$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1863 1861
 		}
@@ -1867,24 +1865,24 @@  discard block
 block discarded – undo
1867 1865
 			foreach ($in as $n => $t) {
1868 1866
 				$elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1869 1867
 			}
1870
-			$this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
1871
-			$this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
1872
-			$in = array('parameters' => 'tns:' . $name . '^');
1868
+			$this->addComplexType($name.'RequestType', 'complexType', 'struct', 'all', '', $elements);
1869
+			$this->addElement(array('name' => $name, 'type' => $name.'RequestType'));
1870
+			$in = array('parameters' => 'tns:'.$name.'^');
1873 1871
 
1874 1872
 			$elements = array();
1875 1873
 			foreach ($out as $n => $t) {
1876 1874
 				$elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1877 1875
 			}
1878
-			$this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
1879
-			$this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified'));
1880
-			$out = array('parameters' => 'tns:' . $name . 'Response' . '^');
1876
+			$this->addComplexType($name.'ResponseType', 'complexType', 'struct', 'all', '', $elements);
1877
+			$this->addElement(array('name' => $name.'Response', 'type' => $name.'ResponseType', 'form' => 'qualified'));
1878
+			$out = array('parameters' => 'tns:'.$name.'Response'.'^');
1881 1879
 		}
1882 1880
 
1883 1881
 		// get binding
1884
-		$this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] =
1882
+		$this->bindings[$this->serviceName.'Binding']['operations'][$name] =
1885 1883
 		array(
1886 1884
 		'name' => $name,
1887
-		'binding' => $this->serviceName . 'Binding',
1885
+		'binding' => $this->serviceName.'Binding',
1888 1886
 		'endpoint' => $this->endpoint,
1889 1887
 		'soapAction' => $soapaction,
1890 1888
 		'style' => $style,
@@ -1892,42 +1890,42 @@  discard block
 block discarded – undo
1892 1890
 			'use' => $use,
1893 1891
 			'namespace' => $namespace,
1894 1892
 			'encodingStyle' => $encodingStyle,
1895
-			'message' => $name . 'Request',
1893
+			'message' => $name.'Request',
1896 1894
 			'parts' => $in),
1897 1895
 		'output' => array(
1898 1896
 			'use' => $use,
1899 1897
 			'namespace' => $namespace,
1900 1898
 			'encodingStyle' => $encodingStyle,
1901
-			'message' => $name . 'Response',
1899
+			'message' => $name.'Response',
1902 1900
 			'parts' => $out),
1903 1901
 		'namespace' => $namespace,
1904 1902
 		'transport' => 'http://schemas.xmlsoap.org/soap/http',
1905 1903
 		'documentation' => $documentation);
1906 1904
 		// add portTypes
1907 1905
 		// add messages
1908
-		if($in)
1906
+		if ($in)
1909 1907
 		{
1910
-			foreach($in as $pName => $pType)
1908
+			foreach ($in as $pName => $pType)
1911 1909
 			{
1912
-				if(strpos($pType,':')) {
1910
+				if (strpos($pType, ':')) {
1913 1911
 					$pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1914 1912
 				}
1915 1913
 				$this->messages[$name.'Request'][$pName] = $pType;
1916 1914
 			}
1917 1915
 		} else {
1918
-            $this->messages[$name.'Request']= '0';
1916
+            $this->messages[$name.'Request'] = '0';
1919 1917
         }
1920
-		if($out)
1918
+		if ($out)
1921 1919
 		{
1922
-			foreach($out as $pName => $pType)
1920
+			foreach ($out as $pName => $pType)
1923 1921
 			{
1924
-				if(strpos($pType,':')) {
1922
+				if (strpos($pType, ':')) {
1925 1923
 					$pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1926 1924
 				}
1927 1925
 				$this->messages[$name.'Response'][$pName] = $pType;
1928 1926
 			}
1929 1927
 		} else {
1930
-            $this->messages[$name.'Response']= '0';
1928
+            $this->messages[$name.'Response'] = '0';
1931 1929
         }
1932 1930
 		return true;
1933 1931
 	}
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.xmlschema.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -791,7 +791,7 @@
 block discarded – undo
791 791
     * returns a sample serialization of a given type, or false if no type by the given name
792 792
     *
793 793
     * @param string $type name of type
794
-    * @return mixed
794
+    * @return string|false
795 795
     * @access public
796 796
     * @deprecated
797 797
     */
Please login to merge, or discard this patch.
Indentation   +910 added lines, -910 removed lines patch added patch discarded remove patch
@@ -11,275 +11,275 @@  discard block
 block discarded – undo
11 11
 */
12 12
 class nusoap_xmlschema extends nusoap_base
13 13
 {
14
-	// files
15
-	var $schema = '';
16
-	var $xml = '';
17
-	// namespaces
18
-	var $enclosingNamespaces;
19
-	// schema info
20
-	var $schemaInfo = array();
21
-	var $schemaTargetNamespace = '';
22
-	// types, elements, attributes defined by the schema
23
-	var $attributes = array();
24
-	var $complexTypes = array();
25
-	var $complexTypeStack = array();
26
-	var $currentComplexType = null;
27
-	var $elements = array();
28
-	var $elementStack = array();
29
-	var $currentElement = null;
30
-	var $simpleTypes = array();
31
-	var $simpleTypeStack = array();
32
-	var $currentSimpleType = null;
33
-	// imports
34
-	var $imports = array();
35
-	// parser vars
36
-	var $parser;
37
-	var $position = 0;
38
-	var $depth = 0;
39
-	var $depth_array = array();
40
-	var $message = array();
41
-	var $defaultNamespace = array();
42
-
43
-	/**
44
-	* constructor
45
-	*
46
-	* @param    string $schema schema document URI
47
-	* @param    string $xml xml document URI
48
-	* @param	string $namespaces namespaces defined in enclosing XML
49
-	* @access   public
50
-	*/
51
-	function __construct($schema='',$xml='',$namespaces=array()){
52
-		parent::__construct();
53
-		$this->debug('nusoap_xmlschema class instantiated, inside constructor');
54
-		// files
55
-		$this->schema = $schema;
56
-		$this->xml = $xml;
57
-
58
-		// namespaces
59
-		$this->enclosingNamespaces = $namespaces;
60
-		$this->namespaces = array_merge($this->namespaces, $namespaces);
61
-
62
-		// parse schema file
63
-		if($schema != ''){
64
-			$this->debug('initial schema file: '.$schema);
65
-			$this->parseFile($schema, 'schema');
66
-		}
67
-
68
-		// parse xml file
69
-		if($xml != ''){
70
-			$this->debug('initial xml file: '.$xml);
71
-			$this->parseFile($xml, 'xml');
72
-		}
73
-
74
-	}
14
+    // files
15
+    var $schema = '';
16
+    var $xml = '';
17
+    // namespaces
18
+    var $enclosingNamespaces;
19
+    // schema info
20
+    var $schemaInfo = array();
21
+    var $schemaTargetNamespace = '';
22
+    // types, elements, attributes defined by the schema
23
+    var $attributes = array();
24
+    var $complexTypes = array();
25
+    var $complexTypeStack = array();
26
+    var $currentComplexType = null;
27
+    var $elements = array();
28
+    var $elementStack = array();
29
+    var $currentElement = null;
30
+    var $simpleTypes = array();
31
+    var $simpleTypeStack = array();
32
+    var $currentSimpleType = null;
33
+    // imports
34
+    var $imports = array();
35
+    // parser vars
36
+    var $parser;
37
+    var $position = 0;
38
+    var $depth = 0;
39
+    var $depth_array = array();
40
+    var $message = array();
41
+    var $defaultNamespace = array();
75 42
 
76 43
     /**
77
-    * parse an XML file
78
-    *
79
-    * @param string $xml path/URL to XML file
80
-    * @param string $type (schema | xml)
81
-	* @return boolean
82
-    * @access public
83
-    */
84
-	function parseFile($xml,$type){
85
-		// parse xml file
86
-		if($xml != ""){
87
-			$xmlStr = @join("",@file($xml));
88
-			if($xmlStr == ""){
89
-				$msg = 'Error reading XML from '.$xml;
90
-				$this->setError($msg);
91
-				$this->debug($msg);
92
-			return false;
93
-			} else {
94
-				$this->debug("parsing $xml");
95
-				$this->parseString($xmlStr,$type);
96
-				$this->debug("done parsing $xml");
97
-			return true;
98
-			}
99
-		}
100
-		return false;
101
-	}
102
-
103
-	/**
104
-	* parse an XML string
105
-	*
106
-	* @param    string $xml path or URL
107
-    * @param	string $type (schema|xml)
108
-	* @access   private
109
-	*/
110
-	function parseString($xml,$type){
111
-		// parse xml string
112
-		if($xml != ""){
113
-
114
-	    	// Create an XML parser.
115
-	    	$this->parser = xml_parser_create();
116
-	    	// Set the options for parsing the XML data.
117
-	    	xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
118
-
119
-	    	// Set the object for the parser.
120
-	    	xml_set_object($this->parser, $this);
121
-
122
-	    	// Set the element handlers for the parser.
123
-			if($type == "schema"){
124
-		    	xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement');
125
-		    	xml_set_character_data_handler($this->parser,'schemaCharacterData');
126
-			} elseif($type == "xml"){
127
-				xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement');
128
-		    	xml_set_character_data_handler($this->parser,'xmlCharacterData');
129
-			}
130
-
131
-		    // Parse the XML file.
132
-		    if(!xml_parse($this->parser,$xml,true)){
133
-			// Display an error message.
134
-				$errstr = sprintf('XML error parsing XML schema on line %d: %s',
135
-				xml_get_current_line_number($this->parser),
136
-				xml_error_string(xml_get_error_code($this->parser))
137
-				);
138
-				$this->debug($errstr);
139
-				$this->debug("XML payload:\n" . $xml);
140
-				$this->setError($errstr);
141
-	    	}
142
-
143
-			xml_parser_free($this->parser);
144
-		} else{
145
-			$this->debug('no xml passed to parseString()!!');
146
-			$this->setError('no xml passed to parseString()!!');
147
-		}
148
-	}
149
-
150
-	/**
151
-	 * gets a type name for an unnamed type
152
-	 *
153
-	 * @param	string	Element name
154
-	 * @return	string	A type name for an unnamed type
155
-	 * @access	private
156
-	 */
157
-	function CreateTypeName($ename) {
158
-		$scope = '';
159
-		for ($i = 0; $i < count($this->complexTypeStack); $i++) {
160
-			$scope .= $this->complexTypeStack[$i] . '_';
161
-		}
162
-		return $scope . $ename . '_ContainedType';
163
-	}
164
-
165
-	/**
166
-	* start-element handler
167
-	*
168
-	* @param    string $parser XML parser object
169
-	* @param    string $name element name
170
-	* @param    string $attrs associative array of attributes
171
-	* @access   private
172
-	*/
173
-	function schemaStartElement($parser, $name, $attrs) {
174
-
175
-		// position in the total number of elements, starting from 0
176
-		$pos = $this->position++;
177
-		$depth = $this->depth++;
178
-		// set self as current value for this depth
179
-		$this->depth_array[$depth] = $pos;
180
-		$this->message[$pos] = array('cdata' => '');
181
-		if ($depth > 0) {
182
-			$this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]];
183
-		} else {
184
-			$this->defaultNamespace[$pos] = false;
185
-		}
186
-
187
-		// get element prefix
188
-		if($prefix = $this->getPrefix($name)){
189
-			// get unqualified name
190
-			$name = $this->getLocalPart($name);
191
-		} else {
192
-        	$prefix = '';
44
+     * constructor
45
+     *
46
+     * @param    string $schema schema document URI
47
+     * @param    string $xml xml document URI
48
+     * @param	string $namespaces namespaces defined in enclosing XML
49
+     * @access   public
50
+     */
51
+    function __construct($schema='',$xml='',$namespaces=array()){
52
+        parent::__construct();
53
+        $this->debug('nusoap_xmlschema class instantiated, inside constructor');
54
+        // files
55
+        $this->schema = $schema;
56
+        $this->xml = $xml;
57
+
58
+        // namespaces
59
+        $this->enclosingNamespaces = $namespaces;
60
+        $this->namespaces = array_merge($this->namespaces, $namespaces);
61
+
62
+        // parse schema file
63
+        if($schema != ''){
64
+            $this->debug('initial schema file: '.$schema);
65
+            $this->parseFile($schema, 'schema');
66
+        }
67
+
68
+        // parse xml file
69
+        if($xml != ''){
70
+            $this->debug('initial xml file: '.$xml);
71
+            $this->parseFile($xml, 'xml');
72
+        }
73
+
74
+    }
75
+
76
+    /**
77
+     * parse an XML file
78
+     *
79
+     * @param string $xml path/URL to XML file
80
+     * @param string $type (schema | xml)
81
+     * @return boolean
82
+     * @access public
83
+     */
84
+    function parseFile($xml,$type){
85
+        // parse xml file
86
+        if($xml != ""){
87
+            $xmlStr = @join("",@file($xml));
88
+            if($xmlStr == ""){
89
+                $msg = 'Error reading XML from '.$xml;
90
+                $this->setError($msg);
91
+                $this->debug($msg);
92
+            return false;
93
+            } else {
94
+                $this->debug("parsing $xml");
95
+                $this->parseString($xmlStr,$type);
96
+                $this->debug("done parsing $xml");
97
+            return true;
98
+            }
99
+        }
100
+        return false;
101
+    }
102
+
103
+    /**
104
+     * parse an XML string
105
+     *
106
+     * @param    string $xml path or URL
107
+     * @param	string $type (schema|xml)
108
+     * @access   private
109
+     */
110
+    function parseString($xml,$type){
111
+        // parse xml string
112
+        if($xml != ""){
113
+
114
+            // Create an XML parser.
115
+            $this->parser = xml_parser_create();
116
+            // Set the options for parsing the XML data.
117
+            xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
118
+
119
+            // Set the object for the parser.
120
+            xml_set_object($this->parser, $this);
121
+
122
+            // Set the element handlers for the parser.
123
+            if($type == "schema"){
124
+                xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement');
125
+                xml_set_character_data_handler($this->parser,'schemaCharacterData');
126
+            } elseif($type == "xml"){
127
+                xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement');
128
+                xml_set_character_data_handler($this->parser,'xmlCharacterData');
129
+            }
130
+
131
+            // Parse the XML file.
132
+            if(!xml_parse($this->parser,$xml,true)){
133
+            // Display an error message.
134
+                $errstr = sprintf('XML error parsing XML schema on line %d: %s',
135
+                xml_get_current_line_number($this->parser),
136
+                xml_error_string(xml_get_error_code($this->parser))
137
+                );
138
+                $this->debug($errstr);
139
+                $this->debug("XML payload:\n" . $xml);
140
+                $this->setError($errstr);
141
+            }
142
+
143
+            xml_parser_free($this->parser);
144
+        } else{
145
+            $this->debug('no xml passed to parseString()!!');
146
+            $this->setError('no xml passed to parseString()!!');
147
+        }
148
+    }
149
+
150
+    /**
151
+     * gets a type name for an unnamed type
152
+     *
153
+     * @param	string	Element name
154
+     * @return	string	A type name for an unnamed type
155
+     * @access	private
156
+     */
157
+    function CreateTypeName($ename) {
158
+        $scope = '';
159
+        for ($i = 0; $i < count($this->complexTypeStack); $i++) {
160
+            $scope .= $this->complexTypeStack[$i] . '_';
161
+        }
162
+        return $scope . $ename . '_ContainedType';
163
+    }
164
+
165
+    /**
166
+     * start-element handler
167
+     *
168
+     * @param    string $parser XML parser object
169
+     * @param    string $name element name
170
+     * @param    string $attrs associative array of attributes
171
+     * @access   private
172
+     */
173
+    function schemaStartElement($parser, $name, $attrs) {
174
+
175
+        // position in the total number of elements, starting from 0
176
+        $pos = $this->position++;
177
+        $depth = $this->depth++;
178
+        // set self as current value for this depth
179
+        $this->depth_array[$depth] = $pos;
180
+        $this->message[$pos] = array('cdata' => '');
181
+        if ($depth > 0) {
182
+            $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]];
183
+        } else {
184
+            $this->defaultNamespace[$pos] = false;
185
+        }
186
+
187
+        // get element prefix
188
+        if($prefix = $this->getPrefix($name)){
189
+            // get unqualified name
190
+            $name = $this->getLocalPart($name);
191
+        } else {
192
+            $prefix = '';
193 193
         }
194 194
 
195 195
         // loop thru attributes, expanding, and registering namespace declarations
196 196
         if(count($attrs) > 0){
197
-        	foreach($attrs as $k => $v){
197
+            foreach($attrs as $k => $v){
198 198
                 // if ns declarations, add to class level array of valid namespaces
199
-				if(preg_match('/^xmlns/',$k)){
200
-                	//$this->xdebug("$k: $v");
201
-                	//$this->xdebug('ns_prefix: '.$this->getPrefix($k));
202
-                	if($ns_prefix = substr(strrchr($k,':'),1)){
203
-                		//$this->xdebug("Add namespace[$ns_prefix] = $v");
204
-						$this->namespaces[$ns_prefix] = $v;
205
-					} else {
206
-						$this->defaultNamespace[$pos] = $v;
207
-						if (! $this->getPrefixFromNamespace($v)) {
208
-							$this->namespaces['ns'.(count($this->namespaces)+1)] = $v;
209
-						}
210
-					}
211
-					if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema'){
212
-						$this->XMLSchemaVersion = $v;
213
-						$this->namespaces['xsi'] = $v.'-instance';
214
-					}
215
-				}
216
-        	}
217
-        	foreach($attrs as $k => $v){
199
+                if(preg_match('/^xmlns/',$k)){
200
+                    //$this->xdebug("$k: $v");
201
+                    //$this->xdebug('ns_prefix: '.$this->getPrefix($k));
202
+                    if($ns_prefix = substr(strrchr($k,':'),1)){
203
+                        //$this->xdebug("Add namespace[$ns_prefix] = $v");
204
+                        $this->namespaces[$ns_prefix] = $v;
205
+                    } else {
206
+                        $this->defaultNamespace[$pos] = $v;
207
+                        if (! $this->getPrefixFromNamespace($v)) {
208
+                            $this->namespaces['ns'.(count($this->namespaces)+1)] = $v;
209
+                        }
210
+                    }
211
+                    if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema'){
212
+                        $this->XMLSchemaVersion = $v;
213
+                        $this->namespaces['xsi'] = $v.'-instance';
214
+                    }
215
+                }
216
+            }
217
+            foreach($attrs as $k => $v){
218 218
                 // expand each attribute
219 219
                 $k = strpos($k,':') ? $this->expandQname($k) : $k;
220 220
                 $v = strpos($v,':') ? $this->expandQname($v) : $v;
221
-        		$eAttrs[$k] = $v;
222
-        	}
223
-        	$attrs = $eAttrs;
221
+                $eAttrs[$k] = $v;
222
+            }
223
+            $attrs = $eAttrs;
224 224
         } else {
225
-        	$attrs = array();
225
+            $attrs = array();
226 226
         }
227
-		// find status, register data
228
-		switch($name){
229
-			case 'all':			// (optional) compositor content for a complexType
230
-			case 'choice':
231
-			case 'group':
232
-			case 'sequence':
233
-				//$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
234
-				$this->complexTypes[$this->currentComplexType]['compositor'] = $name;
235
-				//if($name == 'all' || $name == 'sequence'){
236
-				//	$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
237
-				//}
238
-			break;
239
-			case 'attribute':	// complexType attribute
240
-            	//$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
241
-            	$this->xdebug("parsing attribute:");
242
-            	$this->appendDebug($this->varDump($attrs));
243
-				if (!isset($attrs['form'])) {
244
-					// TODO: handle globals
245
-					$attrs['form'] = $this->schemaInfo['attributeFormDefault'];
246
-				}
247
-            	if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
248
-					$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
249
-					if (!strpos($v, ':')) {
250
-						// no namespace in arrayType attribute value...
251
-						if ($this->defaultNamespace[$pos]) {
252
-							// ...so use the default
253
-							$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
254
-						}
255
-					}
256
-            	}
227
+        // find status, register data
228
+        switch($name){
229
+            case 'all':			// (optional) compositor content for a complexType
230
+            case 'choice':
231
+            case 'group':
232
+            case 'sequence':
233
+                //$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
234
+                $this->complexTypes[$this->currentComplexType]['compositor'] = $name;
235
+                //if($name == 'all' || $name == 'sequence'){
236
+                //	$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
237
+                //}
238
+            break;
239
+            case 'attribute':	// complexType attribute
240
+                //$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
241
+                $this->xdebug("parsing attribute:");
242
+                $this->appendDebug($this->varDump($attrs));
243
+                if (!isset($attrs['form'])) {
244
+                    // TODO: handle globals
245
+                    $attrs['form'] = $this->schemaInfo['attributeFormDefault'];
246
+                }
247
+                if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
248
+                    $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
249
+                    if (!strpos($v, ':')) {
250
+                        // no namespace in arrayType attribute value...
251
+                        if ($this->defaultNamespace[$pos]) {
252
+                            // ...so use the default
253
+                            $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
254
+                        }
255
+                    }
256
+                }
257 257
                 if(isset($attrs['name'])){
258
-					$this->attributes[$attrs['name']] = $attrs;
259
-					$aname = $attrs['name'];
260
-				} elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
261
-					if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
262
-	                	$aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
263
-	                } else {
264
-	                	$aname = '';
265
-	                }
266
-				} elseif(isset($attrs['ref'])){
267
-					$aname = $attrs['ref'];
258
+                    $this->attributes[$attrs['name']] = $attrs;
259
+                    $aname = $attrs['name'];
260
+                } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
261
+                    if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
262
+                        $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
263
+                    } else {
264
+                        $aname = '';
265
+                    }
266
+                } elseif(isset($attrs['ref'])){
267
+                    $aname = $attrs['ref'];
268 268
                     $this->attributes[$attrs['ref']] = $attrs;
269
-				}
270
-
271
-				if($this->currentComplexType){	// This should *always* be
272
-					$this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs;
273
-				}
274
-				// arrayType attribute
275
-				if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
276
-					$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
277
-                	$prefix = $this->getPrefix($aname);
278
-					if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
279
-						$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
280
-					} else {
281
-						$v = '';
282
-					}
269
+                }
270
+
271
+                if($this->currentComplexType){	// This should *always* be
272
+                    $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs;
273
+                }
274
+                // arrayType attribute
275
+                if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
276
+                    $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
277
+                    $prefix = $this->getPrefix($aname);
278
+                    if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
279
+                        $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
280
+                    } else {
281
+                        $v = '';
282
+                    }
283 283
                     if(strpos($v,'[,]')){
284 284
                         $this->complexTypes[$this->currentComplexType]['multidimensional'] = true;
285 285
                     }
@@ -288,676 +288,676 @@  discard block
 block discarded – undo
288 288
                         $v = $this->XMLSchemaVersion.':'.$v;
289 289
                     }
290 290
                     $this->complexTypes[$this->currentComplexType]['arrayType'] = $v;
291
-				}
292
-			break;
293
-			case 'complexContent':	// (optional) content for a complexType
294
-				$this->xdebug("do nothing for element $name");
295
-			break;
296
-			case 'complexType':
297
-				array_push($this->complexTypeStack, $this->currentComplexType);
298
-				if(isset($attrs['name'])){
299
-					// TODO: what is the scope of named complexTypes that appear
300
-					//       nested within other c complexTypes?
301
-					$this->xdebug('processing named complexType '.$attrs['name']);
302
-					//$this->currentElement = false;
303
-					$this->currentComplexType = $attrs['name'];
304
-					$this->complexTypes[$this->currentComplexType] = $attrs;
305
-					$this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
306
-					// This is for constructs like
307
-					//           <complexType name="ListOfString" base="soap:Array">
308
-					//                <sequence>
309
-					//                    <element name="string" type="xsd:string"
310
-					//                        minOccurs="0" maxOccurs="unbounded" />
311
-					//                </sequence>
312
-					//            </complexType>
313
-					if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
314
-						$this->xdebug('complexType is unusual array');
315
-						$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
316
-					} else {
317
-						$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
318
-					}
319
-				} else {
320
-					$name = $this->CreateTypeName($this->currentElement);
321
-					$this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
322
-					$this->currentComplexType = $name;
323
-					//$this->currentElement = false;
324
-					$this->complexTypes[$this->currentComplexType] = $attrs;
325
-					$this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
326
-					// This is for constructs like
327
-					//           <complexType name="ListOfString" base="soap:Array">
328
-					//                <sequence>
329
-					//                    <element name="string" type="xsd:string"
330
-					//                        minOccurs="0" maxOccurs="unbounded" />
331
-					//                </sequence>
332
-					//            </complexType>
333
-					if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
334
-						$this->xdebug('complexType is unusual array');
335
-						$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
336
-					} else {
337
-						$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
338
-					}
339
-				}
340
-				$this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false';
341
-			break;
342
-			case 'element':
343
-				array_push($this->elementStack, $this->currentElement);
344
-				if (!isset($attrs['form'])) {
345
-					if ($this->currentComplexType) {
346
-						$attrs['form'] = $this->schemaInfo['elementFormDefault'];
347
-					} else {
348
-						// global
349
-						$attrs['form'] = 'qualified';
350
-					}
351
-				}
352
-				if(isset($attrs['type'])){
353
-					$this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
354
-					if (! $this->getPrefix($attrs['type'])) {
355
-						if ($this->defaultNamespace[$pos]) {
356
-							$attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type'];
357
-							$this->xdebug('used default namespace to make type ' . $attrs['type']);
358
-						}
359
-					}
360
-					// This is for constructs like
361
-					//           <complexType name="ListOfString" base="soap:Array">
362
-					//                <sequence>
363
-					//                    <element name="string" type="xsd:string"
364
-					//                        minOccurs="0" maxOccurs="unbounded" />
365
-					//                </sequence>
366
-					//            </complexType>
367
-					if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
368
-						$this->xdebug('arrayType for unusual array is ' . $attrs['type']);
369
-						$this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type'];
370
-					}
371
-					$this->currentElement = $attrs['name'];
372
-					$ename = $attrs['name'];
373
-				} elseif(isset($attrs['ref'])){
374
-					$this->xdebug("processing element as ref to ".$attrs['ref']);
375
-					$this->currentElement = "ref to ".$attrs['ref'];
376
-					$ename = $this->getLocalPart($attrs['ref']);
377
-				} else {
378
-					$type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']);
379
-					$this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
380
-					$this->currentElement = $attrs['name'];
381
-					$attrs['type'] = $this->schemaTargetNamespace . ':' . $type;
382
-					$ename = $attrs['name'];
383
-				}
384
-				if (isset($ename) && $this->currentComplexType) {
385
-					$this->xdebug("add element $ename to complexType $this->currentComplexType");
386
-					$this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs;
387
-				} elseif (!isset($attrs['ref'])) {
388
-					$this->xdebug("add element $ename to elements array");
389
-					$this->elements[ $attrs['name'] ] = $attrs;
390
-					$this->elements[ $attrs['name'] ]['typeClass'] = 'element';
391
-				}
392
-			break;
393
-			case 'enumeration':	//	restriction value list member
394
-				$this->xdebug('enumeration ' . $attrs['value']);
395
-				if ($this->currentSimpleType) {
396
-					$this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value'];
397
-				} elseif ($this->currentComplexType) {
398
-					$this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value'];
399
-				}
400
-			break;
401
-			case 'extension':	// simpleContent or complexContent type extension
402
-				$this->xdebug('extension ' . $attrs['base']);
403
-				if ($this->currentComplexType) {
404
-					$ns = $this->getPrefix($attrs['base']);
405
-					if ($ns == '') {
406
-						$this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base'];
407
-					} else {
408
-						$this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base'];
409
-					}
410
-				} else {
411
-					$this->xdebug('no current complexType to set extensionBase');
412
-				}
413
-			break;
414
-			case 'import':
415
-			    if (isset($attrs['schemaLocation'])) {
416
-					$this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
291
+                }
292
+            break;
293
+            case 'complexContent':	// (optional) content for a complexType
294
+                $this->xdebug("do nothing for element $name");
295
+            break;
296
+            case 'complexType':
297
+                array_push($this->complexTypeStack, $this->currentComplexType);
298
+                if(isset($attrs['name'])){
299
+                    // TODO: what is the scope of named complexTypes that appear
300
+                    //       nested within other c complexTypes?
301
+                    $this->xdebug('processing named complexType '.$attrs['name']);
302
+                    //$this->currentElement = false;
303
+                    $this->currentComplexType = $attrs['name'];
304
+                    $this->complexTypes[$this->currentComplexType] = $attrs;
305
+                    $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
306
+                    // This is for constructs like
307
+                    //           <complexType name="ListOfString" base="soap:Array">
308
+                    //                <sequence>
309
+                    //                    <element name="string" type="xsd:string"
310
+                    //                        minOccurs="0" maxOccurs="unbounded" />
311
+                    //                </sequence>
312
+                    //            </complexType>
313
+                    if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
314
+                        $this->xdebug('complexType is unusual array');
315
+                        $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
316
+                    } else {
317
+                        $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
318
+                    }
319
+                } else {
320
+                    $name = $this->CreateTypeName($this->currentElement);
321
+                    $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
322
+                    $this->currentComplexType = $name;
323
+                    //$this->currentElement = false;
324
+                    $this->complexTypes[$this->currentComplexType] = $attrs;
325
+                    $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
326
+                    // This is for constructs like
327
+                    //           <complexType name="ListOfString" base="soap:Array">
328
+                    //                <sequence>
329
+                    //                    <element name="string" type="xsd:string"
330
+                    //                        minOccurs="0" maxOccurs="unbounded" />
331
+                    //                </sequence>
332
+                    //            </complexType>
333
+                    if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
334
+                        $this->xdebug('complexType is unusual array');
335
+                        $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
336
+                    } else {
337
+                        $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
338
+                    }
339
+                }
340
+                $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false';
341
+            break;
342
+            case 'element':
343
+                array_push($this->elementStack, $this->currentElement);
344
+                if (!isset($attrs['form'])) {
345
+                    if ($this->currentComplexType) {
346
+                        $attrs['form'] = $this->schemaInfo['elementFormDefault'];
347
+                    } else {
348
+                        // global
349
+                        $attrs['form'] = 'qualified';
350
+                    }
351
+                }
352
+                if(isset($attrs['type'])){
353
+                    $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
354
+                    if (! $this->getPrefix($attrs['type'])) {
355
+                        if ($this->defaultNamespace[$pos]) {
356
+                            $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type'];
357
+                            $this->xdebug('used default namespace to make type ' . $attrs['type']);
358
+                        }
359
+                    }
360
+                    // This is for constructs like
361
+                    //           <complexType name="ListOfString" base="soap:Array">
362
+                    //                <sequence>
363
+                    //                    <element name="string" type="xsd:string"
364
+                    //                        minOccurs="0" maxOccurs="unbounded" />
365
+                    //                </sequence>
366
+                    //            </complexType>
367
+                    if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
368
+                        $this->xdebug('arrayType for unusual array is ' . $attrs['type']);
369
+                        $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type'];
370
+                    }
371
+                    $this->currentElement = $attrs['name'];
372
+                    $ename = $attrs['name'];
373
+                } elseif(isset($attrs['ref'])){
374
+                    $this->xdebug("processing element as ref to ".$attrs['ref']);
375
+                    $this->currentElement = "ref to ".$attrs['ref'];
376
+                    $ename = $this->getLocalPart($attrs['ref']);
377
+                } else {
378
+                    $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']);
379
+                    $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
380
+                    $this->currentElement = $attrs['name'];
381
+                    $attrs['type'] = $this->schemaTargetNamespace . ':' . $type;
382
+                    $ename = $attrs['name'];
383
+                }
384
+                if (isset($ename) && $this->currentComplexType) {
385
+                    $this->xdebug("add element $ename to complexType $this->currentComplexType");
386
+                    $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs;
387
+                } elseif (!isset($attrs['ref'])) {
388
+                    $this->xdebug("add element $ename to elements array");
389
+                    $this->elements[ $attrs['name'] ] = $attrs;
390
+                    $this->elements[ $attrs['name'] ]['typeClass'] = 'element';
391
+                }
392
+            break;
393
+            case 'enumeration':	//	restriction value list member
394
+                $this->xdebug('enumeration ' . $attrs['value']);
395
+                if ($this->currentSimpleType) {
396
+                    $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value'];
397
+                } elseif ($this->currentComplexType) {
398
+                    $this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value'];
399
+                }
400
+            break;
401
+            case 'extension':	// simpleContent or complexContent type extension
402
+                $this->xdebug('extension ' . $attrs['base']);
403
+                if ($this->currentComplexType) {
404
+                    $ns = $this->getPrefix($attrs['base']);
405
+                    if ($ns == '') {
406
+                        $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base'];
407
+                    } else {
408
+                        $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base'];
409
+                    }
410
+                } else {
411
+                    $this->xdebug('no current complexType to set extensionBase');
412
+                }
413
+            break;
414
+            case 'import':
415
+                if (isset($attrs['schemaLocation'])) {
416
+                    $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
417 417
                     $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
418
-				} else {
419
-					$this->xdebug('import namespace ' . $attrs['namespace']);
418
+                } else {
419
+                    $this->xdebug('import namespace ' . $attrs['namespace']);
420 420
                     $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
421
-					if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
422
-						$this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
423
-					}
424
-				}
425
-			break;
426
-			case 'include':
427
-			    if (isset($attrs['schemaLocation'])) {
428
-					$this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
421
+                    if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
422
+                        $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
423
+                    }
424
+                }
425
+            break;
426
+            case 'include':
427
+                if (isset($attrs['schemaLocation'])) {
428
+                    $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
429 429
                     $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
430
-				} else {
431
-					$this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
432
-				}
433
-			break;
434
-			case 'list':	// simpleType value list
435
-				$this->xdebug("do nothing for element $name");
436
-			break;
437
-			case 'restriction':	// simpleType, simpleContent or complexContent value restriction
438
-				$this->xdebug('restriction ' . $attrs['base']);
439
-				if($this->currentSimpleType){
440
-					$this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base'];
441
-				} elseif($this->currentComplexType){
442
-					$this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base'];
443
-					if(strstr($attrs['base'],':') == ':Array'){
444
-						$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
445
-					}
446
-				}
447
-			break;
448
-			case 'schema':
449
-				$this->schemaInfo = $attrs;
450
-				$this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix);
451
-				if (isset($attrs['targetNamespace'])) {
452
-					$this->schemaTargetNamespace = $attrs['targetNamespace'];
453
-				}
454
-				if (!isset($attrs['elementFormDefault'])) {
455
-					$this->schemaInfo['elementFormDefault'] = 'unqualified';
456
-				}
457
-				if (!isset($attrs['attributeFormDefault'])) {
458
-					$this->schemaInfo['attributeFormDefault'] = 'unqualified';
459
-				}
460
-			break;
461
-			case 'simpleContent':	// (optional) content for a complexType
462
-				if ($this->currentComplexType) {	// This should *always* be
463
-					$this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true';
464
-				} else {
465
-					$this->xdebug("do nothing for element $name because there is no current complexType");
466
-				}
467
-			break;
468
-			case 'simpleType':
469
-				array_push($this->simpleTypeStack, $this->currentSimpleType);
470
-				if(isset($attrs['name'])){
471
-					$this->xdebug("processing simpleType for name " . $attrs['name']);
472
-					$this->currentSimpleType = $attrs['name'];
473
-					$this->simpleTypes[ $attrs['name'] ] = $attrs;
474
-					$this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType';
475
-					$this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar';
476
-				} else {
477
-					$name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement);
478
-					$this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
479
-					$this->currentSimpleType = $name;
480
-					//$this->currentElement = false;
481
-					$this->simpleTypes[$this->currentSimpleType] = $attrs;
482
-					$this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar';
483
-				}
484
-			break;
485
-			case 'union':	// simpleType type list
486
-				$this->xdebug("do nothing for element $name");
487
-			break;
488
-			default:
489
-				$this->xdebug("do not have any logic to process element $name");
490
-		}
491
-	}
492
-
493
-	/**
494
-	* end-element handler
495
-	*
496
-	* @param    string $parser XML parser object
497
-	* @param    string $name element name
498
-	* @access   private
499
-	*/
500
-	function schemaEndElement($parser, $name) {
501
-		// bring depth down a notch
502
-		$this->depth--;
503
-		// position of current element is equal to the last value left in depth_array for my depth
504
-		if(isset($this->depth_array[$this->depth])){
505
-        	$pos = $this->depth_array[$this->depth];
430
+                } else {
431
+                    $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
432
+                }
433
+            break;
434
+            case 'list':	// simpleType value list
435
+                $this->xdebug("do nothing for element $name");
436
+            break;
437
+            case 'restriction':	// simpleType, simpleContent or complexContent value restriction
438
+                $this->xdebug('restriction ' . $attrs['base']);
439
+                if($this->currentSimpleType){
440
+                    $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base'];
441
+                } elseif($this->currentComplexType){
442
+                    $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base'];
443
+                    if(strstr($attrs['base'],':') == ':Array'){
444
+                        $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
445
+                    }
446
+                }
447
+            break;
448
+            case 'schema':
449
+                $this->schemaInfo = $attrs;
450
+                $this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix);
451
+                if (isset($attrs['targetNamespace'])) {
452
+                    $this->schemaTargetNamespace = $attrs['targetNamespace'];
453
+                }
454
+                if (!isset($attrs['elementFormDefault'])) {
455
+                    $this->schemaInfo['elementFormDefault'] = 'unqualified';
456
+                }
457
+                if (!isset($attrs['attributeFormDefault'])) {
458
+                    $this->schemaInfo['attributeFormDefault'] = 'unqualified';
459
+                }
460
+            break;
461
+            case 'simpleContent':	// (optional) content for a complexType
462
+                if ($this->currentComplexType) {	// This should *always* be
463
+                    $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true';
464
+                } else {
465
+                    $this->xdebug("do nothing for element $name because there is no current complexType");
466
+                }
467
+            break;
468
+            case 'simpleType':
469
+                array_push($this->simpleTypeStack, $this->currentSimpleType);
470
+                if(isset($attrs['name'])){
471
+                    $this->xdebug("processing simpleType for name " . $attrs['name']);
472
+                    $this->currentSimpleType = $attrs['name'];
473
+                    $this->simpleTypes[ $attrs['name'] ] = $attrs;
474
+                    $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType';
475
+                    $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar';
476
+                } else {
477
+                    $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement);
478
+                    $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
479
+                    $this->currentSimpleType = $name;
480
+                    //$this->currentElement = false;
481
+                    $this->simpleTypes[$this->currentSimpleType] = $attrs;
482
+                    $this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar';
483
+                }
484
+            break;
485
+            case 'union':	// simpleType type list
486
+                $this->xdebug("do nothing for element $name");
487
+            break;
488
+            default:
489
+                $this->xdebug("do not have any logic to process element $name");
490
+        }
491
+    }
492
+
493
+    /**
494
+     * end-element handler
495
+     *
496
+     * @param    string $parser XML parser object
497
+     * @param    string $name element name
498
+     * @access   private
499
+     */
500
+    function schemaEndElement($parser, $name) {
501
+        // bring depth down a notch
502
+        $this->depth--;
503
+        // position of current element is equal to the last value left in depth_array for my depth
504
+        if(isset($this->depth_array[$this->depth])){
505
+            $pos = $this->depth_array[$this->depth];
506
+        }
507
+        // get element prefix
508
+        if ($prefix = $this->getPrefix($name)){
509
+            // get unqualified name
510
+            $name = $this->getLocalPart($name);
511
+        } else {
512
+            $prefix = '';
513
+        }
514
+        // move on...
515
+        if($name == 'complexType'){
516
+            $this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
517
+            $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType]));
518
+            $this->currentComplexType = array_pop($this->complexTypeStack);
519
+            //$this->currentElement = false;
520
+        }
521
+        if($name == 'element'){
522
+            $this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)'));
523
+            $this->currentElement = array_pop($this->elementStack);
506 524
         }
507
-		// get element prefix
508
-		if ($prefix = $this->getPrefix($name)){
509
-			// get unqualified name
510
-			$name = $this->getLocalPart($name);
511
-		} else {
512
-        	$prefix = '';
525
+        if($name == 'simpleType'){
526
+            $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
527
+            $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType]));
528
+            $this->currentSimpleType = array_pop($this->simpleTypeStack);
513 529
         }
514
-		// move on...
515
-		if($name == 'complexType'){
516
-			$this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
517
-			$this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType]));
518
-			$this->currentComplexType = array_pop($this->complexTypeStack);
519
-			//$this->currentElement = false;
520
-		}
521
-		if($name == 'element'){
522
-			$this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)'));
523
-			$this->currentElement = array_pop($this->elementStack);
524
-		}
525
-		if($name == 'simpleType'){
526
-			$this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
527
-			$this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType]));
528
-			$this->currentSimpleType = array_pop($this->simpleTypeStack);
529
-		}
530
-	}
531
-
532
-	/**
533
-	* element content handler
534
-	*
535
-	* @param    string $parser XML parser object
536
-	* @param    string $data element content
537
-	* @access   private
538
-	*/
539
-	function schemaCharacterData($parser, $data){
540
-		$pos = $this->depth_array[$this->depth - 1];
541
-		$this->message[$pos]['cdata'] .= $data;
542
-	}
543
-
544
-	/**
545
-	* serialize the schema
546
-	*
547
-	* @access   public
548
-	*/
549
-	function serializeSchema(){
550
-
551
-		$schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion);
552
-		$xml = '';
553
-		// imports
554
-		if (sizeof($this->imports) > 0) {
555
-			foreach($this->imports as $ns => $list) {
556
-				foreach ($list as $ii) {
557
-					if ($ii['location'] != '') {
558
-						$xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n";
559
-					} else {
560
-						$xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n";
561
-					}
562
-				}
563
-			}
564
-		}
565
-		// complex types
566
-		foreach($this->complexTypes as $typeName => $attrs){
567
-			$contentStr = '';
568
-			// serialize child elements
569
-			if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
570
-				foreach($attrs['elements'] as $element => $eParts){
571
-					if(isset($eParts['ref'])){
572
-						$contentStr .= "   <$schemaPrefix:element ref=\"$element\"/>\n";
573
-					} else {
574
-						$contentStr .= "   <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"";
575
-						foreach ($eParts as $aName => $aValue) {
576
-							// handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable
577
-							if ($aName != 'name' && $aName != 'type') {
578
-								$contentStr .= " $aName=\"$aValue\"";
579
-							}
580
-						}
581
-						$contentStr .= "/>\n";
582
-					}
583
-				}
584
-				// compositor wraps elements
585
-				if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) {
586
-					$contentStr = "  <$schemaPrefix:$attrs[compositor]>\n".$contentStr."  </$schemaPrefix:$attrs[compositor]>\n";
587
-				}
588
-			}
589
-			// attributes
590
-			if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
591
-				foreach($attrs['attrs'] as $attr => $aParts){
592
-					$contentStr .= "    <$schemaPrefix:attribute";
593
-					foreach ($aParts as $a => $v) {
594
-						if ($a == 'ref' || $a == 'type') {
595
-							$contentStr .= " $a=\"".$this->contractQName($v).'"';
596
-						} elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') {
597
-							$this->usedNamespaces['wsdl'] = $this->namespaces['wsdl'];
598
-							$contentStr .= ' wsdl:arrayType="'.$this->contractQName($v).'"';
599
-						} else {
600
-							$contentStr .= " $a=\"$v\"";
601
-						}
602
-					}
603
-					$contentStr .= "/>\n";
604
-				}
605
-			}
606
-			// if restriction
607
-			if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
608
-				$contentStr = "   <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr."   </$schemaPrefix:restriction>\n";
609
-				// complex or simple content
610
-				if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
611
-					$contentStr = "  <$schemaPrefix:complexContent>\n".$contentStr."  </$schemaPrefix:complexContent>\n";
612
-				}
613
-			}
614
-			// finalize complex type
615
-			if($contentStr != ''){
616
-				$contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n";
617
-			} else {
618
-				$contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n";
619
-			}
620
-			$xml .= $contentStr;
621
-		}
622
-		// simple types
623
-		if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
624
-			foreach($this->simpleTypes as $typeName => $eParts){
625
-				$xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n  <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n";
626
-				if (isset($eParts['enumeration'])) {
627
-					foreach ($eParts['enumeration'] as $e) {
628
-						$xml .= "  <$schemaPrefix:enumeration value=\"$e\"/>\n";
629
-					}
630
-				}
631
-				$xml .= "  </$schemaPrefix:restriction>\n </$schemaPrefix:simpleType>";
632
-			}
633
-		}
634
-		// elements
635
-		if(isset($this->elements) && count($this->elements) > 0){
636
-			foreach($this->elements as $element => $eParts){
637
-				$xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n";
638
-			}
639
-		}
640
-		// attributes
641
-		if(isset($this->attributes) && count($this->attributes) > 0){
642
-			foreach($this->attributes as $attr => $aParts){
643
-				$xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>";
644
-			}
645
-		}
646
-		// finish 'er up
647
-		$attr = '';
648
-		foreach ($this->schemaInfo as $k => $v) {
649
-			if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') {
650
-				$attr .= " $k=\"$v\"";
651
-			}
652
-		}
653
-		$el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n";
654
-		foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
655
-			$el .= " xmlns:$nsp=\"$ns\"";
656
-		}
657
-		$xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n";
658
-		return $xml;
659
-	}
660
-
661
-	/**
662
-	* adds debug data to the clas level debug string
663
-	*
664
-	* @param    string $string debug data
665
-	* @access   private
666
-	*/
667
-	function xdebug($string){
668
-		$this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
669
-	}
530
+    }
531
+
532
+    /**
533
+     * element content handler
534
+     *
535
+     * @param    string $parser XML parser object
536
+     * @param    string $data element content
537
+     * @access   private
538
+     */
539
+    function schemaCharacterData($parser, $data){
540
+        $pos = $this->depth_array[$this->depth - 1];
541
+        $this->message[$pos]['cdata'] .= $data;
542
+    }
670 543
 
671 544
     /**
672
-    * get the PHP type of a user defined type in the schema
673
-    * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays
674
-    * returns false if no type exists, or not w/ the given namespace
675
-    * else returns a string that is either a native php type, or 'struct'
676
-    *
677
-    * @param string $type name of defined type
678
-    * @param string $ns namespace of type
679
-    * @return mixed
680
-    * @access public
681
-    * @deprecated
682
-    */
683
-	function getPHPType($type,$ns){
684
-		if(isset($this->typemap[$ns][$type])){
685
-			//print "found type '$type' and ns $ns in typemap<br>";
686
-			return $this->typemap[$ns][$type];
687
-		} elseif(isset($this->complexTypes[$type])){
688
-			//print "getting type '$type' and ns $ns from complexTypes array<br>";
689
-			return $this->complexTypes[$type]['phpType'];
690
-		}
691
-		return false;
692
-	}
693
-
694
-	/**
695
-    * returns an associative array of information about a given type
696
-    * returns false if no type exists by the given name
697
-    *
698
-	*	For a complexType typeDef = array(
699
-	*	'restrictionBase' => '',
700
-	*	'phpType' => '',
701
-	*	'compositor' => '(sequence|all)',
702
-	*	'elements' => array(), // refs to elements array
703
-	*	'attrs' => array() // refs to attributes array
704
-	*	... and so on (see addComplexType)
705
-	*	)
706
-	*
707
-	*   For simpleType or element, the array has different keys.
708
-    *
709
-    * @param string $type
710
-    * @return mixed
711
-    * @access public
712
-    * @see addComplexType
713
-    * @see addSimpleType
714
-    * @see addElement
715
-    */
716
-	function getTypeDef($type){
717
-		//$this->debug("in getTypeDef for type $type");
718
-		if (substr($type, -1) == '^') {
719
-			$is_element = 1;
720
-			$type = substr($type, 0, -1);
721
-		} else {
722
-			$is_element = 0;
723
-		}
724
-
725
-		if((! $is_element) && isset($this->complexTypes[$type])){
726
-			$this->xdebug("in getTypeDef, found complexType $type");
727
-			return $this->complexTypes[$type];
728
-		} elseif((! $is_element) && isset($this->simpleTypes[$type])){
729
-			$this->xdebug("in getTypeDef, found simpleType $type");
730
-			if (!isset($this->simpleTypes[$type]['phpType'])) {
731
-				// get info for type to tack onto the simple type
732
-				// TODO: can this ever really apply (i.e. what is a simpleType really?)
733
-				$uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1);
734
-				$ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':'));
735
-				$etype = $this->getTypeDef($uqType);
736
-				if ($etype) {
737
-					$this->xdebug("in getTypeDef, found type for simpleType $type:");
738
-					$this->xdebug($this->varDump($etype));
739
-					if (isset($etype['phpType'])) {
740
-						$this->simpleTypes[$type]['phpType'] = $etype['phpType'];
741
-					}
742
-					if (isset($etype['elements'])) {
743
-						$this->simpleTypes[$type]['elements'] = $etype['elements'];
744
-					}
745
-				}
746
-			}
747
-			return $this->simpleTypes[$type];
748
-		} elseif(isset($this->elements[$type])){
749
-			$this->xdebug("in getTypeDef, found element $type");
750
-			if (!isset($this->elements[$type]['phpType'])) {
751
-				// get info for type to tack onto the element
752
-				$uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1);
753
-				$ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':'));
754
-				$etype = $this->getTypeDef($uqType);
755
-				if ($etype) {
756
-					$this->xdebug("in getTypeDef, found type for element $type:");
757
-					$this->xdebug($this->varDump($etype));
758
-					if (isset($etype['phpType'])) {
759
-						$this->elements[$type]['phpType'] = $etype['phpType'];
760
-					}
761
-					if (isset($etype['elements'])) {
762
-						$this->elements[$type]['elements'] = $etype['elements'];
763
-					}
764
-					if (isset($etype['extensionBase'])) {
765
-						$this->elements[$type]['extensionBase'] = $etype['extensionBase'];
766
-					}
767
-				} elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
768
-					$this->xdebug("in getTypeDef, element $type is an XSD type");
769
-					$this->elements[$type]['phpType'] = 'scalar';
770
-				}
771
-			}
772
-			return $this->elements[$type];
773
-		} elseif(isset($this->attributes[$type])){
774
-			$this->xdebug("in getTypeDef, found attribute $type");
775
-			return $this->attributes[$type];
776
-		} elseif (preg_match('/_ContainedType$/', $type)) {
777
-			$this->xdebug("in getTypeDef, have an untyped element $type");
778
-			$typeDef['typeClass'] = 'simpleType';
779
-			$typeDef['phpType'] = 'scalar';
780
-			$typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string';
781
-			return $typeDef;
782
-		}
783
-		$this->xdebug("in getTypeDef, did not find $type");
784
-		return false;
785
-	}
786
-
787
-	/**
788
-    * returns a sample serialization of a given type, or false if no type by the given name
789
-    *
790
-    * @param string $type name of type
791
-    * @return mixed
792
-    * @access public
793
-    * @deprecated
794
-    */
545
+     * serialize the schema
546
+     *
547
+     * @access   public
548
+     */
549
+    function serializeSchema(){
550
+
551
+        $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion);
552
+        $xml = '';
553
+        // imports
554
+        if (sizeof($this->imports) > 0) {
555
+            foreach($this->imports as $ns => $list) {
556
+                foreach ($list as $ii) {
557
+                    if ($ii['location'] != '') {
558
+                        $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n";
559
+                    } else {
560
+                        $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n";
561
+                    }
562
+                }
563
+            }
564
+        }
565
+        // complex types
566
+        foreach($this->complexTypes as $typeName => $attrs){
567
+            $contentStr = '';
568
+            // serialize child elements
569
+            if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
570
+                foreach($attrs['elements'] as $element => $eParts){
571
+                    if(isset($eParts['ref'])){
572
+                        $contentStr .= "   <$schemaPrefix:element ref=\"$element\"/>\n";
573
+                    } else {
574
+                        $contentStr .= "   <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"";
575
+                        foreach ($eParts as $aName => $aValue) {
576
+                            // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable
577
+                            if ($aName != 'name' && $aName != 'type') {
578
+                                $contentStr .= " $aName=\"$aValue\"";
579
+                            }
580
+                        }
581
+                        $contentStr .= "/>\n";
582
+                    }
583
+                }
584
+                // compositor wraps elements
585
+                if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) {
586
+                    $contentStr = "  <$schemaPrefix:$attrs[compositor]>\n".$contentStr."  </$schemaPrefix:$attrs[compositor]>\n";
587
+                }
588
+            }
589
+            // attributes
590
+            if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
591
+                foreach($attrs['attrs'] as $attr => $aParts){
592
+                    $contentStr .= "    <$schemaPrefix:attribute";
593
+                    foreach ($aParts as $a => $v) {
594
+                        if ($a == 'ref' || $a == 'type') {
595
+                            $contentStr .= " $a=\"".$this->contractQName($v).'"';
596
+                        } elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') {
597
+                            $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl'];
598
+                            $contentStr .= ' wsdl:arrayType="'.$this->contractQName($v).'"';
599
+                        } else {
600
+                            $contentStr .= " $a=\"$v\"";
601
+                        }
602
+                    }
603
+                    $contentStr .= "/>\n";
604
+                }
605
+            }
606
+            // if restriction
607
+            if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
608
+                $contentStr = "   <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr."   </$schemaPrefix:restriction>\n";
609
+                // complex or simple content
610
+                if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
611
+                    $contentStr = "  <$schemaPrefix:complexContent>\n".$contentStr."  </$schemaPrefix:complexContent>\n";
612
+                }
613
+            }
614
+            // finalize complex type
615
+            if($contentStr != ''){
616
+                $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n";
617
+            } else {
618
+                $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n";
619
+            }
620
+            $xml .= $contentStr;
621
+        }
622
+        // simple types
623
+        if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
624
+            foreach($this->simpleTypes as $typeName => $eParts){
625
+                $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n  <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n";
626
+                if (isset($eParts['enumeration'])) {
627
+                    foreach ($eParts['enumeration'] as $e) {
628
+                        $xml .= "  <$schemaPrefix:enumeration value=\"$e\"/>\n";
629
+                    }
630
+                }
631
+                $xml .= "  </$schemaPrefix:restriction>\n </$schemaPrefix:simpleType>";
632
+            }
633
+        }
634
+        // elements
635
+        if(isset($this->elements) && count($this->elements) > 0){
636
+            foreach($this->elements as $element => $eParts){
637
+                $xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n";
638
+            }
639
+        }
640
+        // attributes
641
+        if(isset($this->attributes) && count($this->attributes) > 0){
642
+            foreach($this->attributes as $attr => $aParts){
643
+                $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>";
644
+            }
645
+        }
646
+        // finish 'er up
647
+        $attr = '';
648
+        foreach ($this->schemaInfo as $k => $v) {
649
+            if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') {
650
+                $attr .= " $k=\"$v\"";
651
+            }
652
+        }
653
+        $el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n";
654
+        foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
655
+            $el .= " xmlns:$nsp=\"$ns\"";
656
+        }
657
+        $xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n";
658
+        return $xml;
659
+    }
660
+
661
+    /**
662
+     * adds debug data to the clas level debug string
663
+     *
664
+     * @param    string $string debug data
665
+     * @access   private
666
+     */
667
+    function xdebug($string){
668
+        $this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
669
+    }
670
+
671
+    /**
672
+     * get the PHP type of a user defined type in the schema
673
+     * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays
674
+     * returns false if no type exists, or not w/ the given namespace
675
+     * else returns a string that is either a native php type, or 'struct'
676
+     *
677
+     * @param string $type name of defined type
678
+     * @param string $ns namespace of type
679
+     * @return mixed
680
+     * @access public
681
+     * @deprecated
682
+     */
683
+    function getPHPType($type,$ns){
684
+        if(isset($this->typemap[$ns][$type])){
685
+            //print "found type '$type' and ns $ns in typemap<br>";
686
+            return $this->typemap[$ns][$type];
687
+        } elseif(isset($this->complexTypes[$type])){
688
+            //print "getting type '$type' and ns $ns from complexTypes array<br>";
689
+            return $this->complexTypes[$type]['phpType'];
690
+        }
691
+        return false;
692
+    }
693
+
694
+    /**
695
+     * returns an associative array of information about a given type
696
+     * returns false if no type exists by the given name
697
+     *
698
+     *	For a complexType typeDef = array(
699
+     *	'restrictionBase' => '',
700
+     *	'phpType' => '',
701
+     *	'compositor' => '(sequence|all)',
702
+     *	'elements' => array(), // refs to elements array
703
+     *	'attrs' => array() // refs to attributes array
704
+     *	... and so on (see addComplexType)
705
+     *	)
706
+     *
707
+     *   For simpleType or element, the array has different keys.
708
+     *
709
+     * @param string $type
710
+     * @return mixed
711
+     * @access public
712
+     * @see addComplexType
713
+     * @see addSimpleType
714
+     * @see addElement
715
+     */
716
+    function getTypeDef($type){
717
+        //$this->debug("in getTypeDef for type $type");
718
+        if (substr($type, -1) == '^') {
719
+            $is_element = 1;
720
+            $type = substr($type, 0, -1);
721
+        } else {
722
+            $is_element = 0;
723
+        }
724
+
725
+        if((! $is_element) && isset($this->complexTypes[$type])){
726
+            $this->xdebug("in getTypeDef, found complexType $type");
727
+            return $this->complexTypes[$type];
728
+        } elseif((! $is_element) && isset($this->simpleTypes[$type])){
729
+            $this->xdebug("in getTypeDef, found simpleType $type");
730
+            if (!isset($this->simpleTypes[$type]['phpType'])) {
731
+                // get info for type to tack onto the simple type
732
+                // TODO: can this ever really apply (i.e. what is a simpleType really?)
733
+                $uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1);
734
+                $ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':'));
735
+                $etype = $this->getTypeDef($uqType);
736
+                if ($etype) {
737
+                    $this->xdebug("in getTypeDef, found type for simpleType $type:");
738
+                    $this->xdebug($this->varDump($etype));
739
+                    if (isset($etype['phpType'])) {
740
+                        $this->simpleTypes[$type]['phpType'] = $etype['phpType'];
741
+                    }
742
+                    if (isset($etype['elements'])) {
743
+                        $this->simpleTypes[$type]['elements'] = $etype['elements'];
744
+                    }
745
+                }
746
+            }
747
+            return $this->simpleTypes[$type];
748
+        } elseif(isset($this->elements[$type])){
749
+            $this->xdebug("in getTypeDef, found element $type");
750
+            if (!isset($this->elements[$type]['phpType'])) {
751
+                // get info for type to tack onto the element
752
+                $uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1);
753
+                $ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':'));
754
+                $etype = $this->getTypeDef($uqType);
755
+                if ($etype) {
756
+                    $this->xdebug("in getTypeDef, found type for element $type:");
757
+                    $this->xdebug($this->varDump($etype));
758
+                    if (isset($etype['phpType'])) {
759
+                        $this->elements[$type]['phpType'] = $etype['phpType'];
760
+                    }
761
+                    if (isset($etype['elements'])) {
762
+                        $this->elements[$type]['elements'] = $etype['elements'];
763
+                    }
764
+                    if (isset($etype['extensionBase'])) {
765
+                        $this->elements[$type]['extensionBase'] = $etype['extensionBase'];
766
+                    }
767
+                } elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
768
+                    $this->xdebug("in getTypeDef, element $type is an XSD type");
769
+                    $this->elements[$type]['phpType'] = 'scalar';
770
+                }
771
+            }
772
+            return $this->elements[$type];
773
+        } elseif(isset($this->attributes[$type])){
774
+            $this->xdebug("in getTypeDef, found attribute $type");
775
+            return $this->attributes[$type];
776
+        } elseif (preg_match('/_ContainedType$/', $type)) {
777
+            $this->xdebug("in getTypeDef, have an untyped element $type");
778
+            $typeDef['typeClass'] = 'simpleType';
779
+            $typeDef['phpType'] = 'scalar';
780
+            $typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string';
781
+            return $typeDef;
782
+        }
783
+        $this->xdebug("in getTypeDef, did not find $type");
784
+        return false;
785
+    }
786
+
787
+    /**
788
+     * returns a sample serialization of a given type, or false if no type by the given name
789
+     *
790
+     * @param string $type name of type
791
+     * @return mixed
792
+     * @access public
793
+     * @deprecated
794
+     */
795 795
     function serializeTypeDef($type){
796
-    	//print "in sTD() for type $type<br>";
797
-	if($typeDef = $this->getTypeDef($type)){
798
-		$str .= '<'.$type;
799
-	    if(is_array($typeDef['attrs'])){
800
-		foreach($typeDef['attrs'] as $attName => $data){
801
-		    $str .= " $attName=\"{type = ".$data['type']."}\"";
802
-		}
803
-	    }
804
-	    $str .= " xmlns=\"".$this->schema['targetNamespace']."\"";
805
-	    if(count($typeDef['elements']) > 0){
806
-		$str .= ">";
807
-		foreach($typeDef['elements'] as $element => $eData){
808
-		    $str .= $this->serializeTypeDef($element);
809
-		}
810
-		$str .= "</$type>";
811
-	    } elseif($typeDef['typeClass'] == 'element') {
812
-		$str .= "></$type>";
813
-	    } else {
814
-		$str .= "/>";
815
-	    }
816
-			return $str;
817
-	}
818
-    	return false;
796
+        //print "in sTD() for type $type<br>";
797
+    if($typeDef = $this->getTypeDef($type)){
798
+        $str .= '<'.$type;
799
+        if(is_array($typeDef['attrs'])){
800
+        foreach($typeDef['attrs'] as $attName => $data){
801
+            $str .= " $attName=\"{type = ".$data['type']."}\"";
802
+        }
803
+        }
804
+        $str .= " xmlns=\"".$this->schema['targetNamespace']."\"";
805
+        if(count($typeDef['elements']) > 0){
806
+        $str .= ">";
807
+        foreach($typeDef['elements'] as $element => $eData){
808
+            $str .= $this->serializeTypeDef($element);
809
+        }
810
+        $str .= "</$type>";
811
+        } elseif($typeDef['typeClass'] == 'element') {
812
+        $str .= "></$type>";
813
+        } else {
814
+        $str .= "/>";
815
+        }
816
+            return $str;
817
+    }
818
+        return false;
819 819
     }
820 820
 
821 821
     /**
822
-    * returns HTML form elements that allow a user
823
-    * to enter values for creating an instance of the given type.
824
-    *
825
-    * @param string $name name for type instance
826
-    * @param string $type name of type
827
-    * @return string
828
-    * @access public
829
-    * @deprecated
830
-	*/
831
-	function typeToForm($name,$type){
832
-		// get typedef
833
-		if($typeDef = $this->getTypeDef($type)){
834
-			// if struct
835
-			if($typeDef['phpType'] == 'struct'){
836
-				$buffer .= '<table>';
837
-				foreach($typeDef['elements'] as $child => $childDef){
838
-					$buffer .= "
822
+     * returns HTML form elements that allow a user
823
+     * to enter values for creating an instance of the given type.
824
+     *
825
+     * @param string $name name for type instance
826
+     * @param string $type name of type
827
+     * @return string
828
+     * @access public
829
+     * @deprecated
830
+     */
831
+    function typeToForm($name,$type){
832
+        // get typedef
833
+        if($typeDef = $this->getTypeDef($type)){
834
+            // if struct
835
+            if($typeDef['phpType'] == 'struct'){
836
+                $buffer .= '<table>';
837
+                foreach($typeDef['elements'] as $child => $childDef){
838
+                    $buffer .= "
839 839
 					<tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td>
840 840
 					<td><input type='text' name='parameters[".$name."][$childDef[name]]'></td></tr>";
841
-				}
842
-				$buffer .= '</table>';
843
-			// if array
844
-			} elseif($typeDef['phpType'] == 'array'){
845
-				$buffer .= '<table>';
846
-				for($i=0;$i < 3; $i++){
847
-					$buffer .= "
841
+                }
842
+                $buffer .= '</table>';
843
+            // if array
844
+            } elseif($typeDef['phpType'] == 'array'){
845
+                $buffer .= '<table>';
846
+                for($i=0;$i < 3; $i++){
847
+                    $buffer .= "
848 848
 					<tr><td align='right'>array item (type: $typeDef[arrayType]):</td>
849 849
 					<td><input type='text' name='parameters[".$name."][]'></td></tr>";
850
-				}
851
-				$buffer .= '</table>';
852
-			// if scalar
853
-			} else {
854
-				$buffer .= "<input type='text' name='parameters[$name]'>";
855
-			}
856
-		} else {
857
-			$buffer .= "<input type='text' name='parameters[$name]'>";
858
-		}
859
-		return $buffer;
860
-	}
861
-
862
-	/**
863
-	* adds a complex type to the schema
864
-	*
865
-	* example: array
866
-	*
867
-	* addType(
868
-	* 	'ArrayOfstring',
869
-	* 	'complexType',
870
-	* 	'array',
871
-	* 	'',
872
-	* 	'SOAP-ENC:Array',
873
-	* 	array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'),
874
-	* 	'xsd:string'
875
-	* );
876
-	*
877
-	* example: PHP associative array ( SOAP Struct )
878
-	*
879
-	* addType(
880
-	* 	'SOAPStruct',
881
-	* 	'complexType',
882
-	* 	'struct',
883
-	* 	'all',
884
-	* 	array('myVar'=> array('name'=>'myVar','type'=>'string')
885
-	* );
886
-	*
887
-	* @param name
888
-	* @param typeClass (complexType|simpleType|attribute)
889
-	* @param phpType: currently supported are array and struct (php assoc array)
890
-	* @param compositor (all|sequence|choice)
891
-	* @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
892
-	* @param elements = array ( name = array(name=>'',type=>'') )
893
-	* @param attrs = array(
894
-	* 	array(
895
-	*		'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType",
896
-	*		"http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]"
897
-	* 	)
898
-	* )
899
-	* @param arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string)
900
-	* @access public
901
-	* @see getTypeDef
902
-	*/
903
-	function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){
904
-		$this->complexTypes[$name] = array(
905
-	    'name'		=> $name,
906
-	    'typeClass'	=> $typeClass,
907
-	    'phpType'	=> $phpType,
908
-		'compositor'=> $compositor,
909
-	    'restrictionBase' => $restrictionBase,
910
-		'elements'	=> $elements,
911
-	    'attrs'		=> $attrs,
912
-	    'arrayType'	=> $arrayType
913
-		);
914
-
915
-		$this->xdebug("addComplexType $name:");
916
-		$this->appendDebug($this->varDump($this->complexTypes[$name]));
917
-	}
918
-
919
-	/**
920
-	* adds a simple type to the schema
921
-	*
922
-	* @param string $name
923
-	* @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
924
-	* @param string $typeClass (should always be simpleType)
925
-	* @param string $phpType (should always be scalar)
926
-	* @param array $enumeration array of values
927
-	* @access public
928
-	* @see nusoap_xmlschema
929
-	* @see getTypeDef
930
-	*/
931
-	function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
932
-		$this->simpleTypes[$name] = array(
933
-	    'name'			=> $name,
934
-	    'typeClass'		=> $typeClass,
935
-	    'phpType'		=> $phpType,
936
-	    'type'			=> $restrictionBase,
937
-	    'enumeration'	=> $enumeration
938
-		);
939
-
940
-		$this->xdebug("addSimpleType $name:");
941
-		$this->appendDebug($this->varDump($this->simpleTypes[$name]));
942
-	}
943
-
944
-	/**
945
-	* adds an element to the schema
946
-	*
947
-	* @param array $attrs attributes that must include name and type
948
-	* @see nusoap_xmlschema
949
-	* @access public
950
-	*/
951
-	function addElement($attrs) {
952
-		if (! $this->getPrefix($attrs['type'])) {
953
-			$attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type'];
954
-		}
955
-		$this->elements[ $attrs['name'] ] = $attrs;
956
-		$this->elements[ $attrs['name'] ]['typeClass'] = 'element';
957
-
958
-		$this->xdebug("addElement " . $attrs['name']);
959
-		$this->appendDebug($this->varDump($this->elements[ $attrs['name'] ]));
960
-	}
850
+                }
851
+                $buffer .= '</table>';
852
+            // if scalar
853
+            } else {
854
+                $buffer .= "<input type='text' name='parameters[$name]'>";
855
+            }
856
+        } else {
857
+            $buffer .= "<input type='text' name='parameters[$name]'>";
858
+        }
859
+        return $buffer;
860
+    }
861
+
862
+    /**
863
+     * adds a complex type to the schema
864
+     *
865
+     * example: array
866
+     *
867
+     * addType(
868
+     * 	'ArrayOfstring',
869
+     * 	'complexType',
870
+     * 	'array',
871
+     * 	'',
872
+     * 	'SOAP-ENC:Array',
873
+     * 	array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'),
874
+     * 	'xsd:string'
875
+     * );
876
+     *
877
+     * example: PHP associative array ( SOAP Struct )
878
+     *
879
+     * addType(
880
+     * 	'SOAPStruct',
881
+     * 	'complexType',
882
+     * 	'struct',
883
+     * 	'all',
884
+     * 	array('myVar'=> array('name'=>'myVar','type'=>'string')
885
+     * );
886
+     *
887
+     * @param name
888
+     * @param typeClass (complexType|simpleType|attribute)
889
+     * @param phpType: currently supported are array and struct (php assoc array)
890
+     * @param compositor (all|sequence|choice)
891
+     * @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
892
+     * @param elements = array ( name = array(name=>'',type=>'') )
893
+     * @param attrs = array(
894
+     * 	array(
895
+     *		'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType",
896
+     *		"http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]"
897
+     * 	)
898
+     * )
899
+     * @param arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string)
900
+     * @access public
901
+     * @see getTypeDef
902
+     */
903
+    function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){
904
+        $this->complexTypes[$name] = array(
905
+        'name'		=> $name,
906
+        'typeClass'	=> $typeClass,
907
+        'phpType'	=> $phpType,
908
+        'compositor'=> $compositor,
909
+        'restrictionBase' => $restrictionBase,
910
+        'elements'	=> $elements,
911
+        'attrs'		=> $attrs,
912
+        'arrayType'	=> $arrayType
913
+        );
914
+
915
+        $this->xdebug("addComplexType $name:");
916
+        $this->appendDebug($this->varDump($this->complexTypes[$name]));
917
+    }
918
+
919
+    /**
920
+     * adds a simple type to the schema
921
+     *
922
+     * @param string $name
923
+     * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
924
+     * @param string $typeClass (should always be simpleType)
925
+     * @param string $phpType (should always be scalar)
926
+     * @param array $enumeration array of values
927
+     * @access public
928
+     * @see nusoap_xmlschema
929
+     * @see getTypeDef
930
+     */
931
+    function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
932
+        $this->simpleTypes[$name] = array(
933
+        'name'			=> $name,
934
+        'typeClass'		=> $typeClass,
935
+        'phpType'		=> $phpType,
936
+        'type'			=> $restrictionBase,
937
+        'enumeration'	=> $enumeration
938
+        );
939
+
940
+        $this->xdebug("addSimpleType $name:");
941
+        $this->appendDebug($this->varDump($this->simpleTypes[$name]));
942
+    }
943
+
944
+    /**
945
+     * adds an element to the schema
946
+     *
947
+     * @param array $attrs attributes that must include name and type
948
+     * @see nusoap_xmlschema
949
+     * @access public
950
+     */
951
+    function addElement($attrs) {
952
+        if (! $this->getPrefix($attrs['type'])) {
953
+            $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type'];
954
+        }
955
+        $this->elements[ $attrs['name'] ] = $attrs;
956
+        $this->elements[ $attrs['name'] ]['typeClass'] = 'element';
957
+
958
+        $this->xdebug("addElement " . $attrs['name']);
959
+        $this->appendDebug($this->varDump($this->elements[ $attrs['name'] ]));
960
+    }
961 961
 }
962 962
 
963 963
 /**
Please login to merge, or discard this patch.
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	* @param	string $namespaces namespaces defined in enclosing XML
49 49
 	* @access   public
50 50
 	*/
51
-	function __construct($schema='',$xml='',$namespaces=array()){
51
+	function __construct($schema = '', $xml = '', $namespaces = array()) {
52 52
 		parent::__construct();
53 53
 		$this->debug('nusoap_xmlschema class instantiated, inside constructor');
54 54
 		// files
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
 		$this->namespaces = array_merge($this->namespaces, $namespaces);
61 61
 
62 62
 		// parse schema file
63
-		if($schema != ''){
63
+		if ($schema != '') {
64 64
 			$this->debug('initial schema file: '.$schema);
65 65
 			$this->parseFile($schema, 'schema');
66 66
 		}
67 67
 
68 68
 		// parse xml file
69
-		if($xml != ''){
69
+		if ($xml != '') {
70 70
 			$this->debug('initial xml file: '.$xml);
71 71
 			$this->parseFile($xml, 'xml');
72 72
 		}
@@ -81,18 +81,18 @@  discard block
 block discarded – undo
81 81
 	* @return boolean
82 82
     * @access public
83 83
     */
84
-	function parseFile($xml,$type){
84
+	function parseFile($xml, $type) {
85 85
 		// parse xml file
86
-		if($xml != ""){
87
-			$xmlStr = @join("",@file($xml));
88
-			if($xmlStr == ""){
86
+		if ($xml != "") {
87
+			$xmlStr = @join("", @file($xml));
88
+			if ($xmlStr == "") {
89 89
 				$msg = 'Error reading XML from '.$xml;
90 90
 				$this->setError($msg);
91 91
 				$this->debug($msg);
92 92
 			return false;
93 93
 			} else {
94 94
 				$this->debug("parsing $xml");
95
-				$this->parseString($xmlStr,$type);
95
+				$this->parseString($xmlStr, $type);
96 96
 				$this->debug("done parsing $xml");
97 97
 			return true;
98 98
 			}
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
     * @param	string $type (schema|xml)
108 108
 	* @access   private
109 109
 	*/
110
-	function parseString($xml,$type){
110
+	function parseString($xml, $type) {
111 111
 		// parse xml string
112
-		if($xml != ""){
112
+		if ($xml != "") {
113 113
 
114 114
 	    	// Create an XML parser.
115 115
 	    	$this->parser = xml_parser_create();
@@ -120,28 +120,28 @@  discard block
 block discarded – undo
120 120
 	    	xml_set_object($this->parser, $this);
121 121
 
122 122
 	    	// Set the element handlers for the parser.
123
-			if($type == "schema"){
124
-		    	xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement');
125
-		    	xml_set_character_data_handler($this->parser,'schemaCharacterData');
126
-			} elseif($type == "xml"){
127
-				xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement');
128
-		    	xml_set_character_data_handler($this->parser,'xmlCharacterData');
123
+			if ($type == "schema") {
124
+		    	xml_set_element_handler($this->parser, 'schemaStartElement', 'schemaEndElement');
125
+		    	xml_set_character_data_handler($this->parser, 'schemaCharacterData');
126
+			} elseif ($type == "xml") {
127
+				xml_set_element_handler($this->parser, 'xmlStartElement', 'xmlEndElement');
128
+		    	xml_set_character_data_handler($this->parser, 'xmlCharacterData');
129 129
 			}
130 130
 
131 131
 		    // Parse the XML file.
132
-		    if(!xml_parse($this->parser,$xml,true)){
132
+		    if (!xml_parse($this->parser, $xml, true)) {
133 133
 			// Display an error message.
134 134
 				$errstr = sprintf('XML error parsing XML schema on line %d: %s',
135 135
 				xml_get_current_line_number($this->parser),
136 136
 				xml_error_string(xml_get_error_code($this->parser))
137 137
 				);
138 138
 				$this->debug($errstr);
139
-				$this->debug("XML payload:\n" . $xml);
139
+				$this->debug("XML payload:\n".$xml);
140 140
 				$this->setError($errstr);
141 141
 	    	}
142 142
 
143 143
 			xml_parser_free($this->parser);
144
-		} else{
144
+		} else {
145 145
 			$this->debug('no xml passed to parseString()!!');
146 146
 			$this->setError('no xml passed to parseString()!!');
147 147
 		}
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
 	function CreateTypeName($ename) {
158 158
 		$scope = '';
159 159
 		for ($i = 0; $i < count($this->complexTypeStack); $i++) {
160
-			$scope .= $this->complexTypeStack[$i] . '_';
160
+			$scope .= $this->complexTypeStack[$i].'_';
161 161
 		}
162
-		return $scope . $ename . '_ContainedType';
162
+		return $scope.$ename.'_ContainedType';
163 163
 	}
164 164
 
165 165
 	/**
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		}
186 186
 
187 187
 		// get element prefix
188
-		if($prefix = $this->getPrefix($name)){
188
+		if ($prefix = $this->getPrefix($name)) {
189 189
 			// get unqualified name
190 190
 			$name = $this->getLocalPart($name);
191 191
 		} else {
@@ -193,31 +193,31 @@  discard block
 block discarded – undo
193 193
         }
194 194
 
195 195
         // loop thru attributes, expanding, and registering namespace declarations
196
-        if(count($attrs) > 0){
197
-        	foreach($attrs as $k => $v){
196
+        if (count($attrs) > 0) {
197
+        	foreach ($attrs as $k => $v) {
198 198
                 // if ns declarations, add to class level array of valid namespaces
199
-				if(preg_match('/^xmlns/',$k)){
199
+				if (preg_match('/^xmlns/', $k)) {
200 200
                 	//$this->xdebug("$k: $v");
201 201
                 	//$this->xdebug('ns_prefix: '.$this->getPrefix($k));
202
-                	if($ns_prefix = substr(strrchr($k,':'),1)){
202
+                	if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
203 203
                 		//$this->xdebug("Add namespace[$ns_prefix] = $v");
204 204
 						$this->namespaces[$ns_prefix] = $v;
205 205
 					} else {
206 206
 						$this->defaultNamespace[$pos] = $v;
207
-						if (! $this->getPrefixFromNamespace($v)) {
208
-							$this->namespaces['ns'.(count($this->namespaces)+1)] = $v;
207
+						if (!$this->getPrefixFromNamespace($v)) {
208
+							$this->namespaces['ns'.(count($this->namespaces) + 1)] = $v;
209 209
 						}
210 210
 					}
211
-					if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema'){
211
+					if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
212 212
 						$this->XMLSchemaVersion = $v;
213 213
 						$this->namespaces['xsi'] = $v.'-instance';
214 214
 					}
215 215
 				}
216 216
         	}
217
-        	foreach($attrs as $k => $v){
217
+        	foreach ($attrs as $k => $v) {
218 218
                 // expand each attribute
219
-                $k = strpos($k,':') ? $this->expandQname($k) : $k;
220
-                $v = strpos($v,':') ? $this->expandQname($v) : $v;
219
+                $k = strpos($k, ':') ? $this->expandQname($k) : $k;
220
+                $v = strpos($v, ':') ? $this->expandQname($v) : $v;
221 221
         		$eAttrs[$k] = $v;
222 222
         	}
223 223
         	$attrs = $eAttrs;
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         	$attrs = array();
226 226
         }
227 227
 		// find status, register data
228
-		switch($name){
228
+		switch ($name) {
229 229
 			case 'all':			// (optional) compositor content for a complexType
230 230
 			case 'choice':
231 231
 			case 'group':
@@ -250,41 +250,41 @@  discard block
 block discarded – undo
250 250
 						// no namespace in arrayType attribute value...
251 251
 						if ($this->defaultNamespace[$pos]) {
252 252
 							// ...so use the default
253
-							$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
253
+							$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos].':'.$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
254 254
 						}
255 255
 					}
256 256
             	}
257
-                if(isset($attrs['name'])){
257
+                if (isset($attrs['name'])) {
258 258
 					$this->attributes[$attrs['name']] = $attrs;
259 259
 					$aname = $attrs['name'];
260
-				} elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
260
+				} elseif (isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType') {
261 261
 					if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
262 262
 	                	$aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
263 263
 	                } else {
264 264
 	                	$aname = '';
265 265
 	                }
266
-				} elseif(isset($attrs['ref'])){
266
+				} elseif (isset($attrs['ref'])) {
267 267
 					$aname = $attrs['ref'];
268 268
                     $this->attributes[$attrs['ref']] = $attrs;
269 269
 				}
270 270
 
271
-				if($this->currentComplexType){	// This should *always* be
271
+				if ($this->currentComplexType) {	// This should *always* be
272 272
 					$this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs;
273 273
 				}
274 274
 				// arrayType attribute
275
-				if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
275
+				if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType') {
276 276
 					$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
277 277
                 	$prefix = $this->getPrefix($aname);
278
-					if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
278
+					if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
279 279
 						$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
280 280
 					} else {
281 281
 						$v = '';
282 282
 					}
283
-                    if(strpos($v,'[,]')){
283
+                    if (strpos($v, '[,]')) {
284 284
                         $this->complexTypes[$this->currentComplexType]['multidimensional'] = true;
285 285
                     }
286
-                    $v = substr($v,0,strpos($v,'[')); // clip the []
287
-                    if(!strpos($v,':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){
286
+                    $v = substr($v, 0, strpos($v, '[')); // clip the []
287
+                    if (!strpos($v, ':') && isset($this->typemap[$this->XMLSchemaVersion][$v])) {
288 288
                         $v = $this->XMLSchemaVersion.':'.$v;
289 289
                     }
290 290
                     $this->complexTypes[$this->currentComplexType]['arrayType'] = $v;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 			break;
296 296
 			case 'complexType':
297 297
 				array_push($this->complexTypeStack, $this->currentComplexType);
298
-				if(isset($attrs['name'])){
298
+				if (isset($attrs['name'])) {
299 299
 					// TODO: what is the scope of named complexTypes that appear
300 300
 					//       nested within other c complexTypes?
301 301
 					$this->xdebug('processing named complexType '.$attrs['name']);
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 					//                        minOccurs="0" maxOccurs="unbounded" />
311 311
 					//                </sequence>
312 312
 					//            </complexType>
313
-					if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
313
+					if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
314 314
 						$this->xdebug('complexType is unusual array');
315 315
 						$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
316 316
 					} else {
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 					}
319 319
 				} else {
320 320
 					$name = $this->CreateTypeName($this->currentElement);
321
-					$this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
321
+					$this->xdebug('processing unnamed complexType for element '.$this->currentElement.' named '.$name);
322 322
 					$this->currentComplexType = $name;
323 323
 					//$this->currentElement = false;
324 324
 					$this->complexTypes[$this->currentComplexType] = $attrs;
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 					//                        minOccurs="0" maxOccurs="unbounded" />
331 331
 					//                </sequence>
332 332
 					//            </complexType>
333
-					if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
333
+					if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
334 334
 						$this->xdebug('complexType is unusual array');
335 335
 						$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
336 336
 					} else {
@@ -349,12 +349,12 @@  discard block
 block discarded – undo
349 349
 						$attrs['form'] = 'qualified';
350 350
 					}
351 351
 				}
352
-				if(isset($attrs['type'])){
352
+				if (isset($attrs['type'])) {
353 353
 					$this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
354
-					if (! $this->getPrefix($attrs['type'])) {
354
+					if (!$this->getPrefix($attrs['type'])) {
355 355
 						if ($this->defaultNamespace[$pos]) {
356
-							$attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type'];
357
-							$this->xdebug('used default namespace to make type ' . $attrs['type']);
356
+							$attrs['type'] = $this->defaultNamespace[$pos].':'.$attrs['type'];
357
+							$this->xdebug('used default namespace to make type '.$attrs['type']);
358 358
 						}
359 359
 					}
360 360
 					// This is for constructs like
@@ -365,20 +365,20 @@  discard block
 block discarded – undo
365 365
 					//                </sequence>
366 366
 					//            </complexType>
367 367
 					if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
368
-						$this->xdebug('arrayType for unusual array is ' . $attrs['type']);
368
+						$this->xdebug('arrayType for unusual array is '.$attrs['type']);
369 369
 						$this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type'];
370 370
 					}
371 371
 					$this->currentElement = $attrs['name'];
372 372
 					$ename = $attrs['name'];
373
-				} elseif(isset($attrs['ref'])){
373
+				} elseif (isset($attrs['ref'])) {
374 374
 					$this->xdebug("processing element as ref to ".$attrs['ref']);
375 375
 					$this->currentElement = "ref to ".$attrs['ref'];
376 376
 					$ename = $this->getLocalPart($attrs['ref']);
377 377
 				} else {
378
-					$type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']);
379
-					$this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
378
+					$type = $this->CreateTypeName($this->currentComplexType.'_'.$attrs['name']);
379
+					$this->xdebug("processing untyped element ".$attrs['name'].' type '.$type);
380 380
 					$this->currentElement = $attrs['name'];
381
-					$attrs['type'] = $this->schemaTargetNamespace . ':' . $type;
381
+					$attrs['type'] = $this->schemaTargetNamespace.':'.$type;
382 382
 					$ename = $attrs['name'];
383 383
 				}
384 384
 				if (isset($ename) && $this->currentComplexType) {
@@ -386,12 +386,12 @@  discard block
 block discarded – undo
386 386
 					$this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs;
387 387
 				} elseif (!isset($attrs['ref'])) {
388 388
 					$this->xdebug("add element $ename to elements array");
389
-					$this->elements[ $attrs['name'] ] = $attrs;
390
-					$this->elements[ $attrs['name'] ]['typeClass'] = 'element';
389
+					$this->elements[$attrs['name']] = $attrs;
390
+					$this->elements[$attrs['name']]['typeClass'] = 'element';
391 391
 				}
392 392
 			break;
393 393
 			case 'enumeration':	//	restriction value list member
394
-				$this->xdebug('enumeration ' . $attrs['value']);
394
+				$this->xdebug('enumeration '.$attrs['value']);
395 395
 				if ($this->currentSimpleType) {
396 396
 					$this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value'];
397 397
 				} elseif ($this->currentComplexType) {
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
 				}
400 400
 			break;
401 401
 			case 'extension':	// simpleContent or complexContent type extension
402
-				$this->xdebug('extension ' . $attrs['base']);
402
+				$this->xdebug('extension '.$attrs['base']);
403 403
 				if ($this->currentComplexType) {
404 404
 					$ns = $this->getPrefix($attrs['base']);
405 405
 					if ($ns == '') {
406
-						$this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base'];
406
+						$this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace.':'.$attrs['base'];
407 407
 					} else {
408 408
 						$this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base'];
409 409
 					}
@@ -413,19 +413,19 @@  discard block
 block discarded – undo
413 413
 			break;
414 414
 			case 'import':
415 415
 			    if (isset($attrs['schemaLocation'])) {
416
-					$this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
416
+					$this->xdebug('import namespace '.$attrs['namespace'].' from '.$attrs['schemaLocation']);
417 417
                     $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
418 418
 				} else {
419
-					$this->xdebug('import namespace ' . $attrs['namespace']);
419
+					$this->xdebug('import namespace '.$attrs['namespace']);
420 420
                     $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
421
-					if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
422
-						$this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
421
+					if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
422
+						$this->namespaces['ns'.(count($this->namespaces) + 1)] = $attrs['namespace'];
423 423
 					}
424 424
 				}
425 425
 			break;
426 426
 			case 'include':
427 427
 			    if (isset($attrs['schemaLocation'])) {
428
-					$this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
428
+					$this->xdebug('include into namespace '.$this->schemaTargetNamespace.' from '.$attrs['schemaLocation']);
429 429
                     $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
430 430
 				} else {
431 431
 					$this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
@@ -435,12 +435,12 @@  discard block
 block discarded – undo
435 435
 				$this->xdebug("do nothing for element $name");
436 436
 			break;
437 437
 			case 'restriction':	// simpleType, simpleContent or complexContent value restriction
438
-				$this->xdebug('restriction ' . $attrs['base']);
439
-				if($this->currentSimpleType){
438
+				$this->xdebug('restriction '.$attrs['base']);
439
+				if ($this->currentSimpleType) {
440 440
 					$this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base'];
441
-				} elseif($this->currentComplexType){
441
+				} elseif ($this->currentComplexType) {
442 442
 					$this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base'];
443
-					if(strstr($attrs['base'],':') == ':Array'){
443
+					if (strstr($attrs['base'], ':') == ':Array') {
444 444
 						$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
445 445
 					}
446 446
 				}
@@ -467,15 +467,15 @@  discard block
 block discarded – undo
467 467
 			break;
468 468
 			case 'simpleType':
469 469
 				array_push($this->simpleTypeStack, $this->currentSimpleType);
470
-				if(isset($attrs['name'])){
471
-					$this->xdebug("processing simpleType for name " . $attrs['name']);
470
+				if (isset($attrs['name'])) {
471
+					$this->xdebug("processing simpleType for name ".$attrs['name']);
472 472
 					$this->currentSimpleType = $attrs['name'];
473
-					$this->simpleTypes[ $attrs['name'] ] = $attrs;
474
-					$this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType';
475
-					$this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar';
473
+					$this->simpleTypes[$attrs['name']] = $attrs;
474
+					$this->simpleTypes[$attrs['name']]['typeClass'] = 'simpleType';
475
+					$this->simpleTypes[$attrs['name']]['phpType'] = 'scalar';
476 476
 				} else {
477
-					$name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement);
478
-					$this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
477
+					$name = $this->CreateTypeName($this->currentComplexType.'_'.$this->currentElement);
478
+					$this->xdebug('processing unnamed simpleType for element '.$this->currentElement.' named '.$name);
479 479
 					$this->currentSimpleType = $name;
480 480
 					//$this->currentElement = false;
481 481
 					$this->simpleTypes[$this->currentSimpleType] = $attrs;
@@ -501,29 +501,29 @@  discard block
 block discarded – undo
501 501
 		// bring depth down a notch
502 502
 		$this->depth--;
503 503
 		// position of current element is equal to the last value left in depth_array for my depth
504
-		if(isset($this->depth_array[$this->depth])){
504
+		if (isset($this->depth_array[$this->depth])) {
505 505
         	$pos = $this->depth_array[$this->depth];
506 506
         }
507 507
 		// get element prefix
508
-		if ($prefix = $this->getPrefix($name)){
508
+		if ($prefix = $this->getPrefix($name)) {
509 509
 			// get unqualified name
510 510
 			$name = $this->getLocalPart($name);
511 511
 		} else {
512 512
         	$prefix = '';
513 513
         }
514 514
 		// move on...
515
-		if($name == 'complexType'){
516
-			$this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
515
+		if ($name == 'complexType') {
516
+			$this->xdebug('done processing complexType '.($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
517 517
 			$this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType]));
518 518
 			$this->currentComplexType = array_pop($this->complexTypeStack);
519 519
 			//$this->currentElement = false;
520 520
 		}
521
-		if($name == 'element'){
522
-			$this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)'));
521
+		if ($name == 'element') {
522
+			$this->xdebug('done processing element '.($this->currentElement ? $this->currentElement : '(unknown)'));
523 523
 			$this->currentElement = array_pop($this->elementStack);
524 524
 		}
525
-		if($name == 'simpleType'){
526
-			$this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
525
+		if ($name == 'simpleType') {
526
+			$this->xdebug('done processing simpleType '.($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
527 527
 			$this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType]));
528 528
 			$this->currentSimpleType = array_pop($this->simpleTypeStack);
529 529
 		}
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 	* @param    string $data element content
537 537
 	* @access   private
538 538
 	*/
539
-	function schemaCharacterData($parser, $data){
539
+	function schemaCharacterData($parser, $data) {
540 540
 		$pos = $this->depth_array[$this->depth - 1];
541 541
 		$this->message[$pos]['cdata'] .= $data;
542 542
 	}
@@ -546,32 +546,32 @@  discard block
 block discarded – undo
546 546
 	*
547 547
 	* @access   public
548 548
 	*/
549
-	function serializeSchema(){
549
+	function serializeSchema() {
550 550
 
551 551
 		$schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion);
552 552
 		$xml = '';
553 553
 		// imports
554 554
 		if (sizeof($this->imports) > 0) {
555
-			foreach($this->imports as $ns => $list) {
555
+			foreach ($this->imports as $ns => $list) {
556 556
 				foreach ($list as $ii) {
557 557
 					if ($ii['location'] != '') {
558
-						$xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n";
558
+						$xml .= " <$schemaPrefix:import location=\"".$ii['location'].'" namespace="'.$ns."\" />\n";
559 559
 					} else {
560
-						$xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n";
560
+						$xml .= " <$schemaPrefix:import namespace=\"".$ns."\" />\n";
561 561
 					}
562 562
 				}
563 563
 			}
564 564
 		}
565 565
 		// complex types
566
-		foreach($this->complexTypes as $typeName => $attrs){
566
+		foreach ($this->complexTypes as $typeName => $attrs) {
567 567
 			$contentStr = '';
568 568
 			// serialize child elements
569
-			if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
570
-				foreach($attrs['elements'] as $element => $eParts){
571
-					if(isset($eParts['ref'])){
569
+			if (isset($attrs['elements']) && (count($attrs['elements']) > 0)) {
570
+				foreach ($attrs['elements'] as $element => $eParts) {
571
+					if (isset($eParts['ref'])) {
572 572
 						$contentStr .= "   <$schemaPrefix:element ref=\"$element\"/>\n";
573 573
 					} else {
574
-						$contentStr .= "   <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"";
574
+						$contentStr .= "   <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"";
575 575
 						foreach ($eParts as $aName => $aValue) {
576 576
 							// handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable
577 577
 							if ($aName != 'name' && $aName != 'type') {
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
 				}
588 588
 			}
589 589
 			// attributes
590
-			if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
591
-				foreach($attrs['attrs'] as $attr => $aParts){
590
+			if (isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)) {
591
+				foreach ($attrs['attrs'] as $attr => $aParts) {
592 592
 					$contentStr .= "    <$schemaPrefix:attribute";
593 593
 					foreach ($aParts as $a => $v) {
594 594
 						if ($a == 'ref' || $a == 'type') {
@@ -604,15 +604,15 @@  discard block
 block discarded – undo
604 604
 				}
605 605
 			}
606 606
 			// if restriction
607
-			if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
607
+			if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != '') {
608 608
 				$contentStr = "   <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr."   </$schemaPrefix:restriction>\n";
609 609
 				// complex or simple content
610
-				if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
610
+				if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)) {
611 611
 					$contentStr = "  <$schemaPrefix:complexContent>\n".$contentStr."  </$schemaPrefix:complexContent>\n";
612 612
 				}
613 613
 			}
614 614
 			// finalize complex type
615
-			if($contentStr != ''){
615
+			if ($contentStr != '') {
616 616
 				$contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n";
617 617
 			} else {
618 618
 				$contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n";
@@ -620,8 +620,8 @@  discard block
 block discarded – undo
620 620
 			$xml .= $contentStr;
621 621
 		}
622 622
 		// simple types
623
-		if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
624
-			foreach($this->simpleTypes as $typeName => $eParts){
623
+		if (isset($this->simpleTypes) && count($this->simpleTypes) > 0) {
624
+			foreach ($this->simpleTypes as $typeName => $eParts) {
625 625
 				$xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n  <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n";
626 626
 				if (isset($eParts['enumeration'])) {
627 627
 					foreach ($eParts['enumeration'] as $e) {
@@ -632,14 +632,14 @@  discard block
 block discarded – undo
632 632
 			}
633 633
 		}
634 634
 		// elements
635
-		if(isset($this->elements) && count($this->elements) > 0){
636
-			foreach($this->elements as $element => $eParts){
635
+		if (isset($this->elements) && count($this->elements) > 0) {
636
+			foreach ($this->elements as $element => $eParts) {
637 637
 				$xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n";
638 638
 			}
639 639
 		}
640 640
 		// attributes
641
-		if(isset($this->attributes) && count($this->attributes) > 0){
642
-			foreach($this->attributes as $attr => $aParts){
641
+		if (isset($this->attributes) && count($this->attributes) > 0) {
642
+			foreach ($this->attributes as $attr => $aParts) {
643 643
 				$xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>";
644 644
 			}
645 645
 		}
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 		foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
655 655
 			$el .= " xmlns:$nsp=\"$ns\"";
656 656
 		}
657
-		$xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n";
657
+		$xml = $el.">\n".$xml."</$schemaPrefix:schema>\n";
658 658
 		return $xml;
659 659
 	}
660 660
 
@@ -664,8 +664,8 @@  discard block
 block discarded – undo
664 664
 	* @param    string $string debug data
665 665
 	* @access   private
666 666
 	*/
667
-	function xdebug($string){
668
-		$this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
667
+	function xdebug($string) {
668
+		$this->debug('<'.$this->schemaTargetNamespace.'> '.$string);
669 669
 	}
670 670
 
671 671
     /**
@@ -680,11 +680,11 @@  discard block
 block discarded – undo
680 680
     * @access public
681 681
     * @deprecated
682 682
     */
683
-	function getPHPType($type,$ns){
684
-		if(isset($this->typemap[$ns][$type])){
683
+	function getPHPType($type, $ns) {
684
+		if (isset($this->typemap[$ns][$type])) {
685 685
 			//print "found type '$type' and ns $ns in typemap<br>";
686 686
 			return $this->typemap[$ns][$type];
687
-		} elseif(isset($this->complexTypes[$type])){
687
+		} elseif (isset($this->complexTypes[$type])) {
688 688
 			//print "getting type '$type' and ns $ns from complexTypes array<br>";
689 689
 			return $this->complexTypes[$type]['phpType'];
690 690
 		}
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
     * @see addSimpleType
714 714
     * @see addElement
715 715
     */
716
-	function getTypeDef($type){
716
+	function getTypeDef($type) {
717 717
 		//$this->debug("in getTypeDef for type $type");
718 718
 		if (substr($type, -1) == '^') {
719 719
 			$is_element = 1;
@@ -722,10 +722,10 @@  discard block
 block discarded – undo
722 722
 			$is_element = 0;
723 723
 		}
724 724
 
725
-		if((! $is_element) && isset($this->complexTypes[$type])){
725
+		if ((!$is_element) && isset($this->complexTypes[$type])) {
726 726
 			$this->xdebug("in getTypeDef, found complexType $type");
727 727
 			return $this->complexTypes[$type];
728
-		} elseif((! $is_element) && isset($this->simpleTypes[$type])){
728
+		} elseif ((!$is_element) && isset($this->simpleTypes[$type])) {
729 729
 			$this->xdebug("in getTypeDef, found simpleType $type");
730 730
 			if (!isset($this->simpleTypes[$type]['phpType'])) {
731 731
 				// get info for type to tack onto the simple type
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 				}
746 746
 			}
747 747
 			return $this->simpleTypes[$type];
748
-		} elseif(isset($this->elements[$type])){
748
+		} elseif (isset($this->elements[$type])) {
749 749
 			$this->xdebug("in getTypeDef, found element $type");
750 750
 			if (!isset($this->elements[$type]['phpType'])) {
751 751
 				// get info for type to tack onto the element
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 				}
771 771
 			}
772 772
 			return $this->elements[$type];
773
-		} elseif(isset($this->attributes[$type])){
773
+		} elseif (isset($this->attributes[$type])) {
774 774
 			$this->xdebug("in getTypeDef, found attribute $type");
775 775
 			return $this->attributes[$type];
776 776
 		} elseif (preg_match('/_ContainedType$/', $type)) {
@@ -792,23 +792,23 @@  discard block
 block discarded – undo
792 792
     * @access public
793 793
     * @deprecated
794 794
     */
795
-    function serializeTypeDef($type){
795
+    function serializeTypeDef($type) {
796 796
     	//print "in sTD() for type $type<br>";
797
-	if($typeDef = $this->getTypeDef($type)){
797
+	if ($typeDef = $this->getTypeDef($type)) {
798 798
 		$str .= '<'.$type;
799
-	    if(is_array($typeDef['attrs'])){
800
-		foreach($typeDef['attrs'] as $attName => $data){
799
+	    if (is_array($typeDef['attrs'])) {
800
+		foreach ($typeDef['attrs'] as $attName => $data) {
801 801
 		    $str .= " $attName=\"{type = ".$data['type']."}\"";
802 802
 		}
803 803
 	    }
804 804
 	    $str .= " xmlns=\"".$this->schema['targetNamespace']."\"";
805
-	    if(count($typeDef['elements']) > 0){
805
+	    if (count($typeDef['elements']) > 0) {
806 806
 		$str .= ">";
807
-		foreach($typeDef['elements'] as $element => $eData){
807
+		foreach ($typeDef['elements'] as $element => $eData) {
808 808
 		    $str .= $this->serializeTypeDef($element);
809 809
 		}
810 810
 		$str .= "</$type>";
811
-	    } elseif($typeDef['typeClass'] == 'element') {
811
+	    } elseif ($typeDef['typeClass'] == 'element') {
812 812
 		$str .= "></$type>";
813 813
 	    } else {
814 814
 		$str .= "/>";
@@ -828,22 +828,22 @@  discard block
 block discarded – undo
828 828
     * @access public
829 829
     * @deprecated
830 830
 	*/
831
-	function typeToForm($name,$type){
831
+	function typeToForm($name, $type) {
832 832
 		// get typedef
833
-		if($typeDef = $this->getTypeDef($type)){
833
+		if ($typeDef = $this->getTypeDef($type)) {
834 834
 			// if struct
835
-			if($typeDef['phpType'] == 'struct'){
835
+			if ($typeDef['phpType'] == 'struct') {
836 836
 				$buffer .= '<table>';
837
-				foreach($typeDef['elements'] as $child => $childDef){
837
+				foreach ($typeDef['elements'] as $child => $childDef) {
838 838
 					$buffer .= "
839 839
 					<tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td>
840 840
 					<td><input type='text' name='parameters[".$name."][$childDef[name]]'></td></tr>";
841 841
 				}
842 842
 				$buffer .= '</table>';
843 843
 			// if array
844
-			} elseif($typeDef['phpType'] == 'array'){
844
+			} elseif ($typeDef['phpType'] == 'array') {
845 845
 				$buffer .= '<table>';
846
-				for($i=0;$i < 3; $i++){
846
+				for ($i = 0; $i < 3; $i++) {
847 847
 					$buffer .= "
848 848
 					<tr><td align='right'>array item (type: $typeDef[arrayType]):</td>
849 849
 					<td><input type='text' name='parameters[".$name."][]'></td></tr>";
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 	* @access public
901 901
 	* @see getTypeDef
902 902
 	*/
903
-	function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){
903
+	function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') {
904 904
 		$this->complexTypes[$name] = array(
905 905
 	    'name'		=> $name,
906 906
 	    'typeClass'	=> $typeClass,
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	* @see nusoap_xmlschema
929 929
 	* @see getTypeDef
930 930
 	*/
931
-	function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
931
+	function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) {
932 932
 		$this->simpleTypes[$name] = array(
933 933
 	    'name'			=> $name,
934 934
 	    'typeClass'		=> $typeClass,
@@ -949,14 +949,14 @@  discard block
 block discarded – undo
949 949
 	* @access public
950 950
 	*/
951 951
 	function addElement($attrs) {
952
-		if (! $this->getPrefix($attrs['type'])) {
953
-			$attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type'];
952
+		if (!$this->getPrefix($attrs['type'])) {
953
+			$attrs['type'] = $this->schemaTargetNamespace.':'.$attrs['type'];
954 954
 		}
955
-		$this->elements[ $attrs['name'] ] = $attrs;
956
-		$this->elements[ $attrs['name'] ]['typeClass'] = 'element';
955
+		$this->elements[$attrs['name']] = $attrs;
956
+		$this->elements[$attrs['name']]['typeClass'] = 'element';
957 957
 
958
-		$this->xdebug("addElement " . $attrs['name']);
959
-		$this->appendDebug($this->varDump($this->elements[ $attrs['name'] ]));
958
+		$this->xdebug("addElement ".$attrs['name']);
959
+		$this->appendDebug($this->varDump($this->elements[$attrs['name']]));
960 960
 	}
961 961
 }
962 962
 
Please login to merge, or discard this patch.
main/inc/lib/nusoap/nusoapmime.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -447,7 +447,7 @@
 block discarded – undo
447 447
 	*
448 448
 	* @param	array	$headers	The HTTP headers
449 449
 	* @param	string	$data		unprocessed request data from client
450
-	* @return	mixed	value of the message, decoded into a PHP type
450
+	* @return	false|null	value of the message, decoded into a PHP type
451 451
 	* @access   private
452 452
 	*/
453 453
     function parseRequest($headers, $data) {
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	* @access public
87 87
 	*/
88 88
 	function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
89
-		if (! $cid) {
89
+		if (!$cid) {
90 90
 			$cid = md5(uniqid(time()));
91 91
 		}
92 92
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	* @access   private
222 222
 	*/
223 223
     function parseResponse($headers, $data) {
224
-		$this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
224
+		$this->debug('Entering parseResponse() for payload of length '.strlen($data).' and type of '.$headers['content-type']);
225 225
 		$this->responseAttachments = array();
226 226
 		if (strstr($headers['content-type'], 'multipart/related')) {
227 227
 			$this->debug('Decode multipart/related');
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 			foreach ($headers as $k => $v) {
230 230
 				$input .= "$k: $v\r\n";
231 231
 			}
232
-			$params['input'] = $input . "\r\n" . $data;
232
+			$params['input'] = $input."\r\n".$data;
233 233
 			$params['include_bodies'] = true;
234 234
 			$params['decode_bodies'] = true;
235 235
 			$params['decode_headers'] = true;
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
 
239 239
 			foreach ($structure->parts as $part) {
240 240
 				if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
241
-					$this->debug('Have root part of type ' . $part->headers['content-type']);
241
+					$this->debug('Have root part of type '.$part->headers['content-type']);
242 242
 					$root = $part->body;
243 243
 					$return = parent::parseResponse($part->headers, $part->body);
244 244
 				} else {
245
-					$this->debug('Have an attachment of type ' . $part->headers['content-type']);
245
+					$this->debug('Have an attachment of type '.$part->headers['content-type']);
246 246
 					$info['data'] = $part->body;
247 247
 					$info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
248 248
 					$info['contenttype'] = $part->headers['content-type'];
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	* @access public
317 317
 	*/
318 318
 	function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
319
-		if (! $cid) {
319
+		if (!$cid) {
320 320
 			$cid = md5(uniqid(time()));
321 321
 		}
322 322
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	* @access   private
452 452
 	*/
453 453
     function parseRequest($headers, $data) {
454
-		$this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
454
+		$this->debug('Entering parseRequest() for payload of length '.strlen($data).' and type of '.$headers['content-type']);
455 455
 		$this->requestAttachments = array();
456 456
 		if (strstr($headers['content-type'], 'multipart/related')) {
457 457
 			$this->debug('Decode multipart/related');
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 			foreach ($headers as $k => $v) {
460 460
 				$input .= "$k: $v\r\n";
461 461
 			}
462
-			$params['input'] = $input . "\r\n" . $data;
462
+			$params['input'] = $input."\r\n".$data;
463 463
 			$params['include_bodies'] = true;
464 464
 			$params['decode_bodies'] = true;
465 465
 			$params['decode_headers'] = true;
@@ -468,10 +468,10 @@  discard block
 block discarded – undo
468 468
 
469 469
 			foreach ($structure->parts as $part) {
470 470
 				if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
471
-					$this->debug('Have root part of type ' . $part->headers['content-type']);
471
+					$this->debug('Have root part of type '.$part->headers['content-type']);
472 472
 					$return = parent::parseRequest($part->headers, $part->body);
473 473
 				} else {
474
-					$this->debug('Have an attachment of type ' . $part->headers['content-type']);
474
+					$this->debug('Have an attachment of type '.$part->headers['content-type']);
475 475
 					$info['data'] = $part->body;
476 476
 					$info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
477 477
 					$info['contenttype'] = $part->headers['content-type'];
Please login to merge, or discard this patch.
Indentation   +418 added lines, -418 removed lines patch added patch discarded remove patch
@@ -52,224 +52,224 @@  discard block
 block discarded – undo
52 52
 * @access   public
53 53
 */
54 54
 class nusoap_client_mime extends nusoap_client {
55
-	/**
56
-	 * @var array Each array element in the return is an associative array with keys
57
-	 * data, filename, contenttype, cid
58
-	 * @access private
59
-	 */
60
-	var $requestAttachments = array();
61
-	/**
62
-	 * @var array Each array element in the return is an associative array with keys
63
-	 * data, filename, contenttype, cid
64
-	 * @access private
65
-	 */
66
-	var $responseAttachments;
67
-	/**
68
-	 * @var string
69
-	 * @access private
70
-	 */
71
-	var $mimeContentType;
72
-
73
-	/**
74
-	* adds a MIME attachment to the current request.
75
-	*
76
-	* If the $data parameter contains an empty string, this method will read
77
-	* the contents of the file named by the $filename parameter.
78
-	*
79
-	* If the $cid parameter is false, this method will generate the cid.
80
-	*
81
-	* @param string $data The data of the attachment
82
-	* @param string $filename The filename of the attachment (default is empty string)
83
-	* @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
84
-	* @param string $cid The content-id (cid) of the attachment (default is false)
85
-	* @return string The content-id (cid) of the attachment
86
-	* @access public
87
-	*/
88
-	function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
89
-		if (! $cid) {
90
-			$cid = md5(uniqid(time()));
91
-		}
92
-
93
-		$info['data'] = $data;
94
-		$info['filename'] = $filename;
95
-		$info['contenttype'] = $contenttype;
96
-		$info['cid'] = $cid;
97
-
98
-		$this->requestAttachments[] = $info;
99
-
100
-		return $cid;
101
-	}
102
-
103
-	/**
104
-	* clears the MIME attachments for the current request.
105
-	*
106
-	* @access public
107
-	*/
108
-	function clearAttachments() {
109
-		$this->requestAttachments = array();
110
-	}
111
-
112
-	/**
113
-	* gets the MIME attachments from the current response.
114
-	*
115
-	* Each array element in the return is an associative array with keys
116
-	* data, filename, contenttype, cid.  These keys correspond to the parameters
117
-	* for addAttachment.
118
-	*
119
-	* @return array The attachments.
120
-	* @access public
121
-	*/
122
-	function getAttachments() {
123
-		return $this->responseAttachments;
124
-	}
125
-
126
-	/**
127
-	* gets the HTTP body for the current request.
128
-	*
129
-	* @param string $soapmsg The SOAP payload
130
-	* @return string The HTTP body, which includes the SOAP payload
131
-	* @access private
132
-	*/
133
-	function getHTTPBody($soapmsg) {
134
-		if (count($this->requestAttachments) > 0) {
135
-			$params['content_type'] = 'multipart/related; type="text/xml"';
136
-			$mimeMessage = new Mail_mimePart('', $params);
137
-			unset($params);
138
-
139
-			$params['content_type'] = 'text/xml';
140
-			$params['encoding']     = '8bit';
141
-			$params['charset']      = $this->soap_defencoding;
142
-			$mimeMessage->addSubpart($soapmsg, $params);
143
-
144
-			foreach ($this->requestAttachments as $att) {
145
-				unset($params);
146
-
147
-				$params['content_type'] = $att['contenttype'];
148
-				$params['encoding']     = 'base64';
149
-				$params['disposition']  = 'attachment';
150
-				$params['dfilename']    = $att['filename'];
151
-				$params['cid']          = $att['cid'];
152
-
153
-				if ($att['data'] == '' && $att['filename'] <> '') {
154
-					if ($fd = fopen($att['filename'], 'rb')) {
155
-						$data = fread($fd, filesize($att['filename']));
156
-						fclose($fd);
157
-					} else {
158
-						$data = '';
159
-					}
160
-					$mimeMessage->addSubpart($data, $params);
161
-				} else {
162
-					$mimeMessage->addSubpart($att['data'], $params);
163
-				}
164
-			}
165
-
166
-			$output = $mimeMessage->encode();
167
-			$mimeHeaders = $output['headers'];
168
-
169
-			foreach ($mimeHeaders as $k => $v) {
170
-				$this->debug("MIME header $k: $v");
171
-				if (strtolower($k) == 'content-type') {
172
-					// PHP header() seems to strip leading whitespace starting
173
-					// the second line, so force everything to one line
174
-					$this->mimeContentType = str_replace("\r\n", " ", $v);
175
-				}
176
-			}
177
-
178
-			return $output['body'];
179
-		}
180
-
181
-		return parent::getHTTPBody($soapmsg);
182
-	}
183
-
184
-	/**
185
-	* gets the HTTP content type for the current request.
186
-	*
187
-	* Note: getHTTPBody must be called before this.
188
-	*
189
-	* @return string the HTTP content type for the current request.
190
-	* @access private
191
-	*/
192
-	function getHTTPContentType() {
193
-		if (count($this->requestAttachments) > 0) {
194
-			return $this->mimeContentType;
195
-		}
196
-		return parent::getHTTPContentType();
197
-	}
198
-
199
-	/**
200
-	* gets the HTTP content type charset for the current request.
201
-	* returns false for non-text content types.
202
-	*
203
-	* Note: getHTTPBody must be called before this.
204
-	*
205
-	* @return string the HTTP content type charset for the current request.
206
-	* @access private
207
-	*/
208
-	function getHTTPContentTypeCharset() {
209
-		if (count($this->requestAttachments) > 0) {
210
-			return false;
211
-		}
212
-		return parent::getHTTPContentTypeCharset();
213
-	}
214
-
215
-	/**
216
-	* processes SOAP message returned from server
217
-	*
218
-	* @param	array	$headers	The HTTP headers
219
-	* @param	string	$data		unprocessed response data from server
220
-	* @return	mixed	value of the message, decoded into a PHP type
221
-	* @access   private
222
-	*/
55
+    /**
56
+     * @var array Each array element in the return is an associative array with keys
57
+     * data, filename, contenttype, cid
58
+     * @access private
59
+     */
60
+    var $requestAttachments = array();
61
+    /**
62
+     * @var array Each array element in the return is an associative array with keys
63
+     * data, filename, contenttype, cid
64
+     * @access private
65
+     */
66
+    var $responseAttachments;
67
+    /**
68
+     * @var string
69
+     * @access private
70
+     */
71
+    var $mimeContentType;
72
+
73
+    /**
74
+     * adds a MIME attachment to the current request.
75
+     *
76
+     * If the $data parameter contains an empty string, this method will read
77
+     * the contents of the file named by the $filename parameter.
78
+     *
79
+     * If the $cid parameter is false, this method will generate the cid.
80
+     *
81
+     * @param string $data The data of the attachment
82
+     * @param string $filename The filename of the attachment (default is empty string)
83
+     * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
84
+     * @param string $cid The content-id (cid) of the attachment (default is false)
85
+     * @return string The content-id (cid) of the attachment
86
+     * @access public
87
+     */
88
+    function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
89
+        if (! $cid) {
90
+            $cid = md5(uniqid(time()));
91
+        }
92
+
93
+        $info['data'] = $data;
94
+        $info['filename'] = $filename;
95
+        $info['contenttype'] = $contenttype;
96
+        $info['cid'] = $cid;
97
+
98
+        $this->requestAttachments[] = $info;
99
+
100
+        return $cid;
101
+    }
102
+
103
+    /**
104
+     * clears the MIME attachments for the current request.
105
+     *
106
+     * @access public
107
+     */
108
+    function clearAttachments() {
109
+        $this->requestAttachments = array();
110
+    }
111
+
112
+    /**
113
+     * gets the MIME attachments from the current response.
114
+     *
115
+     * Each array element in the return is an associative array with keys
116
+     * data, filename, contenttype, cid.  These keys correspond to the parameters
117
+     * for addAttachment.
118
+     *
119
+     * @return array The attachments.
120
+     * @access public
121
+     */
122
+    function getAttachments() {
123
+        return $this->responseAttachments;
124
+    }
125
+
126
+    /**
127
+     * gets the HTTP body for the current request.
128
+     *
129
+     * @param string $soapmsg The SOAP payload
130
+     * @return string The HTTP body, which includes the SOAP payload
131
+     * @access private
132
+     */
133
+    function getHTTPBody($soapmsg) {
134
+        if (count($this->requestAttachments) > 0) {
135
+            $params['content_type'] = 'multipart/related; type="text/xml"';
136
+            $mimeMessage = new Mail_mimePart('', $params);
137
+            unset($params);
138
+
139
+            $params['content_type'] = 'text/xml';
140
+            $params['encoding']     = '8bit';
141
+            $params['charset']      = $this->soap_defencoding;
142
+            $mimeMessage->addSubpart($soapmsg, $params);
143
+
144
+            foreach ($this->requestAttachments as $att) {
145
+                unset($params);
146
+
147
+                $params['content_type'] = $att['contenttype'];
148
+                $params['encoding']     = 'base64';
149
+                $params['disposition']  = 'attachment';
150
+                $params['dfilename']    = $att['filename'];
151
+                $params['cid']          = $att['cid'];
152
+
153
+                if ($att['data'] == '' && $att['filename'] <> '') {
154
+                    if ($fd = fopen($att['filename'], 'rb')) {
155
+                        $data = fread($fd, filesize($att['filename']));
156
+                        fclose($fd);
157
+                    } else {
158
+                        $data = '';
159
+                    }
160
+                    $mimeMessage->addSubpart($data, $params);
161
+                } else {
162
+                    $mimeMessage->addSubpart($att['data'], $params);
163
+                }
164
+            }
165
+
166
+            $output = $mimeMessage->encode();
167
+            $mimeHeaders = $output['headers'];
168
+
169
+            foreach ($mimeHeaders as $k => $v) {
170
+                $this->debug("MIME header $k: $v");
171
+                if (strtolower($k) == 'content-type') {
172
+                    // PHP header() seems to strip leading whitespace starting
173
+                    // the second line, so force everything to one line
174
+                    $this->mimeContentType = str_replace("\r\n", " ", $v);
175
+                }
176
+            }
177
+
178
+            return $output['body'];
179
+        }
180
+
181
+        return parent::getHTTPBody($soapmsg);
182
+    }
183
+
184
+    /**
185
+     * gets the HTTP content type for the current request.
186
+     *
187
+     * Note: getHTTPBody must be called before this.
188
+     *
189
+     * @return string the HTTP content type for the current request.
190
+     * @access private
191
+     */
192
+    function getHTTPContentType() {
193
+        if (count($this->requestAttachments) > 0) {
194
+            return $this->mimeContentType;
195
+        }
196
+        return parent::getHTTPContentType();
197
+    }
198
+
199
+    /**
200
+     * gets the HTTP content type charset for the current request.
201
+     * returns false for non-text content types.
202
+     *
203
+     * Note: getHTTPBody must be called before this.
204
+     *
205
+     * @return string the HTTP content type charset for the current request.
206
+     * @access private
207
+     */
208
+    function getHTTPContentTypeCharset() {
209
+        if (count($this->requestAttachments) > 0) {
210
+            return false;
211
+        }
212
+        return parent::getHTTPContentTypeCharset();
213
+    }
214
+
215
+    /**
216
+     * processes SOAP message returned from server
217
+     *
218
+     * @param	array	$headers	The HTTP headers
219
+     * @param	string	$data		unprocessed response data from server
220
+     * @return	mixed	value of the message, decoded into a PHP type
221
+     * @access   private
222
+     */
223 223
     function parseResponse($headers, $data) {
224
-		$this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
225
-		$this->responseAttachments = array();
226
-		if (strstr($headers['content-type'], 'multipart/related')) {
227
-			$this->debug('Decode multipart/related');
228
-			$input = '';
229
-			foreach ($headers as $k => $v) {
230
-				$input .= "$k: $v\r\n";
231
-			}
232
-			$params['input'] = $input . "\r\n" . $data;
233
-			$params['include_bodies'] = true;
234
-			$params['decode_bodies'] = true;
235
-			$params['decode_headers'] = true;
236
-
237
-			$structure = Mail_mimeDecode::decode($params);
238
-
239
-			foreach ($structure->parts as $part) {
240
-				if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
241
-					$this->debug('Have root part of type ' . $part->headers['content-type']);
242
-					$root = $part->body;
243
-					$return = parent::parseResponse($part->headers, $part->body);
244
-				} else {
245
-					$this->debug('Have an attachment of type ' . $part->headers['content-type']);
246
-					$info['data'] = $part->body;
247
-					$info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
248
-					$info['contenttype'] = $part->headers['content-type'];
249
-					$info['cid'] = $part->headers['content-id'];
250
-					$this->responseAttachments[] = $info;
251
-				}
252
-			}
253
-
254
-			if (isset($return)) {
255
-				$this->responseData = $root;
256
-				return $return;
257
-			}
258
-
259
-			$this->setError('No root part found in multipart/related content');
260
-			return '';
261
-		}
262
-		$this->debug('Not multipart/related');
263
-		return parent::parseResponse($headers, $data);
264
-	}
224
+        $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
225
+        $this->responseAttachments = array();
226
+        if (strstr($headers['content-type'], 'multipart/related')) {
227
+            $this->debug('Decode multipart/related');
228
+            $input = '';
229
+            foreach ($headers as $k => $v) {
230
+                $input .= "$k: $v\r\n";
231
+            }
232
+            $params['input'] = $input . "\r\n" . $data;
233
+            $params['include_bodies'] = true;
234
+            $params['decode_bodies'] = true;
235
+            $params['decode_headers'] = true;
236
+
237
+            $structure = Mail_mimeDecode::decode($params);
238
+
239
+            foreach ($structure->parts as $part) {
240
+                if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
241
+                    $this->debug('Have root part of type ' . $part->headers['content-type']);
242
+                    $root = $part->body;
243
+                    $return = parent::parseResponse($part->headers, $part->body);
244
+                } else {
245
+                    $this->debug('Have an attachment of type ' . $part->headers['content-type']);
246
+                    $info['data'] = $part->body;
247
+                    $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
248
+                    $info['contenttype'] = $part->headers['content-type'];
249
+                    $info['cid'] = $part->headers['content-id'];
250
+                    $this->responseAttachments[] = $info;
251
+                }
252
+            }
253
+
254
+            if (isset($return)) {
255
+                $this->responseData = $root;
256
+                return $return;
257
+            }
258
+
259
+            $this->setError('No root part found in multipart/related content');
260
+            return '';
261
+        }
262
+        $this->debug('Not multipart/related');
263
+        return parent::parseResponse($headers, $data);
264
+    }
265 265
 }
266 266
 
267 267
 /*
268 268
  *	For backwards compatiblity, define soapclientmime unless the PHP SOAP extension is loaded.
269 269
  */
270 270
 if (!extension_loaded('soap')) {
271
-	class soapclientmime extends nusoap_client_mime {
272
-	}
271
+    class soapclientmime extends nusoap_client_mime {
272
+    }
273 273
 }
274 274
 
275 275
 /**
@@ -282,214 +282,214 @@  discard block
 block discarded – undo
282 282
 * @access   public
283 283
 */
284 284
 class nusoap_server_mime extends nusoap_server {
285
-	/**
286
-	 * @var array Each array element in the return is an associative array with keys
287
-	 * data, filename, contenttype, cid
288
-	 * @access private
289
-	 */
290
-	var $requestAttachments = array();
291
-	/**
292
-	 * @var array Each array element in the return is an associative array with keys
293
-	 * data, filename, contenttype, cid
294
-	 * @access private
295
-	 */
296
-	var $responseAttachments;
297
-	/**
298
-	 * @var string
299
-	 * @access private
300
-	 */
301
-	var $mimeContentType;
302
-
303
-	/**
304
-	* adds a MIME attachment to the current response.
305
-	*
306
-	* If the $data parameter contains an empty string, this method will read
307
-	* the contents of the file named by the $filename parameter.
308
-	*
309
-	* If the $cid parameter is false, this method will generate the cid.
310
-	*
311
-	* @param string $data The data of the attachment
312
-	* @param string $filename The filename of the attachment (default is empty string)
313
-	* @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
314
-	* @param string $cid The content-id (cid) of the attachment (default is false)
315
-	* @return string The content-id (cid) of the attachment
316
-	* @access public
317
-	*/
318
-	function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
319
-		if (! $cid) {
320
-			$cid = md5(uniqid(time()));
321
-		}
322
-
323
-		$info['data'] = $data;
324
-		$info['filename'] = $filename;
325
-		$info['contenttype'] = $contenttype;
326
-		$info['cid'] = $cid;
327
-
328
-		$this->responseAttachments[] = $info;
329
-
330
-		return $cid;
331
-	}
332
-
333
-	/**
334
-	* clears the MIME attachments for the current response.
335
-	*
336
-	* @access public
337
-	*/
338
-	function clearAttachments() {
339
-		$this->responseAttachments = array();
340
-	}
341
-
342
-	/**
343
-	* gets the MIME attachments from the current request.
344
-	*
345
-	* Each array element in the return is an associative array with keys
346
-	* data, filename, contenttype, cid.  These keys correspond to the parameters
347
-	* for addAttachment.
348
-	*
349
-	* @return array The attachments.
350
-	* @access public
351
-	*/
352
-	function getAttachments() {
353
-		return $this->requestAttachments;
354
-	}
355
-
356
-	/**
357
-	* gets the HTTP body for the current response.
358
-	*
359
-	* @param string $soapmsg The SOAP payload
360
-	* @return string The HTTP body, which includes the SOAP payload
361
-	* @access private
362
-	*/
363
-	function getHTTPBody($soapmsg) {
364
-		if (count($this->responseAttachments) > 0) {
365
-			$params['content_type'] = 'multipart/related; type="text/xml"';
366
-			$mimeMessage = new Mail_mimePart('', $params);
367
-			unset($params);
368
-
369
-			$params['content_type'] = 'text/xml';
370
-			$params['encoding']     = '8bit';
371
-			$params['charset']      = $this->soap_defencoding;
372
-			$mimeMessage->addSubpart($soapmsg, $params);
373
-
374
-			foreach ($this->responseAttachments as $att) {
375
-				unset($params);
376
-
377
-				$params['content_type'] = $att['contenttype'];
378
-				$params['encoding']     = 'base64';
379
-				$params['disposition']  = 'attachment';
380
-				$params['dfilename']    = $att['filename'];
381
-				$params['cid']          = $att['cid'];
382
-
383
-				if ($att['data'] == '' && $att['filename'] <> '') {
384
-					if ($fd = fopen($att['filename'], 'rb')) {
385
-						$data = fread($fd, filesize($att['filename']));
386
-						fclose($fd);
387
-					} else {
388
-						$data = '';
389
-					}
390
-					$mimeMessage->addSubpart($data, $params);
391
-				} else {
392
-					$mimeMessage->addSubpart($att['data'], $params);
393
-				}
394
-			}
395
-
396
-			$output = $mimeMessage->encode();
397
-			$mimeHeaders = $output['headers'];
398
-
399
-			foreach ($mimeHeaders as $k => $v) {
400
-				$this->debug("MIME header $k: $v");
401
-				if (strtolower($k) == 'content-type') {
402
-					// PHP header() seems to strip leading whitespace starting
403
-					// the second line, so force everything to one line
404
-					$this->mimeContentType = str_replace("\r\n", " ", $v);
405
-				}
406
-			}
407
-
408
-			return $output['body'];
409
-		}
410
-
411
-		return parent::getHTTPBody($soapmsg);
412
-	}
413
-
414
-	/**
415
-	* gets the HTTP content type for the current response.
416
-	*
417
-	* Note: getHTTPBody must be called before this.
418
-	*
419
-	* @return string the HTTP content type for the current response.
420
-	* @access private
421
-	*/
422
-	function getHTTPContentType() {
423
-		if (count($this->responseAttachments) > 0) {
424
-			return $this->mimeContentType;
425
-		}
426
-		return parent::getHTTPContentType();
427
-	}
428
-
429
-	/**
430
-	* gets the HTTP content type charset for the current response.
431
-	* returns false for non-text content types.
432
-	*
433
-	* Note: getHTTPBody must be called before this.
434
-	*
435
-	* @return string the HTTP content type charset for the current response.
436
-	* @access private
437
-	*/
438
-	function getHTTPContentTypeCharset() {
439
-		if (count($this->responseAttachments) > 0) {
440
-			return false;
441
-		}
442
-		return parent::getHTTPContentTypeCharset();
443
-	}
444
-
445
-	/**
446
-	* processes SOAP message received from client
447
-	*
448
-	* @param	array	$headers	The HTTP headers
449
-	* @param	string	$data		unprocessed request data from client
450
-	* @return	mixed	value of the message, decoded into a PHP type
451
-	* @access   private
452
-	*/
285
+    /**
286
+     * @var array Each array element in the return is an associative array with keys
287
+     * data, filename, contenttype, cid
288
+     * @access private
289
+     */
290
+    var $requestAttachments = array();
291
+    /**
292
+     * @var array Each array element in the return is an associative array with keys
293
+     * data, filename, contenttype, cid
294
+     * @access private
295
+     */
296
+    var $responseAttachments;
297
+    /**
298
+     * @var string
299
+     * @access private
300
+     */
301
+    var $mimeContentType;
302
+
303
+    /**
304
+     * adds a MIME attachment to the current response.
305
+     *
306
+     * If the $data parameter contains an empty string, this method will read
307
+     * the contents of the file named by the $filename parameter.
308
+     *
309
+     * If the $cid parameter is false, this method will generate the cid.
310
+     *
311
+     * @param string $data The data of the attachment
312
+     * @param string $filename The filename of the attachment (default is empty string)
313
+     * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
314
+     * @param string $cid The content-id (cid) of the attachment (default is false)
315
+     * @return string The content-id (cid) of the attachment
316
+     * @access public
317
+     */
318
+    function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
319
+        if (! $cid) {
320
+            $cid = md5(uniqid(time()));
321
+        }
322
+
323
+        $info['data'] = $data;
324
+        $info['filename'] = $filename;
325
+        $info['contenttype'] = $contenttype;
326
+        $info['cid'] = $cid;
327
+
328
+        $this->responseAttachments[] = $info;
329
+
330
+        return $cid;
331
+    }
332
+
333
+    /**
334
+     * clears the MIME attachments for the current response.
335
+     *
336
+     * @access public
337
+     */
338
+    function clearAttachments() {
339
+        $this->responseAttachments = array();
340
+    }
341
+
342
+    /**
343
+     * gets the MIME attachments from the current request.
344
+     *
345
+     * Each array element in the return is an associative array with keys
346
+     * data, filename, contenttype, cid.  These keys correspond to the parameters
347
+     * for addAttachment.
348
+     *
349
+     * @return array The attachments.
350
+     * @access public
351
+     */
352
+    function getAttachments() {
353
+        return $this->requestAttachments;
354
+    }
355
+
356
+    /**
357
+     * gets the HTTP body for the current response.
358
+     *
359
+     * @param string $soapmsg The SOAP payload
360
+     * @return string The HTTP body, which includes the SOAP payload
361
+     * @access private
362
+     */
363
+    function getHTTPBody($soapmsg) {
364
+        if (count($this->responseAttachments) > 0) {
365
+            $params['content_type'] = 'multipart/related; type="text/xml"';
366
+            $mimeMessage = new Mail_mimePart('', $params);
367
+            unset($params);
368
+
369
+            $params['content_type'] = 'text/xml';
370
+            $params['encoding']     = '8bit';
371
+            $params['charset']      = $this->soap_defencoding;
372
+            $mimeMessage->addSubpart($soapmsg, $params);
373
+
374
+            foreach ($this->responseAttachments as $att) {
375
+                unset($params);
376
+
377
+                $params['content_type'] = $att['contenttype'];
378
+                $params['encoding']     = 'base64';
379
+                $params['disposition']  = 'attachment';
380
+                $params['dfilename']    = $att['filename'];
381
+                $params['cid']          = $att['cid'];
382
+
383
+                if ($att['data'] == '' && $att['filename'] <> '') {
384
+                    if ($fd = fopen($att['filename'], 'rb')) {
385
+                        $data = fread($fd, filesize($att['filename']));
386
+                        fclose($fd);
387
+                    } else {
388
+                        $data = '';
389
+                    }
390
+                    $mimeMessage->addSubpart($data, $params);
391
+                } else {
392
+                    $mimeMessage->addSubpart($att['data'], $params);
393
+                }
394
+            }
395
+
396
+            $output = $mimeMessage->encode();
397
+            $mimeHeaders = $output['headers'];
398
+
399
+            foreach ($mimeHeaders as $k => $v) {
400
+                $this->debug("MIME header $k: $v");
401
+                if (strtolower($k) == 'content-type') {
402
+                    // PHP header() seems to strip leading whitespace starting
403
+                    // the second line, so force everything to one line
404
+                    $this->mimeContentType = str_replace("\r\n", " ", $v);
405
+                }
406
+            }
407
+
408
+            return $output['body'];
409
+        }
410
+
411
+        return parent::getHTTPBody($soapmsg);
412
+    }
413
+
414
+    /**
415
+     * gets the HTTP content type for the current response.
416
+     *
417
+     * Note: getHTTPBody must be called before this.
418
+     *
419
+     * @return string the HTTP content type for the current response.
420
+     * @access private
421
+     */
422
+    function getHTTPContentType() {
423
+        if (count($this->responseAttachments) > 0) {
424
+            return $this->mimeContentType;
425
+        }
426
+        return parent::getHTTPContentType();
427
+    }
428
+
429
+    /**
430
+     * gets the HTTP content type charset for the current response.
431
+     * returns false for non-text content types.
432
+     *
433
+     * Note: getHTTPBody must be called before this.
434
+     *
435
+     * @return string the HTTP content type charset for the current response.
436
+     * @access private
437
+     */
438
+    function getHTTPContentTypeCharset() {
439
+        if (count($this->responseAttachments) > 0) {
440
+            return false;
441
+        }
442
+        return parent::getHTTPContentTypeCharset();
443
+    }
444
+
445
+    /**
446
+     * processes SOAP message received from client
447
+     *
448
+     * @param	array	$headers	The HTTP headers
449
+     * @param	string	$data		unprocessed request data from client
450
+     * @return	mixed	value of the message, decoded into a PHP type
451
+     * @access   private
452
+     */
453 453
     function parseRequest($headers, $data) {
454
-		$this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
455
-		$this->requestAttachments = array();
456
-		if (strstr($headers['content-type'], 'multipart/related')) {
457
-			$this->debug('Decode multipart/related');
458
-			$input = '';
459
-			foreach ($headers as $k => $v) {
460
-				$input .= "$k: $v\r\n";
461
-			}
462
-			$params['input'] = $input . "\r\n" . $data;
463
-			$params['include_bodies'] = true;
464
-			$params['decode_bodies'] = true;
465
-			$params['decode_headers'] = true;
466
-
467
-			$structure = Mail_mimeDecode::decode($params);
468
-
469
-			foreach ($structure->parts as $part) {
470
-				if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
471
-					$this->debug('Have root part of type ' . $part->headers['content-type']);
472
-					$return = parent::parseRequest($part->headers, $part->body);
473
-				} else {
474
-					$this->debug('Have an attachment of type ' . $part->headers['content-type']);
475
-					$info['data'] = $part->body;
476
-					$info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
477
-					$info['contenttype'] = $part->headers['content-type'];
478
-					$info['cid'] = $part->headers['content-id'];
479
-					$this->requestAttachments[] = $info;
480
-				}
481
-			}
482
-
483
-			if (isset($return)) {
484
-				return $return;
485
-			}
486
-
487
-			$this->setError('No root part found in multipart/related content');
488
-			return;
489
-		}
490
-		$this->debug('Not multipart/related');
491
-		return parent::parseRequest($headers, $data);
492
-	}
454
+        $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
455
+        $this->requestAttachments = array();
456
+        if (strstr($headers['content-type'], 'multipart/related')) {
457
+            $this->debug('Decode multipart/related');
458
+            $input = '';
459
+            foreach ($headers as $k => $v) {
460
+                $input .= "$k: $v\r\n";
461
+            }
462
+            $params['input'] = $input . "\r\n" . $data;
463
+            $params['include_bodies'] = true;
464
+            $params['decode_bodies'] = true;
465
+            $params['decode_headers'] = true;
466
+
467
+            $structure = Mail_mimeDecode::decode($params);
468
+
469
+            foreach ($structure->parts as $part) {
470
+                if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
471
+                    $this->debug('Have root part of type ' . $part->headers['content-type']);
472
+                    $return = parent::parseRequest($part->headers, $part->body);
473
+                } else {
474
+                    $this->debug('Have an attachment of type ' . $part->headers['content-type']);
475
+                    $info['data'] = $part->body;
476
+                    $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
477
+                    $info['contenttype'] = $part->headers['content-type'];
478
+                    $info['cid'] = $part->headers['content-id'];
479
+                    $this->requestAttachments[] = $info;
480
+                }
481
+            }
482
+
483
+            if (isset($return)) {
484
+                return $return;
485
+            }
486
+
487
+            $this->setError('No root part found in multipart/related content');
488
+            return;
489
+        }
490
+        $this->debug('Not multipart/related');
491
+        return parent::parseRequest($headers, $data);
492
+    }
493 493
 }
494 494
 
495 495
 /*
Please login to merge, or discard this patch.
main/inc/lib/plugin.class.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
     /**
145 145
      * Returns the contents of the CSS defined by the plugin
146
-     * @return array
146
+     * @return string
147 147
      */
148 148
     public function get_css()
149 149
     {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 
162 162
     /**
163 163
      * Returns an HTML form (generated by FormValidator) of the plugin settings
164
-     * @return string FormValidator-generated form
164
+     * @return FormValidator FormValidator-generated form
165 165
      */
166 166
     public function get_settings_form()
167 167
     {
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
      * @param boolean $add_tool_link Whether to add a tool link or not
384 384
      * (some tools might just offer a configuration section and act on the backend)
385 385
      *
386
-     * @return boolean  False on error, null otherwise
386
+     * @return boolean|null  False on error, null otherwise
387 387
      */
388 388
     public function install_course_fields($courseId, $add_tool_link = true)
389 389
     {
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
      * tool on the course's homepage
492 492
      * @param int $courseId
493 493
      *
494
-     * @return void
494
+     * @return false|null
495 495
      */
496 496
     public function uninstall_course_fields($courseId)
497 497
     {
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
     * @param string   $tabName
597 597
     * @param string   $url
598 598
     *
599
-    * @return boolean
599
+    * @return false|string
600 600
     */
601 601
     public function addTab($tabName, $url)
602 602
     {
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -591,13 +591,13 @@
 block discarded – undo
591 591
 
592 592
     }
593 593
 
594
-   /**
595
-    * Add a tab to platform
596
-    * @param string   $tabName
597
-    * @param string   $url
598
-    *
599
-    * @return boolean
600
-    */
594
+    /**
595
+     * Add a tab to platform
596
+     * @param string   $tabName
597
+     * @param string   $url
598
+     *
599
+     * @return boolean
600
+     */
601 601
     public function addTab($tabName, $url)
602 602
     {
603 603
         $sql = "SELECT * FROM settings_current
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $this->fields = $settings;
64 64
 
65 65
         global $language_files;
66
-        $language_files[] = 'plugin_' . $this->get_name();
66
+        $language_files[] = 'plugin_'.$this->get_name();
67 67
     }
68 68
 
69 69
     /**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
     {
273 273
         $settings = $this->get_settings();
274 274
         foreach ($settings as $setting) {
275
-            if ($setting['variable'] == $this->get_name() . '_' . $name) {
275
+            if ($setting['variable'] == $this->get_name().'_'.$name) {
276 276
                 return $setting['selected_value'];
277 277
             }
278 278
         }
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
         if (!empty($this->course_settings)) {
407 407
             foreach ($this->course_settings as $setting) {
408 408
                 $variable = $setting['name'];
409
-                $value ='';
409
+                $value = '';
410 410
                 if (isset($setting['init_value'])) {
411 411
                     $value = $setting['init_value'];
412 412
                 }
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 
623 623
         // Avoid Tab Name Spaces
624 624
         $tabNameNoSpaces = preg_replace('/\s+/', '', $tabName);
625
-        $subkeytext = "Tabs" . $tabNameNoSpaces;
625
+        $subkeytext = "Tabs".$tabNameNoSpaces;
626 626
 
627 627
         // Check if it is already added
628 628
         $checkCondition = array(
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
         }
641 641
 
642 642
         // End Check
643
-        $subkey = 'custom_tab_' . $tabNum;
643
+        $subkey = 'custom_tab_'.$tabNum;
644 644
         $attributes = array(
645 645
             'variable' => 'show_tabs',
646 646
             'subkey' => $subkey,
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 
659 659
         // Save the id
660 660
         $settings = $this->get_settings();
661
-        $setData = array (
661
+        $setData = array(
662 662
             'comment' => $subkey
663 663
         );
664 664
         $whereCondition = array(
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
                 $i = 1;
700 700
                 foreach ($tabs as $row) {
701 701
                     $attributes = array(
702
-                        'subkey' => 'custom_tab_' . $i
702
+                        'subkey' => 'custom_tab_'.$i
703 703
                     );
704 704
                     $this->updateTab($row['subkey'], $attributes);
705 705
                     $i++;
Please login to merge, or discard this patch.