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 if ($fp = @fopen($path, 'r')) {
294 while ($data = fread($fp, 32768)) {
295 $wsdl_string .= $data;
299 $errstr = "Bad path to WSDL file $path";
300 $this->debug($errstr);
301 $this->setError($errstr);
305 $this->debug('Parse WSDL');
306 // end new code added
307 // Create an XML parser.
308 $this->parser = xml_parser_create();
309 // Set the options for parsing the XML data.
310 // xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
311 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
312 // Set the object for the parser.
313 xml_set_object($this->parser, $this);
314 // Set the element handlers for the parser.
315 xml_set_element_handler($this->parser, 'start_element', 'end_element');
316 xml_set_character_data_handler($this->parser, 'character_data');
317 // Parse the XML file.
318 if (!xml_parse($this->parser, $wsdl_string, true)) {
319 // Display an error message.
321 'XML error parsing WSDL from %s on line %d: %s',
323 xml_get_current_line_number($this->parser),
324 xml_error_string(xml_get_error_code($this->parser))
326 $this->debug($errstr);
327 $this->debug("XML payload:\n" . $wsdl_string);
328 $this->setError($errstr);
332 xml_parser_free($this->parser);
333 $this->debug('Parsing WSDL done');
334 // catch wsdl parse errors
335 if($this->getError()){
342 * start-element handler
344 * @param string $parser XML parser object
345 * @param string $name element name
346 * @param string $attrs associative array of attributes
349 function start_element($parser, $name, $attrs)
351 if ($this->status == 'schema') {
352 $this->currentSchema->schemaStartElement($parser, $name, $attrs);
353 $this->appendDebug($this->currentSchema->getDebug());
354 $this->currentSchema->clearDebug();
355 } elseif (preg_match('/schema$/', $name)) {
356 $this->debug('Parsing WSDL schema');
357 // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")");
358 $this->status = 'schema';
359 $this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces);
360 $this->currentSchema->schemaStartElement($parser, $name, $attrs);
361 $this->appendDebug($this->currentSchema->getDebug());
362 $this->currentSchema->clearDebug();
364 // position in the total number of elements, starting from 0
365 $pos = $this->position++;
366 $depth = $this->depth++;
367 // set self as current value for this depth
368 $this->depth_array[$depth] = $pos;
369 $this->message[$pos] = array('cdata' => '');
370 // process attributes
371 if (count($attrs) > 0) {
372 // register namespace declarations
373 foreach($attrs as $k => $v) {
374 if (preg_match('/^xmlns/',$k)) {
375 if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
376 $this->namespaces[$ns_prefix] = $v;
378 $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
380 if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
381 $this->XMLSchemaVersion = $v;
382 $this->namespaces['xsi'] = $v . '-instance';
386 // expand each attribute prefix to its namespace
387 foreach($attrs as $k => $v) {
388 $k = strpos($k, ':') ? $this->expandQname($k) : $k;
389 if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') {
390 $v = strpos($v, ':') ? $this->expandQname($v) : $v;
398 // get element prefix, namespace and name
399 if (preg_match('/:/', $name)) {
401 $prefix = substr($name, 0, strpos($name, ':'));
403 $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : '';
404 // get unqualified name
405 $name = substr(strstr($name, ':'), 1);
407 // process attributes, expanding any prefixes to namespaces
408 // find status, register data
409 switch ($this->status) {
411 if ($name == 'part') {
412 if (isset($attrs['type'])) {
413 $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
414 $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
416 if (isset($attrs['element'])) {
417 $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
418 $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
425 $this->currentPortOperation = $attrs['name'];
426 $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
427 if (isset($attrs['parameterOrder'])) {
428 $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
431 case 'documentation':
432 $this->documentation = true;
434 // merge input/output data
436 $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
437 $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
445 if (isset($attrs['style'])) {
446 $this->bindings[$this->currentBinding]['prefix'] = $prefix;
448 $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
451 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs;
454 if (isset($attrs['soapAction'])) {
455 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction'];
457 if (isset($attrs['style'])) {
458 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style'];
460 if (isset($attrs['name'])) {
461 $this->currentOperation = $attrs['name'];
462 $this->debug("current binding operation: $this->currentOperation");
463 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name'];
464 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding;
465 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : '';
469 $this->opStatus = 'input';
472 $this->opStatus = 'output';
475 if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
476 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs);
478 $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs;
486 $this->currentPort = $attrs['name'];
487 $this->debug('current port: ' . $this->currentPort);
488 $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
492 $this->ports[$this->currentPort]['location'] = $attrs['location'];
493 $this->ports[$this->currentPort]['bindingType'] = $namespace;
494 $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
495 $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
503 if (isset($attrs['location'])) {
504 $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
505 $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')');
507 $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
508 if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
509 $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
511 $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')');
516 // $this->status = 'schema';
519 $this->status = 'message';
520 $this->messages[$attrs['name']] = array();
521 $this->currentMessage = $attrs['name'];
524 $this->status = 'portType';
525 $this->portTypes[$attrs['name']] = array();
526 $this->currentPortType = $attrs['name'];
529 if (isset($attrs['name'])) {
531 if (strpos($attrs['name'], ':')) {
532 $this->currentBinding = $this->getLocalPart($attrs['name']);
534 $this->currentBinding = $attrs['name'];
536 $this->status = 'binding';
537 $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
538 $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
542 $this->serviceName = $attrs['name'];
543 $this->status = 'service';
544 $this->debug('current service: ' . $this->serviceName);
547 foreach ($attrs as $name => $value) {
548 $this->wsdl_info[$name] = $value;
556 * end-element handler
558 * @param string $parser XML parser object
559 * @param string $name element name
562 function end_element($parser, $name){
563 // unset schema status
564 if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
566 $this->appendDebug($this->currentSchema->getDebug());
567 $this->currentSchema->clearDebug();
568 $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
569 $this->debug('Parsing WSDL schema done');
571 if ($this->status == 'schema') {
572 $this->currentSchema->schemaEndElement($parser, $name);
574 // bring depth down a notch
578 if ($this->documentation) {
579 //TODO: track the node to which documentation should be assigned; it can be a part, message, etc.
580 //$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation;
581 $this->documentation = false;
586 * element content handler
588 * @param string $parser XML parser object
589 * @param string $data element content
592 function character_data($parser, $data)
594 $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
595 if (isset($this->message[$pos]['cdata'])) {
596 $this->message[$pos]['cdata'] .= $data;
598 if ($this->documentation) {
599 $this->documentation .= $data;
604 * if authenticating, set user credentials here
606 * @param string $username
607 * @param string $password
608 * @param string $authtype (basic|digest|certificate|ntlm)
609 * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
612 function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
613 $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
614 $this->appendDebug($this->varDump($certRequest));
615 $this->username = $username;
616 $this->password = $password;
617 $this->authtype = $authtype;
618 $this->certRequest = $certRequest;
621 function getBindingData($binding)
623 if (is_array($this->bindings[$binding])) {
624 return $this->bindings[$binding];
629 * returns an assoc array of operation names => operation data
631 * @param string $portName WSDL port name
632 * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported)
636 function getOperations($portName = '', $bindingType = 'soap') {
638 if ($bindingType == 'soap') {
639 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
640 } elseif ($bindingType == 'soap12') {
641 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
643 $this->debug("getOperations bindingType $bindingType may not be supported");
645 $this->debug("getOperations for port '$portName' bindingType $bindingType");
647 foreach($this->ports as $port => $portData) {
648 $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
649 if ($portName == '' || $port == $portName) {
650 // binding type of port matches parameter
651 if ($portData['bindingType'] == $bindingType) {
652 $this->debug("getOperations found port $port bindingType $bindingType");
653 //$this->debug("port data: " . $this->varDump($portData));
654 //$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
656 if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
657 $ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']);
662 if (count($ops) == 0) {
663 $this->debug("getOperations found no operations for port '$portName' bindingType $bindingType");
669 * returns an associative array of data necessary for calling an operation
671 * @param string $operation name of operation
672 * @param string $bindingType type of binding eg: soap, soap12
676 function getOperationData($operation, $bindingType = 'soap')
678 if ($bindingType == 'soap') {
679 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
680 } elseif ($bindingType == 'soap12') {
681 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
684 foreach($this->ports as $port => $portData) {
685 // binding type of port matches parameter
686 if ($portData['bindingType'] == $bindingType) {
688 //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
689 foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
690 // note that we could/should also check the namespace here
691 if ($operation == $bOperation) {
692 $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
701 * returns an associative array of data necessary for calling an operation
703 * @param string $soapAction soapAction for operation
704 * @param string $bindingType type of binding eg: soap, soap12
708 function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') {
709 if ($bindingType == 'soap') {
710 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
711 } elseif ($bindingType == 'soap12') {
712 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
715 foreach($this->ports as $port => $portData) {
716 // binding type of port matches parameter
717 if ($portData['bindingType'] == $bindingType) {
718 // loop through operations for the binding
719 foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
720 if ($opData['soapAction'] == $soapAction) {
729 * returns an array of information about a given type
730 * returns false if no type exists by the given name
733 * 'elements' => array(), // refs to elements array
734 * 'restrictionBase' => '',
736 * 'order' => '(sequence|all)',
737 * 'attrs' => array() // refs to attributes array
740 * @param string $type the type
741 * @param string $ns namespace (not prefix) of the type
744 * @see nusoap_xmlschema
746 function getTypeDef($type, $ns) {
747 $this->debug("in getTypeDef: type=$type, ns=$ns");
748 if ((! $ns) && isset($this->namespaces['tns'])) {
749 $ns = $this->namespaces['tns'];
750 $this->debug("in getTypeDef: type namespace forced to $ns");
752 if (!isset($this->schemas[$ns])) {
753 foreach ($this->schemas as $ns0 => $schema0) {
754 if (strcasecmp($ns, $ns0) == 0) {
755 $this->debug("in getTypeDef: replacing schema namespace $ns with $ns0");
761 if (isset($this->schemas[$ns])) {
762 $this->debug("in getTypeDef: have schema for namespace $ns");
763 for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
764 $xs = &$this->schemas[$ns][$i];
765 $t = $xs->getTypeDef($type);
766 $this->appendDebug($xs->getDebug());
769 $this->debug("in getTypeDef: found type $type");
770 if (!isset($t['phpType'])) {
771 // get info for type to tack onto the element
772 $uqType = substr($t['type'], strrpos($t['type'], ':') + 1);
773 $ns = substr($t['type'], 0, strrpos($t['type'], ':'));
774 $etype = $this->getTypeDef($uqType, $ns);
776 $this->debug("found type for [element] $type:");
777 $this->debug($this->varDump($etype));
778 if (isset($etype['phpType'])) {
779 $t['phpType'] = $etype['phpType'];
781 if (isset($etype['elements'])) {
782 $t['elements'] = $etype['elements'];
784 if (isset($etype['attrs'])) {
785 $t['attrs'] = $etype['attrs'];
788 $this->debug("did not find type for [element] $type");
794 $this->debug("in getTypeDef: did not find type $type");
796 $this->debug("in getTypeDef: do not have schema for namespace $ns");
802 * prints html description of services
806 function webDescription(){
807 global $HTTP_SERVER_VARS;
809 if (isset($_SERVER)) {
810 $PHP_SELF = $_SERVER['PHP_SELF'];
811 } elseif (isset($HTTP_SERVER_VARS)) {
812 $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
814 $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
818 <html><head><title>NuSOAP: '.$this->serviceName.'</title>
819 <style type="text/css">
820 body { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
821 p { font-family: arial; color: #000000; margin-top: 0px; margin-bottom: 12px; }
822 pre { background-color: silver; padding: 5px; font-family: Courier New; font-size: x-small; color: #000000;}
823 ul { margin-top: 10px; margin-left: 20px; }
824 li { list-style-type: none; margin-top: 10px; color: #000000; }
826 margin-left: 0px; padding-bottom: 2em; }
828 padding-top: 10px; padding-bottom: 10px; padding-left: 15px; font-size: .70em;
829 margin-top: 10px; margin-left: 0px; color: #000000;
830 background-color: #ccccff; width: 20%; margin-left: 20px; margin-top: 20px; }
832 font-family: arial; font-size: 26px; color: #ffffff;
833 background-color: #999999; width: 100%;
834 margin-left: 0px; margin-right: 0px;
835 padding-top: 10px; padding-bottom: 10px;}
837 position: absolute; visibility: hidden; z-index: 200; left: 250px; top: 100px;
838 font-family: arial; overflow: hidden; width: 600;
839 padding: 20px; font-size: 10px; background-color: #999999;
840 layer-background-color:#FFFFFF; }
841 a,a:active { color: charcoal; font-weight: bold; }
842 a:visited { color: #666666; font-weight: bold; }
843 a:hover { color: cc3300; font-weight: bold; }
845 <script language="JavaScript" type="text/javascript">
847 // POP-UP CAPTIONS...
848 function lib_bwcheck(){ //Browsercheck (needed)
849 this.ver=navigator.appVersion
850 this.agent=navigator.userAgent
851 this.dom=document.getElementById?1:0
852 this.opera5=this.agent.indexOf("Opera 5")>-1
853 this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
854 this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
855 this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
856 this.ie=this.ie4||this.ie5||this.ie6
857 this.mac=this.agent.indexOf("Mac")>-1
858 this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
859 this.ns4=(document.layers && !this.dom)?1:0;
860 this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
863 var bw = new lib_bwcheck()
864 //Makes crossbrowser object.
865 function makeObj(obj){
866 this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj]:0;
867 if(!this.evnt) return false
868 this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;
869 this.wref=bw.dom||bw.ie4?this.evnt:bw.ns4?this.css.document:0;
870 this.writeIt=b_writeIt;
873 // A unit of measure that will be added when setting the position of a layer.
874 //var px = bw.ns4||window.opera?"":"px";
875 function b_writeIt(text){
876 if (bw.ns4){this.wref.write(text);this.wref.close()}
877 else this.wref.innerHTML = text
881 function popup(divid){
882 if(oDesc = new makeObj(divid)){
883 oDesc.css.visibility = "visible"
886 function popout(){ // Hides message
887 if(oDesc) oDesc.css.visibility = "hidden"
895 <div class=title>'.$this->serviceName.'</div>
897 <p>View the <a href="'.$PHP_SELF.'?wsdl">WSDL</a> for the service.
898 Click on an operation name to view it's details.</p>
900 foreach($this->getOperations() as $op => $data){
901 $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
903 $b .= "<div id='$op' class='hidden'>
904 <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
905 foreach($data as $donnie => $marie){ // loop through opdata
906 if($donnie == 'input' || $donnie == 'output'){ // show input/output data
907 $b .= "<font color='white'>".ucfirst($donnie).':</font><br>';
908 foreach($marie as $captain => $tenille){ // loop through data
909 if($captain == 'parts'){ // loop thru parts
910 $b .= " $captain:<br>";
911 //if(is_array($tenille)){
912 foreach($tenille as $joanie => $chachi){
913 $b .= " $joanie: $chachi<br>";
917 $b .= " $captain: $tenille<br>";
921 $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>";
929 </div></body></html>';
934 * serialize the parsed wsdl
936 * @param mixed $debug whether to put debug=1 in endpoint URL
937 * @return string serialization of WSDL
940 function serialize($debug = 0)
942 $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
943 $xml .= "\n<definitions";
944 foreach($this->namespaces as $k => $v) {
945 $xml .= " xmlns:$k=\"$v\"";
947 // 10.9.02 - add poulter fix for wsdl and tns declarations
948 if (isset($this->namespaces['wsdl'])) {
949 $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
951 if (isset($this->namespaces['tns'])) {
952 $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
956 if (sizeof($this->import) > 0) {
957 foreach($this->import as $ns => $list) {
958 foreach ($list as $ii) {
959 if ($ii['location'] != '') {
960 $xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />';
962 $xml .= '<import namespace="' . $ns . '" />';
968 if (count($this->schemas)>=1) {
969 $xml .= "\n<types>\n";
970 foreach ($this->schemas as $ns => $list) {
971 foreach ($list as $xs) {
972 $xml .= $xs->serializeSchema();
978 if (count($this->messages) >= 1) {
979 foreach($this->messages as $msgName => $msgParts) {
980 $xml .= "\n<message name=\"" . $msgName . '">';
981 if(is_array($msgParts)){
982 foreach($msgParts as $partName => $partType) {
983 // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
984 if (strpos($partType, ':')) {
985 $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
986 } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
987 // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
990 foreach($this->typemap as $ns => $types) {
991 if (isset($types[$partType])) {
992 $typePrefix = $this->getPrefixFromNamespace($ns);
995 if (!isset($typePrefix)) {
996 die("$partType has no namespace!");
999 $ns = $this->getNamespaceFromPrefix($typePrefix);
1000 $localPart = $this->getLocalPart($partType);
1001 $typeDef = $this->getTypeDef($localPart, $ns);
1002 if ($typeDef['typeClass'] == 'element') {
1003 $elementortype = 'element';
1004 if (substr($localPart, -1) == '^') {
1005 $localPart = substr($localPart, 0, -1);
1008 $elementortype = 'type';
1010 $xml .= "\n" . ' <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />';
1013 $xml .= '</message>';
1016 // bindings & porttypes
1017 if (count($this->bindings) >= 1) {
1020 foreach($this->bindings as $bindingName => $attrs) {
1021 $binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
1022 $binding_xml .= "\n" . ' <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
1023 $portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
1024 foreach($attrs['operations'] as $opName => $opParts) {
1025 $binding_xml .= "\n" . ' <operation name="' . $opName . '">';
1026 $binding_xml .= "\n" . ' <soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>';
1027 if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
1028 $enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
1032 $binding_xml .= "\n" . ' <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
1033 if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
1034 $enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
1038 $binding_xml .= "\n" . ' <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
1039 $binding_xml .= "\n" . ' </operation>';
1040 $portType_xml .= "\n" . ' <operation name="' . $opParts['name'] . '"';
1041 if (isset($opParts['parameterOrder'])) {
1042 $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
1044 $portType_xml .= '>';
1045 if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
1046 $portType_xml .= "\n" . ' <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
1048 $portType_xml .= "\n" . ' <input message="tns:' . $opParts['input']['message'] . '"/>';
1049 $portType_xml .= "\n" . ' <output message="tns:' . $opParts['output']['message'] . '"/>';
1050 $portType_xml .= "\n" . ' </operation>';
1052 $portType_xml .= "\n" . '</portType>';
1053 $binding_xml .= "\n" . '</binding>';
1055 $xml .= $portType_xml . $binding_xml;
1058 $xml .= "\n<service name=\"" . $this->serviceName . '">';
1059 if (count($this->ports) >= 1) {
1060 foreach($this->ports as $pName => $attrs) {
1061 $xml .= "\n" . ' <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
1062 $xml .= "\n" . ' <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
1063 $xml .= "\n" . ' </port>';
1066 $xml .= "\n" . '</service>';
1067 return $xml . "\n</definitions>";
1071 * determine whether a set of parameters are unwrapped
1072 * when they are expect to be wrapped, Microsoft-style.
1074 * @param string $type the type (element name) of the wrapper
1075 * @param array $parameters the parameter values for the SOAP call
1076 * @return boolean whether they parameters are unwrapped (and should be wrapped)
1079 function parametersMatchWrapped($type, &$parameters) {
1080 $this->debug("in parametersMatchWrapped type=$type, parameters=");
1081 $this->appendDebug($this->varDump($parameters));
1083 // split type into namespace:unqualified-type
1084 if (strpos($type, ':')) {
1085 $uqType = substr($type, strrpos($type, ':') + 1);
1086 $ns = substr($type, 0, strrpos($type, ':'));
1087 $this->debug("in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
1088 if ($this->getNamespaceFromPrefix($ns)) {
1089 $ns = $this->getNamespaceFromPrefix($ns);
1090 $this->debug("in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
1093 // TODO: should the type be compared to types in XSD, and the namespace
1094 // set to XSD if the type matches?
1095 $this->debug("in parametersMatchWrapped: No namespace for type $type");
1100 // get the type information
1101 if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
1102 $this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type.");
1105 $this->debug("in parametersMatchWrapped: found typeDef=");
1106 $this->appendDebug($this->varDump($typeDef));
1107 if (substr($uqType, -1) == '^') {
1108 $uqType = substr($uqType, 0, -1);
1110 $phpType = $typeDef['phpType'];
1111 $arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '');
1112 $this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
1114 // we expect a complexType or element of complexType
1115 if ($phpType != 'struct') {
1116 $this->debug("in parametersMatchWrapped: not a struct");
1120 // see whether the parameter names match the elements
1121 if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1124 foreach ($typeDef['elements'] as $name => $attrs) {
1125 if (isset($parameters[$name])) {
1126 $this->debug("in parametersMatchWrapped: have parameter named $name");
1129 $this->debug("in parametersMatchWrapped: do not have parameter named $name");
1134 $this->debug("in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names");
1135 if ($matches == 0) {
1141 // since there are no elements for the type, if the user passed no
1142 // parameters, the parameters match wrapped.
1143 $this->debug("in parametersMatchWrapped: no elements type $ns:$uqType");
1144 return count($parameters) == 0;
1148 * serialize PHP values according to a WSDL message definition
1149 * contrary to the method name, this is not limited to RPC
1152 * - multi-ref serialization
1153 * - validate PHP values against type definitions, return errors if invalid
1155 * @param string $operation operation name
1156 * @param string $direction (input|output)
1157 * @param mixed $parameters parameter value(s)
1158 * @param string $bindingType (soap|soap12)
1159 * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1162 function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
1163 $this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
1164 $this->appendDebug('parameters=' . $this->varDump($parameters));
1166 if ($direction != 'input' && $direction != 'output') {
1167 $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1168 $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1171 if (!$opData = $this->getOperationData($operation, $bindingType)) {
1172 $this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1173 $this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1176 $this->debug('in serializeRPCParameters: opData:');
1177 $this->appendDebug($this->varDump($opData));
1179 // Get encoding style for output and set to current
1180 $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1181 if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1182 $encodingStyle = $opData['output']['encodingStyle'];
1183 $enc_style = $encodingStyle;
1188 if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1189 $parts = &$opData[$direction]['parts'];
1190 $part_count = sizeof($parts);
1191 $style = $opData['style'];
1192 $use = $opData[$direction]['use'];
1193 $this->debug("have $part_count part(s) to serialize using $style/$use");
1194 if (is_array($parameters)) {
1195 $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1196 $parameter_count = count($parameters);
1197 $this->debug("have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
1198 // check for Microsoft-style wrapped parameters
1199 if ($style == 'document' && $use == 'literal' && $part_count == 1 && isset($parts['parameters'])) {
1200 $this->debug('check whether the caller has wrapped the parameters');
1201 if ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1) {
1202 // TODO: consider checking here for double-wrapping, when
1203 // service function wraps, then NuSOAP wraps again
1204 $this->debug("change simple array to associative with 'parameters' element");
1205 $parameters['parameters'] = $parameters[0];
1206 unset($parameters[0]);
1208 if (($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) {
1209 $this->debug('check whether caller\'s parameters match the wrapped ones');
1210 if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) {
1211 $this->debug('wrap the parameters for the caller');
1212 $parameters = array('parameters' => $parameters);
1213 $parameter_count = 1;
1217 foreach ($parts as $name => $type) {
1218 $this->debug("serializing part $name of type $type");
1219 // Track encoding style
1220 if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1221 $encodingStyle = $opData[$direction]['encodingStyle'];
1222 $enc_style = $encodingStyle;
1226 // NOTE: add error handling here
1227 // if serializeType returns false, then catch global error and fault
1228 if ($parametersArrayType == 'arraySimple') {
1229 $p = array_shift($parameters);
1230 $this->debug('calling serializeType w/indexed param');
1231 $xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1232 } elseif (isset($parameters[$name])) {
1233 $this->debug('calling serializeType w/named param');
1234 $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1236 // TODO: only send nillable
1237 $this->debug('calling serializeType w/null param');
1238 $xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1242 $this->debug('no parameters passed.');
1245 $this->debug("serializeRPCParameters returning: $xml");
1250 * serialize a PHP value according to a WSDL message definition
1253 * - multi-ref serialization
1254 * - validate PHP values against type definitions, return errors if invalid
1256 * @param string $operation operation name
1257 * @param string $direction (input|output)
1258 * @param mixed $parameters parameter value(s)
1259 * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1263 function serializeParameters($operation, $direction, $parameters)
1265 $this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
1266 $this->appendDebug('parameters=' . $this->varDump($parameters));
1268 if ($direction != 'input' && $direction != 'output') {
1269 $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1270 $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1273 if (!$opData = $this->getOperationData($operation)) {
1274 $this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
1275 $this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
1278 $this->debug('opData:');
1279 $this->appendDebug($this->varDump($opData));
1281 // Get encoding style for output and set to current
1282 $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1283 if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1284 $encodingStyle = $opData['output']['encodingStyle'];
1285 $enc_style = $encodingStyle;
1290 if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1292 $use = $opData[$direction]['use'];
1293 $this->debug("use=$use");
1294 $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
1295 if (is_array($parameters)) {
1296 $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1297 $this->debug('have ' . $parametersArrayType . ' parameters');
1298 foreach($opData[$direction]['parts'] as $name => $type) {
1299 $this->debug('serializing part "'.$name.'" of type "'.$type.'"');
1300 // Track encoding style
1301 if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1302 $encodingStyle = $opData[$direction]['encodingStyle'];
1303 $enc_style = $encodingStyle;
1307 // NOTE: add error handling here
1308 // if serializeType returns false, then catch global error and fault
1309 if ($parametersArrayType == 'arraySimple') {
1310 $p = array_shift($parameters);
1311 $this->debug('calling serializeType w/indexed param');
1312 $xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1313 } elseif (isset($parameters[$name])) {
1314 $this->debug('calling serializeType w/named param');
1315 $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1317 // TODO: only send nillable
1318 $this->debug('calling serializeType w/null param');
1319 $xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1323 $this->debug('no parameters passed.');
1326 $this->debug("serializeParameters returning: $xml");
1331 * serializes a PHP value according a given type definition
1333 * @param string $name name of value (part or element)
1334 * @param string $type XML schema type of value (type or element)
1335 * @param mixed $value a native PHP value (parameter value)
1336 * @param string $use use for part (encoded|literal)
1337 * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1338 * @param boolean $unqualified a kludge for what should be XML namespace form handling
1339 * @return string value serialized as an XML string
1342 function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false)
1344 $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
1345 $this->appendDebug("value=" . $this->varDump($value));
1346 if($use == 'encoded' && $encodingStyle) {
1347 $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
1350 // if a soapval has been supplied, let its type override the WSDL
1351 if (is_object($value) && get_class($value) == 'soapval') {
1352 if ($value->type_ns) {
1353 $type = $value->type_ns . ':' . $value->type;
1355 $this->debug("in serializeType: soapval overrides type to $type");
1356 } elseif ($value->type) {
1357 $type = $value->type;
1359 $this->debug("in serializeType: soapval overrides type to $type");
1362 $this->debug("in serializeType: soapval does not override type");
1364 $attrs = $value->attributes;
1365 $value = $value->value;
1366 $this->debug("in serializeType: soapval overrides value to $value");
1368 if (!is_array($value)) {
1369 $value['!'] = $value;
1371 foreach ($attrs as $n => $v) {
1372 $value['!' . $n] = $v;
1374 $this->debug("in serializeType: soapval provides attributes");
1381 if (strpos($type, ':')) {
1382 $uqType = substr($type, strrpos($type, ':') + 1);
1383 $ns = substr($type, 0, strrpos($type, ':'));
1384 $this->debug("in serializeType: got a prefixed type: $uqType, $ns");
1385 if ($this->getNamespaceFromPrefix($ns)) {
1386 $ns = $this->getNamespaceFromPrefix($ns);
1387 $this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
1390 if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
1391 $this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
1392 if ($unqualified && $use == 'literal') {
1393 $elementNS = " xmlns=\"\"";
1397 if (is_null($value)) {
1398 if ($use == 'literal') {
1399 // TODO: depends on minOccurs
1400 $xml = "<$name$elementNS/>";
1402 // TODO: depends on nillable, which should be checked before calling this method
1403 $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1405 $this->debug("in serializeType: returning: $xml");
1408 if ($uqType == 'Array') {
1409 // JBoss/Axis does this sometimes
1410 return $this->serialize_val($value, $name, false, false, false, false, $use);
1412 if ($uqType == 'boolean') {
1413 if ((is_string($value) && $value == 'false') || (! $value)) {
1419 if ($uqType == 'string' && gettype($value) == 'string') {
1420 $value = $this->expandEntities($value);
1422 if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') {
1423 $value = sprintf("%.0lf", $value);
1426 // TODO: what about null/nil values?
1427 // check type isn't a custom type extending xmlschema namespace
1428 if (!$this->getTypeDef($uqType, $ns)) {
1429 if ($use == 'literal') {
1431 $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1433 $xml = "<$name$elementNS>$value</$name>";
1436 $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1438 $this->debug("in serializeType: returning: $xml");
1441 $this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
1442 } else if ($ns == 'http://xml.apache.org/xml-soap') {
1443 $this->debug('in serializeType: appears to be Apache SOAP type');
1444 if ($uqType == 'Map') {
1445 $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1447 $this->debug('in serializeType: Add namespace for Apache SOAP type');
1448 $tt_prefix = 'ns' . rand(1000, 9999);
1449 $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
1450 // force this to be added to usedNamespaces
1451 $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1454 foreach($value as $k => $v) {
1455 $this->debug("serializing map element: key $k, value $v");
1456 $contents .= '<item>';
1457 $contents .= $this->serialize_val($k,'key',false,false,false,false,$use);
1458 $contents .= $this->serialize_val($v,'value',false,false,false,false,$use);
1459 $contents .= '</item>';
1461 if ($use == 'literal') {
1463 $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>";
1465 $xml = "<$name>$contents</$name>";
1468 $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>";
1470 $this->debug("in serializeType: returning: $xml");
1473 $this->debug('in serializeType: Apache SOAP type, but only support Map');
1476 // TODO: should the type be compared to types in XSD, and the namespace
1477 // set to XSD if the type matches?
1478 $this->debug("in serializeType: No namespace for type $type");
1482 if(!$typeDef = $this->getTypeDef($uqType, $ns)){
1483 $this->setError("$type ($uqType) is not a supported type.");
1484 $this->debug("in serializeType: $type ($uqType) is not a supported type.");
1487 $this->debug("in serializeType: found typeDef");
1488 $this->appendDebug('typeDef=' . $this->varDump($typeDef));
1489 if (substr($uqType, -1) == '^') {
1490 $uqType = substr($uqType, 0, -1);
1493 if (!isset($typeDef['phpType'])) {
1494 $this->setError("$type ($uqType) has no phpType.");
1495 $this->debug("in serializeType: $type ($uqType) has no phpType.");
1498 $phpType = $typeDef['phpType'];
1499 $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
1500 // if php type == struct, map value to the <all> element names
1501 if ($phpType == 'struct') {
1502 if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
1503 $elementName = $uqType;
1504 if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1505 $elementNS = " xmlns=\"$ns\"";
1507 $elementNS = " xmlns=\"\"";
1510 $elementName = $name;
1512 $elementNS = " xmlns=\"\"";
1517 if (is_null($value)) {
1518 if ($use == 'literal') {
1519 // TODO: depends on minOccurs and nillable
1520 $xml = "<$elementName$elementNS/>";
1522 $xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1524 $this->debug("in serializeType: returning: $xml");
1527 if (is_object($value)) {
1528 $value = get_object_vars($value);
1530 if (is_array($value)) {
1531 $elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
1532 if ($use == 'literal') {
1534 $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
1536 $xml = "<$elementName$elementNS$elementAttrs>";
1539 $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
1542 if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
1543 if (isset($value['!'])) {
1544 $xml .= $value['!'];
1545 $this->debug("in serializeType: serialized simpleContent for type $type");
1547 $this->debug("in serializeType: no simpleContent to serialize for type $type");
1551 $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
1553 $xml .= "</$elementName>";
1555 $this->debug("in serializeType: phpType is struct, but value is not an array");
1556 $this->setError("phpType is struct, but value is not an array: see debug output for details");
1559 } elseif ($phpType == 'array') {
1560 if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1561 $elementNS = " xmlns=\"$ns\"";
1564 $elementNS = " xmlns=\"\"";
1569 if (is_null($value)) {
1570 if ($use == 'literal') {
1571 // TODO: depends on minOccurs
1572 $xml = "<$name$elementNS/>";
1574 $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
1575 $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1577 $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1579 $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
1581 $this->getLocalPart($typeDef['arrayType'])."[0]\"/>";
1583 $this->debug("in serializeType: returning: $xml");
1586 if (isset($typeDef['multidimensional'])) {
1588 foreach($value as $v) {
1589 $cols = ',' . sizeof($v);
1590 $nv = array_merge($nv, $v);
1596 if (is_array($value) && sizeof($value) >= 1) {
1597 $rows = sizeof($value);
1599 foreach($value as $k => $v) {
1600 $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
1601 //if (strpos($typeDef['arrayType'], ':') ) {
1602 if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
1603 $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
1605 $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
1612 // TODO: for now, an empty value will be serialized as a zero element
1613 // array. Revisit this when coding the handling of null/nil values.
1614 if ($use == 'literal') {
1615 $xml = "<$name$elementNS>"
1619 $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '.
1620 $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
1622 .$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
1623 .":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">"
1627 } elseif ($phpType == 'scalar') {
1628 if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1629 $elementNS = " xmlns=\"$ns\"";
1632 $elementNS = " xmlns=\"\"";
1637 if ($use == 'literal') {
1639 $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1641 $xml = "<$name$elementNS>$value</$name>";
1644 $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1647 $this->debug("in serializeType: returning: $xml");
1652 * serializes the attributes for a complexType
1654 * @param array $typeDef our internal representation of an XML schema type (or element)
1655 * @param mixed $value a native PHP value (parameter value)
1656 * @param string $ns the namespace of the type
1657 * @param string $uqType the local part of the type
1658 * @return string value serialized as an XML string
1661 function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
1662 $this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType");
1664 if (isset($typeDef['extensionBase'])) {
1665 $nsx = $this->getPrefix($typeDef['extensionBase']);
1666 $uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1667 if ($this->getNamespaceFromPrefix($nsx)) {
1668 $nsx = $this->getNamespaceFromPrefix($nsx);
1670 if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1671 $this->debug("serialize attributes for extension base $nsx:$uqTypex");
1672 $xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex);
1674 $this->debug("extension base $nsx:$uqTypex is not a supported type");
1677 if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
1678 $this->debug("serialize attributes for XML Schema type $ns:$uqType");
1679 if (is_array($value)) {
1681 } elseif (is_object($value)) {
1682 $xvalue = get_object_vars($value);
1684 $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1687 foreach ($typeDef['attrs'] as $aName => $attrs) {
1688 if (isset($xvalue['!' . $aName])) {
1689 $xname = '!' . $aName;
1690 $this->debug("value provided for attribute $aName with key $xname");
1691 } elseif (isset($xvalue[$aName])) {
1693 $this->debug("value provided for attribute $aName with key $xname");
1694 } elseif (isset($attrs['default'])) {
1695 $xname = '!' . $aName;
1696 $xvalue[$xname] = $attrs['default'];
1697 $this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
1700 $this->debug("no value provided for attribute $aName");
1703 $xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
1707 $this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
1713 * serializes the elements for a complexType
1715 * @param array $typeDef our internal representation of an XML schema type (or element)
1716 * @param mixed $value a native PHP value (parameter value)
1717 * @param string $ns the namespace of the type
1718 * @param string $uqType the local part of the type
1719 * @param string $use use for part (encoded|literal)
1720 * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1721 * @return string value serialized as an XML string
1724 function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
1725 $this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
1727 if (isset($typeDef['extensionBase'])) {
1728 $nsx = $this->getPrefix($typeDef['extensionBase']);
1729 $uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1730 if ($this->getNamespaceFromPrefix($nsx)) {
1731 $nsx = $this->getNamespaceFromPrefix($nsx);
1733 if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1734 $this->debug("serialize elements for extension base $nsx:$uqTypex");
1735 $xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle);
1737 $this->debug("extension base $nsx:$uqTypex is not a supported type");
1740 if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1741 $this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
1742 if (is_array($value)) {
1744 } elseif (is_object($value)) {
1745 $xvalue = get_object_vars($value);
1747 $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1750 // toggle whether all elements are present - ideally should validate against schema
1751 if (count($typeDef['elements']) != count($xvalue)){
1754 foreach ($typeDef['elements'] as $eName => $attrs) {
1755 if (!isset($xvalue[$eName])) {
1756 if (isset($attrs['default'])) {
1757 $xvalue[$eName] = $attrs['default'];
1758 $this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
1761 // if user took advantage of a minOccurs=0, then only serialize named parameters
1762 if (isset($optionals)
1763 && (!isset($xvalue[$eName]))
1764 && ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
1766 if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
1767 $this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
1770 $this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
1773 if (isset($xvalue[$eName])) {
1774 $v = $xvalue[$eName];
1778 if (isset($attrs['form'])) {
1779 $unqualified = ($attrs['form'] == 'unqualified');
1781 $unqualified = false;
1783 if (isset($attrs['maxOccurs']) && ($attrs['maxOccurs'] == 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruct($v) == 'arraySimple') {
1785 foreach ($vv as $k => $v) {
1786 if (isset($attrs['type']) || isset($attrs['ref'])) {
1787 // serialize schema-defined type
1788 $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1790 // serialize generic type (can this ever really happen?)
1791 $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1792 $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1796 if (is_null($v) && isset($attrs['minOccurs']) && $attrs['minOccurs'] == '0') {
1798 } elseif (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true') {
1799 // TODO: serialize a nil correctly, but for now serialize schema-defined type
1800 $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1801 } elseif (isset($attrs['type']) || isset($attrs['ref'])) {
1802 // serialize schema-defined type
1803 $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1805 // serialize generic type (can this ever really happen?)
1806 $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1807 $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1813 $this->debug("no elements to serialize for XML Schema type $ns:$uqType");
1819 * adds an XML Schema complex type to the WSDL types
1821 * @param string $name
1822 * @param string $typeClass (complexType|simpleType|attribute)
1823 * @param string $phpType currently supported are array and struct (php assoc array)
1824 * @param string $compositor (all|sequence|choice)
1825 * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1826 * @param array $elements e.g. array ( name => array(name=>'',type=>'') )
1827 * @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
1828 * @param string $arrayType as namespace:name (xsd:string)
1829 * @see nusoap_xmlschema
1832 function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') {
1833 if (count($elements) > 0) {
1834 $eElements = array();
1835 foreach($elements as $n => $e){
1836 // expand each element
1838 foreach ($e as $k => $v) {
1839 $k = strpos($k,':') ? $this->expandQname($k) : $k;
1840 $v = strpos($v,':') ? $this->expandQname($v) : $v;
1843 $eElements[$n] = $ee;
1845 $elements = $eElements;
1848 if (count($attrs) > 0) {
1849 foreach($attrs as $n => $a){
1850 // expand each attribute
1851 foreach ($a as $k => $v) {
1852 $k = strpos($k,':') ? $this->expandQname($k) : $k;
1853 $v = strpos($v,':') ? $this->expandQname($v) : $v;
1861 $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1862 $arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType;
1864 $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1865 $this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType);
1869 * adds an XML Schema simple type to the WSDL types
1871 * @param string $name
1872 * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1873 * @param string $typeClass (should always be simpleType)
1874 * @param string $phpType (should always be scalar)
1875 * @param array $enumeration array of values
1876 * @see nusoap_xmlschema
1879 function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
1880 $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1882 $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1883 $this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration);
1887 * adds an element to the WSDL types
1889 * @param array $attrs attributes that must include name and type
1890 * @see nusoap_xmlschema
1893 function addElement($attrs) {
1894 $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1895 $this->schemas[$typens][0]->addElement($attrs);
1899 * register an operation with the server
1901 * @param string $name operation (method) name
1902 * @param array $in assoc array of input values: key = param name, value = param type
1903 * @param array $out assoc array of output values: key = param name, value = param type
1904 * @param string $namespace optional The namespace for the operation
1905 * @param string $soapaction optional The soapaction for the operation
1906 * @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
1907 * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now)
1908 * @param string $documentation optional The description to include in the WSDL
1909 * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
1912 function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
1913 if ($use == 'encoded' && $encodingStyle == '') {
1914 $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1917 if ($style == 'document') {
1918 $elements = array();
1919 foreach ($in as $n => $t) {
1920 $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1922 $this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
1923 $this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
1924 $in = array('parameters' => 'tns:' . $name . '^');
1926 $elements = array();
1927 foreach ($out as $n => $t) {
1928 $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1930 $this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
1931 $this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified'));
1932 $out = array('parameters' => 'tns:' . $name . 'Response' . '^');
1936 $this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] =
1939 'binding' => $this->serviceName . 'Binding',
1940 'endpoint' => $this->endpoint,
1941 'soapAction' => $soapaction,
1945 'namespace' => $namespace,
1946 'encodingStyle' => $encodingStyle,
1947 'message' => $name . 'Request',
1951 'namespace' => $namespace,
1952 'encodingStyle' => $encodingStyle,
1953 'message' => $name . 'Response',
1955 'namespace' => $namespace,
1956 'transport' => 'http://schemas.xmlsoap.org/soap/http',
1957 'documentation' => $documentation);
1962 foreach($in as $pName => $pType)
1964 if(strpos($pType,':')) {
1965 $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1967 $this->messages[$name.'Request'][$pName] = $pType;
1970 $this->messages[$name.'Request']= '0';
1974 foreach($out as $pName => $pType)
1976 if(strpos($pType,':')) {
1977 $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1979 $this->messages[$name.'Response'][$pName] = $pType;
1982 $this->messages[$name.'Response']= '0';