5 Modification information for LGPL compliance
7 r57813 - 2010-08-19 10:34:44 -0700 (Thu, 19 Aug 2010) - kjing - Author: John Mertic <jmertic@sugarcrm.com>
8 Bug 39085 - When loading the opposite search panel via ajax on the ListViews, call the index action instead of the ListView action to avoid touching pre-MVC code by accident.
10 r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync
12 r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
14 r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
16 r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3 tags and updated the build system
18 r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development
20 r51443 - 2009-10-12 13:34:36 -0700 (Mon, 12 Oct 2009) - jmertic - Bug 33332 - Made application PHP 5.3 compliant with E_DEPRECATED warnings on by:
21 - Changing all ereg function to either preg or simple string based ones
22 - No more references to magic quotes.
23 - Change all the session_unregister() functions to just unset() the correct session variable instead.
25 r50375 - 2009-08-24 18:07:43 -0700 (Mon, 24 Aug 2009) - dwong - branch kobe2 from tokyo r50372
27 r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm
29 r13782 - 2006-06-06 10:58:55 -0700 (Tue, 06 Jun 2006) - majed - changes entry point code
31 r11115 - 2006-01-17 14:54:45 -0800 (Tue, 17 Jan 2006) - majed - add entry point validation
33 r8846 - 2005-10-31 11:01:12 -0800 (Mon, 31 Oct 2005) - majed - new version of nusoap
35 r7905 - 2005-09-21 19:12:57 -0700 (Wed, 21 Sep 2005) - majed - restores old nusoap pre & with a few fixes
37 r7861 - 2005-09-20 15:40:25 -0700 (Tue, 20 Sep 2005) - majed - & fix for 3.5.1
39 r5462 - 2005-05-25 13:50:11 -0700 (Wed, 25 May 2005) - majed - upgraded nusoap to .6.9
41 r573 - 2004-09-04 13:03:32 -0700 (Sat, 04 Sep 2004) - sugarclint - undoing copyrights added in inadvertantly. --clint
43 r546 - 2004-09-03 11:49:38 -0700 (Fri, 03 Sep 2004) - sugarmsi - removed echo count
45 r354 - 2004-08-02 23:00:37 -0700 (Mon, 02 Aug 2004) - sugarjacob - Adding Soap
51 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
57 * parses a WSDL file, allows access to it's data, other utility methods.
58 * also builds WSDL structures programmatically.
60 * @author Dietrich Ayala <dietrich@ganx4.com>
61 * @author Scott Nichol <snichol@users.sourceforge.net>
65 class wsdl extends nusoap_base {
66 // URL or filename of the root of this WSDL
68 // define internal arrays of bindings, ports, operations, messages, etc.
69 var $schemas = array();
71 var $message = array();
72 var $complexTypes = array();
73 var $messages = array();
75 var $currentOperation;
76 var $portTypes = array();
78 var $bindings = array();
82 var $opData = array();
84 var $documentation = false;
86 // array of wsdl docs to import
87 var $import = array();
92 var $depth_array = array();
96 var $proxyusername = '';
97 var $proxypassword = '';
99 var $response_timeout = 30;
100 var $curl_options = array(); // User-specified cURL options
101 var $use_curl = false; // whether to always try to use cURL
102 // for HTTP authentication
103 var $username = ''; // Username for HTTP authentication
104 var $password = ''; // Password for HTTP authentication
105 var $authtype = ''; // Type of HTTP authentication
106 var $certRequest = array(); // Certificate for HTTP SSL authentication
111 * @param string $wsdl WSDL document URL
112 * @param string $proxyhost
113 * @param string $proxyport
114 * @param string $proxyusername
115 * @param string $proxypassword
116 * @param integer $timeout set the connection timeout
117 * @param integer $response_timeout set the response timeout
118 * @param array $curl_options user-specified cURL options
119 * @param boolean $use_curl try to use cURL
122 function wsdl($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){
123 parent::nusoap_base();
124 $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
125 $this->proxyhost = $proxyhost;
126 $this->proxyport = $proxyport;
127 $this->proxyusername = $proxyusername;
128 $this->proxypassword = $proxypassword;
129 $this->timeout = $timeout;
130 $this->response_timeout = $response_timeout;
131 if (is_array($curl_options))
132 $this->curl_options = $curl_options;
133 $this->use_curl = $use_curl;
134 $this->fetchWSDL($wsdl);
138 * fetches the WSDL document and parses it
142 function fetchWSDL($wsdl) {
143 $this->debug("parse and process WSDL path=$wsdl");
146 if ($this->wsdl != "") {
147 $this->parseWSDL($this->wsdl);
150 // TODO: handle imports more properly, grabbing them in-line and nesting them
151 $imported_urls = array();
153 while ($imported > 0) {
156 foreach ($this->schemas as $ns => $list) {
157 foreach ($list as $xs) {
158 $wsdlparts = parse_url($this->wsdl); // this is bogusly simple!
159 foreach ($xs->imports as $ns2 => $list2) {
160 for ($ii = 0; $ii < count($list2); $ii++) {
161 if (! $list2[$ii]['loaded']) {
162 $this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
163 $url = $list2[$ii]['location'];
165 $urlparts = parse_url($url);
166 if (!isset($urlparts['host'])) {
167 $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') .
168 substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
170 if (! in_array($url, $imported_urls)) {
171 $this->parseWSDL($url);
173 $imported_urls[] = $url;
176 $this->debug("Unexpected scenario: empty URL for unloaded import");
184 $wsdlparts = parse_url($this->wsdl); // this is bogusly simple!
185 foreach ($this->import as $ns => $list) {
186 for ($ii = 0; $ii < count($list); $ii++) {
187 if (! $list[$ii]['loaded']) {
188 $this->import[$ns][$ii]['loaded'] = true;
189 $url = $list[$ii]['location'];
191 $urlparts = parse_url($url);
192 if (!isset($urlparts['host'])) {
193 $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
194 substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
196 if (! in_array($url, $imported_urls)) {
197 $this->parseWSDL($url);
199 $imported_urls[] = $url;
202 $this->debug("Unexpected scenario: empty URL for unloaded import");
208 // add new data to operation data
209 foreach($this->bindings as $binding => $bindingData) {
210 if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
211 foreach($bindingData['operations'] as $operation => $data) {
212 $this->debug('post-parse data gathering for ' . $operation);
213 $this->bindings[$binding]['operations'][$operation]['input'] =
214 isset($this->bindings[$binding]['operations'][$operation]['input']) ?
215 array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) :
216 $this->portTypes[ $bindingData['portType'] ][$operation]['input'];
217 $this->bindings[$binding]['operations'][$operation]['output'] =
218 isset($this->bindings[$binding]['operations'][$operation]['output']) ?
219 array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) :
220 $this->portTypes[ $bindingData['portType'] ][$operation]['output'];
221 if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){
222 $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ];
224 if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){
225 $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ];
227 // Set operation style if necessary, but do not override one already provided
228 if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
229 $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style'];
231 $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : '';
232 $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : '';
233 $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : '';
240 * parses the wsdl document
242 * @param string $wsdl path or URL
245 function parseWSDL($wsdl = '') {
246 $this->debug("parse WSDL at path=$wsdl");
249 $this->debug('no wsdl passed to parseWSDL()!!');
250 $this->setError('no wsdl passed to parseWSDL()!!');
254 // parse $wsdl for url format
255 $wsdl_props = parse_url($wsdl);
257 if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) {
258 $this->debug('getting WSDL http(s) URL ' . $wsdl);
260 $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl);
261 $tr->request_method = 'GET';
262 $tr->useSOAPAction = false;
263 if($this->proxyhost && $this->proxyport){
264 $tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
266 if ($this->authtype != '') {
267 $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
269 $tr->setEncoding('gzip, deflate');
270 $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
271 //$this->debug("WSDL request\n" . $tr->outgoing_payload);
272 //$this->debug("WSDL response\n" . $tr->incoming_payload);
273 $this->appendDebug($tr->getDebug());
275 if($err = $tr->getError() ){
276 $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err;
277 $this->debug($errstr);
278 $this->setError($errstr);
283 $this->debug("got WSDL URL");
285 // $wsdl is not http(s), so treat it as a file URL or plain file path
286 if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
287 $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path'];
291 $this->debug('getting WSDL file ' . $path);
292 $wsdl_string = @file_get_contents($path);
293 if ($wsdl_string === false) {
294 $errstr = "Bad path to WSDL file $path";
295 $this->debug($errstr);
296 $this->setError($errstr);
300 $this->debug('Parse WSDL');
301 // end new code added
302 // Create an XML parser.
303 $this->parser = xml_parser_create();
304 // Set the options for parsing the XML data.
305 // xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
306 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
307 // Set the object for the parser.
308 xml_set_object($this->parser, $this);
309 // Set the element handlers for the parser.
310 xml_set_element_handler($this->parser, 'start_element', 'end_element');
311 xml_set_character_data_handler($this->parser, 'character_data');
312 // Parse the XML file.
313 if (!xml_parse($this->parser, $wsdl_string, true)) {
314 // Display an error message.
316 'XML error parsing WSDL from %s on line %d: %s',
318 xml_get_current_line_number($this->parser),
319 xml_error_string(xml_get_error_code($this->parser))
321 $this->debug($errstr);
322 $this->debug("XML payload:\n" . $wsdl_string);
323 $this->setError($errstr);
327 xml_parser_free($this->parser);
328 $this->debug('Parsing WSDL done');
329 // catch wsdl parse errors
330 if($this->getError()){
337 * start-element handler
339 * @param string $parser XML parser object
340 * @param string $name element name
341 * @param string $attrs associative array of attributes
344 function start_element($parser, $name, $attrs)
346 if ($this->status == 'schema') {
347 $this->currentSchema->schemaStartElement($parser, $name, $attrs);
348 $this->appendDebug($this->currentSchema->getDebug());
349 $this->currentSchema->clearDebug();
350 } elseif (preg_match('/schema$/', $name)) {
351 $this->debug('Parsing WSDL schema');
352 // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")");
353 $this->status = 'schema';
354 $this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces);
355 $this->currentSchema->schemaStartElement($parser, $name, $attrs);
356 $this->appendDebug($this->currentSchema->getDebug());
357 $this->currentSchema->clearDebug();
359 // position in the total number of elements, starting from 0
360 $pos = $this->position++;
361 $depth = $this->depth++;
362 // set self as current value for this depth
363 $this->depth_array[$depth] = $pos;
364 $this->message[$pos] = array('cdata' => '');
365 // process attributes
366 if (count($attrs) > 0) {
367 // register namespace declarations
368 foreach($attrs as $k => $v) {
369 if (preg_match('/^xmlns/',$k)) {
370 if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
371 $this->namespaces[$ns_prefix] = $v;
373 $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
375 if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
376 $this->XMLSchemaVersion = $v;
377 $this->namespaces['xsi'] = $v . '-instance';
381 // expand each attribute prefix to its namespace
382 foreach($attrs as $k => $v) {
383 $k = strpos($k, ':') ? $this->expandQname($k) : $k;
384 if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') {
385 $v = strpos($v, ':') ? $this->expandQname($v) : $v;
393 // get element prefix, namespace and name
394 if (preg_match('/:/', $name)) {
396 $prefix = substr($name, 0, strpos($name, ':'));
398 $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : '';
399 // get unqualified name
400 $name = substr(strstr($name, ':'), 1);
402 // process attributes, expanding any prefixes to namespaces
403 // find status, register data
404 switch ($this->status) {
406 if ($name == 'part') {
407 if (isset($attrs['type'])) {
408 $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
409 $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
411 if (isset($attrs['element'])) {
412 $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
413 $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
420 $this->currentPortOperation = $attrs['name'];
421 $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
422 if (isset($attrs['parameterOrder'])) {
423 $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
426 case 'documentation':
427 $this->documentation = true;
429 // merge input/output data
431 $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
432 $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
440 if (isset($attrs['style'])) {
441 $this->bindings[$this->currentBinding]['prefix'] = $prefix;
443 $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
446 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs;
449 if (isset($attrs['soapAction'])) {
450 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction'];
452 if (isset($attrs['style'])) {
453 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style'];
455 if (isset($attrs['name'])) {
456 $this->currentOperation = $attrs['name'];
457 $this->debug("current binding operation: $this->currentOperation");
458 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name'];
459 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding;
460 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : '';
464 $this->opStatus = 'input';
467 $this->opStatus = 'output';
470 if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
471 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs);
473 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs;
481 $this->currentPort = $attrs['name'];
482 $this->debug('current port: ' . $this->currentPort);
483 $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
487 $this->ports[$this->currentPort]['location'] = $attrs['location'];
488 $this->ports[$this->currentPort]['bindingType'] = $namespace;
489 $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
490 $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
498 if (isset($attrs['location'])) {
499 $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
500 $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')');
502 $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
503 if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
504 $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
506 $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')');
511 // $this->status = 'schema';
514 $this->status = 'message';
515 $this->messages[$attrs['name']] = array();
516 $this->currentMessage = $attrs['name'];
519 $this->status = 'portType';
520 $this->portTypes[$attrs['name']] = array();
521 $this->currentPortType = $attrs['name'];
524 if (isset($attrs['name'])) {
526 if (strpos($attrs['name'], ':')) {
527 $this->currentBinding = $this->getLocalPart($attrs['name']);
529 $this->currentBinding = $attrs['name'];
531 $this->status = 'binding';
532 $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
533 $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
537 $this->serviceName = $attrs['name'];
538 $this->status = 'service';
539 $this->debug('current service: ' . $this->serviceName);
542 foreach ($attrs as $name => $value) {
543 $this->wsdl_info[$name] = $value;
551 * end-element handler
553 * @param string $parser XML parser object
554 * @param string $name element name
557 function end_element($parser, $name){
558 // unset schema status
559 if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
561 $this->appendDebug($this->currentSchema->getDebug());
562 $this->currentSchema->clearDebug();
563 $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
564 $this->debug('Parsing WSDL schema done');
566 if ($this->status == 'schema') {
567 $this->currentSchema->schemaEndElement($parser, $name);
569 // bring depth down a notch
573 if ($this->documentation) {
574 //TODO: track the node to which documentation should be assigned; it can be a part, message, etc.
575 //$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation;
576 $this->documentation = false;
581 * element content handler
583 * @param string $parser XML parser object
584 * @param string $data element content
587 function character_data($parser, $data)
589 $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
590 if (isset($this->message[$pos]['cdata'])) {
591 $this->message[$pos]['cdata'] .= $data;
593 if ($this->documentation) {
594 $this->documentation .= $data;
599 * if authenticating, set user credentials here
601 * @param string $username
602 * @param string $password
603 * @param string $authtype (basic|digest|certificate|ntlm)
604 * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
607 function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
608 $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
609 $this->appendDebug($this->varDump($certRequest));
610 $this->username = $username;
611 $this->password = $password;
612 $this->authtype = $authtype;
613 $this->certRequest = $certRequest;
616 function getBindingData($binding)
618 if (is_array($this->bindings[$binding])) {
619 return $this->bindings[$binding];
624 * returns an assoc array of operation names => operation data
626 * @param string $portName WSDL port name
627 * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported)
631 function getOperations($portName = '', $bindingType = 'soap') {
633 if ($bindingType == 'soap') {
634 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
635 } elseif ($bindingType == 'soap12') {
636 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
638 $this->debug("getOperations bindingType $bindingType may not be supported");
640 $this->debug("getOperations for port '$portName' bindingType $bindingType");
642 foreach($this->ports as $port => $portData) {
643 $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
644 if ($portName == '' || $port == $portName) {
645 // binding type of port matches parameter
646 if ($portData['bindingType'] == $bindingType) {
647 $this->debug("getOperations found port $port bindingType $bindingType");
648 //$this->debug("port data: " . $this->varDump($portData));
649 //$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
651 if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
652 $ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']);
657 if (count($ops) == 0) {
658 $this->debug("getOperations found no operations for port '$portName' bindingType $bindingType");
664 * returns an associative array of data necessary for calling an operation
666 * @param string $operation name of operation
667 * @param string $bindingType type of binding eg: soap, soap12
671 function getOperationData($operation, $bindingType = 'soap')
673 if ($bindingType == 'soap') {
674 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
675 } elseif ($bindingType == 'soap12') {
676 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
679 foreach($this->ports as $port => $portData) {
680 // binding type of port matches parameter
681 if ($portData['bindingType'] == $bindingType) {
683 //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
684 foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
685 // note that we could/should also check the namespace here
686 if ($operation == $bOperation) {
687 $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
696 * returns an associative array of data necessary for calling an operation
698 * @param string $soapAction soapAction for operation
699 * @param string $bindingType type of binding eg: soap, soap12
703 function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') {
704 if ($bindingType == 'soap') {
705 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
706 } elseif ($bindingType == 'soap12') {
707 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
710 foreach($this->ports as $port => $portData) {
711 // binding type of port matches parameter
712 if ($portData['bindingType'] == $bindingType) {
713 // loop through operations for the binding
714 foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
715 if ($opData['soapAction'] == $soapAction) {
724 * returns an array of information about a given type
725 * returns false if no type exists by the given name
728 * 'elements' => array(), // refs to elements array
729 * 'restrictionBase' => '',
731 * 'order' => '(sequence|all)',
732 * 'attrs' => array() // refs to attributes array
735 * @param string $type the type
736 * @param string $ns namespace (not prefix) of the type
739 * @see nusoap_xmlschema
741 function getTypeDef($type, $ns) {
742 $this->debug("in getTypeDef: type=$type, ns=$ns");
743 if ((! $ns) && isset($this->namespaces['tns'])) {
744 $ns = $this->namespaces['tns'];
745 $this->debug("in getTypeDef: type namespace forced to $ns");
747 if (!isset($this->schemas[$ns])) {
748 foreach ($this->schemas as $ns0 => $schema0) {
749 if (strcasecmp($ns, $ns0) == 0) {
750 $this->debug("in getTypeDef: replacing schema namespace $ns with $ns0");
756 if (isset($this->schemas[$ns])) {
757 $this->debug("in getTypeDef: have schema for namespace $ns");
758 for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
759 $xs = &$this->schemas[$ns][$i];
760 $t = $xs->getTypeDef($type);
761 $this->appendDebug($xs->getDebug());
764 $this->debug("in getTypeDef: found type $type");
765 if (!isset($t['phpType'])) {
766 // get info for type to tack onto the element
767 $uqType = substr($t['type'], strrpos($t['type'], ':') + 1);
768 $ns = substr($t['type'], 0, strrpos($t['type'], ':'));
769 $etype = $this->getTypeDef($uqType, $ns);
771 $this->debug("found type for [element] $type:");
772 $this->debug($this->varDump($etype));
773 if (isset($etype['phpType'])) {
774 $t['phpType'] = $etype['phpType'];
776 if (isset($etype['elements'])) {
777 $t['elements'] = $etype['elements'];
779 if (isset($etype['attrs'])) {
780 $t['attrs'] = $etype['attrs'];
783 $this->debug("did not find type for [element] $type");
789 $this->debug("in getTypeDef: did not find type $type");
791 $this->debug("in getTypeDef: do not have schema for namespace $ns");
797 * prints html description of services
801 function webDescription(){
802 global $HTTP_SERVER_VARS;
804 if (isset($_SERVER)) {
805 $PHP_SELF = $_SERVER['PHP_SELF'];
806 } elseif (isset($HTTP_SERVER_VARS)) {
807 $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
809 $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
813 <html><head><title>NuSOAP: '.$this->serviceName.'</title>
814 <style type="text/css">
815 body { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
816 p { font-family: arial; color: #000000; margin-top: 0px; margin-bottom: 12px; }
817 pre { background-color: silver; padding: 5px; font-family: Courier New; font-size: x-small; color: #000000;}
818 ul { margin-top: 10px; margin-left: 20px; }
819 li { list-style-type: none; margin-top: 10px; color: #000000; }
821 margin-left: 0px; padding-bottom: 2em; }
823 padding-top: 10px; padding-bottom: 10px; padding-left: 15px; font-size: .70em;
824 margin-top: 10px; margin-left: 0px; color: #000000;
825 background-color: #ccccff; width: 20%; margin-left: 20px; margin-top: 20px; }
827 font-family: arial; font-size: 26px; color: #ffffff;
828 background-color: #999999; width: 100%;
829 margin-left: 0px; margin-right: 0px;
830 padding-top: 10px; padding-bottom: 10px;}
832 position: absolute; visibility: hidden; z-index: 200; left: 250px; top: 100px;
833 font-family: arial; overflow: hidden; width: 600;
834 padding: 20px; font-size: 10px; background-color: #999999;
835 layer-background-color:#FFFFFF; }
836 a,a:active { color: charcoal; font-weight: bold; }
837 a:visited { color: #666666; font-weight: bold; }
838 a:hover { color: cc3300; font-weight: bold; }
840 <script language="JavaScript" type="text/javascript">
842 // POP-UP CAPTIONS...
843 function lib_bwcheck(){ //Browsercheck (needed)
844 this.ver=navigator.appVersion
845 this.agent=navigator.userAgent
846 this.dom=document.getElementById?1:0
847 this.opera5=this.agent.indexOf("Opera 5")>-1
848 this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
849 this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
850 this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
851 this.ie=this.ie4||this.ie5||this.ie6
852 this.mac=this.agent.indexOf("Mac")>-1
853 this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
854 this.ns4=(document.layers && !this.dom)?1:0;
855 this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
858 var bw = new lib_bwcheck()
859 //Makes crossbrowser object.
860 function makeObj(obj){
861 this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj]:0;
862 if(!this.evnt) return false
863 this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;
864 this.wref=bw.dom||bw.ie4?this.evnt:bw.ns4?this.css.document:0;
865 this.writeIt=b_writeIt;
868 // A unit of measure that will be added when setting the position of a layer.
869 //var px = bw.ns4||window.opera?"":"px";
870 function b_writeIt(text){
871 if (bw.ns4){this.wref.write(text);this.wref.close()}
872 else this.wref.innerHTML = text
876 function popup(divid){
877 if(oDesc = new makeObj(divid)){
878 oDesc.css.visibility = "visible"
881 function popout(){ // Hides message
882 if(oDesc) oDesc.css.visibility = "hidden"
890 <div class=title>'.$this->serviceName.'</div>
892 <p>View the <a href="'.$PHP_SELF.'?wsdl">WSDL</a> for the service.
893 Click on an operation name to view it's details.</p>
895 foreach($this->getOperations() as $op => $data){
896 $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
898 $b .= "<div id='$op' class='hidden'>
899 <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
900 foreach($data as $donnie => $marie){ // loop through opdata
901 if($donnie == 'input' || $donnie == 'output'){ // show input/output data
902 $b .= "<font color='white'>".ucfirst($donnie).':</font><br>';
903 foreach($marie as $captain => $tenille){ // loop through data
904 if($captain == 'parts'){ // loop thru parts
905 $b .= " $captain:<br>";
906 //if(is_array($tenille)){
907 foreach($tenille as $joanie => $chachi){
908 $b .= " $joanie: $chachi<br>";
912 $b .= " $captain: $tenille<br>";
916 $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>";
924 </div></body></html>';
929 * serialize the parsed wsdl
931 * @param mixed $debug whether to put debug=1 in endpoint URL
932 * @return string serialization of WSDL
935 function serialize($debug = 0)
937 $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
938 $xml .= "\n<definitions";
939 foreach($this->namespaces as $k => $v) {
940 $xml .= " xmlns:$k=\"$v\"";
942 // 10.9.02 - add poulter fix for wsdl and tns declarations
943 if (isset($this->namespaces['wsdl'])) {
944 $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
946 if (isset($this->namespaces['tns'])) {
947 $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
951 if (sizeof($this->import) > 0) {
952 foreach($this->import as $ns => $list) {
953 foreach ($list as $ii) {
954 if ($ii['location'] != '') {
955 $xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />';
957 $xml .= '<import namespace="' . $ns . '" />';
963 if (count($this->schemas)>=1) {
964 $xml .= "\n<types>\n";
965 foreach ($this->schemas as $ns => $list) {
966 foreach ($list as $xs) {
967 $xml .= $xs->serializeSchema();
973 if (count($this->messages) >= 1) {
974 foreach($this->messages as $msgName => $msgParts) {
975 $xml .= "\n<message name=\"" . $msgName . '">';
976 if(is_array($msgParts)){
977 foreach($msgParts as $partName => $partType) {
978 // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
979 if (strpos($partType, ':')) {
980 $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
981 } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
982 // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
985 foreach($this->typemap as $ns => $types) {
986 if (isset($types[$partType])) {
987 $typePrefix = $this->getPrefixFromNamespace($ns);
990 if (!isset($typePrefix)) {
991 die("$partType has no namespace!");
994 $ns = $this->getNamespaceFromPrefix($typePrefix);
995 $localPart = $this->getLocalPart($partType);
996 $typeDef = $this->getTypeDef($localPart, $ns);
997 if ($typeDef['typeClass'] == 'element') {
998 $elementortype = 'element';
999 if (substr($localPart, -1) == '^') {
1000 $localPart = substr($localPart, 0, -1);
1003 $elementortype = 'type';
1005 $xml .= "\n" . ' <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />';
1008 $xml .= '</message>';
1011 // bindings & porttypes
1012 if (count($this->bindings) >= 1) {
1015 foreach($this->bindings as $bindingName => $attrs) {
1016 $binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
1017 $binding_xml .= "\n" . ' <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
1018 $portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
1019 foreach($attrs['operations'] as $opName => $opParts) {
1020 $binding_xml .= "\n" . ' <operation name="' . $opName . '">';
1021 $binding_xml .= "\n" . ' <soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>';
1022 if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
1023 $enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
1027 $binding_xml .= "\n" . ' <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
1028 if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
1029 $enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
1033 $binding_xml .= "\n" . ' <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
1034 $binding_xml .= "\n" . ' </operation>';
1035 $portType_xml .= "\n" . ' <operation name="' . $opParts['name'] . '"';
1036 if (isset($opParts['parameterOrder'])) {
1037 $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
1039 $portType_xml .= '>';
1040 if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
1041 $portType_xml .= "\n" . ' <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
1043 $portType_xml .= "\n" . ' <input message="tns:' . $opParts['input']['message'] . '"/>';
1044 $portType_xml .= "\n" . ' <output message="tns:' . $opParts['output']['message'] . '"/>';
1045 $portType_xml .= "\n" . ' </operation>';
1047 $portType_xml .= "\n" . '</portType>';
1048 $binding_xml .= "\n" . '</binding>';
1050 $xml .= $portType_xml . $binding_xml;
1053 $xml .= "\n<service name=\"" . $this->serviceName . '">';
1054 if (count($this->ports) >= 1) {
1055 foreach($this->ports as $pName => $attrs) {
1056 $xml .= "\n" . ' <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
1057 $xml .= "\n" . ' <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
1058 $xml .= "\n" . ' </port>';
1061 $xml .= "\n" . '</service>';
1062 return $xml . "\n</definitions>";
1066 * determine whether a set of parameters are unwrapped
1067 * when they are expect to be wrapped, Microsoft-style.
1069 * @param string $type the type (element name) of the wrapper
1070 * @param array $parameters the parameter values for the SOAP call
1071 * @return boolean whether they parameters are unwrapped (and should be wrapped)
1074 function parametersMatchWrapped($type, &$parameters) {
1075 $this->debug("in parametersMatchWrapped type=$type, parameters=");
1076 $this->appendDebug($this->varDump($parameters));
1078 // split type into namespace:unqualified-type
1079 if (strpos($type, ':')) {
1080 $uqType = substr($type, strrpos($type, ':') + 1);
1081 $ns = substr($type, 0, strrpos($type, ':'));
1082 $this->debug("in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
1083 if ($this->getNamespaceFromPrefix($ns)) {
1084 $ns = $this->getNamespaceFromPrefix($ns);
1085 $this->debug("in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
1088 // TODO: should the type be compared to types in XSD, and the namespace
1089 // set to XSD if the type matches?
1090 $this->debug("in parametersMatchWrapped: No namespace for type $type");
1095 // get the type information
1096 if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
1097 $this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type.");
1100 $this->debug("in parametersMatchWrapped: found typeDef=");
1101 $this->appendDebug($this->varDump($typeDef));
1102 if (substr($uqType, -1) == '^') {
1103 $uqType = substr($uqType, 0, -1);
1105 $phpType = $typeDef['phpType'];
1106 $arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '');
1107 $this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
1109 // we expect a complexType or element of complexType
1110 if ($phpType != 'struct') {
1111 $this->debug("in parametersMatchWrapped: not a struct");
1115 // see whether the parameter names match the elements
1116 if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1119 foreach ($typeDef['elements'] as $name => $attrs) {
1120 if (isset($parameters[$name])) {
1121 $this->debug("in parametersMatchWrapped: have parameter named $name");
1124 $this->debug("in parametersMatchWrapped: do not have parameter named $name");
1129 $this->debug("in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names");
1130 if ($matches == 0) {
1136 // since there are no elements for the type, if the user passed no
1137 // parameters, the parameters match wrapped.
1138 $this->debug("in parametersMatchWrapped: no elements type $ns:$uqType");
1139 return count($parameters) == 0;
1143 * serialize PHP values according to a WSDL message definition
1144 * contrary to the method name, this is not limited to RPC
1147 * - multi-ref serialization
1148 * - validate PHP values against type definitions, return errors if invalid
1150 * @param string $operation operation name
1151 * @param string $direction (input|output)
1152 * @param mixed $parameters parameter value(s)
1153 * @param string $bindingType (soap|soap12)
1154 * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1157 function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
1158 $this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
1159 $this->appendDebug('parameters=' . $this->varDump($parameters));
1161 if ($direction != 'input' && $direction != 'output') {
1162 $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1163 $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1166 if (!$opData = $this->getOperationData($operation, $bindingType)) {
1167 $this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1168 $this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1171 $this->debug('in serializeRPCParameters: opData:');
1172 $this->appendDebug($this->varDump($opData));
1174 // Get encoding style for output and set to current
1175 $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1176 if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1177 $encodingStyle = $opData['output']['encodingStyle'];
1178 $enc_style = $encodingStyle;
1183 if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1184 $parts = &$opData[$direction]['parts'];
1185 $part_count = sizeof($parts);
1186 $style = $opData['style'];
1187 $use = $opData[$direction]['use'];
1188 $this->debug("have $part_count part(s) to serialize using $style/$use");
1189 if (is_array($parameters)) {
1190 $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1191 $parameter_count = count($parameters);
1192 $this->debug("have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
1193 // check for Microsoft-style wrapped parameters
1194 if ($style == 'document' && $use == 'literal' && $part_count == 1 && isset($parts['parameters'])) {
1195 $this->debug('check whether the caller has wrapped the parameters');
1196 if ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1) {
1197 // TODO: consider checking here for double-wrapping, when
1198 // service function wraps, then NuSOAP wraps again
1199 $this->debug("change simple array to associative with 'parameters' element");
1200 $parameters['parameters'] = $parameters[0];
1201 unset($parameters[0]);
1203 if (($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) {
1204 $this->debug('check whether caller\'s parameters match the wrapped ones');
1205 if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) {
1206 $this->debug('wrap the parameters for the caller');
1207 $parameters = array('parameters' => $parameters);
1208 $parameter_count = 1;
1212 foreach ($parts as $name => $type) {
1213 $this->debug("serializing part $name of type $type");
1214 // Track encoding style
1215 if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1216 $encodingStyle = $opData[$direction]['encodingStyle'];
1217 $enc_style = $encodingStyle;
1221 // NOTE: add error handling here
1222 // if serializeType returns false, then catch global error and fault
1223 if ($parametersArrayType == 'arraySimple') {
1224 $p = array_shift($parameters);
1225 $this->debug('calling serializeType w/indexed param');
1226 $xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1227 } elseif (isset($parameters[$name])) {
1228 $this->debug('calling serializeType w/named param');
1229 $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1231 // TODO: only send nillable
1232 $this->debug('calling serializeType w/null param');
1233 $xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1237 $this->debug('no parameters passed.');
1240 $this->debug("serializeRPCParameters returning: $xml");
1245 * serialize a PHP value according to a WSDL message definition
1248 * - multi-ref serialization
1249 * - validate PHP values against type definitions, return errors if invalid
1251 * @param string $operation operation name
1252 * @param string $direction (input|output)
1253 * @param mixed $parameters parameter value(s)
1254 * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1258 function serializeParameters($operation, $direction, $parameters)
1260 $this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
1261 $this->appendDebug('parameters=' . $this->varDump($parameters));
1263 if ($direction != 'input' && $direction != 'output') {
1264 $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1265 $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1268 if (!$opData = $this->getOperationData($operation)) {
1269 $this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
1270 $this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
1273 $this->debug('opData:');
1274 $this->appendDebug($this->varDump($opData));
1276 // Get encoding style for output and set to current
1277 $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1278 if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1279 $encodingStyle = $opData['output']['encodingStyle'];
1280 $enc_style = $encodingStyle;
1285 if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1287 $use = $opData[$direction]['use'];
1288 $this->debug("use=$use");
1289 $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
1290 if (is_array($parameters)) {
1291 $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1292 $this->debug('have ' . $parametersArrayType . ' parameters');
1293 foreach($opData[$direction]['parts'] as $name => $type) {
1294 $this->debug('serializing part "'.$name.'" of type "'.$type.'"');
1295 // Track encoding style
1296 if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1297 $encodingStyle = $opData[$direction]['encodingStyle'];
1298 $enc_style = $encodingStyle;
1302 // NOTE: add error handling here
1303 // if serializeType returns false, then catch global error and fault
1304 if ($parametersArrayType == 'arraySimple') {
1305 $p = array_shift($parameters);
1306 $this->debug('calling serializeType w/indexed param');
1307 $xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1308 } elseif (isset($parameters[$name])) {
1309 $this->debug('calling serializeType w/named param');
1310 $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1312 // TODO: only send nillable
1313 $this->debug('calling serializeType w/null param');
1314 $xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1318 $this->debug('no parameters passed.');
1321 $this->debug("serializeParameters returning: $xml");
1326 * serializes a PHP value according a given type definition
1328 * @param string $name name of value (part or element)
1329 * @param string $type XML schema type of value (type or element)
1330 * @param mixed $value a native PHP value (parameter value)
1331 * @param string $use use for part (encoded|literal)
1332 * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1333 * @param boolean $unqualified a kludge for what should be XML namespace form handling
1334 * @return string value serialized as an XML string
1337 function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false)
1339 $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
1340 $this->appendDebug("value=" . $this->varDump($value));
1341 if($use == 'encoded' && $encodingStyle) {
1342 $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
1345 // if a soapval has been supplied, let its type override the WSDL
1346 if (is_object($value) && get_class($value) == 'soapval') {
1347 if ($value->type_ns) {
1348 $type = $value->type_ns . ':' . $value->type;
1350 $this->debug("in serializeType: soapval overrides type to $type");
1351 } elseif ($value->type) {
1352 $type = $value->type;
1354 $this->debug("in serializeType: soapval overrides type to $type");
1357 $this->debug("in serializeType: soapval does not override type");
1359 $attrs = $value->attributes;
1360 $value = $value->value;
1361 $this->debug("in serializeType: soapval overrides value to $value");
1363 if (!is_array($value)) {
1364 $value['!'] = $value;
1366 foreach ($attrs as $n => $v) {
1367 $value['!' . $n] = $v;
1369 $this->debug("in serializeType: soapval provides attributes");
1376 if (strpos($type, ':')) {
1377 $uqType = substr($type, strrpos($type, ':') + 1);
1378 $ns = substr($type, 0, strrpos($type, ':'));
1379 $this->debug("in serializeType: got a prefixed type: $uqType, $ns");
1380 if ($this->getNamespaceFromPrefix($ns)) {
1381 $ns = $this->getNamespaceFromPrefix($ns);
1382 $this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
1385 if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
1386 $this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
1387 if ($unqualified && $use == 'literal') {
1388 $elementNS = " xmlns=\"\"";
1392 if (is_null($value)) {
1393 if ($use == 'literal') {
1394 // TODO: depends on minOccurs
1395 $xml = "<$name$elementNS/>";
1397 // TODO: depends on nillable, which should be checked before calling this method
1398 $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1400 $this->debug("in serializeType: returning: $xml");
1403 if ($uqType == 'Array') {
1404 // JBoss/Axis does this sometimes
1405 return $this->serialize_val($value, $name, false, false, false, false, $use);
1407 if ($uqType == 'boolean') {
1408 if ((is_string($value) && $value == 'false') || (! $value)) {
1414 if ($uqType == 'string' && gettype($value) == 'string') {
1415 $value = $this->expandEntities($value);
1417 if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') {
1418 $value = sprintf("%.0lf", $value);
1421 // TODO: what about null/nil values?
1422 // check type isn't a custom type extending xmlschema namespace
1423 if (!$this->getTypeDef($uqType, $ns)) {
1424 if ($use == 'literal') {
1426 $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1428 $xml = "<$name$elementNS>$value</$name>";
1431 $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1433 $this->debug("in serializeType: returning: $xml");
1436 $this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
1437 } else if ($ns == 'http://xml.apache.org/xml-soap') {
1438 $this->debug('in serializeType: appears to be Apache SOAP type');
1439 if ($uqType == 'Map') {
1440 $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1442 $this->debug('in serializeType: Add namespace for Apache SOAP type');
1443 $tt_prefix = 'ns' . rand(1000, 9999);
1444 $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
1445 // force this to be added to usedNamespaces
1446 $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1449 foreach($value as $k => $v) {
1450 $this->debug("serializing map element: key $k, value $v");
1451 $contents .= '<item>';
1452 $contents .= $this->serialize_val($k,'key',false,false,false,false,$use);
1453 $contents .= $this->serialize_val($v,'value',false,false,false,false,$use);
1454 $contents .= '</item>';
1456 if ($use == 'literal') {
1458 $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>";
1460 $xml = "<$name>$contents</$name>";
1463 $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>";
1465 $this->debug("in serializeType: returning: $xml");
1468 $this->debug('in serializeType: Apache SOAP type, but only support Map');
1471 // TODO: should the type be compared to types in XSD, and the namespace
1472 // set to XSD if the type matches?
1473 $this->debug("in serializeType: No namespace for type $type");
1477 if(!$typeDef = $this->getTypeDef($uqType, $ns)){
1478 $this->setError("$type ($uqType) is not a supported type.");
1479 $this->debug("in serializeType: $type ($uqType) is not a supported type.");
1482 $this->debug("in serializeType: found typeDef");
1483 $this->appendDebug('typeDef=' . $this->varDump($typeDef));
1484 if (substr($uqType, -1) == '^') {
1485 $uqType = substr($uqType, 0, -1);
1488 if (!isset($typeDef['phpType'])) {
1489 $this->setError("$type ($uqType) has no phpType.");
1490 $this->debug("in serializeType: $type ($uqType) has no phpType.");
1493 $phpType = $typeDef['phpType'];
1494 $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
1495 // if php type == struct, map value to the <all> element names
1496 if ($phpType == 'struct') {
1497 if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
1498 $elementName = $uqType;
1499 if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1500 $elementNS = " xmlns=\"$ns\"";
1502 $elementNS = " xmlns=\"\"";
1505 $elementName = $name;
1507 $elementNS = " xmlns=\"\"";
1512 if (is_null($value)) {
1513 if ($use == 'literal') {
1514 // TODO: depends on minOccurs and nillable
1515 $xml = "<$elementName$elementNS/>";
1517 $xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1519 $this->debug("in serializeType: returning: $xml");
1522 if (is_object($value)) {
1523 $value = get_object_vars($value);
1525 if (is_array($value)) {
1526 $elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
1527 if ($use == 'literal') {
1529 $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
1531 $xml = "<$elementName$elementNS$elementAttrs>";
1534 $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
1537 if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
1538 if (isset($value['!'])) {
1539 $xml .= $value['!'];
1540 $this->debug("in serializeType: serialized simpleContent for type $type");
1542 $this->debug("in serializeType: no simpleContent to serialize for type $type");
1546 $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
1548 $xml .= "</$elementName>";
1550 $this->debug("in serializeType: phpType is struct, but value is not an array");
1551 $this->setError("phpType is struct, but value is not an array: see debug output for details");
1554 } elseif ($phpType == 'array') {
1555 if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1556 $elementNS = " xmlns=\"$ns\"";
1559 $elementNS = " xmlns=\"\"";
1564 if (is_null($value)) {
1565 if ($use == 'literal') {
1566 // TODO: depends on minOccurs
1567 $xml = "<$name$elementNS/>";
1569 $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
1570 $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1572 $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1574 $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
1576 $this->getLocalPart($typeDef['arrayType'])."[0]\"/>";
1578 $this->debug("in serializeType: returning: $xml");
1581 if (isset($typeDef['multidimensional'])) {
1583 foreach($value as $v) {
1584 $cols = ',' . sizeof($v);
1585 $nv = array_merge($nv, $v);
1591 if (is_array($value) && sizeof($value) >= 1) {
1592 $rows = sizeof($value);
1594 foreach($value as $k => $v) {
1595 $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
1596 //if (strpos($typeDef['arrayType'], ':') ) {
1597 if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
1598 $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
1600 $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
1607 // TODO: for now, an empty value will be serialized as a zero element
1608 // array. Revisit this when coding the handling of null/nil values.
1609 if ($use == 'literal') {
1610 $xml = "<$name$elementNS>"
1614 $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '.
1615 $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
1617 .$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
1618 .":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">"
1622 } elseif ($phpType == 'scalar') {
1623 if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1624 $elementNS = " xmlns=\"$ns\"";
1627 $elementNS = " xmlns=\"\"";
1632 if ($use == 'literal') {
1634 $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1636 $xml = "<$name$elementNS>$value</$name>";
1639 $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1642 $this->debug("in serializeType: returning: $xml");
1647 * serializes the attributes for a complexType
1649 * @param array $typeDef our internal representation of an XML schema type (or element)
1650 * @param mixed $value a native PHP value (parameter value)
1651 * @param string $ns the namespace of the type
1652 * @param string $uqType the local part of the type
1653 * @return string value serialized as an XML string
1656 function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
1657 $this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType");
1659 if (isset($typeDef['extensionBase'])) {
1660 $nsx = $this->getPrefix($typeDef['extensionBase']);
1661 $uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1662 if ($this->getNamespaceFromPrefix($nsx)) {
1663 $nsx = $this->getNamespaceFromPrefix($nsx);
1665 if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1666 $this->debug("serialize attributes for extension base $nsx:$uqTypex");
1667 $xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex);
1669 $this->debug("extension base $nsx:$uqTypex is not a supported type");
1672 if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
1673 $this->debug("serialize attributes for XML Schema type $ns:$uqType");
1674 if (is_array($value)) {
1676 } elseif (is_object($value)) {
1677 $xvalue = get_object_vars($value);
1679 $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1682 foreach ($typeDef['attrs'] as $aName => $attrs) {
1683 if (isset($xvalue['!' . $aName])) {
1684 $xname = '!' . $aName;
1685 $this->debug("value provided for attribute $aName with key $xname");
1686 } elseif (isset($xvalue[$aName])) {
1688 $this->debug("value provided for attribute $aName with key $xname");
1689 } elseif (isset($attrs['default'])) {
1690 $xname = '!' . $aName;
1691 $xvalue[$xname] = $attrs['default'];
1692 $this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
1695 $this->debug("no value provided for attribute $aName");
1698 $xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
1702 $this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
1708 * serializes the elements for a complexType
1710 * @param array $typeDef our internal representation of an XML schema type (or element)
1711 * @param mixed $value a native PHP value (parameter value)
1712 * @param string $ns the namespace of the type
1713 * @param string $uqType the local part of the type
1714 * @param string $use use for part (encoded|literal)
1715 * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1716 * @return string value serialized as an XML string
1719 function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
1720 $this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
1722 if (isset($typeDef['extensionBase'])) {
1723 $nsx = $this->getPrefix($typeDef['extensionBase']);
1724 $uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1725 if ($this->getNamespaceFromPrefix($nsx)) {
1726 $nsx = $this->getNamespaceFromPrefix($nsx);
1728 if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1729 $this->debug("serialize elements for extension base $nsx:$uqTypex");
1730 $xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle);
1732 $this->debug("extension base $nsx:$uqTypex is not a supported type");
1735 if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1736 $this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
1737 if (is_array($value)) {
1739 } elseif (is_object($value)) {
1740 $xvalue = get_object_vars($value);
1742 $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1745 // toggle whether all elements are present - ideally should validate against schema
1746 if (count($typeDef['elements']) != count($xvalue)){
1749 foreach ($typeDef['elements'] as $eName => $attrs) {
1750 if (!isset($xvalue[$eName])) {
1751 if (isset($attrs['default'])) {
1752 $xvalue[$eName] = $attrs['default'];
1753 $this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
1756 // if user took advantage of a minOccurs=0, then only serialize named parameters
1757 if (isset($optionals)
1758 && (!isset($xvalue[$eName]))
1759 && ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
1761 if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
1762 $this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
1765 $this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
1768 if (isset($xvalue[$eName])) {
1769 $v = $xvalue[$eName];
1773 if (isset($attrs['form'])) {
1774 $unqualified = ($attrs['form'] == 'unqualified');
1776 $unqualified = false;
1778 if (isset($attrs['maxOccurs']) && ($attrs['maxOccurs'] == 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruct($v) == 'arraySimple') {
1780 foreach ($vv as $k => $v) {
1781 if (isset($attrs['type']) || isset($attrs['ref'])) {
1782 // serialize schema-defined type
1783 $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1785 // serialize generic type (can this ever really happen?)
1786 $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1787 $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1791 if (is_null($v) && isset($attrs['minOccurs']) && $attrs['minOccurs'] == '0') {
1793 } elseif (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true') {
1794 // TODO: serialize a nil correctly, but for now serialize schema-defined type
1795 $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1796 } elseif (isset($attrs['type']) || isset($attrs['ref'])) {
1797 // serialize schema-defined type
1798 $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1800 // serialize generic type (can this ever really happen?)
1801 $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1802 $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1808 $this->debug("no elements to serialize for XML Schema type $ns:$uqType");
1814 * adds an XML Schema complex type to the WSDL types
1816 * @param string $name
1817 * @param string $typeClass (complexType|simpleType|attribute)
1818 * @param string $phpType currently supported are array and struct (php assoc array)
1819 * @param string $compositor (all|sequence|choice)
1820 * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1821 * @param array $elements e.g. array ( name => array(name=>'',type=>'') )
1822 * @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
1823 * @param string $arrayType as namespace:name (xsd:string)
1824 * @see nusoap_xmlschema
1827 function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') {
1828 if (count($elements) > 0) {
1829 $eElements = array();
1830 foreach($elements as $n => $e){
1831 // expand each element
1833 foreach ($e as $k => $v) {
1834 $k = strpos($k,':') ? $this->expandQname($k) : $k;
1835 $v = strpos($v,':') ? $this->expandQname($v) : $v;
1838 $eElements[$n] = $ee;
1840 $elements = $eElements;
1843 if (count($attrs) > 0) {
1844 foreach($attrs as $n => $a){
1845 // expand each attribute
1846 foreach ($a as $k => $v) {
1847 $k = strpos($k,':') ? $this->expandQname($k) : $k;
1848 $v = strpos($v,':') ? $this->expandQname($v) : $v;
1856 $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1857 $arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType;
1859 $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1860 $this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType);
1864 * adds an XML Schema simple type to the WSDL types
1866 * @param string $name
1867 * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1868 * @param string $typeClass (should always be simpleType)
1869 * @param string $phpType (should always be scalar)
1870 * @param array $enumeration array of values
1871 * @see nusoap_xmlschema
1874 function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
1875 $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1877 $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1878 $this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration);
1882 * adds an element to the WSDL types
1884 * @param array $attrs attributes that must include name and type
1885 * @see nusoap_xmlschema
1888 function addElement($attrs) {
1889 $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1890 $this->schemas[$typens][0]->addElement($attrs);
1894 * register an operation with the server
1896 * @param string $name operation (method) name
1897 * @param array $in assoc array of input values: key = param name, value = param type
1898 * @param array $out assoc array of output values: key = param name, value = param type
1899 * @param string $namespace optional The namespace for the operation
1900 * @param string $soapaction optional The soapaction for the operation
1901 * @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
1902 * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now)
1903 * @param string $documentation optional The description to include in the WSDL
1904 * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
1907 function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
1908 if ($use == 'encoded' && $encodingStyle == '') {
1909 $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1912 if ($style == 'document') {
1913 $elements = array();
1914 foreach ($in as $n => $t) {
1915 $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1917 $this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
1918 $this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
1919 $in = array('parameters' => 'tns:' . $name . '^');
1921 $elements = array();
1922 foreach ($out as $n => $t) {
1923 $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1925 $this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
1926 $this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified'));
1927 $out = array('parameters' => 'tns:' . $name . 'Response' . '^');
1931 $this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] =
1934 'binding' => $this->serviceName . 'Binding',
1935 'endpoint' => $this->endpoint,
1936 'soapAction' => $soapaction,
1940 'namespace' => $namespace,
1941 'encodingStyle' => $encodingStyle,
1942 'message' => $name . 'Request',
1946 'namespace' => $namespace,
1947 'encodingStyle' => $encodingStyle,
1948 'message' => $name . 'Response',
1950 'namespace' => $namespace,
1951 'transport' => 'http://schemas.xmlsoap.org/soap/http',
1952 'documentation' => $documentation);
1957 foreach($in as $pName => $pType)
1959 if(strpos($pType,':')) {
1960 $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1962 $this->messages[$name.'Request'][$pName] = $pType;
1965 $this->messages[$name.'Request']= '0';
1969 foreach($out as $pName => $pType)
1971 if(strpos($pType,':')) {
1972 $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1974 $this->messages[$name.'Response'][$pName] = $pType;
1977 $this->messages[$name.'Response']= '0';