Lines Matching +full:- +full:- +full:debug

6 NuSOAP - Web Services Toolkit for PHP
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 nusoap-general@lists.sourceforge.net
44 * SOAP 1.1 (http://www.w3.org/TR/2000/NOTE-SOAP-20000508/)
45 * WSDL 1.1 (http://www.w3.org/TR/2001/NOTE-wsdl-20010315)
46 * SOAP Messages With Attachments (http://www.w3.org/TR/SOAP-attachments)
47 * XML 1.0 (http://www.w3.org/TR/2006/REC-xml-20060816/)
48 * Namespaces in XML 1.0 (http://www.w3.org/TR/2006/REC-xml-names-20060816/)
49 * XML Schema 1.0 (http://www.w3.org/TR/xmlschema-0/)
51 * RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1
66 // optional add-on classes
74 // cf. http://www.webkreator.com/php/techniques/php-static-class-variables.html
75 $GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel = 9;
116 … * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment)
131 * the debug level for this instance
152 var $soap_defencoding = 'ISO-8859-1';
153 //var $soap_defencoding = 'UTF-8';
164 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
166 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
167 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/'
200 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
204 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
207 'http://xml.apache.org/xml-soap' => array('Map')
227 $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel;
231 * gets the global debug level, which applies to future instances
233 * @return integer Debug level 0-9, where 0 turns off
237 return $GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel;
241 * sets the global debug level, which applies to future instances
243 * @param int $level Debug level 0-9, where 0 turns off
247 $GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel = $level;
251 * gets the debug level for this instance
253 * @return int Debug level 0-9, where 0 turns off
257 return $this->debugLevel;
261 * sets the debug level for this instance
263 * @param int $level Debug level 0-9, where 0 turns off
267 $this->debugLevel = $level;
271 * adds debug data to the instance debug string with formatting
273 * @param string $string debug data
276 function debug($string){ function in nusoap_base
277 if ($this->debugLevel > 0) {
278 $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n");
283 * adds debug data to the instance debug string without formatting
285 * @param string $string debug data
289 if ($this->debugLevel > 0) {
292 $this->debug_str .= $string;
297 * clears the current debug data for this instance
304 $this->debug_str = '';
308 * gets the current debug data for this instance
310 * @return debug data
316 return $this->debug_str;
320 * gets the current debug data for this instance as an XML comment
321 * this may change the contents of the debug data
323 * @return debug data as an XML comment
329 while (strpos($this->debug_str, '--')) {
330 $this->debug_str = str_replace('--', '- -', $this->debug_str);
332 $ret = "<!--\n" . $this->debug_str . "\n-->";
343 if ($this->charencoding) {
360 if($this->error_str != ''){
361 return $this->error_str;
373 $this->error_str = $str;
409 …$this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$u…
410 $this->appendDebug('value=' . $this->varDump($val));
411 $this->appendDebug('attributes=' . $this->varDump($attributes));
414 $this->debug("serialize_val: serialize soapval");
415 $xml = $val->serialize($use);
416 $this->appendDebug($val->getDebug());
417 $val->clearDebug();
418 $this->debug("serialize_val of soapval returning $xml");
435 if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
447 $atts .= " $k=\"".$this->expandEntities($v).'"';
452 $this->debug("serialize_val: serialize null");
456 $this->debug("serialize_val returning $xml");
465 $this->debug("serialize_val returning $xml");
469 // serialize if an xsd built-in primitive type
470 if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){
471 $this->debug("serialize_val: serialize xsd built-in primitive type");
479 $val = $this->expandEntities($val);
483 $this->debug("serialize_val returning $xml");
487 $this->debug("serialize_val returning $xml");
495 $this->debug("serialize_val: serialize boolean");
508 $this->debug("serialize_val: serialize int");
516 $this->debug("serialize_val: serialize float");
524 $this->debug("serialize_val: serialize string");
525 $val = $this->expandEntities($val);
533 $this->debug("serialize_val: serialize object");
535 $this->debug("serialize_val: serialize soapval object");
536 $pXml = $val->serialize($use);
537 $this->appendDebug($val->getDebug());
538 $val->clearDebug();
542 $this->debug("In serialize_val, used class name $name as element name");
544 …$this->debug("In serialize_val, do not override name $name for element name for class " . get_clas…
547 …$pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->ser…
564 $valueType = $this->isArraySimpleOrStruct($val);
566 $this->debug("serialize_val: serialize array");
571 $tt_ns = $v->type_ns;
572 $tt = $v->type;
574 $tt = $this->isArraySimpleOrStruct($v);
580 $xml .= $this->serialize_val($v,'item',false,false,false,false,$use);
585 } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
591 $array_typename = 'SOAP-ENC:Array';
596 if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
612 …$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\"";
621 $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
628 $this->debug("serialize_val: serialize struct");
641 if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
643 $xml .= $this->serialize_val($k,'key',false,false,false,false,$use);
644 $xml .= $this->serialize_val($v,'value',false,false,false,false,$use);
647 $xml .= $this->serialize_val($v,$k,false,false,false,false,$use);
654 $this->debug("serialize_val: serialize unknown");
658 $this->debug("serialize_val returning $xml");
676 // if $this->soap_defencoding is UTF-8. Not doing this automatically allows
677 // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1
679 …$this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . sub…
680 $this->debug("headers:");
681 $this->appendDebug($this->varDump($headers));
682 $this->debug("namespaces:");
683 $this->appendDebug($this->varDump($namespaces));
687 foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
691 $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
700 $xml .= $this->serialize_val($v, false, false, false, false, false, $use);
702 $xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
706 $this->debug("In serializeEnvelope, serialized array of headers to $headers");
708 $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>";
712 '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">".
713 '<SOAP-ENV:Envelope'.$ns_string.">".
715 "<SOAP-ENV:Body>".
717 "</SOAP-ENV:Body>".
718 "</SOAP-ENV:Envelope>";
743 //$this->xdebug("Contract $qname");
749 $p = $this->getPrefixFromNamespace($ns);
773 if(isset($this->namespaces[$prefix])){
774 return $this->namespaces[$prefix].':'.$name;
824 if (isset($this->namespaces[$prefix])) {
825 return $this->namespaces[$prefix];
827 //$this->setError("No namespace registered for prefix '$prefix'");
840 foreach ($this->namespaces as $p => $n) {
842 $this->usedNamespaces[$p] = $n;
864 return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
889 return $this->varDump($this);
905 $datestr = date('Y-m-d\TH:i:sO',$timestamp);
908 '([0-9]{4})-'. // centuries & years CCYY-
909 '([0-9]{2})-'. // months MM-
910 '([0-9]{2})'. // days DD
912 '([0-9]{2}):'. // hours hh:
913 '([0-9]{2}):'. // minutes mm:
914 '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
915 '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
918 …return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs…
934 '([0-9]{4})-'. // centuries & years CCYY-
935 '([0-9]{2})-'. // months MM-
936 '([0-9]{2})'. // days DD
938 '([0-9]{2}):'. // hours hh:
939 '([0-9]{2}):'. // minutes mm:
940 '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
941 '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
947 $m = substr($regs[8],strlen($regs[8])-2,2);
948 if($op == '-'){
952 $regs[4] = $regs[4] - $h;
953 $regs[5] = $regs[5] - $m;
957 // return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z");
977 $timePassed = 1000000 * ($stop['sec'] - $start['sec'])
978 + $stop['usec'] - $start['usec'];
1024 * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server)
1031 $this->faultcode = $faultcode;
1032 $this->faultactor = $faultactor;
1033 $this->faultstring = $faultstring;
1034 $this->faultdetail = $faultdetail;
1045 foreach($this->namespaces as $k => $v){
1049 '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>'.
1050 …'<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string…
1051 '<SOAP-ENV:Body>'.
1052 '<SOAP-ENV:Fault>'.
1053 $this->serialize_val($this->faultcode, 'faultcode').
1054 $this->serialize_val($this->faultactor, 'faultactor').
1055 $this->serialize_val($this->faultstring, 'faultstring').
1056 $this->serialize_val($this->faultdetail, 'detail').
1057 '</SOAP-ENV:Fault>'.
1058 '</SOAP-ENV:Body>'.
1059 '</SOAP-ENV:Envelope>';
1124 $this->debug('nusoap_xmlschema class instantiated, inside constructor');
1126 $this->schema = $schema;
1127 $this->xml = $xml;
1130 $this->enclosingNamespaces = $namespaces;
1131 $this->namespaces = array_merge($this->namespaces, $namespaces);
1135 $this->debug('initial schema file: '.$schema);
1136 $this->parseFile($schema, 'schema');
1141 $this->debug('initial xml file: '.$xml);
1142 $this->parseFile($xml, 'xml');
1161 $this->setError($msg);
1162 $this->debug($msg);
1165 $this->debug("parsing $xml");
1166 $this->parseString($xmlStr,$type);
1167 $this->debug("done parsing $xml");
1186 $this->parser = xml_parser_create();
1188 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
1191 xml_set_object($this->parser, $this);
1195 xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement');
1196 xml_set_character_data_handler($this->parser,'schemaCharacterData');
1198 xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement');
1199 xml_set_character_data_handler($this->parser,'xmlCharacterData');
1203 if(!xml_parse($this->parser,$xml,true)){
1206 xml_get_current_line_number($this->parser),
1207 xml_error_string(xml_get_error_code($this->parser))
1209 $this->debug($errstr);
1210 $this->debug("XML payload:\n" . $xml);
1211 $this->setError($errstr);
1214 xml_parser_free($this->parser);
1216 $this->debug('no xml passed to parseString()!!');
1217 $this->setError('no xml passed to parseString()!!');
1230 for ($i = 0; $i < count($this->complexTypeStack); $i++) {
1231 $scope .= $this->complexTypeStack[$i] . '_';
1237 * start-element handler
1247 $pos = $this->position++;
1248 $depth = $this->depth++;
1250 $this->depth_array[$depth] = $pos;
1251 $this->message[$pos] = array('cdata' => '');
1253 $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]];
1255 $this->defaultNamespace[$pos] = false;
1259 if($prefix = $this->getPrefix($name)){
1261 $name = $this->getLocalPart($name);
1271 //$this->xdebug("$k: $v");
1272 //$this->xdebug('ns_prefix: '.$this->getPrefix($k));
1274 //$this->xdebug("Add namespace[$ns_prefix] = $v");
1275 $this->namespaces[$ns_prefix] = $v;
1277 $this->defaultNamespace[$pos] = $v;
1278 if (! $this->getPrefixFromNamespace($v)) {
1279 $this->namespaces['ns'.(count($this->namespaces)+1)] = $v;
1283 $this->XMLSchemaVersion = $v;
1284 $this->namespaces['xsi'] = $v.'-instance';
1290 $k = strpos($k,':') ? $this->expandQname($k) : $k;
1291 $v = strpos($v,':') ? $this->expandQname($v) : $v;
1304 …//$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentEle…
1305 $this->complexTypes[$this->currentComplexType]['compositor'] = $name;
1307 // $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
1311 …//$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xml…
1312 $this->xdebug("parsing attribute:");
1313 $this->appendDebug($this->varDump($attrs));
1315 $attrs['form'] = $this->schemaInfo['attributeFormDefault'];
1321 if ($this->defaultNamespace[$pos]) {
1323 …$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attr…
1328 $this->attributes[$attrs['name']] = $attrs;
1338 $this->attributes[$attrs['ref']] = $attrs;
1341 if($this->currentComplexType){ // This should *always* be
1342 $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs;
1345 …if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == '…
1346 $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1347 $prefix = $this->getPrefix($aname);
1354 $this->complexTypes[$this->currentComplexType]['multidimensional'] = true;
1357 if(!strpos($v,':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){
1358 $v = $this->XMLSchemaVersion.':'.$v;
1360 $this->complexTypes[$this->currentComplexType]['arrayType'] = $v;
1366 array_push($this->complexTypeStack, $this->currentComplexType);
1370 $this->xdebug('processing named complexType '.$attrs['name']);
1371 //$this->currentElement = false;
1372 $this->currentComplexType = $attrs['name'];
1373 $this->complexTypes[$this->currentComplexType] = $attrs;
1374 $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
1383 $this->xdebug('complexType is unusual array');
1384 $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1386 $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
1389 $name = $this->CreateTypeName($this->currentElement);
1390 …$this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . …
1391 $this->currentComplexType = $name;
1392 //$this->currentElement = false;
1393 $this->complexTypes[$this->currentComplexType] = $attrs;
1394 $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
1403 $this->xdebug('complexType is unusual array');
1404 $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1406 $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
1411 array_push($this->elementStack, $this->currentElement);
1413 $attrs['form'] = $this->schemaInfo['elementFormDefault'];
1416 $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
1417 if (! $this->getPrefix($attrs['type'])) {
1418 if ($this->defaultNamespace[$pos]) {
1419 $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type'];
1420 $this->xdebug('used default namespace to make type ' . $attrs['type']);
1430 …if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'arr…
1431 $this->xdebug('arrayType for unusual array is ' . $attrs['type']);
1432 $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type'];
1434 $this->currentElement = $attrs['name'];
1437 $this->xdebug("processing element as ref to ".$attrs['ref']);
1438 $this->currentElement = "ref to ".$attrs['ref'];
1439 $ename = $this->getLocalPart($attrs['ref']);
1441 $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']);
1442 $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
1443 $this->currentElement = $attrs['name'];
1444 $attrs['type'] = $this->schemaTargetNamespace . ':' . $type;
1447 if (isset($ename) && $this->currentComplexType) {
1448 $this->xdebug("add element $ename to complexType $this->currentComplexType");
1449 $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs;
1451 $this->xdebug("add element $ename to elements array");
1452 $this->elements[ $attrs['name'] ] = $attrs;
1453 $this->elements[ $attrs['name'] ]['typeClass'] = 'element';
1457 $this->xdebug('enumeration ' . $attrs['value']);
1458 if ($this->currentSimpleType) {
1459 $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value'];
1460 } elseif ($this->currentComplexType) {
1461 $this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value'];
1465 $this->xdebug('extension ' . $attrs['base']);
1466 if ($this->currentComplexType) {
1467 $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base'];
1472 … //$this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
1473 …$this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => …
1475 //$this->xdebug('import namespace ' . $attrs['namespace']);
1476 … $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
1477 if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
1478 $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
1485 $this->xdebug('restriction ' . $attrs['base']);
1486 if($this->currentSimpleType){
1487 $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base'];
1488 } elseif($this->currentComplexType){
1489 $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base'];
1491 $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1496 $this->schemaInfo = $attrs;
1497 $this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix);
1499 $this->schemaTargetNamespace = $attrs['targetNamespace'];
1502 $this->schemaInfo['elementFormDefault'] = 'unqualified';
1505 $this->schemaInfo['attributeFormDefault'] = 'unqualified';
1511 array_push($this->simpleTypeStack, $this->currentSimpleType);
1513 $this->xdebug("processing simpleType for name " . $attrs['name']);
1514 $this->currentSimpleType = $attrs['name'];
1515 $this->simpleTypes[ $attrs['name'] ] = $attrs;
1516 $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType';
1517 $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar';
1519 $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement);
1520 …$this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $…
1521 $this->currentSimpleType = $name;
1522 //$this->currentElement = false;
1523 $this->simpleTypes[$this->currentSimpleType] = $attrs;
1524 $this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar';
1530 //$this->xdebug("do not have anything to do for element $name");
1535 * end-element handler
1543 $this->depth--;
1545 if(isset($this->depth_array[$this->depth])){
1546 $pos = $this->depth_array[$this->depth];
1549 if ($prefix = $this->getPrefix($name)){
1551 $name = $this->getLocalPart($name);
1557 …$this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexT…
1558 $this->currentComplexType = array_pop($this->complexTypeStack);
1559 //$this->currentElement = false;
1562 …$this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unkn…
1563 $this->currentElement = array_pop($this->elementStack);
1566 …$this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType…
1567 $this->currentSimpleType = array_pop($this->simpleTypeStack);
1579 $pos = $this->depth_array[$this->depth - 1];
1580 $this->message[$pos]['cdata'] .= $data;
1590 $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion);
1593 if (sizeof($this->imports) > 0) {
1594 foreach($this->imports as $ns => $list) {
1605 foreach($this->complexTypes as $typeName => $attrs){
1613 …$contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($ePart…
1634 $contentStr .= " $a=\"".$this->contractQName($v).'"';
1636 $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl'];
1637 $contentStr .= ' wsdl:arrayType="'.$this->contractQName($v).'"';
1647 …$contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase…
1662 if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
1663 foreach($this->simpleTypes as $typeName => $eParts){
1664 …:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"".$this->contractQName($ePart…
1674 if(isset($this->elements) && count($this->elements) > 0){
1675 foreach($this->elements as $element => $eParts){
1676 …$xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type']).…
1680 if(isset($this->attributes) && count($this->attributes) > 0){
1681 foreach($this->attributes as $attr => $aParts){
1682 …$xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."…
1687 foreach ($this->schemaInfo as $k => $v) {
1692 $el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n";
1693 foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
1701 * adds debug data to the clas level debug string
1703 * @param string $string debug data
1707 $this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
1723 if(isset($this->typemap[$ns][$type])){
1725 return $this->typemap[$ns][$type];
1726 } elseif(isset($this->complexTypes[$type])){
1728 return $this->complexTypes[$type]['phpType'];
1756 //$this->debug("in getTypeDef for type $type");
1757 if (substr($type, -1) == '^') {
1759 $type = substr($type, 0, -1);
1764 if((! $is_element) && isset($this->complexTypes[$type])){
1765 $this->xdebug("in getTypeDef, found complexType $type");
1766 return $this->complexTypes[$type];
1767 } elseif((! $is_element) && isset($this->simpleTypes[$type])){
1768 $this->xdebug("in getTypeDef, found simpleType $type");
1769 if (!isset($this->simpleTypes[$type]['phpType'])) {
1772 …$uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':'…
1773 …$ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':')…
1774 $etype = $this->getTypeDef($uqType);
1776 $this->xdebug("in getTypeDef, found type for simpleType $type:");
1777 $this->xdebug($this->varDump($etype));
1779 $this->simpleTypes[$type]['phpType'] = $etype['phpType'];
1782 $this->simpleTypes[$type]['elements'] = $etype['elements'];
1786 return $this->simpleTypes[$type];
1787 } elseif(isset($this->elements[$type])){
1788 $this->xdebug("in getTypeDef, found element $type");
1789 if (!isset($this->elements[$type]['phpType'])) {
1791 …$uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1);
1792 $ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':'));
1793 $etype = $this->getTypeDef($uqType);
1795 $this->xdebug("in getTypeDef, found type for element $type:");
1796 $this->xdebug($this->varDump($etype));
1798 $this->elements[$type]['phpType'] = $etype['phpType'];
1801 $this->elements[$type]['elements'] = $etype['elements'];
1804 $this->xdebug("in getTypeDef, element $type is an XSD type");
1805 $this->elements[$type]['phpType'] = 'scalar';
1808 return $this->elements[$type];
1809 } elseif(isset($this->attributes[$type])){
1810 $this->xdebug("in getTypeDef, found attribute $type");
1811 return $this->attributes[$type];
1813 $this->xdebug("in getTypeDef, have an untyped element $type");
1819 $this->xdebug("in getTypeDef, did not find $type");
1833 if($typeDef = $this->getTypeDef($type)){
1840 $str .= " xmlns=\"".$this->schema['targetNamespace']."\"";
1844 $str .= $this->serializeTypeDef($element);
1869 if($typeDef = $this->getTypeDef($type)){
1875 <tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td>
1908 * 'SOAP-ENC:Array',
1909 * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'),
1940 $this->complexTypes[$name] = array(
1951 $this->xdebug("addComplexType $name:");
1952 $this->appendDebug($this->varDump($this->complexTypes[$name]));
1968 $this->simpleTypes[$name] = array(
1976 $this->xdebug("addSimpleType $name:");
1977 $this->appendDebug($this->varDump($this->simpleTypes[$name]));
1988 if (! $this->getPrefix($attrs['type'])) {
1989 $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type'];
1991 $this->elements[ $attrs['name'] ] = $attrs;
1992 $this->elements[ $attrs['name'] ]['typeClass'] = 'element';
1994 $this->xdebug("addElement " . $attrs['name']);
1995 $this->appendDebug($this->varDump($this->elements[ $attrs['name'] ]));
2014 * xsd:anyType and user-defined types.
2075 …function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attribute…
2077 $this->name = $name;
2078 $this->type = $type;
2079 $this->value = $value;
2080 $this->element_ns = $element_ns;
2081 $this->type_ns = $type_ns;
2082 $this->attributes = $attributes;
2093 …return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type…
2103 return $this->value;
2163 * @param array $curl_options User-specified cURL options
2169 $this->debug("ctor url=$url use_curl=$use_curl curl_options:");
2170 $this->appendDebug($this->varDump($curl_options));
2171 $this->setURL($url);
2173 $this->ch_options = $curl_options;
2175 $this->use_curl = $use_curl;
2176 ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev);
2177 $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
2188 $this->debug("setCurlOption option=$option, value=");
2189 $this->appendDebug($this->varDump($value));
2190 curl_setopt($this->ch, $option, $value);
2201 $this->outgoing_headers[$name] = $value;
2202 $this->debug("set header $name: $value");
2212 if (isset($this->outgoing_headers[$name])) {
2213 $this->debug("unset header $name");
2214 unset($this->outgoing_headers[$name]);
2225 $this->url = $url;
2229 $this->debug("parsed URL $k = $v");
2230 $this->$k = $v;
2235 $this->path .= '?' . $u['query'];
2241 $this->port = 443;
2243 $this->port = 80;
2247 $this->uri = $this->path;
2248 $this->digest_uri = $this->uri;
2252 $this->setHeader('Host', $this->host);
2254 $this->setHeader('Host', $this->host.':'.$this->port);
2258 $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
2269->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm')…
2271 …if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array…
2289 // if ($this->scheme == 'https') {
2292 // $this->scheme = 'ssl';
2293 // $this->debug('Using SSL over OpenSSL');
2297 …this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, s…
2298 if ($this->io_method() == 'socket') {
2299 if (!is_array($this->proxy)) {
2300 $host = $this->host;
2301 $port = $this->port;
2303 $host = $this->proxy['host'];
2304 $port = $this->proxy['port'];
2308 if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
2309 if (!feof($this->fp)) {
2310 $this->debug('Re-use persistent connection');
2313 fclose($this->fp);
2314 $this->debug('Closed persistent connection at EOF');
2318 if ($this->scheme == 'ssl') {
2321 …$this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout…
2325 $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout);
2327 $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str);
2331 if(!$this->fp) {
2332 $msg = 'Couldn\'t open socket connection to server ' . $this->url;
2333 if ($this->errno) {
2334 $msg .= ', Error ('.$this->errno.'): '.$this->error_str;
2338 $this->debug($msg);
2339 $this->setError($msg);
2344 $this->debug('set response timeout to ' . $response_timeout);
2345 socket_set_timeout( $this->fp, $response_timeout);
2347 $this->debug('socket connected');
2349 } else if ($this->io_method() == 'curl') {
2351 // $this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HT…
2352 …$this->setError('The PHP cURL Extension is required for HTTPS or NLTM. You will need to re-build …
2381 $this->debug('connect using cURL');
2383 $this->ch = curl_init();
2385 …$hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$thi…
2387 $hostURL .= $this->path;
2388 $this->setCurlOption(CURLOPT_URL, $hostURL);
2389 // follow location headers (re-directs)
2391 $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
2392 $this->debug('safe_mode = ');
2393 $this->appendDebug($this->varDump(ini_get('safe_mode')));
2394 $this->debug('open_basedir = ');
2395 $this->appendDebug($this->varDump(ini_get('open_basedir')));
2397 $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1);
2400 $this->setCurlOption(CURLOPT_HEADER, 1);
2402 $this->setCurlOption(CURLOPT_RETURNTRANSFER, 1);
2406 // $this->setCurlOption(CURLOPT_ENCODING, 'deflate');
2409 if ($this->persistentConnection) {
2414 //$this->setCurlOption(CURL_HTTP_VERSION_1_1, true);
2415 $this->persistentConnection = false;
2416 $this->setHeader('Connection', 'close');
2420 $this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
2423 $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout);
2426 if ($this->scheme == 'https') {
2427 $this->debug('set cURL SSL verify options');
2431 //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt');
2432 $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
2433 $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
2436 if ($this->authtype == 'certificate') {
2437 $this->debug('set cURL certificate options');
2438 if (isset($this->certRequest['cainfofile'])) {
2439 $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']);
2441 if (isset($this->certRequest['verifypeer'])) {
2442 $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
2444 $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
2446 if (isset($this->certRequest['verifyhost'])) {
2447 $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
2449 $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
2451 if (isset($this->certRequest['sslcertfile'])) {
2452 $this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
2454 if (isset($this->certRequest['sslkeyfile'])) {
2455 $this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
2457 if (isset($this->certRequest['passphrase'])) {
2458 $this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']);
2460 if (isset($this->certRequest['certpassword'])) {
2461 $this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']);
2465 if ($this->authtype && ($this->authtype != 'certificate')) {
2466 if ($this->username) {
2467 $this->debug('set cURL username/password');
2468 $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password");
2470 if ($this->authtype == 'basic') {
2471 $this->debug('set cURL for Basic authentication');
2472 $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC);
2474 if ($this->authtype == 'digest') {
2475 $this->debug('set cURL for digest authentication');
2476 $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST);
2478 if ($this->authtype == 'ntlm') {
2479 $this->debug('set cURL for NTLM authentication');
2480 $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM);
2483 if (is_array($this->proxy)) {
2484 $this->debug('set cURL proxy options');
2485 if ($this->proxy['port'] != '') {
2486 $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'].':'.$this->proxy['port']);
2488 $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']);
2490 if ($this->proxy['username'] || $this->proxy['password']) {
2491 $this->debug('set cURL proxy authentication options');
2492 … $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'].':'.$this->proxy['password']);
2493 if ($this->proxy['authtype'] == 'basic') {
2494 $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC);
2496 if ($this->proxy['authtype'] == 'ntlm') {
2497 $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM);
2501 $this->debug('cURL connection set up');
2504 $this->setError('Unknown scheme ' . $this->scheme);
2505 $this->debug('Unknown scheme ' . $this->scheme);
2522 $this->debug('entered send() with data of length: '.strlen($data));
2524 $this->tryagain = true;
2526 while ($this->tryagain) {
2527 $this->tryagain = false;
2530 if (!$this->connect($timeout, $response_timeout)){
2535 if (!$this->sendRequest($data, $cookies)){
2540 $respdata = $this->getResponse();
2542 $this->setError("Too many tries to get an OK response ($this->response_status_line)");
2545 $this->debug('end of send()');
2562 return $this->send($data, $timeout, $response_timeout, $cookies);
2576 $this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
2577 $this->appendDebug($this->varDump($digestRequest));
2578 $this->debug("certRequest=");
2579 $this->appendDebug($this->varDump($certRequest));
2582 …$this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':','',$username).':'.$passwo…
2589 // A1 = unq(username-value) ":" unq(realm-value) ":" passwd
2595 // A2 = Method ":" digest-uri-value
2596 $A2 = $this->request_method . ':' . $this->digest_uri;
2603 // request-digest = <"> < KD ( H(A1), unq(nonce-value)
2604 // ":" nc-value
2605 // ":" unq(cnonce-value)
2606 // ":" unq(qop-value)
2610 // request-digest = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
2628 …his->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['r…
2631 $this->certRequest = $certRequest;
2632 $this->debug('Authorization header not set for certificate');
2635 $this->debug('Authorization header not set for ntlm');
2637 $this->username = $username;
2638 $this->password = $password;
2639 $this->authtype = $authtype;
2640 $this->digestRequest = $digestRequest;
2650 $this->setHeader('SOAPAction', '"' . $soapaction . '"');
2661 $this->protocol_version = '1.1';
2662 $this->setHeader('Accept-Encoding', $enc);
2663 if (!isset($this->outgoing_headers['Connection'])) {
2664 $this->setHeader('Connection', 'close');
2665 $this->persistentConnection = false;
2669 $this->encoding = $enc;
2685 $this->proxy = array(
2693 …$this->setHeader('Proxy-Authorization', ' Basic '.base64_encode($proxyusername.':'.$proxypassword)…
2696 $this->debug('remove proxy');
2698 unsetHeader('Proxy-Authorization');
2743 // read chunk-size, chunk-extension (if any) and CRLF
2747 $this->debug('no linebreak found in decodeChunked');
2753 // while (chunk-size > 0) {
2755 $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
2761 // append chunk-data to entity-body
2767 // read chunk-data and CRLF
2768 $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
2769 // append chunk-data to entity-body
2771 // length := length + chunk-size
2773 // read chunk-size and CRLF
2780 $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
2788 * Writes the payload, including HTTP headers, to $this->outgoing_payload.
2796 // Note: for cURL connections, $this->outgoing_payload is ignored,
2797 // as is the Content-Length header, but these are still created as
2800 // add content-length header
2801 $this->setHeader('Content-Length', strlen($data));
2804 if ($this->proxy) {
2805 $uri = $this->url;
2807 $uri = $this->uri;
2809 $req = "$this->request_method $uri HTTP/$this->protocol_version";
2810 $this->debug("HTTP request: $req");
2811 $this->outgoing_payload = "$req\r\n";
2814 foreach($this->outgoing_headers as $k => $v){
2816 $this->debug("HTTP header: $hdr");
2817 $this->outgoing_payload .= "$hdr\r\n";
2823 $this->debug("HTTP header: $hdr");
2824 $this->outgoing_payload .= "$hdr\r\n";
2828 $this->outgoing_payload .= "\r\n";
2831 $this->outgoing_payload .= $data;
2844 …$cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme ==…
2847 $this->buildPayload($data, $cookie_str);
2849 if ($this->io_method() == 'socket') {
2851 if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
2852 $this->setError('couldn\'t write message data to socket');
2853 $this->debug('couldn\'t write message data to socket');
2856 $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
2858 } else if ($this->io_method() == 'curl') {
2863 //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
2865 foreach($this->outgoing_headers as $k => $v){
2866 …if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k ==…
2867 $this->debug("Skip cURL header $k: $v");
2875 $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
2876 $this->debug('set cURL HTTP headers');
2877 if ($this->request_method == "POST") {
2878 $this->setCurlOption(CURLOPT_POST, 1);
2879 $this->setCurlOption(CURLOPT_POSTFIELDS, $data);
2880 $this->debug('set cURL POST data');
2883 // insert custom user-set cURL options
2884 foreach ($this->ch_options as $key => $val) {
2885 $this->setCurlOption($key, $val);
2888 $this->debug('set cURL payload');
2900 $this->incoming_payload = '';
2902 if ($this->io_method() == 'socket') {
2908 if(feof($this->fp)) {
2909 $this->incoming_payload = $data;
2910 $this->debug('found no headers before EOF after length ' . strlen($data));
2911 $this->debug("received before EOF:\n" . $data);
2912 $this->setError('server failed to send headers');
2916 $tmp = fgets($this->fp, 256);
2918 $this->debug("read line of $tmplen bytes: " . trim($tmp));
2921 $this->incoming_payload = $data;
2922 $this->debug('socket read of headers timed out after length ' . strlen($data));
2923 $this->debug("read before timeout: " . $data);
2924 $this->setError('socket read of headers timed out');
2945 $this->incoming_payload .= $data;
2946 $this->debug('found end of headers after length ' . strlen($data));
2950 $this->incoming_headers = array();
2951 $this->incoming_cookies = array();
2956 $this->incoming_headers[$header_name] = trim($arr[1]);
2957 if ($header_name == 'set-cookie') {
2959 $cookie = $this->parseCookie(trim($arr[1]));
2961 $this->incoming_cookies[] = $cookie;
2962 $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
2964 $this->debug('did not find cookie in ' . trim($arr[1]));
2969 $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
2974 …if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['tra…
2975 $content_length = 2147483647; // ignore any content-length header
2977 $this->debug("want to read chunked content");
2978 } elseif (isset($this->incoming_headers['content-length'])) {
2979 $content_length = $this->incoming_headers['content-length'];
2981 $this->debug("want to read content of length $content_length");
2985 $this->debug("want to read content to EOF");
2990 $tmp = fgets($this->fp, 256);
2992 $this->debug("read chunk line of $tmplen bytes");
2994 $this->incoming_payload = $data;
2995 $this->debug('socket read of chunk length timed out after length ' . strlen($data));
2996 $this->debug("read before timeout:\n" . $data);
2997 $this->setError('socket read of chunk length timed out');
3001 $this->debug("chunk length $content_length");
3004 while (($strlen < $content_length) && (!feof($this->fp))) {
3005 $readlen = min(8192, $content_length - $strlen);
3006 $tmp = fread($this->fp, $readlen);
3008 $this->debug("read buffer of $tmplen bytes");
3009 if (($tmplen == 0) && (!feof($this->fp))) {
3010 $this->incoming_payload = $data;
3011 $this->debug('socket read of body timed out after length ' . strlen($data));
3012 $this->debug("read before timeout:\n" . $data);
3013 $this->setError('socket read of body timed out');
3020 $tmp = fgets($this->fp, 256);
3022 $this->debug("read chunk terminator of $tmplen bytes");
3024 $this->incoming_payload = $data;
3025 $this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
3026 $this->debug("read before timeout:\n" . $data);
3027 $this->setError('socket read of chunk terminator timed out');
3031 } while ($chunked && ($content_length > 0) && (!feof($this->fp)));
3032 if (feof($this->fp)) {
3033 $this->debug('read to EOF');
3035 $this->debug('read body of length ' . strlen($data));
3036 $this->incoming_payload .= $data;
3037 $this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
3041 …(isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection'])…
3042 (! $this->persistentConnection) || feof($this->fp)){
3043 fclose($this->fp);
3044 $this->fp = false;
3045 $this->debug('closed socket');
3049 if($this->incoming_payload == ''){
3050 $this->setError('no response from server');
3054 // decode transfer-encoding
3055 // if(isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['t…
3056 // if(!$data = $this->decodeChunked($data, $lb)){
3057 // $this->setError('Decoding of chunked data failed');
3060 //print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
3062 // $this->incoming_payload = $header_data.$lb.$lb.$data;
3065 } else if ($this->io_method() == 'curl') {
3067 $this->debug('send and receive with cURL');
3068 $this->incoming_payload = curl_exec($this->ch);
3069 $data = $this->incoming_payload;
3071 $cErr = curl_error($this->ch);
3073 $err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>';
3075 foreach(curl_getinfo($this->ch) as $k => $v){
3078 $this->debug($err);
3079 $this->setError($err);
3080 curl_close($this->ch);
3084 //var_dump(curl_getinfo($this->ch));
3088 $this->debug('No cURL error, closing cURL');
3089 curl_close($this->ch);
3093 while ($this->isSkippableCurlHeader($data)) {
3094 $this->debug("Found HTTP header to skip");
3120 $this->debug('no proper separation of headers and document');
3121 $this->setError('no proper separation of headers and document');
3127 $this->debug('found proper separation of headers and document');
3128 $this->debug('cleaned data, stringlen: '.strlen($data));
3134 $this->incoming_headers[$header_name] = trim($arr[1]);
3135 if ($header_name == 'set-cookie') {
3137 $cookie = $this->parseCookie(trim($arr[1]));
3139 $this->incoming_cookies[] = $cookie;
3140 $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
3142 $this->debug('did not find cookie in ' . trim($arr[1]));
3147 $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
3152 $this->response_status_line = $header_array[0];
3153 $arr = explode(' ', $this->response_status_line, 3);
3159 if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
3160 …$this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']…
3161 $this->setURL($this->incoming_headers['location']);
3162 $this->tryagain = true;
3167 if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
3168 …$this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authent…
3169 if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
3170 $this->debug('Server wants digest authentication');
3172 $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
3183 $this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
3184 $this->tryagain = true;
3188 $this->debug('HTTP authentication failed');
3189 $this->setError('HTTP authentication failed');
3198 …$this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response …
3202 // decode content-encoding
3203 …if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding…
3204 …if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incom…
3207 //$timer->setMarker('starting decoding of gzip/deflated content');
3210 $this->debug('The gzinflate function exists');
3212 if ($this->incoming_headers['content-encoding'] == 'deflate') {
3215 $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
3218 $this->debug('The inflated payload is smaller than the gzipped one; try again');
3221 $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
3225 $this->debug('Error using gzinflate to inflate the payload');
3226 $this->setError('Error using gzinflate to inflate the payload');
3228 } elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
3231 $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
3234 $this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
3237 $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
3241 $this->debug('Error using gzinflate to un-gzip the payload');
3242 $this->setError('Error using gzinflate to un-gzip the payload');
3245 //$timer->setMarker('finished decoding of gzip/deflated content');
3246 //print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
3248 $this->incoming_payload = $header_data.$lb.$lb.$data;
3250 …$this->debug('The server sent compressed data. Your php install must have the Zlib extension compi…
3251 …$this->setError('The server sent compressed data. Your php install must have the Zlib extension co…
3254 $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
3255 $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
3258 $this->debug('No Content-Encoding header');
3262 $this->debug('no data after headers!');
3263 $this->setError('no data present after HTTP headers');
3271 * sets the content-type for the SOAP message to be sent
3278 $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
3288 if (isset($this->outgoing_headers['Accept-Encoding'])) {
3291 $this->protocol_version = '1.1';
3292 $this->persistentConnection = true;
3293 $this->setHeader('Connection', 'Keep-Alive');
3305 * TODO: allow a Set-Cookie string to be parsed into multiple cookies
3367 * @param boolean $secure is the send-content secure or not?
3368 * @return string for Cookie-HTTP-Header
3378 $this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
3381 $this->debug('cookie has expired');
3387 if (! preg_match("'.*$domain$'i", $this->host)) {
3388 $this->debug('cookie has different domain');
3394 if (! preg_match("'^$path.*'i", $this->path)) {
3395 $this->debug('cookie is for a different path');
3400 $this->debug('cookie is secure, transport is not');
3404 $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
3568 * whether to append debug to response as XML comment
3585 global $debug;
3589 $this->debug("_SERVER is defined:");
3590 $this->appendDebug($this->varDump($_SERVER));
3592 $this->debug("HTTP_SERVER_VARS is defined:");
3593 $this->appendDebug($this->varDump($HTTP_SERVER_VARS));
3595 $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
3598 if (isset($debug)) {
3599 $this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
3600 $this->debug_flag = $debug;
3604 if (substr($v, 0, 6) == 'debug=') {
3605 … $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
3606 $this->debug_flag = substr($v, 6);
3612 if (substr($v, 0, 6) == 'debug=') {
3613 … $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
3614 $this->debug_flag = substr($v, 6);
3621 $this->debug("In nusoap_server, WSDL is specified");
3623 $this->wsdl = $wsdl;
3624 $this->externalWSDLURL = $this->wsdl->wsdl;
3625 $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
3627 $this->debug('Create wsdl from ' . $wsdl);
3628 $this->wsdl = new wsdl($wsdl);
3629 $this->externalWSDLURL = $wsdl;
3631 $this->appendDebug($this->wsdl->getDebug());
3632 $this->wsdl->clearDebug();
3633 if($err = $this->wsdl->getError()){
3655 $this->debug("In service, query string=$qs");
3658 $this->debug("In service, this is a request for WSDL");
3659 if($this->externalWSDLURL){
3660 if (strpos($this->externalWSDLURL,"://")!==false) { // assume URL
3661 header('Location: '.$this->externalWSDLURL);
3663 header("Content-Type: text/xml\r\n");
3664 $fp = fopen($this->externalWSDLURL, 'r');
3667 } elseif ($this->wsdl) {
3668 header("Content-Type: text/xml; charset=ISO-8859-1\r\n");
3669 print $this->wsdl->serialize($this->debug_flag);
3670 if ($this->debug_flag) {
3671 $this->debug('wsdl:');
3672 $this->appendDebug($this->varDump($this->wsdl));
3673 print $this->getDebugAsXMLComment();
3676 header("Content-Type: text/html; charset=ISO-8859-1\r\n");
3679 } elseif ($data == '' && $this->wsdl) {
3680 $this->debug("In service, there is no data, so return Web description");
3681 print $this->wsdl->webDescription();
3683 $this->debug("In service, invoke the request");
3684 $this->parse_request($data);
3685 if (! $this->fault) {
3686 $this->invoke_method();
3688 if (! $this->fault) {
3689 $this->serialize_return();
3691 $this->send_response();
3710 $this->request = '';
3711 $this->SOAPAction = '';
3713 $this->debug("In parse_http_headers, use getallheaders");
3717 $this->headers[$k] = $v;
3718 $this->request .= "$k: $v\r\n";
3719 $this->debug("$k: $v");
3722 if(isset($this->headers['soapaction'])){
3723 $this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
3726 if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
3727 $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
3728 if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
3729 $this->xml_encoding = strtoupper($enc);
3731 $this->xml_encoding = 'US-ASCII';
3734 // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
3735 $this->xml_encoding = 'ISO-8859-1';
3738 $this->debug("In parse_http_headers, use _SERVER");
3741 $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
3743 $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
3750 $this->SOAPAction = $v;
3751 } else if ($k == 'content-type') {
3757 if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
3758 $this->xml_encoding = strtoupper($enc);
3760 $this->xml_encoding = 'US-ASCII';
3763 // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
3764 $this->xml_encoding = 'ISO-8859-1';
3767 $this->headers[$k] = $v;
3768 $this->request .= "$k: $v\r\n";
3769 $this->debug("$k: $v");
3772 $this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
3775 …$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); …
3777 …$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); …
3784 $this->SOAPAction = $v;
3785 } else if ($k == 'content-type') {
3791 if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
3792 $this->xml_encoding = strtoupper($enc);
3794 $this->xml_encoding = 'US-ASCII';
3797 // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
3798 $this->xml_encoding = 'ISO-8859-1';
3801 $this->headers[$k] = $v;
3802 $this->request .= "$k: $v\r\n";
3803 $this->debug("$k: $v");
3806 $this->debug("In parse_http_headers, HTTP headers not accessible");
3807 $this->setError("HTTP headers not accessible");
3834 $this->debug('entering parse_request()');
3835 $this->parse_http_headers();
3836 $this->debug('got character encoding: '.$this->xml_encoding);
3838 if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
3839 $this->debug('got content encoding: ' . $this->headers['content-encoding']);
3840 …if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip…
3843 if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
3845 …} elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))…
3848 $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
3852 $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
3857 $this->request .= "\r\n".$data;
3858 $data = $this->parseRequest($this->headers, $data);
3859 $this->requestSOAP = $data;
3860 $this->debug('leaving parse_request');
3881 …$this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodUR…
3884 // NEW - BSP
3885 $data = split("_", $this->methodname);
3899 if ($this->wsdl) {
3900 if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
3901 $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
3902 $this->appendDebug('opData=' . $this->varDump($this->opData));
3903 } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
3905 …$this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . …
3906 $this->appendDebug('opData=' . $this->varDump($this->opData));
3907 $this->methodname = $this->opData['name'];
3909 $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
3910 …$this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL …
3914 $this->debug('in invoke_method, no WSDL to validate method');
3917 // if a . is present in $this->methodname, we see if there is a class in scope,
3922 if (strpos($this->methodname, '..') > 0) {
3924 } else if (strpos($this->methodname, '.') > 0) {
3926 } else if (strpos($this->methodname, '_') > 0) {
3932 if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1 &&
3933 class_exists(substr($this->methodname, 0, strpos($this->methodname, $delim)))) {
3935 $class = substr($this->methodname, 0, strpos($this->methodname, $delim));
3936 $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
3937 $this->debug("in invoke_method, class=$class method=$method delim=$delim");
3942 if (!function_exists($this->methodname)) {
3943 $this->debug("in invoke_method, function '$this->methodname' not found!");
3944 $this->result = 'fault: method not found';
3945 // $this->fault('SOAP-ENV:Client',"method '$this->methodname' not defined in service");
3946->fault('SOAP-ENV:Client',"method '$this->methodname' not defined in service methodname=' . $this-
3952 $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
3953 $this->result = 'fault: method not found';
3954 $this->fault('SOAP-ENV:Client',"method '$this->methodname' not defined in service");
3961 if(! $this->verify_method($this->methodname,$this->methodparams)){
3962 // debug
3963 $this->debug('ERROR: request not verified against method signature');
3964 $this->result = 'fault: request failed validation against method signature';
3966 $this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
3971 $this->debug('in invoke_method, params:');
3972 $this->appendDebug($this->varDump($this->methodparams));
3973 $this->debug("in invoke_method, calling '$this->methodname'");
3976 $this->debug('in invoke_method, calling function using eval()');
3977 $funcCall = "\$this->methodreturn = $this->methodname(";
3980 $this->debug('in invoke_method, calling class method using eval()');
3981 $funcCall = "\$this->methodreturn = ".$class."::".$method."(";
3983 $this->debug('in invoke_method, calling instance method using eval()');
3987 $funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
3990 if ($this->methodparams) {
3991 foreach ($this->methodparams as $param) {
3993 …$this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when usin…
3998 $funcCall = substr($funcCall, 0, -1);
4001 $this->debug('in invoke_method, function call: '.$funcCall);
4005 $this->debug('in invoke_method, calling function using call_user_func_array()');
4006 …$call_arg = "$this->methodname"; // straight assignment changes $this->methodname to lower case af…
4008 $this->debug('in invoke_method, calling class method using call_user_func_array()');
4011 $this->debug('in invoke_method, calling instance method using call_user_func_array()');
4021 if (is_array($this->methodparams)) {
4022 $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
4024 $this->methodreturn = call_user_func_array($call_arg, array());
4027 $this->debug('in invoke_method, methodreturn:');
4028 $this->appendDebug($this->varDump($this->methodreturn));
4029 …$this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($…
4044 …$this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this
4046 …if (isset($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class(…
4047 $this->debug('got a fault object from method');
4048 $this->fault = $this->methodreturn;
4050 } elseif ($this->methodreturnisliteralxml) {
4051 $return_val = $this->methodreturn;
4054 $this->debug('got a(n) '.gettype($this->methodreturn).' from method');
4055 $this->debug('serializing return value');
4056 if($this->wsdl){
4057 if (sizeof($this->opData['output']['parts']) > 1) {
4058 $this->debug('more than one output part, so use the method return unchanged');
4059 $opParams = $this->methodreturn;
4060 } elseif (sizeof($this->opData['output']['parts']) == 1) {
4061 $this->debug('exactly one output part, so wrap the method return in a simple array');
4063 //foreach ($this->opData['output']['parts'] as $name => $type) {
4064 // $this->debug('wrap in element named ' . $name);
4066 $opParams = array($this->methodreturn);
4068 $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
4069 $this->appendDebug($this->wsdl->getDebug());
4070 $this->wsdl->clearDebug();
4071 if($errstr = $this->wsdl->getError()){
4072 $this->debug('got wsdl error: '.$errstr);
4073 $this->fault('SOAP-ENV:Server', 'unable to serialize result');
4077 if (isset($this->methodreturn)) {
4078 $return_val = $this->serialize_val($this->methodreturn, 'return');
4081 $this->debug('in absence of WSDL, assume void return for backward compatibility');
4085 $this->debug('return value:');
4086 $this->appendDebug($this->varDump($return_val));
4088 $this->debug('serializing response');
4089 if ($this->wsdl) {
4090 $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
4091 if ($this->opData['style'] == 'rpc') {
4092 $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
4093 if ($this->opData['output']['use'] == 'literal') {
4094 …// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor e…
4095 …$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</n…
4097 …$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</n…
4100 $this->debug('style is not rpc for serialization: assume document');
4104 $this->debug('do not have WSDL for serialization: assume rpc/encoded');
4105 …$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</n…
4107 $this->result = 'successful';
4108 if($this->wsdl){
4109 //if($this->debug_flag){
4110 $this->appendDebug($this->wsdl->getDebug());
4118 /* CHANGED 2009-04-08 BY Björn Spichal ---------------------------------*/
4121 /*----------------------------------------------------------------------*/
4124 …$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNa…
4126 $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
4129 $this->debug("Leaving serialize_return");
4143 $this->debug('Enter send_response');
4144 if ($this->fault) {
4145 $payload = $this->fault->serialize();
4146 $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
4147 $this->outgoing_headers[] = "Status: 500 Internal Server Error";
4149 $payload = $this->responseSOAP;
4153 // $this->outgoing_headers[] = "HTTP/1.0 200 OK";
4154 // $this->outgoing_headers[] = "Status: 200 OK";
4156 // add debug data if in debug mode
4157 if(isset($this->debug_flag) && $this->debug_flag){
4158 $payload .= $this->getDebugAsXMLComment();
4160 $this->outgoing_headers[] = "Server: $this->title Server v$this->version";
4161 ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev);
4162 $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
4164 //$this->outgoing_headers[] = "Connection: Close\r\n";
4165 $payload = $this->getHTTPBody($payload);
4166 $type = $this->getHTTPContentType();
4167 $charset = $this->getHTTPContentTypeCharset();
4168 $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
4169 //begin code to compress payload - by John
4172 …if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) …
4173 if (strstr($this->headers['accept-encoding'], 'gzip')) {
4175 if (isset($this->debug_flag) && $this->debug_flag) {
4176 $payload .= "<!-- Content being gzipped -->";
4178 $this->outgoing_headers[] = "Content-Encoding: gzip";
4181 if (isset($this->debug_flag) && $this->debug_flag) {
4182 $payload .= "<!-- Content will not be gzipped: no gzencode -->";
4185 } elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
4188 …// which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.…
4190 if (isset($this->debug_flag) && $this->debug_flag) {
4191 $payload .= "<!-- Content being deflated -->";
4193 $this->outgoing_headers[] = "Content-Encoding: deflate";
4196 if (isset($this->debug_flag) && $this->debug_flag) {
4197 $payload .= "<!-- Content will not be deflated: no gzcompress -->";
4203 $this->outgoing_headers[] = "Content-Length: ".strlen($payload);
4204 reset($this->outgoing_headers);
4205 foreach($this->outgoing_headers as $hdr){
4210 $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
4223 if(isset($this->wsdl) && is_object($this->wsdl)){
4224 if($this->wsdl->getOperationData($operation)){
4227 } elseif(isset($this->operations[$operation])){
4242 …$this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' and type ' . $heade…
4243 if (!strstr($headers['content-type'], 'text/xml')) {
4244 $this->setError('Request not of type text/xml');
4247 if (strpos($headers['content-type'], '=')) {
4248 $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
4249 $this->debug('Got response encoding: ' . $enc);
4250 if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
4251 $this->xml_encoding = strtoupper($enc);
4253 $this->xml_encoding = 'US-ASCII';
4256 // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
4257 $this->xml_encoding = 'ISO-8859-1';
4259 $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
4261 $parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
4262 // parser debug
4263 $this->debug("parser debug: \n".$parser->getDebug());
4265 if($err = $parser->getError()){
4266 $this->result = 'fault: error in msg parsing: '.$err;
4267 $this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
4271 $this->methodURI = $parser->root_struct_namespace;
4272 $this->methodname = $parser->root_struct_name;
4273 $this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
4274 $this->debug('calling parser->get_soapbody()');
4275 $this->methodparams = $parser->get_soapbody();
4277 $this->requestHeaders = $parser->getHeaders();
4279 $this->requestHeader = $parser->get_soapheader();
4281 $this->document = $parser->document;
4310 * returns false for non-text content types.
4318 return $this->soap_defencoding;
4331 $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
4351 if($this->externalWSDLURL){
4375 $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
4394 $this->operations[$name] = array(
4401 if($this->wsdl){
4402 …$this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodi…
4418 if ($faultdetail == '' && $this->debug_flag) {
4419 $faultdetail = $this->getDebug();
4421 $this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
4422 $this->fault->soap_defencoding = $this->soap_defencoding;
4451 $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
4480 $this->wsdl = new wsdl;
4481 $this->wsdl->serviceName = $serviceName;
4482 $this->wsdl->endpoint = $endpoint;
4483 $this->wsdl->namespaces['tns'] = $namespace;
4484 $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
4485 $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
4487 $this->wsdl->namespaces['types'] = $schemaTargetNamespace;
4489 …$this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namesp…
4491 … $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
4493 … $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
4494 …$this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding…
4495 …$this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = …
4496 $this->wsdl->bindings[$serviceName.'Binding'] = array(
4501 $this->wsdl->ports[$serviceName.'Port'] = array(
4562 var $curl_options = array(); // User-specified cURL options
4580 * @param array $curl_options user-specified cURL options
4586 $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
4587 $this->proxyhost = $proxyhost;
4588 $this->proxyport = $proxyport;
4589 $this->proxyusername = $proxyusername;
4590 $this->proxypassword = $proxypassword;
4591 $this->timeout = $timeout;
4592 $this->response_timeout = $response_timeout;
4594 $this->curl_options = $curl_options;
4595 $this->use_curl = $use_curl;
4596 $this->fetchWSDL($wsdl);
4605 $this->debug("parse and process WSDL path=$wsdl");
4606 $this->wsdl = $wsdl;
4608 if ($this->wsdl != "") {
4609 $this->parseWSDL($this->wsdl);
4612 // TODO: handle imports more properly, grabbing them in-line and nesting them
4618 foreach ($this->schemas as $ns => $list) {
4620 $wsdlparts = parse_url($this->wsdl); // this is bogusly simple!
4621 foreach ($xs->imports as $ns2 => $list2) {
4624 $this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
4633 $this->parseWSDL($url);
4638 $this->debug("Unexpected scenario: empty URL for unloaded import");
4646 $wsdlparts = parse_url($this->wsdl); // this is bogusly simple!
4647 foreach ($this->import as $ns => $list) {
4650 $this->import[$ns][$ii]['loaded'] = true;
4659 $this->parseWSDL($url);
4664 $this->debug("Unexpected scenario: empty URL for unloaded import");
4671 foreach($this->bindings as $binding => $bindingData) {
4674 $this->debug('post-parse data gathering for ' . $operation);
4675 $this->bindings[$binding]['operations'][$operation]['input'] =
4676 isset($this->bindings[$binding]['operations'][$operation]['input']) ?
4677 …array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindi…
4678 $this->portTypes[ $bindingData['portType'] ][$operation]['input'];
4679 $this->bindings[$binding]['operations'][$operation]['output'] =
4680 isset($this->bindings[$binding]['operations'][$operation]['output']) ?
4681 …array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bind…
4682 $this->portTypes[ $bindingData['portType'] ][$operation]['output'];
4683 …if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] …
4684 …$this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bi…
4686 …if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message']…
4687 …$this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->b…
4690 …if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['st…
4691 … $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style'];
4693 …$this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']…
4694->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $binding…
4695 …$this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) …
4708 $this->debug("parse WSDL at path=$wsdl");
4711 $this->debug('no wsdl passed to parseWSDL()!!');
4712 $this->setError('no wsdl passed to parseWSDL()!!');
4720 $this->debug('getting WSDL http(s) URL ' . $wsdl);
4722 $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl);
4723 $tr->request_method = 'GET';
4724 $tr->useSOAPAction = false;
4725 if($this->proxyhost && $this->proxyport){
4726 $tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
4728 if ($this->authtype != '') {
4729 …$tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest…
4731 $tr->setEncoding('gzip, deflate');
4732 $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
4733 //$this->debug("WSDL request\n" . $tr->outgoing_payload);
4734 //$this->debug("WSDL response\n" . $tr->incoming_payload);
4735 $this->appendDebug($tr->getDebug());
4737 if($err = $tr->getError() ){
4739 $this->debug($errstr);
4740 $this->setError($errstr);
4745 $this->debug("got WSDL URL");
4753 $this->debug('getting WSDL file ' . $path);
4762 $this->debug($errstr);
4763 $this->setError($errstr);
4767 $this->debug('Parse WSDL');
4770 $this->parser = xml_parser_create();
4773 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
4775 xml_set_object($this->parser, $this);
4777 xml_set_element_handler($this->parser, 'start_element', 'end_element');
4778 xml_set_character_data_handler($this->parser, 'character_data');
4780 if (!xml_parse($this->parser, $wsdl_string, true)) {
4785 xml_get_current_line_number($this->parser),
4786 xml_error_string(xml_get_error_code($this->parser))
4788 $this->debug($errstr);
4789 $this->debug("XML payload:\n" . $wsdl_string);
4790 $this->setError($errstr);
4794 xml_parser_free($this->parser);
4795 $this->debug('Parsing WSDL done');
4797 if($this->getError()){
4804 * start-element handler
4813 if ($this->status == 'schema') {
4814 $this->currentSchema->schemaStartElement($parser, $name, $attrs);
4815 $this->appendDebug($this->currentSchema->getDebug());
4816 $this->currentSchema->clearDebug();
4818 $this->debug('Parsing WSDL schema');
4819 …// $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalP…
4820 $this->status = 'schema';
4821 $this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces);
4822 $this->currentSchema->schemaStartElement($parser, $name, $attrs);
4823 $this->appendDebug($this->currentSchema->getDebug());
4824 $this->currentSchema->clearDebug();
4827 $pos = $this->position++;
4828 $depth = $this->depth++;
4830 $this->depth_array[$depth] = $pos;
4831 $this->message[$pos] = array('cdata' => '');
4838 $this->namespaces[$ns_prefix] = $v;
4840 $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
4843 $this->XMLSchemaVersion = $v;
4844 $this->namespaces['xsi'] = $v . '-instance';
4850 $k = strpos($k, ':') ? $this->expandQname($k) : $k;
4852 $v = strpos($v, ':') ? $this->expandQname($v) : $v;
4865 $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : '';
4871 switch ($this->status) {
4875 …$this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(…
4876 $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
4879 …$this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implo…
4880 $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
4887 $this->currentPortOperation = $attrs['name'];
4888 … $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
4890 …$this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrde…
4894 $this->documentation = true;
4898 $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
4899 … $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
4908 $this->bindings[$this->currentBinding]['prefix'] = $prefix;
4910 …$this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attr…
4913 …$this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['he…
4917 …$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $att…
4920 …$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['s…
4923 $this->currentOperation = $attrs['name'];
4924 $this->debug("current binding operation: $this->currentOperation");
4925 …$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['na…
4926 …$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->…
4927->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this
4931 $this->opStatus = 'input';
4934 $this->opStatus = 'output';
4937 …if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opS…
4938->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_…
4940 …$this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $…
4948 $this->currentPort = $attrs['name'];
4949 $this->debug('current port: ' . $this->currentPort);
4950 $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
4954 $this->ports[$this->currentPort]['location'] = $attrs['location'];
4955 $this->ports[$this->currentPort]['bindingType'] = $namespace;
4956 … $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
4957 … $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
4966 … $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
4967 …$this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($t…
4969 … $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
4970 if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
4971 $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
4973 …$this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$…
4978 // $this->status = 'schema';
4981 $this->status = 'message';
4982 $this->messages[$attrs['name']] = array();
4983 $this->currentMessage = $attrs['name'];
4986 $this->status = 'portType';
4987 $this->portTypes[$attrs['name']] = array();
4988 $this->currentPortType = $attrs['name'];
4994 $this->currentBinding = $this->getLocalPart($attrs['name']);
4996 $this->currentBinding = $attrs['name'];
4998 $this->status = 'binding';
4999 $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
5000 $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
5004 $this->serviceName = $attrs['name'];
5005 $this->status = 'service';
5006 $this->debug('current service: ' . $this->serviceName);
5010 $this->wsdl_info[$name] = $value;
5018 * end-element handler
5027 $this->status = "";
5028 $this->appendDebug($this->currentSchema->getDebug());
5029 $this->currentSchema->clearDebug();
5030 $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
5031 $this->debug('Parsing WSDL schema done');
5033 if ($this->status == 'schema') {
5034 $this->currentSchema->schemaEndElement($parser, $name);
5037 $this->depth--;
5040 if ($this->documentation) {
5042 …//$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->…
5043 $this->documentation = false;
5056 $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
5057 if (isset($this->message[$pos]['cdata'])) {
5058 $this->message[$pos]['cdata'] .= $data;
5060 if ($this->documentation) {
5061 $this->documentation .= $data;
5075 $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
5076 $this->appendDebug($this->varDump($certRequest));
5077 $this->username = $username;
5078 $this->password = $password;
5079 $this->authtype = $authtype;
5080 $this->certRequest = $certRequest;
5085 if (is_array($this->bindings[$binding])) {
5086 return $this->bindings[$binding];
5105 foreach($this->ports as $port => $portData) {
5108 //$this->debug("getOperations for port $port");
5109 //$this->debug("port data: " . $this->varDump($portData));
5110 //$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
5112 if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
5113 $ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']);
5136 foreach($this->ports as $port => $portData) {
5140 //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
5141 foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
5144 $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
5167 foreach($this->ports as $port => $portData) {
5171 foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
5199 $this->debug("in getTypeDef: type=$type, ns=$ns");
5200 if ((! $ns) && isset($this->namespaces['tns'])) {
5201 $ns = $this->namespaces['tns'];
5202 $this->debug("in getTypeDef: type namespace forced to $ns");
5204 if (!isset($this->schemas[$ns])) {
5205 foreach ($this->schemas as $ns0 => $schema0) {
5207 $this->debug("in getTypeDef: replacing schema namespace $ns with $ns0");
5213 if (isset($this->schemas[$ns])) {
5214 $this->debug("in getTypeDef: have schema for namespace $ns");
5215 for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
5216 $xs = &$this->schemas[$ns][$i];
5217 $t = $xs->getTypeDef($type);
5218 //$this->appendDebug($xs->getDebug());
5219 //$xs->clearDebug();
5225 $etype = $this->getTypeDef($uqType, $ns);
5227 $this->debug("found type for [element] $type:");
5228 $this->debug($this->varDump($etype));
5244 $this->debug("in getTypeDef: do not have schema for namespace $ns");
5262 $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
5266 <html><head><title>NuSOAP: '.$this->serviceName.'</title>
5268 …body { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
5269 p { font-family: arial; color: #000000; margin-top: 0px; margin-bottom: 12px; }
5270 …pre { background-color: silver; padding: 5px; font-family: Courier New; font-size: x-small; color:…
5271 ul { margin-top: 10px; margin-left: 20px; }
5272 li { list-style-type: none; margin-top: 10px; color: #000000; }
5274 margin-left: 0px; padding-bottom: 2em; }
5276 padding-top: 10px; padding-bottom: 10px; padding-left: 15px; font-size: .70em;
5277 margin-top: 10px; margin-left: 0px; color: #000000;
5278 background-color: #ccccff; width: 20%; margin-left: 20px; margin-top: 20px; }
5280 font-family: arial; font-size: 26px; color: #ffffff;
5281 background-color: #999999; width: 105%; margin-left: 0px;
5282 padding-top: 10px; padding-bottom: 10px; padding-left: 15px;}
5284 position: absolute; visibility: hidden; z-index: 200; left: 250px; top: 100px;
5285 font-family: arial; overflow: hidden; width: 600;
5286 padding: 20px; font-size: 10px; background-color: #999999;
5287 layer-background-color:#FFFFFF; }
5288 a,a:active { color: charcoal; font-weight: bold; }
5289 a:visited { color: #666666; font-weight: bold; }
5290 a:hover { color: cc3300; font-weight: bold; }
5293 <!--
5294 // POP-UP CAPTIONS...
5299 this.opera5=this.agent.indexOf("Opera 5")>-1
5300 this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
5301 this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
5304 this.mac=this.agent.indexOf("Mac")>-1
5336 //-->
5342 <div class=title>'.$this->serviceName.'</div>
5347 foreach($this->getOperations() as $op => $data){
5383 * @param mixed $debug whether to put debug=1 in endpoint URL
5387 function serialize($debug = 0) argument
5389 $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
5391 foreach($this->namespaces as $k => $v) {
5394 // 10.9.02 - add poulter fix for wsdl and tns declarations
5395 if (isset($this->namespaces['wsdl'])) {
5396 $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
5398 if (isset($this->namespaces['tns'])) {
5399 $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
5403 if (sizeof($this->import) > 0) {
5404 foreach($this->import as $ns => $list) {
5415 if (count($this->schemas)>=1) {
5417 foreach ($this->schemas as $ns => $list) {
5419 $xml .= $xs->serializeSchema();
5425 if (count($this->messages) >= 1) {
5426 foreach($this->messages as $msgName => $msgParts) {
5430 // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
5432 $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
5433 } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
5434 // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
5437 foreach($this->typemap as $ns => $types) {
5439 $typePrefix = $this->getPrefixFromNamespace($ns);
5446 $ns = $this->getNamespaceFromPrefix($typePrefix);
5447 $localPart = $this->getLocalPart($partType);
5448 $typeDef = $this->getTypeDef($localPart, $ns);
5451 if (substr($localPart, -1) == '^') {
5452 $localPart = substr($localPart, 0, -1);
5464 if (count($this->bindings) >= 1) {
5467 foreach($this->bindings as $bindingName => $attrs) {
5505 $xml .= "\n<service name=\"" . $this->serviceName . '">';
5506 if (count($this->ports) >= 1) {
5507 foreach($this->ports as $pName => $attrs) {
5509 …$xml .= "\n" . ' <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . …
5519 * when they are expect to be wrapped, Microsoft-style.
5527 $this->debug("in parametersMatchWrapped type=$type, parameters=");
5528 $this->appendDebug($this->varDump($parameters));
5530 // split type into namespace:unqualified-type
5534 $this->debug("in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
5535 if ($this->getNamespaceFromPrefix($ns)) {
5536 $ns = $this->getNamespaceFromPrefix($ns);
5537 $this->debug("in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
5542 $this->debug("in parametersMatchWrapped: No namespace for type $type");
5548 if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
5549 $this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type.");
5552 $this->debug("in parametersMatchWrapped: found typeDef=");
5553 $this->appendDebug($this->varDump($typeDef));
5554 if (substr($uqType, -1) == '^') {
5555 $uqType = substr($uqType, 0, -1);
5559 …$this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $…
5563 $this->debug("in parametersMatchWrapped: not a struct");
5572 …if ($this->isArraySimpleOrStruct($parameters) == 'arraySimple' && count($parameters) == count($typ…
5573 …$this->debug("in parametersMatchWrapped: (wrapped return value kludge) correct number of elements …
5578 $this->debug("in parametersMatchWrapped: change parameter $element to name $name");
5583 $this->debug("in parametersMatchWrapped: have parameter named $name");
5586 $this->debug("in parametersMatchWrapped: do not have parameter named $name");
5591 …$this->debug("in parametersMatchWrapped: $matches parameter names match $elements wrapped paramete…
5600 $this->debug("in parametersMatchWrapped: no elements type $ns:$uqType");
5609 * - multi-ref serialization
5610 * - validate PHP values against type definitions, return errors if invalid
5620 …$this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVers…
5621 $this->appendDebug('parameters=' . $this->varDump($parameters));
5624 $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
5625 $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
5628 if (!$opData = $this->getOperationData($operation, $bindingType)) {
5629 …$this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bin…
5630 …$this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $…
5633 $this->debug('in serializeRPCParameters: opData:');
5634 $this->appendDebug($this->varDump($opData));
5650 $this->debug("have $part_count part(s) to serialize using $style/$use");
5652 $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
5654 … $this->debug("have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
5655 // check for Microsoft-style wrapped parameters
5657 $this->debug('check whether the caller has wrapped the parameters');
5659 $this->debug('check whether caller\'s parameters match the wrapped ones');
5660 if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) {
5661 $this->debug('wrap the parameters for the caller');
5668 $this->debug("serializing part $name of type $type");
5680 $this->debug('calling serializeType w/indexed param');
5681 $xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
5683 $this->debug('calling serializeType w/named param');
5684 $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
5687 $this->debug('calling serializeType w/null param');
5688 $xml .= $this->serializeType($name, $type, null, $use, $enc_style);
5692 $this->debug('no parameters passed.');
5695 $this->debug("serializeRPCParameters returning: $xml");
5703 * - multi-ref serialization
5704 * - validate PHP values against type definitions, return errors if invalid
5715 …$this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion…
5716 $this->appendDebug('parameters=' . $this->varDump($parameters));
5719 $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
5720 $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
5723 if (!$opData = $this->getOperationData($operation)) {
5724 $this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
5725 $this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
5728 $this->debug('opData:');
5729 $this->appendDebug($this->varDump($opData));
5743 $this->debug("use=$use");
5744 $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
5746 $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
5747 $this->debug('have ' . $parametersArrayType . ' parameters');
5749 $this->debug('serializing part "'.$name.'" of type "'.$type.'"');
5761 $this->debug('calling serializeType w/indexed param');
5762 $xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
5764 $this->debug('calling serializeType w/named param');
5765 $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
5768 $this->debug('calling serializeType w/null param');
5769 $xml .= $this->serializeType($name, $type, null, $use, $enc_style);
5773 $this->debug('no parameters passed.');
5776 $this->debug("serializeParameters returning: $xml");
5794 …$this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, un…
5795 $this->appendDebug("value=" . $this->varDump($value));
5797 $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
5802 if ($value->type_ns) {
5803 $type = $value->type_ns . ':' . $value->type;
5805 $this->debug("in serializeType: soapval overrides type to $type");
5806 } elseif ($value->type) {
5807 $type = $value->type;
5809 $this->debug("in serializeType: soapval overrides type to $type");
5812 $this->debug("in serializeType: soapval does not override type");
5814 $attrs = $value->attributes;
5815 $value = $value->value;
5816 $this->debug("in serializeType: soapval overrides value to $value");
5824 $this->debug("in serializeType: soapval provides attributes");
5834 $this->debug("in serializeType: got a prefixed type: $uqType, $ns");
5835 if ($this->getNamespaceFromPrefix($ns)) {
5836 $ns = $this->getNamespaceFromPrefix($ns);
5837 $this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
5840 if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
5841 $this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
5853 …$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$u…
5855 $this->debug("in serializeType: returning: $xml");
5860 return $this->serialize_val($value, $name, false, false, false, false, $use);
5870 // NEW BSP - Preventing to escape if string has a CDATA-Block
5871 if(strpos($value, "<![CDATA[") > -1)
5877 $value = $this->expandEntities($value);
5886 if (!$this->getTypeDef($uqType, $ns)) {
5889 …$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$…
5896 * if($this->getPrefixFromNamespace($ns) . ":" . $uqType == "xsd:string")
5898 …* $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodi…
5902 …* $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encod…
5905 …$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingS…
5907 $this->debug("in serializeType: returning: $xml");
5910 $this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
5911 } else if ($ns == 'http://xml.apache.org/xml-soap') {
5912 $this->debug('in serializeType: appears to be Apache SOAP type');
5914 $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
5916 $this->debug('in serializeType: Add namespace for Apache SOAP type');
5918 $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
5920 $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
5924 $this->debug("serializing map element: key $k, value $v");
5926 $contents .= $this->serialize_val($k,'key',false,false,false,false,$use);
5927 $contents .= $this->serialize_val($v,'value',false,false,false,false,$use);
5939 $this->debug("in serializeType: returning: $xml");
5942 $this->debug('in serializeType: Apache SOAP type, but only support Map');
5947 $this->debug("in serializeType: No namespace for type $type");
5951 if(!$typeDef = $this->getTypeDef($uqType, $ns)){
5952 $this->setError("$type ($uqType) is not a supported type.");
5953 $this->debug("in serializeType: $type ($uqType) is not a supported type.");
5956 $this->debug("in serializeType: found typeDef");
5957 $this->appendDebug('typeDef=' . $this->varDump($typeDef));
5958 if (substr($uqType, -1) == '^') {
5959 $uqType = substr($uqType, 0, -1);
5963 …$this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset…
5986 …$xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns)…
5988 $this->debug("in serializeType: returning: $xml");
5995 $elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
5998 …$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . "…
6003 …$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . "…
6006 … $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
6009 $this->debug("in serializeType: phpType is struct, but value is not an array");
6010 $this->setError("phpType is struct, but value is not an array: see debug output for details");
6029 $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
6031 $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
6033 $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
6035 $this->getLocalPart($typeDef['arrayType'])."[0]\"/>";
6037 $this->debug("in serializeType: returning: $xml");
6054 $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
6056 if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
6057 $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
6059 …$contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion…
6073 …$xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/so…
6074 $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
6076 .$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
6077 .":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">"
6093 …$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$…
6098 …$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingS…
6101 $this->debug("in serializeType: returning: $xml");
6118 $this->debug("serialize attributes for XML Schema type $ns:$uqType");
6124 $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
6130 $this->debug("value provided for attribute $aName with key $xname");
6133 $this->debug("value provided for attribute $aName with key $xname");
6137 $this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
6140 $this->debug("no value provided for attribute $aName");
6143 $xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
6147 $this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
6150 $ns = $this->getPrefix($typeDef['extensionBase']);
6151 $uqType = $this->getLocalPart($typeDef['extensionBase']);
6152 if ($this->getNamespaceFromPrefix($ns)) {
6153 $ns = $this->getNamespaceFromPrefix($ns);
6155 if ($typeDef = $this->getTypeDef($uqType, $ns)) {
6156 $this->debug("serialize attributes for extension base $ns:$uqType");
6157 $xml .= $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
6159 $this->debug("extension base $ns:$uqType is not a supported type");
6180 …$this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType"…
6186 $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
6189 // toggle whether all elements are present - ideally should validate against schema
6197 $this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
6206 …$this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minO…
6209 …$this->debug("no value provided for complexType element $eName and element is not nillable, so ser…
6222 …unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruc…
6226 // serialize schema-defined type
6227 …$xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $…
6230 $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
6231 $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
6236 // serialize schema-defined type
6237 …$xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $…
6240 $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
6241 $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
6247 $this->debug("no elements to serialize for XML Schema type $ns:$uqType");
6250 $ns = $this->getPrefix($typeDef['extensionBase']);
6251 $uqType = $this->getLocalPart($typeDef['extensionBase']);
6252 if ($this->getNamespaceFromPrefix($ns)) {
6253 $ns = $this->getNamespaceFromPrefix($ns);
6255 if ($typeDef = $this->getTypeDef($uqType, $ns)) {
6256 $this->debug("serialize elements for extension base $ns:$uqType");
6257 … $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
6259 $this->debug("extension base $ns:$uqType is not a supported type");
6274 …* @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]…
6286 $k = strpos($k,':') ? $this->expandQname($k) : $k;
6287 $v = strpos($v,':') ? $this->expandQname($v) : $v;
6299 $k = strpos($k,':') ? $this->expandQname($k) : $k;
6300 $v = strpos($v,':') ? $this->expandQname($v) : $v;
6308 …$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrict…
6309 $arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType;
6311 …$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'…
6312 …$this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,…
6327 …$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrict…
6329 …$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'…
6330 …$this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumerat…
6341 …$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'…
6342 $this->schemas[$typens][0]->addElement($attrs);
6369 $this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
6370 $this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
6377 $this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
6378 …$this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => …
6383 $this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] =
6386 'binding' => $this->serviceName . 'Binding',
6387 'endpoint' => $this->endpoint,
6412 … $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
6414 $this->messages[$name.'Request'][$pName] = $pType;
6417 $this->messages[$name.'Request']= '0';
6424 … $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
6426 $this->messages[$name.'Response'][$pName] = $pType;
6429 $this->messages[$name.'Response']= '0';
6480 // toggle for auto-decoding element content
6489 * @param string $decode_utf8 whether to decode UTF-8 to ISO-8859-1
6492 function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){
6494 $this->xml = $xml;
6495 $this->xml_encoding = $encoding;
6496 $this->method = $method;
6497 $this->decode_utf8 = $decode_utf8;
6504 $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1);
6508 …$err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declar…
6509 $this->debug($err);
6510 if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
6511 $this->setError($err);
6514 …// when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endp…
6516 $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration');
6519 $this->debug('No encoding specified in XML declaration');
6522 $this->debug('No XML declaration');
6524 $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding);
6525 // Create an XML parser - why not xml_parser_create_ns?
6526 $this->parser = xml_parser_create($this->xml_encoding);
6529 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
6530 xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
6532 xml_set_object($this->parser, $this);
6534 xml_set_element_handler($this->parser, 'start_element','end_element');
6535 xml_set_character_data_handler($this->parser,'character_data');
6538 if(!xml_parse($this->parser,$xml,true)){
6541 xml_get_current_line_number($this->parser),
6542 xml_error_string(xml_get_error_code($this->parser)));
6543 $this->debug($err);
6544 $this->debug("XML payload:\n" . $xml);
6545 $this->setError($err);
6547 …$this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root…
6549 $this->soapresponse = $this->message[$this->root_struct]['result'];
6551 if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){
6552 $this->soapheader = $this->message[$this->root_header]['result'];
6555 if(sizeof($this->multirefs) > 0){
6556 foreach($this->multirefs as $id => $hrefs){
6557 $this->debug('resolving multirefs for id: '.$id);
6558 $idVal = $this->buildVal($this->ids[$id]);
6563 $this->debug('resolving href at pos '.$refPos);
6564 $this->multirefs[$id][$refPos] = $idVal;
6569 xml_parser_free($this->parser);
6571 $this->debug('xml was empty, didn\'t parse!');
6572 $this->setError('xml was empty, didn\'t parse!');
6577 * start-element handler
6587 $pos = $this->position++;
6589 $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>'');
6592 $this->message[$pos]['depth'] = $this->depth++;
6596 $this->message[$this->parent]['children'] .= '|'.$pos;
6599 $this->message[$pos]['parent'] = $this->parent;
6601 $this->parent = $pos;
6603 $this->depth_array[$this->depth] = $pos;
6613 $this->status = 'envelope';
6614 } elseif($name == 'Header' && $this->status = 'envelope'){
6615 $this->root_header = $pos;
6616 $this->status = 'header';
6617 } elseif($name == 'Body' && $this->status = 'envelope'){
6618 $this->status = 'body';
6619 $this->body_position = $pos;
6621 } elseif($this->status == 'body' && $pos == ($this->body_position+1)){
6622 $this->status = 'method';
6623 $this->root_struct_name = $name;
6624 $this->root_struct = $pos;
6625 $this->message[$pos]['type'] = 'struct';
6626 $this->debug("found root struct $this->root_struct_name, pos $this->root_struct");
6629 $this->message[$pos]['status'] = $this->status;
6631 $this->message[$pos]['name'] = htmlspecialchars($name);
6633 $this->message[$pos]['attrs'] = $attrs;
6638 $key_prefix = $this->getPrefix($key);
6639 $key_localpart = $this->getLocalPart($key);
6642 if(ereg('^http://www.w3.org/[0-9]{4}/XMLSchema$',$value)){
6643 $this->XMLSchemaVersion = $value;
6644 $this->namespaces['xsd'] = $this->XMLSchemaVersion;
6645 $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance';
6647 $this->namespaces[$key_localpart] = $value;
6649 if($name == $this->root_struct_name){
6650 $this->methodNamespace = $value;
6654 if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') {
6657 $value_prefix = $this->getPrefix($value);
6658 $value_localpart = $this->getLocalPart($value);
6659 $this->message[$pos]['type'] = $value_localpart;
6660 $this->message[$pos]['typePrefix'] = $value_prefix;
6661 if(isset($this->namespaces[$value_prefix])){
6662 $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
6664 $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix];
6669 $this->message[$pos]['type'] = 'array';
6678 $expr = '([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]';
6680 $this->message[$pos]['typePrefix'] = $regs[1];
6681 $this->message[$pos]['arrayTypePrefix'] = $regs[1];
6682 if (isset($this->namespaces[$regs[1]])) {
6683 $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
6685 $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]];
6687 $this->message[$pos]['arrayType'] = $regs[2];
6688 $this->message[$pos]['arraySize'] = $regs[3];
6689 $this->message[$pos]['arrayCols'] = $regs[4];
6693 $this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
6696 $this->message[$pos]['xattrs']['!' . $key] = $value;
6700 $this->default_namespace = $value;
6704 $this->ids[$value] = $pos;
6708 $this->status = 'method';
6709 $this->root_struct_name = $name;
6710 $this->root_struct = $pos;
6711 $this->debug("found root struct $this->root_struct_name, pos $pos");
6716 // get namespace - must be done after namespace atts are processed
6718 $this->message[$pos]['namespace'] = $this->namespaces[$prefix];
6719 $this->default_namespace = $this->namespaces[$prefix];
6721 $this->message[$pos]['namespace'] = $this->default_namespace;
6723 if($this->status == 'header'){
6724 if ($this->root_header != $pos) {
6725 $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
6727 } elseif($this->root_struct_name != ''){
6728 $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
6733 * end-element handler
6741 $pos = $this->depth_array[$this->depth--];
6752 if(isset($this->body_position) && $pos > $this->body_position){
6754 if(isset($this->message[$pos]['attrs']['href'])){
6756 $id = substr($this->message[$pos]['attrs']['href'],1);
6758 $this->multirefs[$id][$pos] = 'placeholder';
6760 $this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
6762 } elseif($this->message[$pos]['children'] != ''){
6764 if(!isset($this->message[$pos]['result'])){
6765 $this->message[$pos]['result'] = $this->buildVal($pos);
6768 } elseif (isset($this->message[$pos]['xattrs'])) {
6769 if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
6770 $this->message[$pos]['xattrs']['!'] = null;
6771 } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
6772 if (isset($this->message[$pos]['type'])) {
6773->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message…
6775 $parent = $this->message[$pos]['parent'];
6776 …if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isse…
6777->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message…
6779 $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
6783 $this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
6786 …//$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->me…
6787 if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
6788 $this->message[$pos]['xattrs']['!'] = null;
6789 } elseif (isset($this->message[$pos]['type'])) {
6790->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos…
6792 $parent = $this->message[$pos]['parent'];
6793 …if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isse…
6794->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$par…
6796 $this->message[$pos]['result'] = $this->message[$pos]['cdata'];
6801 $parent = $this->message[$pos]['parent'];
6802 if($this->message[$parent]['type'] != 'map'){
6803 if(strtolower($this->message[$parent]['type']) == 'array'){
6804 $this->message[$parent]['result'][] = $this->message[$pos]['result'];
6806 … $this->message[$parent]['result'][$this->message[$pos]['name']] = $this->message[$pos]['result'];
6814 if($this->status == 'header'){
6815 if ($this->root_header != $pos) {
6816 $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
6818 } elseif($pos >= $this->root_struct){
6819 $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
6822 if($pos == $this->root_struct){
6823 $this->status = 'body';
6824 $this->root_struct_namespace = $this->message[$pos]['namespace'];
6826 $this->status = 'envelope';
6828 $this->status = 'envelope';
6833 $this->parent = $this->message[$pos]['parent'];
6844 $pos = $this->depth_array[$this->depth];
6845 if ($this->xml_encoding=='UTF-8'){
6847 // raw UTF-8 that, e.g., might not map to iso-8859-1
6848 …can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-885…
6849 if($this->decode_utf8){
6853 $this->message[$pos]['cdata'] .= $data;
6855 if($this->status == 'header'){
6856 $this->responseHeaders .= $data;
6858 $this->document .= $data;
6870 return $this->soapresponse;
6880 return $this->soapresponse;
6890 return $this->soapheader;
6900 return $this->responseHeaders;
6930 $this->debug('Decode base64 value');
6957 if(!isset($this->message[$pos]['type'])){
6958 $this->message[$pos]['type'] = '';
6960 …$this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->messag…
6962 if($this->message[$pos]['children'] != ''){
6963 $this->debug('in buildVal, there are children');
6964 $children = explode('|',$this->message[$pos]['children']);
6967 if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){
6971 $this->debug("in buildVal, got an MD array element: $r, $c");
6972 $params[$r][] = $this->message[$child_pos]['result'];
6974 if($c == $this->message[$pos]['arrayCols']){
6980 } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){
6981 $this->debug('in buildVal, adding array '.$this->message[$pos]['name']);
6983 $params[] = &$this->message[$child_pos]['result'];
6986 …} elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http:…
6987 $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']);
6989 $kv = explode("|",$this->message[$child_pos]['children']);
6990 $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
6993 …//} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct…
6996 …$this->debug('in buildVal, adding Java Vector or generic compound type '.$this->message[$pos]['nam…
6997 …if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://…
7005 $params[] = &$this->message[$child_pos]['result'];
7007 if (isset($params[$this->message[$child_pos]['name']])) {
7008 // de-serialize repeated element name into an array
7009 …if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$ch…
7010 … $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]);
7012 … $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result'];
7014 $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result'];
7019 if (isset($this->message[$pos]['xattrs'])) {
7020 $this->debug('in buildVal, handling attributes');
7021 foreach ($this->message[$pos]['xattrs'] as $n => $v) {
7026 if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
7027 $this->debug('in buildVal, handling simpleContent');
7028 if (isset($this->message[$pos]['type'])) {
7029 …!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this
7031 $parent = $this->message[$pos]['parent'];
7032 …if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isse…
7033 …this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($thi…
7035 $params['!'] = $this->message[$pos]['cdata'];
7040 $this->debug('in buildVal, return:');
7041 $this->appendDebug($this->varDump($ret));
7044 $this->debug('in buildVal, no children, building scalar');
7045 $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
7046 if (isset($this->message[$pos]['type'])) {
7047 …$ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_…
7048 $this->debug("in buildVal, return: $ret");
7051 $parent = $this->message[$pos]['parent'];
7052 …if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isse…
7053 …$ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$par…
7054 $this->debug("in buildVal, return: $ret");
7057 $ret = $this->message[$pos]['cdata'];
7058 $this->debug("in buildVal, return: $ret");
7084 * echo $soapclient->call( string methodname [ ,array parameters] );
7123 var $curl_options = array(); // User-specified cURL options
7167 $this->endpoint = $endpoint;
7168 $this->proxyhost = $proxyhost;
7169 $this->proxyport = $proxyport;
7170 $this->proxyusername = $proxyusername;
7171 $this->proxypassword = $proxypassword;
7172 $this->timeout = $timeout;
7173 $this->response_timeout = $response_timeout;
7175 $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
7176 $this->appendDebug('endpoint=' . $this->varDump($endpoint));
7181 $this->wsdl = $endpoint;
7182 $this->endpoint = $this->wsdl->wsdl;
7183 $this->wsdlFile = $this->endpoint;
7184 $this->debug('existing wsdl instance created from ' . $this->endpoint);
7185 $this->checkWSDL();
7187 $this->wsdlFile = $this->endpoint;
7188 $this->wsdl = null;
7189 $this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
7191 $this->endpointType = 'wsdl';
7193 $this->debug("instantiate SOAP with endpoint at $endpoint");
7194 $this->endpointType = 'soap';
7224 $this->operation = $operation;
7225 $this->fault = false;
7226 $this->setError('');
7227 $this->request = '';
7228 $this->response = '';
7229 $this->responseData = '';
7230 $this->faultstring = '';
7231 $this->faultcode = '';
7232 $this->opData = array();
7234 …is->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rp…
7235 $this->appendDebug('params=' . $this->varDump($params));
7236 $this->appendDebug('headers=' . $this->varDump($headers));
7238 $this->requestHeaders = $headers;
7240 if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
7241 $this->loadWSDL();
7242 if ($this->getError())
7246 if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
7248 $this->opData = $opData;
7249 $this->debug("found operation");
7250 $this->appendDebug('opData=' . $this->varDump($opData));
7254 if (! $this->forceEndpoint) {
7255 $this->endpoint = $opData['endpoint'];
7257 $this->endpoint = $this->forceEndpoint;
7263 if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
7265 $this->wsdl->namespaces[$nsPrefix] = $namespace;
7267 $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace);
7270 $this->debug("serializing param string for WSDL operation $operation");
7273 $this->debug("serializing param array for WSDL operation $operation");
7274 $payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType);
7276 $this->debug('params must be array or string');
7277 $this->setError('params must be array or string');
7280 $usedNamespaces = $this->wsdl->usedNamespaces;
7286 $this->appendDebug($this->wsdl->getDebug());
7287 $this->wsdl->clearDebug();
7288 if ($errstr = $this->wsdl->getError()) {
7289 $this->debug('got wsdl error: '.$errstr);
7290 $this->setError('wsdl error: '.$errstr);
7293 } elseif($this->endpointType == 'wsdl') {
7295 $this->appendDebug($this->wsdl->getDebug());
7296 $this->wsdl->clearDebug();
7297 $this->setError( 'operation '.$operation.' not present.');
7298 $this->debug("operation '$operation' not present.");
7302 //$this->namespaces['ns1'] = $namespace;
7307 $this->debug("serializing param string for operation $operation");
7310 $this->debug("serializing param array for operation $operation");
7312 $payload .= $this->serialize_val($v,$k,false,false,false,false,$use);
7315 $this->debug('params must be array or string');
7316 $this->setError('params must be array or string');
7329 $this->debug("wrapping RPC request with literal method element");
7331 …// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor e…
7339 $this->debug("wrapping RPC request with encoded method element");
7352 …$soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$en…
7353 …$this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style…
7354 …$this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($s…
7356 …$return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_time…
7357 if($errstr = $this->getError()){
7358 $this->debug('Error: '.$errstr);
7361 $this->return = $return;
7362 $this->debug('sent message successfully and got a(n) '.gettype($return));
7363 $this->appendDebug('return=' . $this->varDump($return));
7367 $this->debug('got fault');
7368 $this->setError($return['faultcode'].': '.$return['faultstring']);
7369 $this->fault = true;
7371 $this->$k = $v;
7372 $this->debug("$k = $v<br>");
7389 $this->debug('return shifted value: ');
7390 $this->appendDebug($this->varDump($return));
7406 $this->appendDebug($this->wsdl->getDebug());
7407 $this->wsdl->clearDebug();
7408 $this->debug('checkWSDL');
7410 if ($errstr = $this->wsdl->getError()) {
7411 $this->debug('got wsdl error: '.$errstr);
7412 $this->setError('wsdl error: '.$errstr);
7413 } elseif ($this->operations = $this->wsdl->getOperations('soap')) {
7414 $this->bindingType = 'soap';
7415 …$this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for bindin…
7416 } elseif ($this->operations = $this->wsdl->getOperations('soap12')) {
7417 $this->bindingType = 'soap12';
7418 …$this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for bindin…
7419 $this->debug('**************** WARNING: SOAP 1.2 BINDING *****************');
7421 $this->debug('getOperations returned false');
7422 $this->setError('no operations defined in the WSDL document!');
7432 $this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
7433->wsdl =& new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,…
7434 …$this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest);
7435 $this->wsdl->fetchWSDL($this->wsdlFile);
7436 $this->checkWSDL();
7447 if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
7448 $this->loadWSDL();
7449 if ($this->getError())
7452 if(isset($this->operations[$operation])){
7453 return $this->operations[$operation];
7455 $this->debug("No data for operation: $operation");
7473 $this->checkCookies();
7477 case ereg('^http',$this->endpoint):
7478 $this->debug('transporting via HTTP');
7479 if($this->persistentConnection == true && is_object($this->persistentConnection)){
7480 $http =& $this->persistentConnection;
7482 $http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl);
7483 if ($this->persistentConnection) {
7484 $http->usePersistentConnection();
7487 $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset());
7488 $http->setSOAPAction($soapaction);
7489 if($this->proxyhost && $this->proxyport){
7490 $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
7492 if($this->authtype != '') {
7493 …$http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certReque…
7495 if($this->http_encoding != ''){
7496 $http->setEncoding($this->http_encoding);
7498 $this->debug('sending message, length='.strlen($msg));
7499 if(ereg('^http:',$this->endpoint)){
7500 //if(strpos($this->endpoint,'http:')){
7501 $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies);
7502 } elseif(ereg('^https',$this->endpoint)){
7503 //} elseif(strpos($this->endpoint,'https:')){
7504 //if(phpversion() == '4.3.0-dev'){
7505 //$response = $http->send($msg,$timeout,$response_timeout);
7506 //$this->request = $http->outgoing_payload;
7507 //$this->response = $http->incoming_payload;
7509 $this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies);
7511 $this->setError('no http/s in endpoint url');
7513 $this->request = $http->outgoing_payload;
7514 $this->response = $http->incoming_payload;
7515 $this->appendDebug($http->getDebug());
7516 $this->UpdateCookies($http->incoming_cookies);
7519 if ($this->persistentConnection) {
7520 $http->clearDebug();
7521 if (!is_object($this->persistentConnection)) {
7522 $this->persistentConnection = $http;
7526 if($err = $http->getError()){
7527 $this->setError('HTTP Error: '.$err);
7529 } elseif($this->getError()){
7532 …$this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers…
7533 return $this->parseResponse($http->incoming_headers, $this->responseData);
7537 $this->setError('no transport found, or selected transport is not yet supported!');
7552 $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
7553 $this->appendDebug($this->varDump($headers));
7554 if (!strstr($headers['content-type'], 'text/xml')) {
7555 $this->setError('Response not of type text/xml: ' . $headers['content-type']);
7558 if (strpos($headers['content-type'], '=')) {
7559 $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
7560 $this->debug('Got response encoding: ' . $enc);
7561 if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
7562 $this->xml_encoding = strtoupper($enc);
7564 $this->xml_encoding = 'US-ASCII';
7567 // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
7568 $this->xml_encoding = 'ISO-8859-1';
7570 $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
7571 $parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8);
7572 // add parser debug data to our debug
7573 $this->appendDebug($parser->getDebug());
7575 if($errstr = $parser->getError()){
7576 $this->setError( $errstr);
7582 $this->responseHeaders = $parser->getHeaders();
7584 $this->responseHeader = $parser->get_soapheader();
7586 $return = $parser->get_soapbody();
7588 $this->document = $parser->document;
7597 * sets user-specified cURL options
7604 $this->debug("setCurlOption option=$option, value=");
7605 $this->appendDebug($this->varDump($value));
7606 $this->curl_options[$option] = $value;
7616 $this->debug("setEndpoint(\"$endpoint\")");
7617 $this->forceEndpoint = $endpoint;
7627 $this->debug("setHeaders headers=");
7628 $this->appendDebug($this->varDump($headers));
7629 $this->requestHeaders = $headers;
7639 return $this->responseHeaders;
7649 return $this->responseHeader;
7662 $this->proxyhost = $proxyhost;
7663 $this->proxyport = $proxyport;
7664 $this->proxyusername = $proxyusername;
7665 $this->proxypassword = $proxypassword;
7678 $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
7679 $this->appendDebug($this->varDump($certRequest));
7680 $this->username = $username;
7681 $this->password = $password;
7682 $this->authtype = $authtype;
7683 $this->certRequest = $certRequest;
7693 $this->debug("setHTTPEncoding(\"$enc\")");
7694 $this->http_encoding = $enc;
7704 $this->debug("setUseCURL($use)");
7705 $this->use_curl = $use;
7714 $this->debug("useHTTPPersistentConnection");
7715 $this->persistentConnection = true;
7730 return $this->defaultRpcParams;
7745 $this->defaultRpcParams = $rpcParams;
7757 $evalStr = $this->_getProxyClassCode($r);
7758 //$this->debug("proxy class: $evalStr");
7759 if ($this->getError()) {
7760 $this->debug("Error from _getProxyClassCode, so return NULL");
7768 $proxy->endpointType = 'wsdl';
7769 $proxy->wsdlFile = $this->wsdlFile;
7770 $proxy->wsdl = $this->wsdl;
7771 $proxy->operations = $this->operations;
7772 $proxy->defaultRpcParams = $this->defaultRpcParams;
7774 $proxy->soap_defencoding = $this->soap_defencoding;
7775 $proxy->username = $this->username;
7776 $proxy->password = $this->password;
7777 $proxy->authtype = $this->authtype;
7778 $proxy->certRequest = $this->certRequest;
7779 $proxy->requestHeaders = $this->requestHeaders;
7780 $proxy->endpoint = $this->endpoint;
7781 $proxy->forceEndpoint = $this->forceEndpoint;
7782 $proxy->proxyhost = $this->proxyhost;
7783 $proxy->proxyport = $this->proxyport;
7784 $proxy->proxyusername = $this->proxyusername;
7785 $proxy->proxypassword = $this->proxypassword;
7786 $proxy->http_encoding = $this->http_encoding;
7787 $proxy->timeout = $this->timeout;
7788 $proxy->response_timeout = $this->response_timeout;
7789 $proxy->persistentConnection = &$this->persistentConnection;
7790 $proxy->decode_utf8 = $this->decode_utf8;
7791 $proxy->curl_options = $this->curl_options;
7792 $proxy->bindingType = $this->bindingType;
7793 $proxy->use_curl = $this->use_curl;
7804 $this->debug("in getProxy endpointType=$this->endpointType");
7805 $this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
7806 if ($this->endpointType != 'wsdl') {
7808 $this->setError($evalStr);
7812 if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
7813 $this->loadWSDL();
7814 if ($this->getError()) {
7815 return "echo \"" . $this->getError() . "\";";
7819 foreach ($this->operations as $operation => $opData) {
7831 $paramStr = substr($paramStr, 0, strlen($paramStr)-2);
7832 $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2);
7833 $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2);
7843 …return \$this->call('$operation', \$params, '".$opData['namespace']."', '".(isset($opData['soapAct…
7864 return $this->_getProxyClassCode($r);
7892 * returns false for non-text content types.
7900 return $this->soap_defencoding;
7910 $this->decode_utf8 = $bool;
7915 * adds a new Cookie into $this->cookies array
7919 * @return boolean if cookie-set was successful returns true, else false
7926 $this->cookies[] = array('name' => $name, 'value' => $value);
7937 return $this->cookies;
7947 if (sizeof($this->cookies) == 0) {
7950 $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
7951 $curr_cookies = $this->cookies;
7952 $this->cookies = array();
7955 $this->debug('Remove cookie that is not an array');
7960 $this->cookies[] = $cookie;
7962 $this->debug('Remove expired cookie ' . $cookie['name']);
7965 $this->cookies[] = $cookie;
7968 $this->debug('checkCookie: '.sizeof($this->cookies).' cookies left in array');
7980 if (sizeof($this->cookies) == 0) {
7983 $this->debug('Setting new cookie(s)');
7984 $this->cookies = $cookies;
8003 for ($i = 0; $i < count($this->cookies); $i++) {
8004 $cookie = $this->cookies[$i];
8024 $this->cookies[$i] = $newCookie;
8026 $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
8030 $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
8031 $this->cookies[] = $newCookie;