ILIAS  release_8 Revision v8.24
nusoap_base Class Reference

nusoap_base More...

+ Inheritance diagram for nusoap_base:
+ Collaboration diagram for nusoap_base:

Public Member Functions

 __construct ()
 constructor More...
 
 getGlobalDebugLevel ()
 gets the global debug level, which applies to future instances More...
 
 setGlobalDebugLevel ($level)
 sets the global debug level, which applies to future instances More...
 
 getDebugLevel ()
 gets the debug level for this instance More...
 
 setDebugLevel ($level)
 sets the debug level for this instance More...
 
 debug ($string)
 adds debug data to the instance debug string with formatting More...
 
 appendDebug ($string)
 adds debug data to the instance debug string without formatting More...
 
 clearDebug ()
 clears the current debug data for this instance More...
 
getDebug ()
 gets the current debug data for this instance More...
 
getDebugAsXMLComment ()
 gets the current debug data for this instance as an XML comment this may change the contents of the debug data More...
 
 expandEntities ($val)
 expands entities, e.g. More...
 
 getError ()
 returns error string if present More...
 
 setError ($str)
 sets error string More...
 
 isArraySimpleOrStruct ($val)
 detect if array is a simple array or a struct (associative array) More...
 
 serialize_val ($val, $name=false, $type=false, $name_ns=false, $type_ns=false, $attributes=false, $use='encoded', $soapval=false)
 serializes PHP values in accordance w/ section 5. More...
 
 serializeEnvelope ($body, $headers=false, $namespaces=array(), $style='rpc', $use='encoded', $encodingStyle='http://schemas.xmlsoap.org/soap/encoding/')
 serializes a message More...
 
 formatDump ($str)
 formats a string to be inserted into an HTML stream More...
 
 contractQname ($qname)
 contracts (changes namespace to prefix) a qualified name More...
 
 expandQname ($qname)
 expands (changes prefix to namespace) a qualified name More...
 
 getLocalPart ($str)
 returns the local part of a prefixed string returns the original string, if not prefixed More...
 
 getPrefix ($str)
 returns the prefix part of a prefixed string returns false, if not prefixed More...
 
 getNamespaceFromPrefix ($prefix)
 pass it a prefix, it returns a namespace More...
 
 getPrefixFromNamespace ($ns)
 returns the prefix for a given namespace (or prefix) or false if no prefixes registered for the given namespace More...
 
 getmicrotime ()
 returns the time in ODBC canonical form with microseconds More...
 
 varDump ($data)
 Returns a string with the output of var_dump. More...
 
 __toString ()
 represents the object as a string More...
 

Data Fields

 $title = 'NuSOAP'
 
 $version = '0.7.3'
 
 $revision = '$Revision$'
 
 $error_str = ''
 
 $debug_str = ''
 
 $charencoding = true
 
 $debugLevel
 
 $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'
 
 $soap_defencoding = 'UTF-8'
 
 $namespaces
 
 $usedNamespaces = array()
 
 $typemap
 
 $xmlEntities
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

nusoap_base::__construct ( )

constructor

@access public

Definition at line 237 of file nusoap.php.

238 {
239 $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel;
240 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64

References $GLOBALS.

Member Function Documentation

◆ __toString()

nusoap_base::__toString ( )

represents the object as a string

Returns
string @access public

Definition at line 924 of file nusoap.php.

925 {
926 return $this->varDump($this);
927 }
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:909

References varDump().

+ Here is the call graph for this function:

◆ appendDebug()

◆ clearDebug()

nusoap_base::clearDebug ( )

clears the current debug data for this instance

@access public

Definition at line 319 of file nusoap.php.

320 {
321 // it would be nice to use a memory stream here to use
322 // memory more efficiently
323 $this->debug_str = '';
324 }

Referenced by nusoap_server\__construct(), nusoap_client\call(), nusoap_client\checkWSDL(), and nusoap_server\serialize_return().

+ Here is the caller graph for this function:

◆ contractQname()

nusoap_base::contractQname (   $qname)

contracts (changes namespace to prefix) a qualified name

Parameters
string$qnameqname
Returns
string contracted qname @access private

Definition at line 769 of file nusoap.php.

770 {
771 // get element namespace
772 //$this->xdebug("Contract $qname");
773 if (strrpos($qname, ':')) {
774 // get unqualified name
775 $name = substr($qname, strrpos($qname, ':') + 1);
776 // get ns
777 $ns = substr($qname, 0, strrpos($qname, ':'));
778 $p = $this->getPrefixFromNamespace($ns);
779 if ($p) {
780 return $p . ':' . $name;
781 }
782 return $qname;
783 } else {
784 return $qname;
785 }
786 }
getPrefixFromNamespace($ns)
returns the prefix for a given namespace (or prefix) or false if no prefixes registered for the given...
Definition: nusoap.php:872
if($format !==null) $name
Definition: metadata.php:247

References $name, and getPrefixFromNamespace().

+ Here is the call graph for this function:

◆ debug()

nusoap_base::debug (   $string)

adds debug data to the instance debug string with formatting

Parameters
string$stringdebug data @access private

Definition at line 292 of file nusoap.php.

293 {
294 if ($this->debugLevel > 0) {
295 $this->appendDebug($this->getmicrotime() . ' ' . get_class($this) . ": $string\n");
296 }
297 }
getmicrotime()
returns the time in ODBC canonical form with microseconds
Definition: nusoap.php:889
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:305

References appendDebug(), and getmicrotime().

Referenced by nusoap_client\__construct(), nusoap_xmlschema\__construct(), soap_transport_http\__construct(), wsdl\__construct(), nusoap_server\__construct(), nusoap_parser\__construct(), nusoap_client\_getProxyClassCode(), soap_transport_http\buildPayload(), nusoap_parser\buildVal(), nusoap_client\call(), nusoap_client\checkCookies(), nusoap_client\checkWSDL(), soap_transport_http\connect(), soap_transport_http\decodeChunked(), nusoap_parser\decodeSimple(), wsdl\end_element(), wsdl\fetchWSDL(), soap_transport_http\getCookiesForRequest(), nusoap_client\getOperationData(), nusoap_client\getProxy(), soap_transport_http\getResponse(), wsdl\getTypeDef(), nusoap_server\invoke_method(), nusoap_client\loadWSDL(), wsdl\parametersMatchWrapped(), nusoap_server\parse_http_headers(), nusoap_server\parse_request(), nusoap_xmlschema\parseFile(), nusoap_server\parseRequest(), nusoap_client\parseResponse(), nusoap_xmlschema\parseString(), wsdl\parseWSDL(), soap_transport_http\send(), nusoap_client\send(), nusoap_server\send_response(), soap_transport_http\sendRequest(), nusoap_server\serialize_return(), serialize_val(), wsdl\serializeComplexTypeAttributes(), wsdl\serializeComplexTypeElements(), serializeEnvelope(), wsdl\serializeParameters(), wsdl\serializeRPCParameters(), wsdl\serializeType(), nusoap_server\service(), wsdl\setCredentials(), nusoap_client\setCredentials(), soap_transport_http\setCredentials(), soap_transport_http\setCurlOption(), nusoap_client\setCurlOption(), nusoap_client\setEndpoint(), soap_transport_http\setHeader(), nusoap_client\setHeaders(), nusoap_client\setHTTPEncoding(), soap_transport_http\setProxy(), soap_transport_http\setURL(), nusoap_client\setUseCURL(), wsdl\start_element(), nusoap_parser\start_element(), soap_transport_http\unsetHeader(), nusoap_client\UpdateCookies(), nusoap_client\useHTTPPersistentConnection(), and nusoap_xmlschema\xdebug().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expandEntities()

nusoap_base::expandEntities (   $val)

expands entities, e.g.

changes '<' to '<'.

Parameters
string$valThe string in which to expand entities. @access private

Definition at line 363 of file nusoap.php.

364 {
365 if ($this->charencoding) {
366 $val = str_replace('&', '&amp;', $val);
367 $val = str_replace("'", '&apos;', $val);
368 $val = str_replace('"', '&quot;', $val);
369 $val = str_replace('<', '&lt;', $val);
370 $val = str_replace('>', '&gt;', $val);
371 }
372 return $val;
373 }

Referenced by serialize_val(), wsdl\serializeComplexTypeAttributes(), and wsdl\serializeType().

+ Here is the caller graph for this function:

◆ expandQname()

nusoap_base::expandQname (   $qname)

expands (changes prefix to namespace) a qualified name

Parameters
string$qnameqname
Returns
string expanded qname @access private

Definition at line 795 of file nusoap.php.

796 {
797 // get element prefix
798 if (strpos($qname, ':') && !preg_match('/^http:\/\//', $qname)) {
799 // get unqualified name
800 $name = substr(strstr($qname, ':'), 1);
801 // get ns prefix
802 $prefix = substr($qname, 0, strpos($qname, ':'));
803 if (isset($this->namespaces[$prefix])) {
804 return $this->namespaces[$prefix] . ':' . $name;
805 } else {
806 return $qname;
807 }
808 } else {
809 return $qname;
810 }
811 }

References $name.

Referenced by wsdl\addComplexType(), wsdl\addSimpleType(), nusoap_xmlschema\schemaStartElement(), and wsdl\start_element().

+ Here is the caller graph for this function:

◆ formatDump()

nusoap_base::formatDump (   $str)

formats a string to be inserted into an HTML stream

Parameters
string$strThe string to format
Returns
string The formatted string @access public
Deprecated:

Definition at line 756 of file nusoap.php.

757 {
758 $str = htmlspecialchars($str);
759 return nl2br($str);
760 }

◆ getDebug()

& nusoap_base::getDebug ( )

gets the current debug data for this instance

Returns
debug data @access public

Definition at line 332 of file nusoap.php.

333 {
334 // it would be nice to use a memory stream here to use
335 // memory more efficiently
336 return $this->debug_str;
337 }

References $debug_str.

Referenced by nusoap_server\__construct(), nusoap_client\call(), nusoap_client\checkWSDL(), nusoap_server\fault(), and nusoap_server\serialize_return().

+ Here is the caller graph for this function:

◆ getDebugAsXMLComment()

& nusoap_base::getDebugAsXMLComment ( )

gets the current debug data for this instance as an XML comment this may change the contents of the debug data

Returns
debug data as an XML comment @access public

Definition at line 346 of file nusoap.php.

347 {
348 // it would be nice to use a memory stream here to use
349 // memory more efficiently
350 while (strpos($this->debug_str, '--')) {
351 $this->debug_str = str_replace('--', '- -', $this->debug_str);
352 }
353 $ret = "<!--\n" . $this->debug_str . "\n-->";
354 return $ret;
355 }

Referenced by nusoap_server\send_response(), and nusoap_server\service().

+ Here is the caller graph for this function:

◆ getDebugLevel()

nusoap_base::getDebugLevel ( )

gets the debug level for this instance

Returns
int Debug level 0-9, where 0 turns off @access public

Definition at line 270 of file nusoap.php.

271 {
272 return $this->debugLevel;
273 }

References $debugLevel.

◆ getError()

nusoap_base::getError ( )

returns error string if present

Returns
mixed error string or false @access public

Definition at line 381 of file nusoap.php.

382 {
383 if ($this->error_str != '') {
384 return $this->error_str;
385 }
386 return false;
387 }

References $error_str.

Referenced by nusoap_server\__construct(), nusoap_client\_getProxyClassCode(), nusoap_client\call(), nusoap_client\checkWSDL(), nusoap_client\getOperationData(), nusoap_client\getProxy(), wsdl\parseWSDL(), nusoap_client\send(), and nusoap_server\serialize_return().

+ Here is the caller graph for this function:

◆ getGlobalDebugLevel()

nusoap_base::getGlobalDebugLevel ( )

gets the global debug level, which applies to future instances

Returns
integer Debug level 0-9, where 0 turns off @access public

Definition at line 248 of file nusoap.php.

249 {
250 return $GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel;
251 }

References $GLOBALS.

◆ getLocalPart()

nusoap_base::getLocalPart (   $str)

returns the local part of a prefixed string returns the original string, if not prefixed

Parameters
string$strThe prefixed string
Returns
string The local part @access public

Definition at line 821 of file nusoap.php.

822 {
823 if ($sstr = strrchr($str, ':')) {
824 // get unqualified name
825 return substr($sstr, 1);
826 } else {
827 return $str;
828 }
829 }

Referenced by wsdl\addOperation(), nusoap_xmlschema\schemaEndElement(), nusoap_xmlschema\schemaStartElement(), wsdl\serialize(), wsdl\serializeComplexTypeAttributes(), wsdl\serializeComplexTypeElements(), wsdl\serializeType(), wsdl\start_element(), nusoap_parser\start_element(), and nusoap_xmlschema\typeToForm().

+ Here is the caller graph for this function:

◆ getmicrotime()

nusoap_base::getmicrotime ( )

returns the time in ODBC canonical form with microseconds

Returns
string The time in ODBC canonical form with microseconds @access public

Definition at line 889 of file nusoap.php.

890 {
891 if (function_exists('gettimeofday')) {
892 $tod = gettimeofday();
893 $sec = $tod['sec'];
894 $usec = $tod['usec'];
895 } else {
896 $sec = time();
897 $usec = 0;
898 }
899 return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
900 }

Referenced by debug().

+ Here is the caller graph for this function:

◆ getNamespaceFromPrefix()

nusoap_base::getNamespaceFromPrefix (   $prefix)

pass it a prefix, it returns a namespace

Parameters
string$prefixThe prefix
Returns
mixed The namespace, false if no namespace has the specified prefix @access public

Definition at line 855 of file nusoap.php.

856 {
857 if (isset($this->namespaces[$prefix])) {
858 return $this->namespaces[$prefix];
859 }
860 //$this->setError("No namespace registered for prefix '$prefix'");
861 return false;
862 }

Referenced by wsdl\addOperation(), wsdl\parametersMatchWrapped(), nusoap_xmlschema\schemaStartElement(), wsdl\serialize(), wsdl\serializeComplexTypeAttributes(), wsdl\serializeComplexTypeElements(), and wsdl\serializeType().

+ Here is the caller graph for this function:

◆ getPrefix()

nusoap_base::getPrefix (   $str)

returns the prefix part of a prefixed string returns false, if not prefixed

Parameters
string$strThe prefixed string
Returns
mixed The prefix or false if there is no prefix @access public

Definition at line 839 of file nusoap.php.

840 {
841 if ($pos = strrpos($str, ':')) {
842 // get prefix
843 return substr($str, 0, $pos);
844 }
845 return false;
846 }

Referenced by nusoap_xmlschema\addElement(), wsdl\addOperation(), nusoap_xmlschema\schemaEndElement(), nusoap_xmlschema\schemaStartElement(), wsdl\serialize(), wsdl\serializeComplexTypeAttributes(), wsdl\serializeComplexTypeElements(), wsdl\serializeType(), and nusoap_parser\start_element().

+ Here is the caller graph for this function:

◆ getPrefixFromNamespace()

nusoap_base::getPrefixFromNamespace (   $ns)

returns the prefix for a given namespace (or prefix) or false if no prefixes registered for the given namespace

Parameters
string$nsThe namespace
Returns
mixed The prefix, false if the namespace has no prefixes @access public

Definition at line 872 of file nusoap.php.

873 {
874 foreach ($this->namespaces as $p => $n) {
875 if ($ns == $n || $ns == $p) {
876 $this->usedNamespaces[$p] = $n;
877 return $p;
878 }
879 }
880 return false;
881 }

Referenced by nusoap_client\call(), contractQname(), nusoap_xmlschema\schemaStartElement(), wsdl\serialize(), nusoap_xmlschema\serializeSchema(), wsdl\serializeType(), and wsdl\start_element().

+ Here is the caller graph for this function:

◆ isArraySimpleOrStruct()

nusoap_base::isArraySimpleOrStruct (   $val)

detect if array is a simple array or a struct (associative array)

Parameters
mixed$valThe PHP array
Returns
string (arraySimple|arrayStruct) @access private

Definition at line 407 of file nusoap.php.

408 {
409 $keyList = array_keys($val);
410 foreach ($keyList as $keyListValue) {
411 if (!is_int($keyListValue)) {
412 return 'arrayStruct';
413 }
414 }
415 return 'arraySimple';
416 }

Referenced by wsdl\parametersMatchWrapped(), serialize_val(), wsdl\serializeComplexTypeElements(), wsdl\serializeParameters(), and wsdl\serializeRPCParameters().

+ Here is the caller graph for this function:

◆ serialize_val()

nusoap_base::serialize_val (   $val,
  $name = false,
  $type = false,
  $name_ns = false,
  $type_ns = false,
  $attributes = false,
  $use = 'encoded',
  $soapval = false 
)

serializes PHP values in accordance w/ section 5.

Type information is not serialized if $use == 'literal'.

Parameters
mixed$valThe value to serialize
string$nameThe name (local part) of the XML element
string$typeThe XML schema type (local part) for the element
string$name_nsThe namespace for the name of the XML element
string$type_nsThe namespace for the type of the element
array$attributesThe attributes to serialize as name=>value pairs
string$useThe WSDL "use" (encoded|literal)
boolean$soapvalWhether this is called from soapval.
Returns
string The serialized element, possibly with child elements @access public

Definition at line 433 of file nusoap.php.

434 {
435 $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
436 $this->appendDebug('value=' . $this->varDump($val));
437 $this->appendDebug('attributes=' . $this->varDump($attributes));
438
439 if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
440 $this->debug("serialize_val: serialize soapval");
441 $xml = $val->serialize($use);
442 $this->appendDebug($val->getDebug());
443 $val->clearDebug();
444 $this->debug("serialize_val of soapval returning $xml");
445 return $xml;
446 }
447 // force valid name if necessary
448 if (is_numeric($name)) {
449 $name = '__numeric_' . $name;
450 } elseif (! $name) {
451 $name = 'noname';
452 }
453 // if name has ns, add ns prefix to name
454 $xmlns = '';
455 if ($name_ns) {
456 $prefix = 'nu' . rand(1000, 9999);
457 $name = $prefix . ':' . $name;
458 $xmlns .= " xmlns:$prefix=\"$name_ns\"";
459 }
460 // if type is prefixed, create type prefix
461 if ($type_ns != '' && $type_ns == $this->namespaces['xsd']) {
462 // need to fix this. shouldn't default to xsd if no ns specified
463 // w/o checking against typemap
464 $type_prefix = 'xsd';
465 } elseif ($type_ns) {
466 $type_prefix = 'ns' . rand(1000, 9999);
467 $xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
468 }
469 // serialize attributes if present
470 $atts = '';
471 if ($attributes) {
472 foreach ($attributes as $k => $v) {
473 $atts .= " $k=\"" . $this->expandEntities($v) . '"';
474 }
475 }
476 // serialize null value
477 if (is_null($val)) {
478 $this->debug("serialize_val: serialize null");
479 if ($use == 'literal') {
480 // TODO: depends on minOccurs
481 $xml = "<$name$xmlns$atts/>";
482 $this->debug("serialize_val returning $xml");
483 return $xml;
484 } else {
485 if (isset($type) && isset($type_prefix)) {
486 $type_str = " xsi:type=\"$type_prefix:$type\"";
487 } else {
488 $type_str = '';
489 }
490 $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
491 $this->debug("serialize_val returning $xml");
492 return $xml;
493 }
494 }
495 // serialize if an xsd built-in primitive type
496 if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) {
497 $this->debug("serialize_val: serialize xsd built-in primitive type");
498 if (is_bool($val)) {
499 if ($type == 'boolean') {
500 $val = $val ? 'true' : 'false';
501 } elseif (! $val) {
502 $val = 0;
503 }
504 } elseif (is_string($val)) {
505 $val = $this->expandEntities($val);
506 }
507 if ($use == 'literal') {
508 $xml = "<$name$xmlns$atts>$val</$name>";
509 $this->debug("serialize_val returning $xml");
510 return $xml;
511 } else {
512 $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
513 $this->debug("serialize_val returning $xml");
514 return $xml;
515 }
516 }
517 // detect type and serialize
518 $xml = '';
519 switch (true) {
520 case (is_bool($val) || $type == 'boolean'):
521 $this->debug("serialize_val: serialize boolean");
522 if ($type == 'boolean') {
523 $val = $val ? 'true' : 'false';
524 } elseif (! $val) {
525 $val = 0;
526 }
527 if ($use == 'literal') {
528 $xml .= "<$name$xmlns$atts>$val</$name>";
529 } else {
530 $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
531 }
532 break;
533 case (is_int($val) || is_long($val) || $type == 'int'):
534 $this->debug("serialize_val: serialize int");
535 if ($use == 'literal') {
536 $xml .= "<$name$xmlns$atts>$val</$name>";
537 } else {
538 $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
539 }
540 break;
541 case (is_float($val)|| is_double($val) || $type == 'float'):
542 $this->debug("serialize_val: serialize float");
543 if ($use == 'literal') {
544 $xml .= "<$name$xmlns$atts>$val</$name>";
545 } else {
546 $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
547 }
548 break;
549 case (is_string($val) || $type == 'string'):
550 $this->debug("serialize_val: serialize string");
551 $val = $this->expandEntities($val);
552 if ($use == 'literal') {
553 $xml .= "<$name$xmlns$atts>$val</$name>";
554 } else {
555 $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
556 }
557 break;
558 case is_object($val):
559 $this->debug("serialize_val: serialize object");
560 if (get_class($val) == 'soapval') {
561 $this->debug("serialize_val: serialize soapval object");
562 $pXml = $val->serialize($use);
563 $this->appendDebug($val->getDebug());
564 $val->clearDebug();
565 } else {
566 if (! $name) {
567 $name = get_class($val);
568 $this->debug("In serialize_val, used class name $name as element name");
569 } else {
570 $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
571 }
572 foreach (get_object_vars($val) as $k => $v) {
573 $pXml = isset($pXml) ? $pXml . $this->serialize_val($v, $k, false, false, false, false, $use) : $this->serialize_val($v, $k, false, false, false, false, $use);
574 }
575 }
576 if (isset($type) && isset($type_prefix)) {
577 $type_str = " xsi:type=\"$type_prefix:$type\"";
578 } else {
579 $type_str = '';
580 }
581 if ($use == 'literal') {
582 $xml .= "<$name$xmlns$atts>$pXml</$name>";
583 } else {
584 $xml .= "<$name$xmlns$type_str$atts>$pXml</$name>";
585 }
586 break;
587 break;
588 case (is_array($val) || $type):
589 // detect if struct or array
590 $valueType = $this->isArraySimpleOrStruct($val);
591 if ($valueType=='arraySimple' || preg_match('/^ArrayOf/', $type)) {
592 $this->debug("serialize_val: serialize array");
593 $i = 0;
594 if (is_array($val) && count($val)> 0) {
595 foreach ($val as $v) {
596 if (is_object($v) && get_class($v) == 'soapval') {
597 $tt_ns = $v->type_ns;
598 $tt = $v->type;
599 } elseif (is_array($v)) {
600 $tt = $this->isArraySimpleOrStruct($v);
601 } else {
602 $tt = gettype($v);
603 }
604 $array_types[$tt] = 1;
605 // TODO: for literal, the name should be $name
606 $xml .= $this->serialize_val($v, 'item', false, false, false, false, $use);
607 ++$i;
608 }
609 if (count($array_types) > 1) {
610 $array_typename = 'xsd:anyType';
611 } elseif (isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
612 if ($tt == 'integer') {
613 $tt = 'int';
614 }
615 $array_typename = 'xsd:' . $tt;
616 } elseif (isset($tt) && $tt == 'arraySimple') {
617 $array_typename = 'SOAP-ENC:Array';
618 } elseif (isset($tt) && $tt == 'arrayStruct') {
619 $array_typename = 'unnamed_struct_use_soapval';
620 } else {
621 // if type is prefixed, create type prefix
622 if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']) {
623 $array_typename = 'xsd:' . $tt;
624 } elseif ($tt_ns) {
625 $tt_prefix = 'ns' . rand(1000, 9999);
626 $array_typename = "$tt_prefix:$tt";
627 $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
628 } else {
629 $array_typename = $tt;
630 }
631 }
632 $array_type = $i;
633 if ($use == 'literal') {
634 $type_str = '';
635 } elseif (isset($type) && isset($type_prefix)) {
636 $type_str = " xsi:type=\"$type_prefix:$type\"";
637 } else {
638 $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"" . $array_typename . "[$array_type]\"";
639 }
640 // empty array
641 } else {
642 if ($use == 'literal') {
643 $type_str = '';
644 } elseif (isset($type) && isset($type_prefix)) {
645 $type_str = " xsi:type=\"$type_prefix:$type\"";
646 } else {
647 $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
648 }
649 }
650 // TODO: for array in literal, there is no wrapper here
651 $xml = "<$name$xmlns$type_str$atts>" . $xml . "</$name>";
652 } else {
653 // got a struct
654 $this->debug("serialize_val: serialize struct");
655 if (isset($type) && isset($type_prefix)) {
656 $type_str = " xsi:type=\"$type_prefix:$type\"";
657 } else {
658 $type_str = '';
659 }
660 if ($use == 'literal') {
661 $xml .= "<$name$xmlns$atts>";
662 } else {
663 $xml .= "<$name$xmlns$type_str$atts>";
664 }
665 foreach ($val as $k => $v) {
666 // Apache Map
667 if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
668 $xml .= '<item>';
669 $xml .= $this->serialize_val($k, 'key', false, false, false, false, $use);
670 $xml .= $this->serialize_val($v, 'value', false, false, false, false, $use);
671 $xml .= '</item>';
672 } else {
673 $xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
674 }
675 }
676 $xml .= "</$name>";
677 }
678 break;
679 default:
680 $this->debug("serialize_val: serialize unknown");
681 $xml .= 'not detected, got ' . gettype($val) . ' for ' . $val;
682 break;
683 }
684 $this->debug("serialize_val returning $xml");
685 return $xml;
686 }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
serialize_val($val, $name=false, $type=false, $name_ns=false, $type_ns=false, $attributes=false, $use='encoded', $soapval=false)
serializes PHP values in accordance w/ section 5.
Definition: nusoap.php:433
expandEntities($val)
expands entities, e.g.
Definition: nusoap.php:363
isArraySimpleOrStruct($val)
detect if array is a simple array or a struct (associative array)
Definition: nusoap.php:407
$i
Definition: metadata.php:41
$attributes
Definition: metadata.php:248
$xml
Definition: metadata.php:351
$type

References $attributes, $i, $name, $type, $xml, appendDebug(), debug(), expandEntities(), isArraySimpleOrStruct(), serialize_val(), and varDump().

Referenced by nusoap_client\call(), soapval\serialize(), nusoap_fault\serialize(), nusoap_server\serialize_return(), serialize_val(), wsdl\serializeComplexTypeElements(), serializeEnvelope(), and wsdl\serializeType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serializeEnvelope()

nusoap_base::serializeEnvelope (   $body,
  $headers = false,
  $namespaces = array(),
  $style = 'rpc',
  $use = 'encoded',
  $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/' 
)

serializes a message

Parameters
string$bodythe XML of the SOAP body
mixed$headersoptional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
array$namespacesoptional the namespaces used in generating the body and headers
string$styleoptional (rpc|document)
string$useoptional (encoded|literal)
string$encodingStyleoptional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
Returns
string the message @access public

Definition at line 700 of file nusoap.php.

700 ://schemas.xmlsoap.org/soap/encoding/')
701 {
702 // TODO: add an option to automatically run utf8_encode on $body and $headers
703 // if $this->soap_defencoding is UTF-8. Not doing this automatically allows
704 // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1
705
706 $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
707 $this->debug("headers:");
708 $this->appendDebug($this->varDump($headers));
709 $this->debug("namespaces:");
710 $this->appendDebug($this->varDump($namespaces));
711
712 // serialize namespaces
713 $ns_string = '';
714 foreach (array_merge($this->namespaces, $namespaces) as $k => $v) {
715 $ns_string .= " xmlns:$k=\"$v\"";
716 }
717 if ($encodingStyle) {
718 $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
719 }
720
721 // serialize headers
722 if ($headers) {
723 if (is_array($headers)) {
724 $xml = '';
725 foreach ($headers as $k => $v) {
726 if (is_object($v) && get_class($v) == 'soapval') {
727 $xml .= $this->serialize_val($v, false, false, false, false, false, $use);
728 } else {
729 $xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
730 }
731 }
732 $headers = $xml;
733 $this->debug("In serializeEnvelope, serialized array of headers to $headers");
734 }
735 $headers = "<SOAP-ENV:Header>" . $headers . "</SOAP-ENV:Header>";
736 }
737 // serialize envelope
738 return
739 '<?xml version="1.0" encoding="' . $this->soap_defencoding . '"?' . ">" .
740 '<SOAP-ENV:Envelope' . $ns_string . ">" .
741 $headers .
742 "<SOAP-ENV:Body>" .
743 $body .
744 "</SOAP-ENV:Body>" .
745 "</SOAP-ENV:Envelope>";
746 }

References $namespaces, $xml, appendDebug(), debug(), serialize_val(), and varDump().

Referenced by nusoap_client\call(), and nusoap_server\serialize_return().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDebugLevel()

nusoap_base::setDebugLevel (   $level)

sets the debug level for this instance

Parameters
int$levelDebug level 0-9, where 0 turns off @access public

Definition at line 281 of file nusoap.php.

282 {
283 $this->debugLevel = $level;
284 }

◆ setError()

◆ setGlobalDebugLevel()

nusoap_base::setGlobalDebugLevel (   $level)

sets the global debug level, which applies to future instances

Parameters
int$levelDebug level 0-9, where 0 turns off @access public

Definition at line 259 of file nusoap.php.

260 {
261 $GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel = $level;
262 }

References $GLOBALS.

◆ varDump()

Field Documentation

◆ $charencoding

nusoap_base::$charencoding = true

Definition at line 140 of file nusoap.php.

◆ $debug_str

nusoap_base::$debug_str = ''

Definition at line 132 of file nusoap.php.

Referenced by getDebug().

◆ $debugLevel

nusoap_base::$debugLevel

Definition at line 147 of file nusoap.php.

Referenced by getDebugLevel().

◆ $error_str

nusoap_base::$error_str = ''

Definition at line 125 of file nusoap.php.

Referenced by soap_transport_http\connect(), and getError().

◆ $namespaces

nusoap_base::$namespaces
Initial value:
= array(
'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
'xsd' => 'http://www.w3.org/2001/XMLSchema',
'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/'
)

Definition at line 174 of file nusoap.php.

Referenced by nusoap_xmlschema\__construct(), and serializeEnvelope().

◆ $revision

nusoap_base::$revision = '$Revision$'

Definition at line 118 of file nusoap.php.

◆ $soap_defencoding

nusoap_base::$soap_defencoding = 'UTF-8'

◆ $title

nusoap_base::$title = 'NuSOAP'

Definition at line 104 of file nusoap.php.

◆ $typemap

nusoap_base::$typemap
Initial value:
= array(
'http://www.w3.org/2001/XMLSchema' => array(
'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double',
'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'',
'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string',
'anyType'=>'string','anySimpleType'=>'string',
'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'',
'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer',
'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer',
'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''),
'http://www.w3.org/2000/10/XMLSchema' => array(
'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
'float'=>'double','dateTime'=>'string',
'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
'http://www.w3.org/1999/XMLSchema' => array(
'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
'float'=>'double','dateTime'=>'string',
'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
'http://xml.apache.org/xml-soap' => array('Map')
)

Definition at line 196 of file nusoap.php.

◆ $usedNamespaces

nusoap_base::$usedNamespaces = array()

Definition at line 187 of file nusoap.php.

Referenced by nusoap_client\call().

◆ $version

nusoap_base::$version = '0.7.3'

Definition at line 111 of file nusoap.php.

◆ $xmlEntities

nusoap_base::$xmlEntities
Initial value:
= array('quot' => '"','amp' => '&',
'lt' => '<','gt' => '>','apos' => "'")

Definition at line 229 of file nusoap.php.

◆ $XMLSchemaVersion

nusoap_base::$XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'

Definition at line 155 of file nusoap.php.

Referenced by nusoap_parser\start_element().


The documentation for this class was generated from the following file: