Completed
Push — master ( 565c08...93d030 )
by José
125:33 queued 71:22
created
plugin/dashboard/block_session/block_session.class.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -15,36 +15,36 @@  discard block
 block discarded – undo
15 15
 class BlockSession extends Block
16 16
 {
17 17
     private $user_id;
18
-	private $sessions;
19
-	private $path;
20
-	private $permission = array(DRH, SESSIONADMIN);
18
+    private $sessions;
19
+    private $path;
20
+    private $permission = array(DRH, SESSIONADMIN);
21 21
 
22
-	/**
23
-	 * Constructor
24
-	 */
22
+    /**
23
+     * Constructor
24
+     */
25 25
     public function __construct ($user_id)
26 26
     {
27
-    	$this->user_id 	= $user_id;
28
-    	$this->path = 'block_session';
29
-    	if ($this->is_block_visible_for_user($user_id)) {
27
+        $this->user_id 	= $user_id;
28
+        $this->path = 'block_session';
29
+        if ($this->is_block_visible_for_user($user_id)) {
30 30
             $this->sessions = SessionManager::get_sessions_followed_by_drh($user_id);
31
-    	}
31
+        }
32 32
     }
33 33
 
34
-	/**
35
-	 * This method check if a user is allowed to see the block inside dashboard interface
36
-	 * @param	int		User id
37
-	 * @return	bool	Is block visible for user
38
-	 */
34
+    /**
35
+     * This method check if a user is allowed to see the block inside dashboard interface
36
+     * @param	int		User id
37
+     * @return	bool	Is block visible for user
38
+     */
39 39
     public function is_block_visible_for_user($user_id)
40 40
     {
41
-    	$user_info = api_get_user_info($user_id);
42
-		$user_status = $user_info['status'];
43
-		$is_block_visible_for_user = false;
44
-    	if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
45
-    		$is_block_visible_for_user = true;
46
-    	}
47
-    	return $is_block_visible_for_user;
41
+        $user_info = api_get_user_info($user_id);
42
+        $user_status = $user_info['status'];
43
+        $is_block_visible_for_user = false;
44
+        if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
45
+            $is_block_visible_for_user = true;
46
+        }
47
+        return $is_block_visible_for_user;
48 48
     }
49 49
 
50 50
     /**
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
     public function get_block()
56 56
     {
57 57
 
58
-		global $charset;
58
+        global $charset;
59 59
 
60
-    	$column = 2;
61
-    	$data   = array();
60
+        $column = 2;
61
+        $data   = array();
62 62
 
63
-		$content = $this->get_content_html();
63
+        $content = $this->get_content_html();
64 64
 
65
-		$content_html = '
65
+        $content_html = '
66 66
 			            <div class="panel panel-default" id="intro">
67 67
 			                <div class="panel-heading">
68 68
 			                    '.get_lang('SessionsInformation').'
@@ -76,40 +76,40 @@  discard block
 block discarded – undo
76 76
 			            </div>
77 77
 				';
78 78
 
79
-    	$data['column'] = $column;
80
-    	$data['content_html'] = $content_html;
79
+        $data['column'] = $column;
80
+        $data['content_html'] = $content_html;
81 81
 
82
-    	return $data;
82
+        return $data;
83 83
     }
84 84
 
85 85
     /**
86
- 	 * This method return a content html, it's used inside get_block method for showing it inside dashboard interface
87
- 	 * @return string  content html
88
- 	 */
86
+     * This method return a content html, it's used inside get_block method for showing it inside dashboard interface
87
+     * @return string  content html
88
+     */
89 89
     public function get_content_html()
90 90
     {
91 91
 
92
- 		$content = '';
93
-		$sessions = $this->sessions;
92
+            $content = '';
93
+        $sessions = $this->sessions;
94 94
 
95
-		//$content = '<div style="margin:10px;">';
96
-		$content .= '<h4>'.get_lang('YourSessionsList').'</h4>';
95
+        //$content = '<div style="margin:10px;">';
96
+        $content .= '<h4>'.get_lang('YourSessionsList').'</h4>';
97 97
 
98
-		if (count($sessions) > 0) {
99
-			$sessions_table = '<table class="data_table" width:"95%">';
100
- 			$sessions_table .= '<tr>
98
+        if (count($sessions) > 0) {
99
+            $sessions_table = '<table class="data_table" width:"95%">';
100
+                $sessions_table .= '<tr>
101 101
 									<th >'.get_lang('Title').'</th>
102 102
 									<th >'.get_lang('Date').'</th>
103 103
 									<th width="100px">'.get_lang('NbCoursesPerSession').'</th>
104 104
 								</tr>';
105
-			$i = 1;
106
-			foreach ($sessions as $session) {
105
+            $i = 1;
106
+            foreach ($sessions as $session) {
107 107
 
108
-				$session_id = intval($session['id']);
109
-				$title = $session['name'];
108
+                $session_id = intval($session['id']);
109
+                $title = $session['name'];
110 110
 
111
-				if (!empty($session['access_start_date'])) {
112
-				    $dateFrom = api_convert_and_format_date(
111
+                if (!empty($session['access_start_date'])) {
112
+                    $dateFrom = api_convert_and_format_date(
113 113
                         $session['access_start_date'],
114 114
                         DATE_FORMAT_SHORT,
115 115
                         date_default_timezone_get()
@@ -121,44 +121,44 @@  discard block
 block discarded – undo
121 121
                     );
122 122
 
123 123
                     $date = vsprintf(get_lang('FromDateXToDateY'), [$dateFrom, $dateUntil]);
124
-				} else {
125
-					$date = ' - ';
126
-				}
124
+                } else {
125
+                    $date = ' - ';
126
+                }
127 127
 
128
-	 			$count_courses_in_session = count(Tracking::get_courses_list_from_session($session_id));
128
+                    $count_courses_in_session = count(Tracking::get_courses_list_from_session($session_id));
129 129
 
130
-				if ($i%2 == 0) $class_tr = 'row_odd';
131
-	    		else $class_tr = 'row_even';
130
+                if ($i%2 == 0) $class_tr = 'row_odd';
131
+                else $class_tr = 'row_even';
132 132
 
133
-				$sessions_table .= '<tr class="'.$class_tr.'">
133
+                $sessions_table .= '<tr class="'.$class_tr.'">
134 134
 										<td>'.$title.'</td>
135 135
 										<td align="center">'.$date.'</td>
136 136
 										<td align="center">'.$count_courses_in_session.'</td>
137 137
 								   </tr>';
138
-				$i++;
139
-			}
140
-			$sessions_table .= '</table>';
141
-			$content .= $sessions_table;
142
-		} else {
143
-			$content .= get_lang('ThereIsNoInformationAboutYourSessions');
144
-		}
138
+                $i++;
139
+            }
140
+            $sessions_table .= '</table>';
141
+            $content .= $sessions_table;
142
+        } else {
143
+            $content .= get_lang('ThereIsNoInformationAboutYourSessions');
144
+        }
145 145
 
146
-		if (count($sessions) > 0) {
147
-			$content .= '<div style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/session.php">'.get_lang('SeeMore').'</a></div>';
148
-		}
146
+        if (count($sessions) > 0) {
147
+            $content .= '<div style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/session.php">'.get_lang('SeeMore').'</a></div>';
148
+        }
149 149
 
150
-		//$content .= '</div>';
150
+        //$content .= '</div>';
151 151
 
152
- 		return $content;
153
- 	}
152
+            return $content;
153
+        }
154 154
 
155 155
     /**
156
-	 * Get number of sessions
157
-	 * @return int
158
-	 */
159
-	function get_number_of_sessions()
156
+     * Get number of sessions
157
+     * @return int
158
+     */
159
+    function get_number_of_sessions()
160 160
     {
161
-		return count($this->sessions);
162
-	}
161
+        return count($this->sessions);
162
+    }
163 163
 
164 164
 }
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.wsdl.php 1 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.
main/inc/lib/nusoap/class.soapclient.php 1 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.
main/inc/lib/nusoap/class.soap_val.php 1 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.
main/inc/lib/nusoap/class.soap_parser.php 1 patch
Indentation   +546 added lines, -546 removed lines patch added patch discarded remove patch
@@ -11,236 +11,236 @@  discard block
 block discarded – undo
11 11
 */
12 12
 class nusoap_parser extends nusoap_base
13 13
 {
14
-	var $xml = '';
15
-	var $xml_encoding = '';
16
-	var $method = '';
17
-	var $root_struct = '';
18
-	var $root_struct_name = '';
19
-	var $root_struct_namespace = '';
20
-	var $root_header = '';
14
+    var $xml = '';
15
+    var $xml_encoding = '';
16
+    var $method = '';
17
+    var $root_struct = '';
18
+    var $root_struct_name = '';
19
+    var $root_struct_namespace = '';
20
+    var $root_header = '';
21 21
     var $document = '';			// incoming SOAP body (text)
22
-	// determines where in the message we are (envelope,header,body,method)
23
-	var $status = '';
24
-	var $position = 0;
25
-	var $depth = 0;
26
-	var $default_namespace = '';
27
-	var $namespaces = array();
28
-	var $message = array();
22
+    // determines where in the message we are (envelope,header,body,method)
23
+    var $status = '';
24
+    var $position = 0;
25
+    var $depth = 0;
26
+    var $default_namespace = '';
27
+    var $namespaces = array();
28
+    var $message = array();
29 29
     var $parent;
30
-	var $fault = false;
31
-	var $fault_code = '';
32
-	var $fault_str = '';
33
-	var $fault_detail = '';
34
-	var $depth_array = array();
35
-	var $debug_flag = true;
36
-	var $soapresponse = NULL;	// parsed SOAP Body
37
-	var $soapheader = NULL;		// parsed SOAP Header
38
-	var $responseHeaders = '';	// incoming SOAP headers (text)
39
-	var $body_position = 0;
40
-	// for multiref parsing:
41
-	// array of id => pos
42
-	var $ids = array();
43
-	// array of id => hrefs => pos
44
-	var $multirefs = array();
45
-	// toggle for auto-decoding element content
46
-	var $decode_utf8 = true;
30
+    var $fault = false;
31
+    var $fault_code = '';
32
+    var $fault_str = '';
33
+    var $fault_detail = '';
34
+    var $depth_array = array();
35
+    var $debug_flag = true;
36
+    var $soapresponse = NULL;	// parsed SOAP Body
37
+    var $soapheader = NULL;		// parsed SOAP Header
38
+    var $responseHeaders = '';	// incoming SOAP headers (text)
39
+    var $body_position = 0;
40
+    // for multiref parsing:
41
+    // array of id => pos
42
+    var $ids = array();
43
+    // array of id => hrefs => pos
44
+    var $multirefs = array();
45
+    // toggle for auto-decoding element content
46
+    var $decode_utf8 = true;
47 47
 
48
-	/**
49
-	* constructor that actually does the parsing
50
-	*
51
-	* @param    string $xml SOAP message
52
-	* @param    string $encoding character encoding scheme of message
53
-	* @param    string $method method for which XML is parsed (unused?)
54
-	* @param    bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1
55
-	* @return void|bool
56
-	* @access   public
57
-	*/
58
-	function __construct($xml,$encoding='UTF-8',$method='',$decode_utf8=true)
48
+    /**
49
+     * constructor that actually does the parsing
50
+     *
51
+     * @param    string $xml SOAP message
52
+     * @param    string $encoding character encoding scheme of message
53
+     * @param    string $method method for which XML is parsed (unused?)
54
+     * @param    bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1
55
+     * @return void|bool
56
+     * @access   public
57
+     */
58
+    function __construct($xml,$encoding='UTF-8',$method='',$decode_utf8=true)
59 59
     {
60
-		parent::__construct();
61
-		$this->xml = $xml;
62
-		$this->xml_encoding = $encoding;
63
-		$this->method = $method;
64
-		$this->decode_utf8 = $decode_utf8;
60
+        parent::__construct();
61
+        $this->xml = $xml;
62
+        $this->xml_encoding = $encoding;
63
+        $this->method = $method;
64
+        $this->decode_utf8 = $decode_utf8;
65 65
 
66
-		// Check whether content has been read.
67
-		if(!empty($this->xml)){
68
-			// Check XML encoding
69
-			$pos_xml = strpos($xml, '<?xml');
70
-			if ($pos_xml !== FALSE) {
71
-				$xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1);
72
-				if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) {
73
-					$xml_encoding = $res[1];
74
-					if (strtoupper($xml_encoding) != $encoding) {
75
-						$err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'";
76
-						$this->debug($err);
77
-						if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
78
-							$this->setError($err);
79
-							return false;
80
-						}
81
-						// when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed
82
-					} else {
83
-						$this->debug('Charset from HTTP Content-Type matches encoding from XML declaration');
84
-					}
85
-				} else {
86
-					$this->debug('No encoding specified in XML declaration');
87
-				}
88
-			} else {
89
-				$this->debug('No XML declaration');
90
-			}
91
-			$this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding);
92
-			// Create an XML parser - why not xml_parser_create_ns?
93
-			$this->parser = xml_parser_create($this->xml_encoding);
94
-			// Set the options for parsing the XML data.
95
-			//xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
96
-			xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
97
-			xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
98
-			// Set the object for the parser.
99
-			xml_set_object($this->parser, $this);
100
-			// Set the element handlers for the parser.
101
-			xml_set_element_handler($this->parser, 'start_element','end_element');
102
-			xml_set_character_data_handler($this->parser,'character_data');
66
+        // Check whether content has been read.
67
+        if(!empty($this->xml)){
68
+            // Check XML encoding
69
+            $pos_xml = strpos($xml, '<?xml');
70
+            if ($pos_xml !== FALSE) {
71
+                $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1);
72
+                if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) {
73
+                    $xml_encoding = $res[1];
74
+                    if (strtoupper($xml_encoding) != $encoding) {
75
+                        $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'";
76
+                        $this->debug($err);
77
+                        if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
78
+                            $this->setError($err);
79
+                            return false;
80
+                        }
81
+                        // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed
82
+                    } else {
83
+                        $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration');
84
+                    }
85
+                } else {
86
+                    $this->debug('No encoding specified in XML declaration');
87
+                }
88
+            } else {
89
+                $this->debug('No XML declaration');
90
+            }
91
+            $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding);
92
+            // Create an XML parser - why not xml_parser_create_ns?
93
+            $this->parser = xml_parser_create($this->xml_encoding);
94
+            // Set the options for parsing the XML data.
95
+            //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
96
+            xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
97
+            xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
98
+            // Set the object for the parser.
99
+            xml_set_object($this->parser, $this);
100
+            // Set the element handlers for the parser.
101
+            xml_set_element_handler($this->parser, 'start_element','end_element');
102
+            xml_set_character_data_handler($this->parser,'character_data');
103 103
 
104
-			xml_parse($this->parser, $this->xml);
104
+            xml_parse($this->parser, $this->xml);
105 105
 
106
-			// Parse the XML file.
107
-			//if (!xml_parse($this->parser,$xml,true)){
108
-			if (false) {
109
-			    // Display an error message.
110
-			    $err = sprintf('XML error parsing SOAP payload on line %d: %s',
111
-			    xml_get_current_line_number($this->parser),
112
-			    xml_error_string(xml_get_error_code($this->parser)));
113
-				$this->debug($err);
114
-				$this->debug("XML payload:\n" . $xml);
115
-				$this->setError($err);
116
-			} else {
117
-				$this->debug('in nusoap_parser ctor, message:');
118
-				$this->appendDebug($this->varDump($this->message));
119
-				$this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name);
120
-				// get final value
121
-				$this->soapresponse = $this->message[$this->root_struct]['result'];
122
-				// get header value
123
-				if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){
124
-					$this->soapheader = $this->message[$this->root_header]['result'];
125
-				}
126
-				// resolve hrefs/ids
127
-				if(sizeof($this->multirefs) > 0){
128
-					foreach($this->multirefs as $id => $hrefs){
129
-						$this->debug('resolving multirefs for id: '.$id);
130
-						$idVal = $this->buildVal($this->ids[$id]);
131
-						if (is_array($idVal) && isset($idVal['!id'])) {
132
-							unset($idVal['!id']);
133
-						}
134
-						foreach($hrefs as $refPos => $ref){
135
-							$this->debug('resolving href at pos '.$refPos);
136
-							$this->multirefs[$id][$refPos] = $idVal;
137
-						}
138
-					}
139
-				}
140
-			}
141
-			xml_parser_free($this->parser);
142
-		} else {
143
-			$this->debug('xml was empty, didn\'t parse!');
144
-			$this->setError('xml was empty, didn\'t parse!');
145
-		}
146
-	}
106
+            // Parse the XML file.
107
+            //if (!xml_parse($this->parser,$xml,true)){
108
+            if (false) {
109
+                // Display an error message.
110
+                $err = sprintf('XML error parsing SOAP payload on line %d: %s',
111
+                xml_get_current_line_number($this->parser),
112
+                xml_error_string(xml_get_error_code($this->parser)));
113
+                $this->debug($err);
114
+                $this->debug("XML payload:\n" . $xml);
115
+                $this->setError($err);
116
+            } else {
117
+                $this->debug('in nusoap_parser ctor, message:');
118
+                $this->appendDebug($this->varDump($this->message));
119
+                $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name);
120
+                // get final value
121
+                $this->soapresponse = $this->message[$this->root_struct]['result'];
122
+                // get header value
123
+                if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){
124
+                    $this->soapheader = $this->message[$this->root_header]['result'];
125
+                }
126
+                // resolve hrefs/ids
127
+                if(sizeof($this->multirefs) > 0){
128
+                    foreach($this->multirefs as $id => $hrefs){
129
+                        $this->debug('resolving multirefs for id: '.$id);
130
+                        $idVal = $this->buildVal($this->ids[$id]);
131
+                        if (is_array($idVal) && isset($idVal['!id'])) {
132
+                            unset($idVal['!id']);
133
+                        }
134
+                        foreach($hrefs as $refPos => $ref){
135
+                            $this->debug('resolving href at pos '.$refPos);
136
+                            $this->multirefs[$id][$refPos] = $idVal;
137
+                        }
138
+                    }
139
+                }
140
+            }
141
+            xml_parser_free($this->parser);
142
+        } else {
143
+            $this->debug('xml was empty, didn\'t parse!');
144
+            $this->setError('xml was empty, didn\'t parse!');
145
+        }
146
+    }
147 147
 
148
-	/**
149
-	* start-element handler
150
-	*
151
-	* @param    resource $parser XML parser object
152
-	* @param    string $name element name
153
-	* @param    array $attrs associative array of attributes
154
-	* @access   private
155
-	*/
156
-	function start_element($parser, $name, $attrs) {
148
+    /**
149
+     * start-element handler
150
+     *
151
+     * @param    resource $parser XML parser object
152
+     * @param    string $name element name
153
+     * @param    array $attrs associative array of attributes
154
+     * @access   private
155
+     */
156
+    function start_element($parser, $name, $attrs) {
157 157
 
158
-		// position in a total number of elements, starting from 0
159
-		// update class level pos
160
-		$pos = $this->position++;
161
-		// and set mine
162
-		$this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>'');
163
-		// depth = how many levels removed from root?
164
-		// set mine as current global depth and increment global depth value
165
-		$this->message[$pos]['depth'] = $this->depth++;
158
+        // position in a total number of elements, starting from 0
159
+        // update class level pos
160
+        $pos = $this->position++;
161
+        // and set mine
162
+        $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>'');
163
+        // depth = how many levels removed from root?
164
+        // set mine as current global depth and increment global depth value
165
+        $this->message[$pos]['depth'] = $this->depth++;
166 166
 
167
-		// else add self as child to whoever the current parent is
168
-		if($pos != 0){
169
-			$this->message[$this->parent]['children'] .= '|'.$pos;
170
-		}
171
-		// set my parent
172
-		$this->message[$pos]['parent'] = $this->parent;
173
-		// set self as current parent
174
-		$this->parent = $pos;
175
-		// set self as current value for this depth
176
-		$this->depth_array[$this->depth] = $pos;
177
-		// get element prefix
178
-		if(strpos($name,':')){
179
-			// get ns prefix
180
-			$prefix = substr($name,0,strpos($name,':'));
181
-			// get unqualified name
182
-			$name = substr(strstr($name,':'),1);
183
-		}
184
-		// set status
185
-		if ($name == 'Envelope' && $this->status == '') {
186
-			$this->status = 'envelope';
187
-		} elseif ($name == 'Header' && $this->status == 'envelope') {
188
-			$this->root_header = $pos;
189
-			$this->status = 'header';
190
-		} elseif ($name == 'Body' && $this->status == 'envelope'){
191
-			$this->status = 'body';
192
-			$this->body_position = $pos;
193
-		// set method
194
-		} elseif($this->status == 'body' && $pos == ($this->body_position+1)) {
195
-			$this->status = 'method';
196
-			$this->root_struct_name = $name;
197
-			$this->root_struct = $pos;
198
-			$this->message[$pos]['type'] = 'struct';
199
-			$this->debug("found root struct $this->root_struct_name, pos $this->root_struct");
200
-		}
201
-		// set my status
202
-		$this->message[$pos]['status'] = $this->status;
203
-		// set name
204
-		$this->message[$pos]['name'] = htmlspecialchars($name);
205
-		// set attrs
206
-		$this->message[$pos]['attrs'] = $attrs;
167
+        // else add self as child to whoever the current parent is
168
+        if($pos != 0){
169
+            $this->message[$this->parent]['children'] .= '|'.$pos;
170
+        }
171
+        // set my parent
172
+        $this->message[$pos]['parent'] = $this->parent;
173
+        // set self as current parent
174
+        $this->parent = $pos;
175
+        // set self as current value for this depth
176
+        $this->depth_array[$this->depth] = $pos;
177
+        // get element prefix
178
+        if(strpos($name,':')){
179
+            // get ns prefix
180
+            $prefix = substr($name,0,strpos($name,':'));
181
+            // get unqualified name
182
+            $name = substr(strstr($name,':'),1);
183
+        }
184
+        // set status
185
+        if ($name == 'Envelope' && $this->status == '') {
186
+            $this->status = 'envelope';
187
+        } elseif ($name == 'Header' && $this->status == 'envelope') {
188
+            $this->root_header = $pos;
189
+            $this->status = 'header';
190
+        } elseif ($name == 'Body' && $this->status == 'envelope'){
191
+            $this->status = 'body';
192
+            $this->body_position = $pos;
193
+        // set method
194
+        } elseif($this->status == 'body' && $pos == ($this->body_position+1)) {
195
+            $this->status = 'method';
196
+            $this->root_struct_name = $name;
197
+            $this->root_struct = $pos;
198
+            $this->message[$pos]['type'] = 'struct';
199
+            $this->debug("found root struct $this->root_struct_name, pos $this->root_struct");
200
+        }
201
+        // set my status
202
+        $this->message[$pos]['status'] = $this->status;
203
+        // set name
204
+        $this->message[$pos]['name'] = htmlspecialchars($name);
205
+        // set attrs
206
+        $this->message[$pos]['attrs'] = $attrs;
207 207
 
208
-		// loop through atts, logging ns and type declarations
208
+        // loop through atts, logging ns and type declarations
209 209
         $attstr = '';
210
-		foreach($attrs as $key => $value){
211
-        	$key_prefix = $this->getPrefix($key);
212
-			$key_localpart = $this->getLocalPart($key);
213
-			// if ns declarations, add to class level array of valid namespaces
210
+        foreach($attrs as $key => $value){
211
+            $key_prefix = $this->getPrefix($key);
212
+            $key_localpart = $this->getLocalPart($key);
213
+            // if ns declarations, add to class level array of valid namespaces
214 214
             if($key_prefix == 'xmlns'){
215
-				if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){
216
-					$this->XMLSchemaVersion = $value;
217
-					$this->namespaces['xsd'] = $this->XMLSchemaVersion;
218
-					$this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance';
219
-				}
215
+                if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){
216
+                    $this->XMLSchemaVersion = $value;
217
+                    $this->namespaces['xsd'] = $this->XMLSchemaVersion;
218
+                    $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance';
219
+                }
220 220
                 $this->namespaces[$key_localpart] = $value;
221
-				// set method namespace
222
-				if($name == $this->root_struct_name){
223
-					$this->methodNamespace = $value;
224
-				}
225
-			// if it's a type declaration, set type
221
+                // set method namespace
222
+                if($name == $this->root_struct_name){
223
+                    $this->methodNamespace = $value;
224
+                }
225
+            // if it's a type declaration, set type
226 226
         } elseif($key_localpart == 'type'){
227
-        		if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') {
228
-        			// do nothing: already processed arrayType
229
-        		} else {
230
-	            	$value_prefix = $this->getPrefix($value);
231
-	                $value_localpart = $this->getLocalPart($value);
232
-					$this->message[$pos]['type'] = $value_localpart;
233
-					$this->message[$pos]['typePrefix'] = $value_prefix;
234
-	                if(isset($this->namespaces[$value_prefix])){
235
-	                	$this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
236
-	                } else if(isset($attrs['xmlns:'.$value_prefix])) {
237
-						$this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix];
238
-	                }
239
-					// should do something here with the namespace of specified type?
240
-				}
241
-			} elseif($key_localpart == 'arrayType'){
242
-				$this->message[$pos]['type'] = 'array';
243
-				/* do arrayType ereg here
227
+                if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') {
228
+                    // do nothing: already processed arrayType
229
+                } else {
230
+                    $value_prefix = $this->getPrefix($value);
231
+                    $value_localpart = $this->getLocalPart($value);
232
+                    $this->message[$pos]['type'] = $value_localpart;
233
+                    $this->message[$pos]['typePrefix'] = $value_prefix;
234
+                    if(isset($this->namespaces[$value_prefix])){
235
+                        $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
236
+                    } else if(isset($attrs['xmlns:'.$value_prefix])) {
237
+                        $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix];
238
+                    }
239
+                    // should do something here with the namespace of specified type?
240
+                }
241
+            } elseif($key_localpart == 'arrayType'){
242
+                $this->message[$pos]['type'] = 'array';
243
+                /* do arrayType ereg here
244 244
 				[1]    arrayTypeValue    ::=    atype asize
245 245
 				[2]    atype    ::=    QName rank*
246 246
 				[3]    rank    ::=    '[' (',')* ']'
@@ -248,129 +248,129 @@  discard block
 block discarded – undo
248 248
 				[5]    length    ::=    nextDimension* Digit+
249 249
 				[6]    nextDimension    ::=    Digit+ ','
250 250
 				*/
251
-				$expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
252
-				if(preg_match($expr,$value,$regs)){
253
-					$this->message[$pos]['typePrefix'] = $regs[1];
254
-					$this->message[$pos]['arrayTypePrefix'] = $regs[1];
255
-	                if (isset($this->namespaces[$regs[1]])) {
256
-	                	$this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
257
-	                } else if (isset($attrs['xmlns:'.$regs[1]])) {
258
-						$this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]];
259
-	                }
260
-					$this->message[$pos]['arrayType'] = $regs[2];
261
-					$this->message[$pos]['arraySize'] = $regs[3];
262
-					$this->message[$pos]['arrayCols'] = $regs[4];
263
-				}
264
-			// specifies nil value (or not)
265
-			} elseif ($key_localpart == 'nil'){
266
-				$this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
267
-			// some other attribute
268
-			} elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') {
269
-				$this->message[$pos]['xattrs']['!' . $key] = $value;
270
-			}
251
+                $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
252
+                if(preg_match($expr,$value,$regs)){
253
+                    $this->message[$pos]['typePrefix'] = $regs[1];
254
+                    $this->message[$pos]['arrayTypePrefix'] = $regs[1];
255
+                    if (isset($this->namespaces[$regs[1]])) {
256
+                        $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
257
+                    } else if (isset($attrs['xmlns:'.$regs[1]])) {
258
+                        $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]];
259
+                    }
260
+                    $this->message[$pos]['arrayType'] = $regs[2];
261
+                    $this->message[$pos]['arraySize'] = $regs[3];
262
+                    $this->message[$pos]['arrayCols'] = $regs[4];
263
+                }
264
+            // specifies nil value (or not)
265
+            } elseif ($key_localpart == 'nil'){
266
+                $this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
267
+            // some other attribute
268
+            } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') {
269
+                $this->message[$pos]['xattrs']['!' . $key] = $value;
270
+            }
271 271
 
272
-			if ($key == 'xmlns') {
273
-				$this->default_namespace = $value;
274
-			}
275
-			// log id
276
-			if($key == 'id'){
277
-				$this->ids[$value] = $pos;
278
-			}
279
-			// root
280
-			if($key_localpart == 'root' && $value == 1){
281
-				$this->status = 'method';
282
-				$this->root_struct_name = $name;
283
-				$this->root_struct = $pos;
284
-				$this->debug("found root struct $this->root_struct_name, pos $pos");
285
-			}
272
+            if ($key == 'xmlns') {
273
+                $this->default_namespace = $value;
274
+            }
275
+            // log id
276
+            if($key == 'id'){
277
+                $this->ids[$value] = $pos;
278
+            }
279
+            // root
280
+            if($key_localpart == 'root' && $value == 1){
281
+                $this->status = 'method';
282
+                $this->root_struct_name = $name;
283
+                $this->root_struct = $pos;
284
+                $this->debug("found root struct $this->root_struct_name, pos $pos");
285
+            }
286 286
             // for doclit
287 287
             $attstr .= " $key=\"$value\"";
288
-		}
288
+        }
289 289
         // get namespace - must be done after namespace atts are processed
290
-		if(isset($prefix)){
291
-			$this->message[$pos]['namespace'] = $this->namespaces[$prefix];
292
-			$this->default_namespace = $this->namespaces[$prefix];
293
-		} else {
294
-			$this->message[$pos]['namespace'] = $this->default_namespace;
295
-		}
290
+        if(isset($prefix)){
291
+            $this->message[$pos]['namespace'] = $this->namespaces[$prefix];
292
+            $this->default_namespace = $this->namespaces[$prefix];
293
+        } else {
294
+            $this->message[$pos]['namespace'] = $this->default_namespace;
295
+        }
296 296
         if($this->status == 'header'){
297
-        	if ($this->root_header != $pos) {
298
-	        	$this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
299
-	        }
297
+            if ($this->root_header != $pos) {
298
+                $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
299
+            }
300 300
         } elseif($this->root_struct_name != ''){
301
-        	$this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
301
+            $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
302 302
         }
303
-	}
303
+    }
304 304
 
305
-	/**
306
-	* end-element handler
307
-	*
308
-	* @param    resource $parser XML parser object
309
-	* @param    string $name element name
310
-	* @access   private
311
-	*/
312
-	function end_element($parser, $name) {
313
-		// position of current element is equal to the last value left in depth_array for my depth
314
-		$pos = $this->depth_array[$this->depth--];
305
+    /**
306
+     * end-element handler
307
+     *
308
+     * @param    resource $parser XML parser object
309
+     * @param    string $name element name
310
+     * @access   private
311
+     */
312
+    function end_element($parser, $name) {
313
+        // position of current element is equal to the last value left in depth_array for my depth
314
+        $pos = $this->depth_array[$this->depth--];
315 315
 
316 316
         // get element prefix
317
-		if(strpos($name,':')){
318
-			// get ns prefix
319
-			$prefix = substr($name,0,strpos($name,':'));
320
-			// get unqualified name
321
-			$name = substr(strstr($name,':'),1);
322
-		}
317
+        if(strpos($name,':')){
318
+            // get ns prefix
319
+            $prefix = substr($name,0,strpos($name,':'));
320
+            // get unqualified name
321
+            $name = substr(strstr($name,':'),1);
322
+        }
323 323
 
324
-		// build to native type
325
-		if(isset($this->body_position) && $pos > $this->body_position){
326
-			// deal w/ multirefs
327
-			if(isset($this->message[$pos]['attrs']['href'])){
328
-				// get id
329
-				$id = substr($this->message[$pos]['attrs']['href'],1);
330
-				// add placeholder to href array
331
-				$this->multirefs[$id][$pos] = 'placeholder';
332
-				// add set a reference to it as the result value
333
-				$this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
324
+        // build to native type
325
+        if(isset($this->body_position) && $pos > $this->body_position){
326
+            // deal w/ multirefs
327
+            if(isset($this->message[$pos]['attrs']['href'])){
328
+                // get id
329
+                $id = substr($this->message[$pos]['attrs']['href'],1);
330
+                // add placeholder to href array
331
+                $this->multirefs[$id][$pos] = 'placeholder';
332
+                // add set a reference to it as the result value
333
+                $this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
334 334
             // build complexType values
335
-			} elseif($this->message[$pos]['children'] != ''){
336
-				// if result has already been generated (struct/array)
337
-				if(!isset($this->message[$pos]['result'])){
338
-					$this->message[$pos]['result'] = $this->buildVal($pos);
339
-				}
340
-			// build complexType values of attributes and possibly simpleContent
341
-			} elseif (isset($this->message[$pos]['xattrs'])) {
342
-				if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
343
-					$this->message[$pos]['xattrs']['!'] = null;
344
-				} elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
345
-	            	if (isset($this->message[$pos]['type'])) {
346
-						$this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
347
-					} else {
348
-						$parent = $this->message[$pos]['parent'];
349
-						if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
350
-							$this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
351
-						} else {
352
-							$this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
353
-						}
354
-					}
355
-				}
356
-				$this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
357
-			// set value of simpleType (or nil complexType)
358
-			} else {
359
-            	//$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']);
360
-				if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
361
-					$this->message[$pos]['xattrs']['!'] = null;
362
-				} elseif (isset($this->message[$pos]['type'])) {
363
-					$this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
364
-				} else {
365
-					$parent = $this->message[$pos]['parent'];
366
-					if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
367
-						$this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
368
-					} else {
369
-						$this->message[$pos]['result'] = $this->message[$pos]['cdata'];
370
-					}
371
-				}
335
+            } elseif($this->message[$pos]['children'] != ''){
336
+                // if result has already been generated (struct/array)
337
+                if(!isset($this->message[$pos]['result'])){
338
+                    $this->message[$pos]['result'] = $this->buildVal($pos);
339
+                }
340
+            // build complexType values of attributes and possibly simpleContent
341
+            } elseif (isset($this->message[$pos]['xattrs'])) {
342
+                if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
343
+                    $this->message[$pos]['xattrs']['!'] = null;
344
+                } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
345
+                    if (isset($this->message[$pos]['type'])) {
346
+                        $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
347
+                    } else {
348
+                        $parent = $this->message[$pos]['parent'];
349
+                        if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
350
+                            $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
351
+                        } else {
352
+                            $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
353
+                        }
354
+                    }
355
+                }
356
+                $this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
357
+            // set value of simpleType (or nil complexType)
358
+            } else {
359
+                //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']);
360
+                if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
361
+                    $this->message[$pos]['xattrs']['!'] = null;
362
+                } elseif (isset($this->message[$pos]['type'])) {
363
+                    $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
364
+                } else {
365
+                    $parent = $this->message[$pos]['parent'];
366
+                    if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
367
+                        $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
368
+                    } else {
369
+                        $this->message[$pos]['result'] = $this->message[$pos]['cdata'];
370
+                    }
371
+                }
372 372
 
373
-				/* add value to parent's result, if parent is struct/array
373
+                /* add value to parent's result, if parent is struct/array
374 374
 				$parent = $this->message[$pos]['parent'];
375 375
 				if($this->message[$parent]['type'] != 'map'){
376 376
 					if(strtolower($this->message[$parent]['type']) == 'array'){
@@ -380,261 +380,261 @@  discard block
 block discarded – undo
380 380
 					}
381 381
 				}
382 382
 				*/
383
-			}
384
-		}
383
+            }
384
+        }
385 385
 
386 386
         // for doclit
387 387
         if($this->status == 'header'){
388
-        	if ($this->root_header != $pos) {
389
-	        	$this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
390
-	        }
388
+            if ($this->root_header != $pos) {
389
+                $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
390
+            }
391 391
         } elseif($pos >= $this->root_struct){
392
-        	$this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
392
+            $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
393 393
         }
394
-		// switch status
395
-		if ($pos == $this->root_struct){
396
-			$this->status = 'body';
397
-			$this->root_struct_namespace = $this->message[$pos]['namespace'];
398
-		} elseif ($pos == $this->root_header) {
399
-			$this->status = 'envelope';
400
-		} elseif ($name == 'Body' && $this->status == 'body') {
401
-			$this->status = 'envelope';
402
-		} elseif ($name == 'Header' && $this->status == 'header') { // will never happen
403
-			$this->status = 'envelope';
404
-		} elseif ($name == 'Envelope' && $this->status == 'envelope') {
405
-			$this->status = '';
406
-		}
407
-		// set parent back to my parent
408
-		$this->parent = $this->message[$pos]['parent'];
409
-	}
394
+        // switch status
395
+        if ($pos == $this->root_struct){
396
+            $this->status = 'body';
397
+            $this->root_struct_namespace = $this->message[$pos]['namespace'];
398
+        } elseif ($pos == $this->root_header) {
399
+            $this->status = 'envelope';
400
+        } elseif ($name == 'Body' && $this->status == 'body') {
401
+            $this->status = 'envelope';
402
+        } elseif ($name == 'Header' && $this->status == 'header') { // will never happen
403
+            $this->status = 'envelope';
404
+        } elseif ($name == 'Envelope' && $this->status == 'envelope') {
405
+            $this->status = '';
406
+        }
407
+        // set parent back to my parent
408
+        $this->parent = $this->message[$pos]['parent'];
409
+    }
410 410
 
411
-	/**
412
-	* element content handler
413
-	*
414
-	* @param    resource $parser XML parser object
415
-	* @param    string $data element content
416
-	* @access   private
417
-	*/
418
-	function character_data($parser, $data)
411
+    /**
412
+     * element content handler
413
+     *
414
+     * @param    resource $parser XML parser object
415
+     * @param    string $data element content
416
+     * @access   private
417
+     */
418
+    function character_data($parser, $data)
419 419
     {
420
-		$pos = $this->depth_array[$this->depth];
421
-		if ($this->xml_encoding == 'UTF-8'){
422
-			// TODO: add an option to disable this for folks who want
423
-			// raw UTF-8 that, e.g., might not map to iso-8859-1
424
-			// TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
425
-			if($this->decode_utf8){
426
-				$data = utf8_decode($data);
427
-			}
428
-		}
420
+        $pos = $this->depth_array[$this->depth];
421
+        if ($this->xml_encoding == 'UTF-8'){
422
+            // TODO: add an option to disable this for folks who want
423
+            // raw UTF-8 that, e.g., might not map to iso-8859-1
424
+            // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
425
+            if($this->decode_utf8){
426
+                $data = utf8_decode($data);
427
+            }
428
+        }
429 429
         $this->message[$pos]['cdata'] .= $data;
430 430
         // for doclit
431 431
         if($this->status == 'header'){
432
-        	$this->responseHeaders .= $data;
432
+            $this->responseHeaders .= $data;
433 433
         } else {
434
-        	$this->document .= $data;
434
+            $this->document .= $data;
435 435
         }
436
-	}
436
+    }
437 437
 
438
-	/**
439
-	* get the parsed message (SOAP Body)
440
-	*
441
-	* @return	mixed
442
-	* @access   public
443
-	* @deprecated	use get_soapbody instead
444
-	*/
445
-	function get_response(){
446
-		return $this->soapresponse;
447
-	}
438
+    /**
439
+     * get the parsed message (SOAP Body)
440
+     *
441
+     * @return	mixed
442
+     * @access   public
443
+     * @deprecated	use get_soapbody instead
444
+     */
445
+    function get_response(){
446
+        return $this->soapresponse;
447
+    }
448 448
 
449
-	/**
450
-	* get the parsed SOAP Body (NULL if there was none)
451
-	*
452
-	* @return	mixed
453
-	* @access   public
454
-	*/
455
-	function get_soapbody(){
456
-		return $this->soapresponse;
457
-	}
449
+    /**
450
+     * get the parsed SOAP Body (NULL if there was none)
451
+     *
452
+     * @return	mixed
453
+     * @access   public
454
+     */
455
+    function get_soapbody(){
456
+        return $this->soapresponse;
457
+    }
458 458
 
459
-	/**
460
-	* get the parsed SOAP Header (NULL if there was none)
461
-	*
462
-	* @return	mixed
463
-	* @access   public
464
-	*/
465
-	function get_soapheader(){
466
-		return $this->soapheader;
467
-	}
459
+    /**
460
+     * get the parsed SOAP Header (NULL if there was none)
461
+     *
462
+     * @return	mixed
463
+     * @access   public
464
+     */
465
+    function get_soapheader(){
466
+        return $this->soapheader;
467
+    }
468 468
 
469
-	/**
470
-	* get the unparsed SOAP Header
471
-	*
472
-	* @return	string XML or empty if no Header
473
-	* @access   public
474
-	*/
475
-	function getHeaders(){
476
-	    return $this->responseHeaders;
477
-	}
469
+    /**
470
+     * get the unparsed SOAP Header
471
+     *
472
+     * @return	string XML or empty if no Header
473
+     * @access   public
474
+     */
475
+    function getHeaders(){
476
+        return $this->responseHeaders;
477
+    }
478 478
 
479
-	/**
480
-	* decodes simple types into PHP variables
481
-	*
482
-	* @param    string $value value to decode
483
-	* @param    string $type XML type to decode
484
-	* @param    string $typens XML type namespace to decode
485
-	* @return	mixed PHP value
486
-	* @access   private
487
-	*/
488
-	function decodeSimple($value, $type, $typens) {
489
-		// TODO: use the namespace!
490
-		if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
491
-			return (string) $value;
492
-		}
493
-		if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
494
-			return (int) $value;
495
-		}
496
-		if ($type == 'float' || $type == 'double' || $type == 'decimal') {
497
-			return (double) $value;
498
-		}
499
-		if ($type == 'boolean') {
500
-			if (strtolower($value) == 'false' || strtolower($value) == 'f') {
501
-				return false;
502
-			}
503
-			return (boolean) $value;
504
-		}
505
-		if ($type == 'base64' || $type == 'base64Binary') {
506
-			$this->debug('Decode base64 value');
507
-			return base64_decode($value);
508
-		}
509
-		// obscure numeric types
510
-		if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
511
-			|| $type == 'nonNegativeInteger' || $type == 'positiveInteger'
512
-			|| $type == 'unsignedInt'
513
-			|| $type == 'unsignedShort' || $type == 'unsignedByte') {
514
-			return (int) $value;
515
-		}
516
-		// bogus: parser treats array with no elements as a simple type
517
-		if ($type == 'array') {
518
-			return array();
519
-		}
520
-		// everything else
521
-		return (string) $value;
522
-	}
479
+    /**
480
+     * decodes simple types into PHP variables
481
+     *
482
+     * @param    string $value value to decode
483
+     * @param    string $type XML type to decode
484
+     * @param    string $typens XML type namespace to decode
485
+     * @return	mixed PHP value
486
+     * @access   private
487
+     */
488
+    function decodeSimple($value, $type, $typens) {
489
+        // TODO: use the namespace!
490
+        if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
491
+            return (string) $value;
492
+        }
493
+        if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
494
+            return (int) $value;
495
+        }
496
+        if ($type == 'float' || $type == 'double' || $type == 'decimal') {
497
+            return (double) $value;
498
+        }
499
+        if ($type == 'boolean') {
500
+            if (strtolower($value) == 'false' || strtolower($value) == 'f') {
501
+                return false;
502
+            }
503
+            return (boolean) $value;
504
+        }
505
+        if ($type == 'base64' || $type == 'base64Binary') {
506
+            $this->debug('Decode base64 value');
507
+            return base64_decode($value);
508
+        }
509
+        // obscure numeric types
510
+        if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
511
+            || $type == 'nonNegativeInteger' || $type == 'positiveInteger'
512
+            || $type == 'unsignedInt'
513
+            || $type == 'unsignedShort' || $type == 'unsignedByte') {
514
+            return (int) $value;
515
+        }
516
+        // bogus: parser treats array with no elements as a simple type
517
+        if ($type == 'array') {
518
+            return array();
519
+        }
520
+        // everything else
521
+        return (string) $value;
522
+    }
523 523
 
524
-	/**
525
-	* builds response structures for compound values (arrays/structs)
526
-	* and scalars
527
-	*
528
-	* @param    integer $pos position in node tree
529
-	* @return	mixed	PHP value
530
-	* @access   private
531
-	*/
532
-	function buildVal($pos){
533
-		if(!isset($this->message[$pos]['type'])){
534
-			$this->message[$pos]['type'] = '';
535
-		}
536
-		$this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']);
537
-		// if there are children...
538
-		if($this->message[$pos]['children'] != ''){
539
-			$this->debug('in buildVal, there are children');
540
-			$children = explode('|',$this->message[$pos]['children']);
541
-			array_shift($children); // knock off empty
542
-			// md array
543
-			if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){
544
-            	$r=0; // rowcount
545
-            	$c=0; // colcount
546
-            	foreach($children as $child_pos){
547
-					$this->debug("in buildVal, got an MD array element: $r, $c");
548
-					$params[$r][] = $this->message[$child_pos]['result'];
549
-				    $c++;
550
-				    if($c == $this->message[$pos]['arrayCols']){
551
-				    	$c = 0;
552
-						$r++;
553
-				    }
524
+    /**
525
+     * builds response structures for compound values (arrays/structs)
526
+     * and scalars
527
+     *
528
+     * @param    integer $pos position in node tree
529
+     * @return	mixed	PHP value
530
+     * @access   private
531
+     */
532
+    function buildVal($pos){
533
+        if(!isset($this->message[$pos]['type'])){
534
+            $this->message[$pos]['type'] = '';
535
+        }
536
+        $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']);
537
+        // if there are children...
538
+        if($this->message[$pos]['children'] != ''){
539
+            $this->debug('in buildVal, there are children');
540
+            $children = explode('|',$this->message[$pos]['children']);
541
+            array_shift($children); // knock off empty
542
+            // md array
543
+            if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){
544
+                $r=0; // rowcount
545
+                $c=0; // colcount
546
+                foreach($children as $child_pos){
547
+                    $this->debug("in buildVal, got an MD array element: $r, $c");
548
+                    $params[$r][] = $this->message[$child_pos]['result'];
549
+                    $c++;
550
+                    if($c == $this->message[$pos]['arrayCols']){
551
+                        $c = 0;
552
+                        $r++;
553
+                    }
554 554
                 }
555 555
             // array
556
-			} elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){
556
+            } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){
557 557
                 $this->debug('in buildVal, adding array '.$this->message[$pos]['name']);
558 558
                 foreach($children as $child_pos){
559
-                	$params[] = &$this->message[$child_pos]['result'];
559
+                    $params[] = &$this->message[$child_pos]['result'];
560 560
                 }
561 561
             // apache Map type: java hashtable
562 562
             } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){
563 563
                 $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']);
564 564
                 foreach($children as $child_pos){
565
-                	$kv = explode("|",$this->message[$child_pos]['children']);
566
-                   	$params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
565
+                    $kv = explode("|",$this->message[$child_pos]['children']);
566
+                        $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
567 567
                 }
568 568
             // generic compound type
569 569
             //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') {
570
-		    } else {
571
-	    		// Apache Vector type: treat as an array
570
+            } else {
571
+                // Apache Vector type: treat as an array
572 572
                 $this->debug('in buildVal, adding Java Vector or generic compound type '.$this->message[$pos]['name']);
573
-				if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
574
-					$notstruct = 1;
575
-				} else {
576
-					$notstruct = 0;
577
-	            }
578
-            	//
579
-            	foreach($children as $child_pos){
580
-            		if($notstruct){
581
-            			$params[] = &$this->message[$child_pos]['result'];
582
-            		} else {
583
-            			if (isset($params[$this->message[$child_pos]['name']])) {
584
-            				// de-serialize repeated element name into an array
585
-            				if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) {
586
-            					$params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]);
587
-            				}
588
-            				$params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result'];
589
-            			} else {
590
-					    	$params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result'];
591
-					    }
592
-                	}
573
+                if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
574
+                    $notstruct = 1;
575
+                } else {
576
+                    $notstruct = 0;
593 577
                 }
594
-			}
595
-			if (isset($this->message[$pos]['xattrs'])) {
578
+                //
579
+                foreach($children as $child_pos){
580
+                    if($notstruct){
581
+                        $params[] = &$this->message[$child_pos]['result'];
582
+                    } else {
583
+                        if (isset($params[$this->message[$child_pos]['name']])) {
584
+                            // de-serialize repeated element name into an array
585
+                            if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) {
586
+                                $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]);
587
+                            }
588
+                            $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result'];
589
+                        } else {
590
+                            $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result'];
591
+                        }
592
+                    }
593
+                }
594
+            }
595
+            if (isset($this->message[$pos]['xattrs'])) {
596 596
                 $this->debug('in buildVal, handling attributes');
597
-				foreach ($this->message[$pos]['xattrs'] as $n => $v) {
598
-					$params[$n] = $v;
599
-				}
600
-			}
601
-			// handle simpleContent
602
-			if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
597
+                foreach ($this->message[$pos]['xattrs'] as $n => $v) {
598
+                    $params[$n] = $v;
599
+                }
600
+            }
601
+            // handle simpleContent
602
+            if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
603 603
                 $this->debug('in buildVal, handling simpleContent');
604
-            	if (isset($this->message[$pos]['type'])) {
605
-					$params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
606
-				} else {
607
-					$parent = $this->message[$pos]['parent'];
608
-					if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
609
-						$params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
610
-					} else {
611
-						$params['!'] = $this->message[$pos]['cdata'];
612
-					}
613
-				}
614
-			}
615
-			$ret = is_array($params) ? $params : array();
616
-			$this->debug('in buildVal, return:');
617
-			//$this->appendDebug($this->varDump($ret));
618
-			return $ret;
619
-		} else {
620
-        	$this->debug('in buildVal, no children, building scalar');
621
-			$cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
622
-        	if (isset($this->message[$pos]['type'])) {
623
-				$ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
624
-				$this->debug("in buildVal, return: $ret");
625
-				return $ret;
626
-			}
627
-			$parent = $this->message[$pos]['parent'];
628
-			if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
629
-				$ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
630
-				$this->debug("in buildVal, return: $ret");
631
-				return $ret;
632
-			}
633
-           	$ret = $this->message[$pos]['cdata'];
634
-			$this->debug("in buildVal, return: $ret");
635
-           	return $ret;
636
-		}
637
-	}
604
+                if (isset($this->message[$pos]['type'])) {
605
+                    $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
606
+                } else {
607
+                    $parent = $this->message[$pos]['parent'];
608
+                    if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
609
+                        $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
610
+                    } else {
611
+                        $params['!'] = $this->message[$pos]['cdata'];
612
+                    }
613
+                }
614
+            }
615
+            $ret = is_array($params) ? $params : array();
616
+            $this->debug('in buildVal, return:');
617
+            //$this->appendDebug($this->varDump($ret));
618
+            return $ret;
619
+        } else {
620
+            $this->debug('in buildVal, no children, building scalar');
621
+            $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
622
+            if (isset($this->message[$pos]['type'])) {
623
+                $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
624
+                $this->debug("in buildVal, return: $ret");
625
+                return $ret;
626
+            }
627
+            $parent = $this->message[$pos]['parent'];
628
+            if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
629
+                $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
630
+                $this->debug("in buildVal, return: $ret");
631
+                return $ret;
632
+            }
633
+                $ret = $this->message[$pos]['cdata'];
634
+            $this->debug("in buildVal, return: $ret");
635
+                return $ret;
636
+        }
637
+    }
638 638
 }
639 639
 
640 640
 /**
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.nusoap_base.php 1 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.wsdlcache.php 1 patch
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -17,189 +17,189 @@
 block discarded – undo
17 17
 */
18 18
 class nusoap_wsdlcache
19 19
 {
20
-	/**
21
-	 *	@var resource
22
-	 *	@access private
23
-	 */
24
-	var $fplock;
25
-	/**
26
-	 *	@var integer
27
-	 *	@access private
28
-	 */
29
-	var $cache_lifetime;
30
-	/**
31
-	 *	@var string
32
-	 *	@access private
33
-	 */
34
-	var $cache_dir;
35
-	/**
36
-	 *	@var string
37
-	 *	@access public
38
-	 */
39
-	var $debug_str = '';
20
+    /**
21
+     *	@var resource
22
+     *	@access private
23
+     */
24
+    var $fplock;
25
+    /**
26
+     *	@var integer
27
+     *	@access private
28
+     */
29
+    var $cache_lifetime;
30
+    /**
31
+     *	@var string
32
+     *	@access private
33
+     */
34
+    var $cache_dir;
35
+    /**
36
+     *	@var string
37
+     *	@access public
38
+     */
39
+    var $debug_str = '';
40 40
 
41
-	/**
42
-	* constructor
43
-	*
44
-	* @param string $cache_dir directory for cache-files
45
-	* @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited
46
-	* @access public
47
-	*/
48
-	function __construct($cache_dir='.', $cache_lifetime=0) {
49
-		$this->fplock = array();
50
-		$this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
51
-		$this->cache_lifetime = $cache_lifetime;
52
-	}
41
+    /**
42
+     * constructor
43
+     *
44
+     * @param string $cache_dir directory for cache-files
45
+     * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited
46
+     * @access public
47
+     */
48
+    function __construct($cache_dir='.', $cache_lifetime=0) {
49
+        $this->fplock = array();
50
+        $this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
51
+        $this->cache_lifetime = $cache_lifetime;
52
+    }
53 53
 
54
-	/**
55
-	* creates the filename used to cache a wsdl instance
56
-	*
57
-	* @param string $wsdl The URL of the wsdl instance
58
-	* @return string The filename used to cache the instance
59
-	* @access private
60
-	*/
61
-	function createFilename($wsdl) {
62
-		return $this->cache_dir.'/wsdlcache-' . md5($wsdl);
63
-	}
54
+    /**
55
+     * creates the filename used to cache a wsdl instance
56
+     *
57
+     * @param string $wsdl The URL of the wsdl instance
58
+     * @return string The filename used to cache the instance
59
+     * @access private
60
+     */
61
+    function createFilename($wsdl) {
62
+        return $this->cache_dir.'/wsdlcache-' . md5($wsdl);
63
+    }
64 64
 
65
-	/**
66
-	* adds debug data to the class level debug string
67
-	*
68
-	* @param    string $string debug data
69
-	* @access   private
70
-	*/
71
-	function debug($string){
72
-		$this->debug_str .= get_class($this).": $string\n";
73
-	}
65
+    /**
66
+     * adds debug data to the class level debug string
67
+     *
68
+     * @param    string $string debug data
69
+     * @access   private
70
+     */
71
+    function debug($string){
72
+        $this->debug_str .= get_class($this).": $string\n";
73
+    }
74 74
 
75
-	/**
76
-	* gets a wsdl instance from the cache
77
-	*
78
-	* @param string $wsdl The URL of the wsdl instance
79
-	* @return object wsdl The cached wsdl instance, null if the instance is not in the cache
80
-	* @access public
81
-	*/
82
-	function get($wsdl) {
83
-		$filename = $this->createFilename($wsdl);
84
-		if ($this->obtainMutex($filename, "r")) {
85
-			// check for expired WSDL that must be removed from the cache
86
- 			if ($this->cache_lifetime > 0) {
87
-				if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) {
88
-					unlink($filename);
89
-					$this->debug("Expired $wsdl ($filename) from cache");
90
-					$this->releaseMutex($filename);
91
-					return null;
92
-  				}
93
-			}
94
-			// see what there is to return
95
-			if (!file_exists($filename)) {
96
-				$this->debug("$wsdl ($filename) not in cache (1)");
97
-				$this->releaseMutex($filename);
98
-				return null;
99
-			}
100
-			$fp = @fopen($filename, "r");
101
-			if ($fp) {
102
-				$s = implode("", @file($filename));
103
-				fclose($fp);
104
-				$this->debug("Got $wsdl ($filename) from cache");
105
-			} else {
106
-				$s = null;
107
-				$this->debug("$wsdl ($filename) not in cache (2)");
108
-			}
109
-			$this->releaseMutex($filename);
110
-			return (!is_null($s)) ? unserialize($s) : null;
111
-		} else {
112
-			$this->debug("Unable to obtain mutex for $filename in get");
113
-		}
114
-		return null;
115
-	}
75
+    /**
76
+     * gets a wsdl instance from the cache
77
+     *
78
+     * @param string $wsdl The URL of the wsdl instance
79
+     * @return object wsdl The cached wsdl instance, null if the instance is not in the cache
80
+     * @access public
81
+     */
82
+    function get($wsdl) {
83
+        $filename = $this->createFilename($wsdl);
84
+        if ($this->obtainMutex($filename, "r")) {
85
+            // check for expired WSDL that must be removed from the cache
86
+                if ($this->cache_lifetime > 0) {
87
+                if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) {
88
+                    unlink($filename);
89
+                    $this->debug("Expired $wsdl ($filename) from cache");
90
+                    $this->releaseMutex($filename);
91
+                    return null;
92
+                    }
93
+            }
94
+            // see what there is to return
95
+            if (!file_exists($filename)) {
96
+                $this->debug("$wsdl ($filename) not in cache (1)");
97
+                $this->releaseMutex($filename);
98
+                return null;
99
+            }
100
+            $fp = @fopen($filename, "r");
101
+            if ($fp) {
102
+                $s = implode("", @file($filename));
103
+                fclose($fp);
104
+                $this->debug("Got $wsdl ($filename) from cache");
105
+            } else {
106
+                $s = null;
107
+                $this->debug("$wsdl ($filename) not in cache (2)");
108
+            }
109
+            $this->releaseMutex($filename);
110
+            return (!is_null($s)) ? unserialize($s) : null;
111
+        } else {
112
+            $this->debug("Unable to obtain mutex for $filename in get");
113
+        }
114
+        return null;
115
+    }
116 116
 
117
-	/**
118
-	* obtains the local mutex
119
-	*
120
-	* @param string $filename The Filename of the Cache to lock
121
-	* @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode
122
-	* @return boolean Lock successfully obtained ?!
123
-	* @access private
124
-	*/
125
-	function obtainMutex($filename, $mode) {
126
-		if (isset($this->fplock[md5($filename)])) {
127
-			$this->debug("Lock for $filename already exists");
128
-			return false;
129
-		}
130
-		$this->fplock[md5($filename)] = fopen($filename.".lock", "w");
131
-		if ($mode == "r") {
132
-			return flock($this->fplock[md5($filename)], LOCK_SH);
133
-		} else {
134
-			return flock($this->fplock[md5($filename)], LOCK_EX);
135
-		}
136
-	}
117
+    /**
118
+     * obtains the local mutex
119
+     *
120
+     * @param string $filename The Filename of the Cache to lock
121
+     * @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode
122
+     * @return boolean Lock successfully obtained ?!
123
+     * @access private
124
+     */
125
+    function obtainMutex($filename, $mode) {
126
+        if (isset($this->fplock[md5($filename)])) {
127
+            $this->debug("Lock for $filename already exists");
128
+            return false;
129
+        }
130
+        $this->fplock[md5($filename)] = fopen($filename.".lock", "w");
131
+        if ($mode == "r") {
132
+            return flock($this->fplock[md5($filename)], LOCK_SH);
133
+        } else {
134
+            return flock($this->fplock[md5($filename)], LOCK_EX);
135
+        }
136
+    }
137 137
 
138
-	/**
139
-	* adds a wsdl instance to the cache
140
-	*
141
-	* @param object wsdl $wsdl_instance The wsdl instance to add
142
-	* @return boolean WSDL successfully cached
143
-	* @access public
144
-	*/
145
-	function put($wsdl_instance) {
146
-		$filename = $this->createFilename($wsdl_instance->wsdl);
147
-		$s = serialize($wsdl_instance);
148
-		if ($this->obtainMutex($filename, "w")) {
149
-			$fp = fopen($filename, "w");
150
-			if (! $fp) {
151
-				$this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache");
152
-				$this->releaseMutex($filename);
153
-				return false;
154
-			}
155
-			fputs($fp, $s);
156
-			fclose($fp);
157
-			$this->debug("Put $wsdl_instance->wsdl ($filename) in cache");
158
-			$this->releaseMutex($filename);
159
-			return true;
160
-		} else {
161
-			$this->debug("Unable to obtain mutex for $filename in put");
162
-		}
163
-		return false;
164
-	}
138
+    /**
139
+     * adds a wsdl instance to the cache
140
+     *
141
+     * @param object wsdl $wsdl_instance The wsdl instance to add
142
+     * @return boolean WSDL successfully cached
143
+     * @access public
144
+     */
145
+    function put($wsdl_instance) {
146
+        $filename = $this->createFilename($wsdl_instance->wsdl);
147
+        $s = serialize($wsdl_instance);
148
+        if ($this->obtainMutex($filename, "w")) {
149
+            $fp = fopen($filename, "w");
150
+            if (! $fp) {
151
+                $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache");
152
+                $this->releaseMutex($filename);
153
+                return false;
154
+            }
155
+            fputs($fp, $s);
156
+            fclose($fp);
157
+            $this->debug("Put $wsdl_instance->wsdl ($filename) in cache");
158
+            $this->releaseMutex($filename);
159
+            return true;
160
+        } else {
161
+            $this->debug("Unable to obtain mutex for $filename in put");
162
+        }
163
+        return false;
164
+    }
165 165
 
166
-	/**
167
-	* releases the local mutex
168
-	*
169
-	* @param string $filename The Filename of the Cache to lock
170
-	* @return boolean Lock successfully released
171
-	* @access private
172
-	*/
173
-	function releaseMutex($filename) {
174
-		$ret = flock($this->fplock[md5($filename)], LOCK_UN);
175
-		fclose($this->fplock[md5($filename)]);
176
-		unset($this->fplock[md5($filename)]);
177
-		if (! $ret) {
178
-			$this->debug("Not able to release lock for $filename");
179
-		}
180
-		return $ret;
181
-	}
166
+    /**
167
+     * releases the local mutex
168
+     *
169
+     * @param string $filename The Filename of the Cache to lock
170
+     * @return boolean Lock successfully released
171
+     * @access private
172
+     */
173
+    function releaseMutex($filename) {
174
+        $ret = flock($this->fplock[md5($filename)], LOCK_UN);
175
+        fclose($this->fplock[md5($filename)]);
176
+        unset($this->fplock[md5($filename)]);
177
+        if (! $ret) {
178
+            $this->debug("Not able to release lock for $filename");
179
+        }
180
+        return $ret;
181
+    }
182 182
 
183
-	/**
184
-	* removes a wsdl instance from the cache
185
-	*
186
-	* @param string $wsdl The URL of the wsdl instance
187
-	* @return boolean Whether there was an instance to remove
188
-	* @access public
189
-	*/
190
-	function remove($wsdl) {
191
-		$filename = $this->createFilename($wsdl);
192
-		if (!file_exists($filename)) {
193
-			$this->debug("$wsdl ($filename) not in cache to be removed");
194
-			return false;
195
-		}
196
-		// ignore errors obtaining mutex
197
-		$this->obtainMutex($filename, "w");
198
-		$ret = unlink($filename);
199
-		$this->debug("Removed ($ret) $wsdl ($filename) from cache");
200
-		$this->releaseMutex($filename);
201
-		return $ret;
202
-	}
183
+    /**
184
+     * removes a wsdl instance from the cache
185
+     *
186
+     * @param string $wsdl The URL of the wsdl instance
187
+     * @return boolean Whether there was an instance to remove
188
+     * @access public
189
+     */
190
+    function remove($wsdl) {
191
+        $filename = $this->createFilename($wsdl);
192
+        if (!file_exists($filename)) {
193
+            $this->debug("$wsdl ($filename) not in cache to be removed");
194
+            return false;
195
+        }
196
+        // ignore errors obtaining mutex
197
+        $this->obtainMutex($filename, "w");
198
+        $ret = unlink($filename);
199
+        $this->debug("Removed ($ret) $wsdl ($filename) from cache");
200
+        $this->releaseMutex($filename);
201
+        return $ret;
202
+    }
203 203
 }
204 204
 
205 205
 /**
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soap_fault.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -10,72 +10,72 @@
 block discarded – undo
10 10
 */
11 11
 class nusoap_fault extends nusoap_base
12 12
 {
13
-	/**
14
-	 * The fault code (client|server)
15
-	 * @var string
16
-	 * @access private
17
-	 */
18
-	var $faultcode;
19
-	/**
20
-	 * The fault actor
21
-	 * @var string
22
-	 * @access private
23
-	 */
24
-	var $faultactor;
25
-	/**
26
-	 * The fault string, a description of the fault
27
-	 * @var string
28
-	 * @access private
29
-	 */
30
-	var $faultstring;
31
-	/**
32
-	 * The fault detail, typically a string or array of string
33
-	 * @var mixed
34
-	 * @access private
35
-	 */
36
-	var $faultdetail;
13
+    /**
14
+     * The fault code (client|server)
15
+     * @var string
16
+     * @access private
17
+     */
18
+    var $faultcode;
19
+    /**
20
+     * The fault actor
21
+     * @var string
22
+     * @access private
23
+     */
24
+    var $faultactor;
25
+    /**
26
+     * The fault string, a description of the fault
27
+     * @var string
28
+     * @access private
29
+     */
30
+    var $faultstring;
31
+    /**
32
+     * The fault detail, typically a string or array of string
33
+     * @var mixed
34
+     * @access private
35
+     */
36
+    var $faultdetail;
37 37
 
38
-	/**
39
-	* constructor
40
-    *
41
-    * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server)
42
-    * @param string $faultactor only used when msg routed between multiple actors
43
-    * @param string $faultstring human readable error message
44
-    * @param mixed $faultdetail detail, typically a string or array of string
45
-	*/
46
-	public function __construct($faultcode,$faultactor='',$faultstring='',$faultdetail=''){
47
-		parent::__construct();
48
-		$this->faultcode = $faultcode;
49
-		$this->faultactor = $faultactor;
50
-		$this->faultstring = $faultstring;
51
-		$this->faultdetail = $faultdetail;
52
-	}
38
+    /**
39
+     * constructor
40
+     *
41
+     * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server)
42
+     * @param string $faultactor only used when msg routed between multiple actors
43
+     * @param string $faultstring human readable error message
44
+     * @param mixed $faultdetail detail, typically a string or array of string
45
+     */
46
+    public function __construct($faultcode,$faultactor='',$faultstring='',$faultdetail=''){
47
+        parent::__construct();
48
+        $this->faultcode = $faultcode;
49
+        $this->faultactor = $faultactor;
50
+        $this->faultstring = $faultstring;
51
+        $this->faultdetail = $faultdetail;
52
+    }
53 53
 
54
-	/**
55
-	* serialize a fault
56
-	*
57
-	* @return	string	The serialization of the fault instance.
58
-	* @access   public
59
-	*/
60
-	function serialize(){
61
-		$ns_string = '';
62
-		foreach($this->namespaces as $k => $v){
63
-			$ns_string .= "\n  xmlns:$k=\"$v\"";
64
-		}
65
-		$return_msg =
66
-			'<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>'.
67
-			'<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.">\n".
68
-				'<SOAP-ENV:Body>'.
69
-				'<SOAP-ENV:Fault>'.
70
-					$this->serialize_val($this->faultcode, 'faultcode').
71
-					$this->serialize_val($this->faultactor, 'faultactor').
72
-					$this->serialize_val($this->faultstring, 'faultstring').
73
-					$this->serialize_val($this->faultdetail, 'detail').
74
-				'</SOAP-ENV:Fault>'.
75
-				'</SOAP-ENV:Body>'.
76
-			'</SOAP-ENV:Envelope>';
77
-		return $return_msg;
78
-	}
54
+    /**
55
+     * serialize a fault
56
+     *
57
+     * @return	string	The serialization of the fault instance.
58
+     * @access   public
59
+     */
60
+    function serialize(){
61
+        $ns_string = '';
62
+        foreach($this->namespaces as $k => $v){
63
+            $ns_string .= "\n  xmlns:$k=\"$v\"";
64
+        }
65
+        $return_msg =
66
+            '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>'.
67
+            '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.">\n".
68
+                '<SOAP-ENV:Body>'.
69
+                '<SOAP-ENV:Fault>'.
70
+                    $this->serialize_val($this->faultcode, 'faultcode').
71
+                    $this->serialize_val($this->faultactor, 'faultactor').
72
+                    $this->serialize_val($this->faultstring, 'faultstring').
73
+                    $this->serialize_val($this->faultdetail, 'detail').
74
+                '</SOAP-ENV:Fault>'.
75
+                '</SOAP-ENV:Body>'.
76
+            '</SOAP-ENV:Envelope>';
77
+        return $return_msg;
78
+    }
79 79
 }
80 80
 
81 81
 /**
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soap_transport_http.php 1 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.