For backwards compatiblity, define soapclient unless the PHP SOAP extension is loaded.
1013{
1014 $start = gettimeofday();
1015
1016 do {
1017 $stop = gettimeofday();
1018 $timePassed = 1000000 * ($stop['sec'] - $start['sec'])
1019 + $stop['usec'] - $start['usec'];
1020 } while ($timePassed < $usec);
1021}
1022
1023?><?php
1024
1025
1026
1036{
1061
1071 {
1077 }
1078
1086 {
1087 $ns_string = '';
1088 foreach ($this->namespaces as $k => $v) {
1089 $ns_string .= "\n xmlns:$k=\"$v\"";
1090 }
1091 $return_msg =
1092 '<?xml version="1.0" encoding="' . $this->soap_defencoding . '"?>' .
1093 '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"' . $ns_string . ">\n" .
1094 '<SOAP-ENV:Body>' .
1095 '<SOAP-ENV:Fault>' .
1100 '</SOAP-ENV:Fault>' .
1101 '</SOAP-ENV:Body>' .
1102 '</SOAP-ENV:Envelope>';
1103 return $return_msg;
1104 }
1105}
1106
1111{
1112}
1113
1114?><?php
1115
1116
1117
1128{
1129
1132
1134
1137
1148
1150
1157
1167 {
1169 $this->
debug(
'nusoap_xmlschema class instantiated, inside constructor');
1170
1173
1174
1176 $this->namespaces = array_merge($this->namespaces,
$namespaces);
1177
1178
1180 $this->
debug(
'initial schema file: ' . $schema);
1182 }
1183
1184
1186 $this->
debug(
'initial xml file: ' .
$xml);
1188 }
1189 }
1190
1200 {
1201
1203 $xmlStr = @join(
"", @file(
$xml));
1204 if ($xmlStr == "") {
1205 $msg =
'Error reading XML from ' .
$xml;
1208 return false;
1209 } else {
1210 $this->
debug(
"parsing $xml");
1212 $this->
debug(
"done parsing $xml");
1213 return true;
1214 }
1215 }
1216 return false;
1217 }
1218
1227 {
1228
1230
1231
1232 $this->parser = xml_parser_create();
1233
1234 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
1235
1236
1237 xml_set_object($this->parser, $this);
1238
1239
1240 if (
$type ==
"schema") {
1241 xml_set_element_handler($this->parser, 'schemaStartElement', 'schemaEndElement');
1242 xml_set_character_data_handler($this->parser, 'schemaCharacterData');
1243 } elseif (
$type ==
"xml") {
1244 xml_set_element_handler($this->parser, 'xmlStartElement', 'xmlEndElement');
1245 xml_set_character_data_handler($this->parser, 'xmlCharacterData');
1246 }
1247
1248
1249 if (!xml_parse($this->parser,
$xml,
true)) {
1250
1251 $errstr = sprintf(
1252 'XML error parsing XML schema on line %d: %s',
1253 xml_get_current_line_number($this->parser),
1254 xml_error_string(xml_get_error_code($this->parser))
1255 );
1256 $this->
debug($errstr);
1259 }
1260
1261 xml_parser_free($this->parser);
1262 } else {
1263 $this->
debug(
'no xml passed to parseString()!!');
1264 $this->
setError(
'no xml passed to parseString()!!');
1265 }
1266 }
1267
1276 {
1278 for (
$i = 0;
$i < count($this->complexTypeStack);
$i++) {
1279 $scope .= $this->complexTypeStack[
$i] .
'_';
1280 }
1281 return $scope . $ename .
'_ContainedType';
1282 }
1283
1293 {
1294
1295
1296 $pos = $this->position++;
1298
1299 $this->depth_array[
$depth] = $pos;
1300 $this->message[$pos] = array('cdata' => '');
1302 $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[
$depth - 1]];
1303 } else {
1304 $this->defaultNamespace[$pos] = false;
1305 }
1306
1307
1309
1311 } else {
1312 $prefix = '';
1313 }
1314
1315
1316 if (count($attrs) > 0) {
1317 foreach ($attrs as $k => $v) {
1318
1319 if (preg_match('/^xmlns/', $k)) {
1320
1321
1322 if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
1323
1324 $this->namespaces[$ns_prefix] = $v;
1325 } else {
1326 $this->defaultNamespace[$pos] = $v;
1328 $this->namespaces['ns' . (count($this->namespaces)+1)] = $v;
1329 }
1330 }
1331 if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
1332 $this->XMLSchemaVersion = $v;
1333 $this->namespaces['xsi'] = $v . '-instance';
1334 }
1335 }
1336 }
1337 foreach ($attrs as $k => $v) {
1338
1339 $k = strpos($k,
':') ? $this->
expandQname($k) : $k;
1340 $v = strpos($v,
':') ? $this->
expandQname($v) : $v;
1341 $eAttrs[$k] = $v;
1342 }
1343 $attrs = $eAttrs;
1344 } else {
1345 $attrs = array();
1346 }
1347
1349 case 'all':
1350 case 'choice':
1351 case 'group':
1352 case 'sequence':
1353
1355
1356
1357
1358 break;
1359 case 'attribute':
1360
1361 $this->
xdebug(
"parsing attribute:");
1363 if (!isset($attrs['form'])) {
1364 $attrs['form'] = $this->schemaInfo['attributeFormDefault'];
1365 }
1366 if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
1367 $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
1368 if (!strpos($v, ':')) {
1369
1370 if ($this->defaultNamespace[$pos]) {
1371
1372 $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
1373 }
1374 }
1375 }
1376 if (isset($attrs['name'])) {
1377 $this->attributes[$attrs['name']] = $attrs;
1378 $aname = $attrs['name'];
1379 } elseif (isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType') {
1380 if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
1381 $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
1382 } else {
1383 $aname = '';
1384 }
1385 } elseif (isset($attrs['ref'])) {
1386 $aname = $attrs['ref'];
1387 $this->attributes[$attrs['ref']] = $attrs;
1388 }
1389
1390 if ($this->currentComplexType) {
1392 }
1393
1394 if (isset($attrs[
'http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->
getLocalPart($aname) ==
'arrayType') {
1397 if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
1398 $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
1399 } else {
1400 $v = '';
1401 }
1402 if (strpos($v, '[,]')) {
1404 }
1405 $v = substr($v, 0, strpos($v, '['));
1406 if (!strpos($v, ':') && isset($this->typemap[$this->XMLSchemaVersion][$v])) {
1407 $v = $this->XMLSchemaVersion . ':' . $v;
1408 }
1410 }
1411 break;
1412 case 'complexContent':
1413 break;
1414 case 'complexType':
1415 array_push($this->complexTypeStack, $this->currentComplexType);
1416 if (isset($attrs['name'])) {
1417
1418
1419 $this->
xdebug(
'processing named complexType ' . $attrs[
'name']);
1420
1421 $this->currentComplexType = $attrs['name'];
1424
1425
1426
1427
1428
1429
1430
1431 if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
1432 $this->
xdebug(
'complexType is unusual array');
1434 } else {
1436 }
1437 } else {
1439 $this->
xdebug(
'processing unnamed complexType for element ' . $this->currentElement .
' named ' .
$name);
1440 $this->currentComplexType =
$name;
1441
1444
1445
1446
1447
1448
1449
1450
1451 if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
1452 $this->
xdebug(
'complexType is unusual array');
1454 } else {
1456 }
1457 }
1458 break;
1459 case 'element':
1460 array_push($this->elementStack, $this->currentElement);
1461 if (!isset($attrs['form'])) {
1462 $attrs['form'] = $this->schemaInfo['elementFormDefault'];
1463 }
1464 if (isset($attrs['type'])) {
1465 $this->
xdebug(
"processing typed element " . $attrs[
'name'] .
" of type " . $attrs[
'type']);
1466 if (! $this->
getPrefix($attrs[
'type'])) {
1467 if ($this->defaultNamespace[$pos]) {
1468 $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type'];
1469 $this->
xdebug(
'used default namespace to make type ' . $attrs[
'type']);
1470 }
1471 }
1472
1473
1474
1475
1476
1477
1478
1479 if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
1480 $this->
xdebug(
'arrayType for unusual array is ' . $attrs[
'type']);
1482 }
1483 $this->currentElement = $attrs['name'];
1484 $ename = $attrs['name'];
1485 } elseif (isset($attrs['ref'])) {
1486 $this->
xdebug(
"processing element as ref to " . $attrs[
'ref']);
1487 $this->currentElement = "ref to " . $attrs['ref'];
1489 } else {
1491 $this->
xdebug(
"processing untyped element " . $attrs[
'name'] .
' type ' .
$type);
1492 $this->currentElement = $attrs['name'];
1493 $attrs[
'type'] = $this->schemaTargetNamespace .
':' .
$type;
1494 $ename = $attrs['name'];
1495 }
1496 if (isset($ename) && $this->currentComplexType) {
1497 $this->
xdebug(
"add element $ename to complexType $this->currentComplexType");
1499 } elseif (!isset($attrs['ref'])) {
1500 $this->
xdebug(
"add element $ename to elements array");
1501 $this->elements[ $attrs['name'] ] = $attrs;
1502 $this->elements[ $attrs['name'] ]['typeClass'] = 'element';
1503 }
1504 break;
1505 case 'enumeration':
1506 $this->
xdebug(
'enumeration ' . $attrs[
'value']);
1507 if ($this->currentSimpleType) {
1509 } elseif ($this->currentComplexType) {
1511 }
1512 break;
1513 case 'extension':
1514 $this->
xdebug(
'extension ' . $attrs[
'base']);
1515 if ($this->currentComplexType) {
1517 }
1518 break;
1519 case 'import':
1520 if (isset($attrs['schemaLocation'])) {
1521
1522 $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
1523 } else {
1524
1525 $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
1527 $this->namespaces['ns' . (count($this->namespaces)+1)] = $attrs['namespace'];
1528 }
1529 }
1530 break;
1531 case 'list':
1532 break;
1533 case 'restriction':
1534 $this->
xdebug(
'restriction ' . $attrs[
'base']);
1535 if ($this->currentSimpleType) {
1537 } elseif ($this->currentComplexType) {
1539 if (strstr($attrs['base'], ':') == ':Array') {
1541 }
1542 }
1543 break;
1544 case 'schema':
1545 $this->schemaInfo = $attrs;
1547 if (isset($attrs['targetNamespace'])) {
1548 $this->schemaTargetNamespace = $attrs['targetNamespace'];
1549 }
1550 if (!isset($attrs['elementFormDefault'])) {
1551 $this->schemaInfo['elementFormDefault'] = 'unqualified';
1552 }
1553 if (!isset($attrs['attributeFormDefault'])) {
1554 $this->schemaInfo['attributeFormDefault'] = 'unqualified';
1555 }
1556 break;
1557 case 'simpleContent':
1558 break;
1559 case 'simpleType':
1560 array_push($this->simpleTypeStack, $this->currentSimpleType);
1561 if (isset($attrs['name'])) {
1562 $this->
xdebug(
"processing simpleType for name " . $attrs[
'name']);
1563 $this->currentSimpleType = $attrs['name'];
1564 $this->simpleTypes[ $attrs['name'] ] = $attrs;
1565 $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType';
1566 $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar';
1567 } else {
1569 $this->
xdebug(
'processing unnamed simpleType for element ' . $this->currentElement .
' named ' .
$name);
1570 $this->currentSimpleType =
$name;
1571
1574 }
1575 break;
1576 case 'union':
1577 break;
1578 default:
1579
1580 }
1581 }
1582
1591 {
1592
1593 $this->depth--;
1594
1595 if (isset($this->depth_array[$this->depth])) {
1597 }
1598
1600
1602 } else {
1603 $prefix = '';
1604 }
1605
1606 if (
$name ==
'complexType') {
1607 $this->
xdebug(
'done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType :
'(unknown)'));
1608 $this->currentComplexType = array_pop($this->complexTypeStack);
1609
1610 }
1611 if (
$name ==
'element') {
1612 $this->
xdebug(
'done processing element ' . ($this->currentElement ? $this->currentElement :
'(unknown)'));
1613 $this->currentElement = array_pop($this->elementStack);
1614 }
1615 if (
$name ==
'simpleType') {
1616 $this->
xdebug(
'done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType :
'(unknown)'));
1617 $this->currentSimpleType = array_pop($this->simpleTypeStack);
1618 }
1619 }
1620
1629 {
1630 $pos = $this->depth_array[$this->depth - 1];
1631 $this->message[$pos][
'cdata'] .=
$data;
1632 }
1633
1640 {
1643
1644 if (sizeof($this->imports) > 0) {
1645 foreach ($this->imports as $ns => $list) {
1646 foreach ($list as $ii) {
1647 if ($ii['location'] != '') {
1648 $xml .=
" <$schemaPrefix:import location=\"" . $ii[
'location'] .
'" namespace="' . $ns .
"\" />\n";
1649 } else {
1650 $xml .=
" <$schemaPrefix:import namespace=\"" . $ns .
"\" />\n";
1651 }
1652 }
1653 }
1654 }
1655
1656 foreach ($this->complexTypes as $typeName => $attrs) {
1657 $contentStr = '';
1658
1659 if (isset($attrs['elements']) && (count($attrs['elements']) > 0)) {
1660 foreach ($attrs['elements'] as $element => $eParts) {
1661 if (isset($eParts['ref'])) {
1662 $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n";
1663 } else {
1664 $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"";
1665 foreach ($eParts as $aName => $aValue) {
1666
1667 if ($aName != 'name' && $aName != 'type') {
1668 $contentStr .= " $aName=\"$aValue\"";
1669 }
1670 }
1671 $contentStr .= "/>\n";
1672 }
1673 }
1674
1675 if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) {
1676 $contentStr = " <$schemaPrefix:$attrs[compositor]>\n" . $contentStr . " </$schemaPrefix:$attrs[compositor]>\n";
1677 }
1678 }
1679
1680 if (isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)) {
1681 foreach ($attrs['attrs'] as $attr => $aParts) {
1682 $contentStr .= " <$schemaPrefix:attribute";
1683 foreach ($aParts as
$a => $v) {
1684 if (
$a ==
'ref' ||
$a ==
'type') {
1685 $contentStr .= " $a=\"" . $this->contractQName($v) . '"';
1686 } elseif (
$a ==
'http://schemas.xmlsoap.org/wsdl/:arrayType') {
1687 $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl'];
1688 $contentStr .= ' wsdl:arrayType="' . $this->contractQName($v) . '"';
1689 } else {
1690 $contentStr .= " $a=\"$v\"";
1691 }
1692 }
1693 $contentStr .= "/>\n";
1694 }
1695 }
1696
1697 if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != '') {
1698 $contentStr = " <$schemaPrefix:restriction base=\"" . $this->contractQName($attrs['restrictionBase']) . "\">\n" . $contentStr . " </$schemaPrefix:restriction>\n";
1699
1700 if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)) {
1701 $contentStr = " <$schemaPrefix:complexContent>\n" . $contentStr . " </$schemaPrefix:complexContent>\n";
1702 }
1703 }
1704
1705 if ($contentStr != '') {
1706 $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n" . $contentStr . " </$schemaPrefix:complexType>\n";
1707 } else {
1708 $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n";
1709 }
1710 $xml .= $contentStr;
1711 }
1712
1713 if (isset($this->simpleTypes) && count($this->simpleTypes) > 0) {
1714 foreach ($this->simpleTypes as $typeName => $eParts) {
1715 $xml .=
" <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"" . $this->contractQName($eParts[
'type']) .
"\">\n";
1716 if (isset($eParts['enumeration'])) {
1717 foreach ($eParts[
'enumeration'] as
$e) {
1718 $xml .=
" <$schemaPrefix:enumeration value=\"$e\"/>\n";
1719 }
1720 }
1721 $xml .=
" </$schemaPrefix:restriction>\n </$schemaPrefix:simpleType>";
1722 }
1723 }
1724
1725 if (isset($this->elements) && count($this->elements) > 0) {
1726 foreach ($this->elements as $element => $eParts) {
1727 $xml .=
" <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts[
'type']) .
"\"/>\n";
1728 }
1729 }
1730
1731 if (isset($this->attributes) && count($this->attributes) > 0) {
1732 foreach ($this->attributes as $attr => $aParts) {
1733 $xml .=
" <$schemaPrefix:attribute name=\"$attr\" type=\"" . $this->contractQName($aParts[
'type']) .
"\"\n/>";
1734 }
1735 }
1736
1737 $attr = '';
1738 foreach ($this->schemaInfo as $k => $v) {
1739 if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') {
1740 $attr .= " $k=\"$v\"";
1741 }
1742 }
1743 $el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n";
1744 foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
1745 $el .= " xmlns:$nsp=\"$ns\"";
1746 }
1747 $xml = $el .
">\n" .
$xml .
"</$schemaPrefix:schema>\n";
1749 }
1750
1757 public function xdebug($string)
1758 {
1759 $this->
debug(
'<' . $this->schemaTargetNamespace .
'> ' . $string);
1760 }
1761
1775 {
1776 if (isset($this->typemap[$ns][
$type])) {
1777
1778 return $this->typemap[$ns][
$type];
1779 } elseif (isset($this->complexTypes[
$type])) {
1780
1781 return $this->complexTypes[
$type][
'phpType'];
1782 }
1783 return false;
1784 }
1785
1809 {
1810
1811 if (substr(
$type, -1) ==
'^') {
1812 $is_element = 1;
1814 } else {
1815 $is_element = 0;
1816 }
1817
1818 if ((! $is_element) && isset($this->complexTypes[
$type])) {
1819 $this->
xdebug(
"in getTypeDef, found complexType $type");
1820 return $this->complexTypes[
$type];
1821 } elseif ((! $is_element) && isset($this->simpleTypes[
$type])) {
1822 $this->
xdebug(
"in getTypeDef, found simpleType $type");
1823 if (!isset($this->simpleTypes[
$type][
'phpType'])) {
1824
1825
1826 $uqType = substr($this->simpleTypes[
$type][
'type'], strrpos($this->simpleTypes[
$type][
'type'],
':') + 1);
1827 $ns = substr($this->simpleTypes[
$type][
'type'], 0, strrpos($this->simpleTypes[
$type][
'type'],
':'));
1829 if ($etype) {
1830 $this->
xdebug(
"in getTypeDef, found type for simpleType $type:");
1832 if (isset($etype['phpType'])) {
1833 $this->simpleTypes[
$type][
'phpType'] = $etype[
'phpType'];
1834 }
1835 if (isset($etype['elements'])) {
1836 $this->simpleTypes[
$type][
'elements'] = $etype[
'elements'];
1837 }
1838 }
1839 }
1840 return $this->simpleTypes[
$type];
1841 } elseif (isset($this->elements[
$type])) {
1842 $this->
xdebug(
"in getTypeDef, found element $type");
1843 if (!isset($this->elements[
$type][
'phpType'])) {
1844
1845 $uqType = substr($this->elements[
$type][
'type'], strrpos($this->elements[
$type][
'type'],
':') + 1);
1846 $ns = substr($this->elements[
$type][
'type'], 0, strrpos($this->elements[
$type][
'type'],
':'));
1848 if ($etype) {
1849 $this->
xdebug(
"in getTypeDef, found type for element $type:");
1851 if (isset($etype['phpType'])) {
1852 $this->elements[
$type][
'phpType'] = $etype[
'phpType'];
1853 }
1854 if (isset($etype['elements'])) {
1855 $this->elements[
$type][
'elements'] = $etype[
'elements'];
1856 }
1857 } elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
1858 $this->
xdebug(
"in getTypeDef, element $type is an XSD type");
1859 $this->elements[
$type][
'phpType'] =
'scalar';
1860 }
1861 }
1862 return $this->elements[
$type];
1863 } elseif (isset($this->attributes[
$type])) {
1864 $this->
xdebug(
"in getTypeDef, found attribute $type");
1865 return $this->attributes[
$type];
1866 } elseif (preg_match(
'/_ContainedType$/',
$type)) {
1867 $this->
xdebug(
"in getTypeDef, have an untyped element $type");
1868 $typeDef['typeClass'] = 'simpleType';
1869 $typeDef['phpType'] = 'scalar';
1870 $typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string';
1871 return $typeDef;
1872 }
1873 $this->
xdebug(
"in getTypeDef, did not find $type");
1874 return false;
1875 }
1876
1886 {
1887
1889 $str .=
'<' .
$type;
1890 if (is_array($typeDef['attrs'])) {
1891 foreach ($typeDef[
'attrs'] as $attName =>
$data) {
1892 $str .=
" $attName=\"{type = " .
$data[
'type'] .
"}\"";
1893 }
1894 }
1895 $str .= " xmlns=\"" . $this->schema['targetNamespace'] . "\"";
1896 if (count($typeDef['elements']) > 0) {
1897 $str .= ">";
1898 foreach ($typeDef['elements'] as $element => $eData) {
1900 }
1901 $str .= "</$type>";
1902 } elseif ($typeDef['typeClass'] == 'element') {
1903 $str .= "></$type>";
1904 } else {
1905 $str .= "/>";
1906 }
1907 return $str;
1908 }
1909 return false;
1910 }
1911
1923 {
1924
1926
1927 if ($typeDef['phpType'] == 'struct') {
1928 $buffer .= '<table>';
1929 foreach ($typeDef['elements'] as $child => $childDef) {
1930 $buffer .= "
1931 <tr><td align='right'>$childDef[name] (type: " . $this->
getLocalPart($childDef[
'type']) .
"):</td>
1932 <td><input type='text' name='parameters[" .
$name .
"][$childDef[name]]'></td></tr>";
1933 }
1934 $buffer .= '</table>';
1935
1936 } elseif ($typeDef['phpType'] == 'array') {
1937 $buffer .= '<table>';
1938 for (
$i=0;
$i < 3;
$i++) {
1939 $buffer .= "
1940 <tr><td align='right'>array item (type: $typeDef[arrayType]):</td>
1941 <td><input type='text' name='parameters[" .
$name .
"][]'></td></tr>";
1942 }
1943 $buffer .= '</table>';
1944
1945 } else {
1946 $buffer .= "<input type='text' name='parameters[$name]'>";
1947 }
1948 } else {
1949 $buffer .= "<input type='text' name='parameters[$name]'>";
1950 }
1951 return $buffer;
1952 }
1953
1995 public function addComplexType(
$name, $typeClass=
'complexType', $phpType=
'array', $compositor=
'', $restrictionBase=
'',
$elements=array(), $attrs=array(), $arrayType=
'')
1996 {
1997 $this->complexTypes[
$name] = array(
1999 'typeClass' => $typeClass,
2000 'phpType' => $phpType,
2001 'compositor'=> $compositor,
2002 'restrictionBase' => $restrictionBase,
2004 'attrs' => $attrs,
2005 'arrayType' => $arrayType
2006 );
2007
2008 $this->
xdebug(
"addComplexType $name:");
2010 }
2011
2024 public function addSimpleType(
$name, $restrictionBase=
'', $typeClass=
'simpleType', $phpType=
'scalar', $enumeration=array())
2025 {
2026 $this->simpleTypes[
$name] = array(
2028 'typeClass' => $typeClass,
2029 'phpType' => $phpType,
2030 'type' => $restrictionBase,
2031 'enumeration' => $enumeration
2032 );
2033
2034 $this->
xdebug(
"addSimpleType $name:");
2036 }
2037
2046 {
2047 if (! $this->
getPrefix($attrs[
'type'])) {
2048 $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type'];
2049 }
2050 $this->elements[ $attrs['name'] ] = $attrs;
2051 $this->elements[ $attrs['name'] ]['typeClass'] = 'element';
2052
2053 $this->
xdebug(
"addElement " . $attrs[
'name']);
2055 }
2056}
2057
2062{
2063}
2064
2065?><?php
2066
2067
2068
2081{
2124
2137 {
2139 $this->name =
$name;
2140 $this->type =
$type;
2145 }
2146
2154 public function serialize($use=
'encoded')
2155 {
2156 return $this->
serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use,
true);
2157 }
2158
2166 {
2168 }
2169}
2170
2171
2172
2173?><?php
2174
2175
2176
2187{
2215
2216
2217
2218
2219
2220
2221
2222
2232 {
2234 $this->
debug(
"ctor url=$url use_curl=$use_curl curl_options:");
2237 if (is_array($curl_options)) {
2238 $this->ch_options = $curl_options;
2239 }
2241 preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
2242
2243 $this->
setHeader(
'User-Agent', $this->title .
'/' . $this->version .
' (' . ($rev[1] ??
'1.1') .
')');
2244 }
2245
2254 {
2255 $this->
debug(
"setCurlOption option=$option, value=");
2257 curl_setopt($this->ch, $option, $value);
2258 }
2259
2268 {
2269 $this->outgoing_headers[
$name] = $value;
2270 $this->
debug(
"set header $name: $value");
2271 }
2272
2280 {
2281 if (isset($this->outgoing_headers[
$name])) {
2282 $this->
debug(
"unset header $name");
2283 unset($this->outgoing_headers[
$name]);
2284 }
2285 }
2286
2294 {
2296
2297 $u = parse_url(
$url);
2298 foreach ($u as $k => $v) {
2299 $this->
debug(
"parsed URL $k = $v");
2300 $this->$k = $v;
2301 }
2302
2303
2304 if (isset($u['query']) && $u['query'] != '') {
2305 $this->path .= '?' . $u['query'];
2306 }
2307
2308
2309 if (!isset($u['port'])) {
2310 if ($u['scheme'] == 'https') {
2311 $this->port = 443;
2312 } else {
2313 $this->port = 80;
2314 }
2315 }
2316
2319
2320
2321 if (!isset($u['port'])) {
2323 } else {
2324 $this->
setHeader(
'Host', $this->host .
':' . $this->port);
2325 }
2326
2327 if (isset($u['user']) && $u['user'] != '') {
2328 $this->
setCredentials(urldecode($u[
'user']), isset($u[
'pass']) ? urldecode($u[
'pass']) :
'');
2329 }
2330 }
2331
2339 {
2340 if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) {
2341 return 'curl';
2342 }
2343 if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) {
2344 return 'socket';
2345 }
2346 return 'unknown';
2347 }
2348
2357 public function connect($connection_timeout=0, $response_timeout=30)
2358 {
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371 $this->
debug(
"connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
2373 if (!is_array($this->proxy)) {
2376 } else {
2377 $host = $this->proxy[
'host'];
2378 $port = $this->proxy[
'port'];
2379 }
2380
2381
2382 if ($this->persistentConnection && isset($this->fp) && is_resource($this->fp)) {
2383 if (!feof($this->fp)) {
2384 $this->
debug(
'Re-use persistent connection');
2385 return true;
2386 }
2387 fclose($this->fp);
2388 $this->
debug(
'Closed persistent connection at EOF');
2389 }
2390
2391
2392 if ($this->scheme == 'ssl') {
2394 }
2395 $this->
debug(
'calling fsockopen with host ' .
$host .
' connection_timeout ' . $connection_timeout);
2396
2397
2398 if ($connection_timeout > 0) {
2399 $this->fp = @fsockopen(
$host, $this->port, $this->errno, $this->error_str, $connection_timeout);
2400 } else {
2401 $this->fp = @fsockopen(
$host, $this->port, $this->errno, $this->error_str);
2402 }
2403
2404
2405 if (!$this->fp) {
2406 $msg =
'Couldn\'t open socket connection to server ' .
$this->url;
2407 if ($this->errno) {
2409 } else {
2410 $msg .= ' prior to connect(). This is often a problem looking up the host name.';
2411 }
2414 return false;
2415 }
2416
2417
2418 $this->
debug(
'set response timeout to ' . $response_timeout);
2419 socket_set_timeout($this->fp, $response_timeout);
2420
2421 $this->
debug(
'socket connected');
2422 return true;
2423 } elseif ($this->
io_method() ==
'curl') {
2424 if (!extension_loaded('curl')) {
2425
2426 $this->
setError(
'The PHP cURL Extension is required for HTTPS or NLTM. You will need to re-build or update your PHP to included cURL.');
2427 return false;
2428 }
2429
2430 if (defined('CURLOPT_CONNECTIONTIMEOUT')) {
2431 $CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
2432 } else {
2433 $CURLOPT_CONNECTIONTIMEOUT = 78;
2434 }
2435 if (defined('CURLOPT_HTTPAUTH')) {
2436 $CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
2437 } else {
2438 $CURLOPT_HTTPAUTH = 107;
2439 }
2440 if (defined('CURLOPT_PROXYAUTH')) {
2441 $CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
2442 } else {
2443 $CURLOPT_PROXYAUTH = 111;
2444 }
2445 if (defined('CURLAUTH_BASIC')) {
2446 $CURLAUTH_BASIC = CURLAUTH_BASIC;
2447 } else {
2448 $CURLAUTH_BASIC = 1;
2449 }
2450 if (defined('CURLAUTH_DIGEST')) {
2451 $CURLAUTH_DIGEST = CURLAUTH_DIGEST;
2452 } else {
2453 $CURLAUTH_DIGEST = 2;
2454 }
2455 if (defined('CURLAUTH_NTLM')) {
2456 $CURLAUTH_NTLM = CURLAUTH_NTLM;
2457 } else {
2458 $CURLAUTH_NTLM = 8;
2459 }
2460
2461 $this->
debug(
'connect using cURL');
2462
2463 $this->ch = curl_init();
2464
2465 $hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host";
2466
2469
2470 if (ini_get('safe_mode') || ini_get('open_basedir')) {
2471 $this->
debug(
'safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
2472 $this->
debug(
'safe_mode = ');
2474 $this->
debug(
'open_basedir = ');
2476 } else {
2478 }
2479
2481
2483
2484
2485
2486
2487
2488
2489 if ($this->persistentConnection) {
2490
2491
2492
2493
2494
2495 $this->persistentConnection = false;
2496 $this->
setHeader(
'Connection',
'close');
2497 }
2498
2499 if ($connection_timeout != 0) {
2500 $this->
setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
2501 }
2502 if ($response_timeout != 0) {
2504 }
2505
2506 if ($this->scheme == 'https') {
2507 $this->
debug(
'set cURL SSL verify options');
2508
2509
2510
2511
2514
2515
2516 if ($this->authtype == 'certificate') {
2517 $this->
debug(
'set cURL certificate options');
2518 if (isset($this->certRequest['cainfofile'])) {
2519 $this->
setCurlOption(CURLOPT_CAINFO, $this->certRequest[
'cainfofile']);
2520 }
2521 if (isset($this->certRequest['verifypeer'])) {
2522 $this->
setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest[
'verifypeer']);
2523 } else {
2525 }
2526 if (isset($this->certRequest['verifyhost'])) {
2527 $this->
setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest[
'verifyhost']);
2528 } else {
2530 }
2531 if (isset($this->certRequest['sslcertfile'])) {
2532 $this->
setCurlOption(CURLOPT_SSLCERT, $this->certRequest[
'sslcertfile']);
2533 }
2534 if (isset($this->certRequest['sslkeyfile'])) {
2535 $this->
setCurlOption(CURLOPT_SSLKEY, $this->certRequest[
'sslkeyfile']);
2536 }
2537 if (isset($this->certRequest['passphrase'])) {
2538 $this->
setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest[
'passphrase']);
2539 }
2540 if (isset($this->certRequest['certpassword'])) {
2541 $this->
setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest[
'certpassword']);
2542 }
2543 }
2544 }
2545 if ($this->authtype && ($this->authtype != 'certificate')) {
2546 if ($this->username) {
2547 $this->
debug(
'set cURL username/password');
2548 $this->
setCurlOption(CURLOPT_USERPWD,
"$this->username:$this->password");
2549 }
2550 if ($this->authtype == 'basic') {
2551 $this->
debug(
'set cURL for Basic authentication');
2553 }
2554 if ($this->authtype == 'digest') {
2555 $this->
debug(
'set cURL for digest authentication');
2557 }
2558 if ($this->authtype == 'ntlm') {
2559 $this->
debug(
'set cURL for NTLM authentication');
2561 }
2562 }
2563 if (is_array($this->proxy)) {
2564 $this->
debug(
'set cURL proxy options');
2565 if ($this->proxy['port'] != '') {
2566 $this->
setCurlOption(CURLOPT_PROXY, $this->proxy[
'host'] .
':' . $this->proxy[
'port']);
2567 } else {
2569 }
2570 if ($this->proxy['username'] || $this->proxy['password']) {
2571 $this->
debug(
'set cURL proxy authentication options');
2572 $this->
setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy[
'username'] .
':' . $this->proxy[
'password']);
2573 if ($this->proxy['authtype'] == 'basic') {
2575 }
2576 if ($this->proxy['authtype'] == 'ntlm') {
2578 }
2579 }
2580 }
2581 $this->
debug(
'cURL connection set up');
2582 return true;
2583 } else {
2584 $this->
setError(
'Unknown scheme ' . $this->scheme);
2585 $this->
debug(
'Unknown scheme ' . $this->scheme);
2586 return false;
2587 }
2588 }
2589
2600 public function send(
$data, $timeout=0, $response_timeout=30, $cookies=
null)
2601 {
2602 $this->
debug(
'entered send() with data of length: ' . strlen(
$data));
2603
2604 $this->tryagain = true;
2605 $tries = 0;
2606 while ($this->tryagain) {
2607 $this->tryagain = false;
2608 if ($tries++ < 2) {
2609
2610 if (!$this->
connect($timeout, $response_timeout)) {
2611 return false;
2612 }
2613
2614
2616 return false;
2617 }
2618
2619
2621 } else {
2622 $this->
setError(
"Too many tries to get an OK response ($this->response_status_line)");
2623 }
2624 }
2625 $this->
debug(
'end of send()');
2626 return $respdata;
2627 }
2628
2629
2641 public function sendHTTPS(
$data, $timeout=0, $response_timeout=30, $cookies=
null)
2642 {
2643 return $this->
send(
$data, $timeout, $response_timeout, $cookies);
2644 }
2645
2657 {
2658 $this->
debug(
"setCredentials username=$username authtype=$authtype digestRequest=");
2660 $this->
debug(
"certRequest=");
2662
2668
2669
2670
2671
2673
2674
2675 $HA1 = md5($A1);
2676
2677
2679
2680
2681 $HA2 = md5($A2);
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694 $unhashedDigest = '';
2696 $cnonce = $nonce;
2698 $unhashedDigest = $HA1 .
':' . $nonce .
':' . sprintf(
"%08d",
$digestRequest[
'nc']) .
':' . $cnonce .
':' .
$digestRequest[
'qop'] .
':' . $HA2;
2699 } else {
2700 $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
2701 }
2702
2703 $hashedDigest = md5($unhashedDigest);
2704
2705 $opaque = '';
2708 }
2709
2710 $this->
setHeader(
'Authorization',
'Digest username="' .
$username .
'", realm="' .
$digestRequest[
'realm'] .
'", nonce="' . $nonce .
'", uri="' . $this->digest_uri . $opaque .
'", cnonce="' . $cnonce .
'", nc=' . sprintf(
"%08x",
$digestRequest[
'nc']) .
', qop="' .
$digestRequest[
'qop'] .
'", response="' . $hashedDigest .
'"');
2711 }
2714 $this->
debug(
'Authorization header not set for certificate');
2716
2717 $this->
debug(
'Authorization header not set for ntlm');
2718 }
2723 }
2724
2732 {
2733 $this->
setHeader(
'SOAPAction',
'"' . $soapaction .
'"');
2734 }
2735
2743 {
2744 if (function_exists('gzdeflate')) {
2745 $this->protocol_version = '1.1';
2746 $this->
setHeader(
'Accept-Encoding', $enc);
2747 if (!isset($this->outgoing_headers['Connection'])) {
2748 $this->
setHeader(
'Connection',
'close');
2749 $this->persistentConnection = false;
2750 }
2751 #set_magic_quotes_runtime(0);
2752
2753 $this->encoding = $enc;
2754 }
2755 }
2756
2767 public function setProxy($proxyhost, $proxyport, $proxyusername =
'', $proxypassword =
'', $proxyauthtype =
'basic')
2768 {
2769 if ($proxyhost) {
2770 $this->proxy = array(
2771 'host' => $proxyhost,
2772 'port' => $proxyport,
2773 'username' => $proxyusername,
2774 'password' => $proxypassword,
2775 'authtype' => $proxyauthtype
2776 );
2777 if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') {
2778 $this->
setHeader(
'Proxy-Authorization',
' Basic ' . base64_encode($proxyusername .
':' . $proxypassword));
2779 }
2780 } else {
2781 $this->
debug(
'remove proxy');
2784 }
2785 }
2786
2787
2797 {
2798 $skipHeaders = array( 'HTTP/1.1 100',
2799 'HTTP/1.0 301',
2800 'HTTP/1.1 301',
2801 'HTTP/1.0 302',
2802 'HTTP/1.1 302',
2803 'HTTP/1.0 401',
2804 'HTTP/1.1 401',
2805 'HTTP/1.0 200 Connection established');
2806 foreach ($skipHeaders as $hd) {
2807 $prefix = substr(
$data, 0, strlen($hd));
2808 if ($prefix == $hd) {
2809 return true;
2810 }
2811 }
2812
2813 return false;
2814 }
2815
2827 {
2828
2829 $length = 0;
2830 $new = '';
2831
2832
2833
2834 $chunkend = strpos($buffer, $lb);
2835 if ($chunkend == false) {
2836 $this->
debug(
'no linebreak found in decodeChunked');
2837 return $new;
2838 }
2839 $temp = substr($buffer, 0, $chunkend);
2840 $chunk_size = hexdec(trim($temp));
2841 $chunkstart = $chunkend + strlen($lb);
2842
2843 while ($chunk_size > 0) {
2844 $this->
debug(
"chunkstart: $chunkstart chunk_size: $chunk_size");
2845 $chunkend = strpos($buffer, $lb, $chunkstart + $chunk_size);
2846
2847
2848 if ($chunkend == false) {
2849 $chunk = substr($buffer, $chunkstart);
2850
2851 $new .= $chunk;
2852 $length += strlen($chunk);
2853 break;
2854 }
2855
2856
2857 $chunk = substr($buffer, $chunkstart, $chunkend-$chunkstart);
2858
2859 $new .= $chunk;
2860
2861 $length += strlen($chunk);
2862
2863 $chunkstart = $chunkend + strlen($lb);
2864
2865 $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
2866 if ($chunkend == false) {
2867 break;
2868 }
2869 $temp = substr($buffer, $chunkstart, $chunkend-$chunkstart);
2870 $chunk_size = hexdec(trim($temp));
2871 $chunkstart = $chunkend;
2872 }
2873 return $new;
2874 }
2875
2885 {
2886
2887
2888
2889
2890
2892
2893
2894 if ($this->proxy) {
2896 } else {
2898 }
2899 $req =
"$this->request_method $uri HTTP/$this->protocol_version";
2900 $this->
debug(
"HTTP request: $req");
2901 $this->outgoing_payload = "$req\r\n";
2902
2903
2904 foreach ($this->outgoing_headers as $k => $v) {
2905 $hdr = $k . ': ' . $v;
2906 $this->
debug(
"HTTP header: $hdr");
2907 $this->outgoing_payload .= "$hdr\r\n";
2908 }
2909
2910
2911 if ($cookie_str != '') {
2912 $hdr = 'Cookie: ' . $cookie_str;
2913 $this->
debug(
"HTTP header: $hdr");
2914 $this->outgoing_payload .= "$hdr\r\n";
2915 }
2916
2917
2918 $this->outgoing_payload .= "\r\n";
2919
2920
2921 $this->outgoing_payload .=
$data;
2922 }
2923
2933 {
2934
2935 $cookie_str = $this->
getCookiesForRequest($cookies, (($this->scheme ==
'ssl') || ($this->scheme ==
'https')));
2936
2937
2939
2941
2942 if (!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
2943 $this->
setError(
'couldn\'t write message data to socket');
2944 $this->
debug(
'couldn\'t write message data to socket');
2945 return false;
2946 }
2947 $this->
debug(
'wrote data to socket, length = ' . strlen($this->outgoing_payload));
2948 return true;
2949 } elseif ($this->
io_method() ==
'curl') {
2950
2951
2952
2953
2954
2955 $curl_headers = array();
2956 foreach ($this->outgoing_headers as $k => $v) {
2957 if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
2958 $this->
debug(
"Skip cURL header $k: $v");
2959 } else {
2960 $curl_headers[] = "$k: $v";
2961 }
2962 }
2963 if ($cookie_str != '') {
2964 $curl_headers[] = 'Cookie: ' . $cookie_str;
2965 }
2967 $this->
debug(
'set cURL HTTP headers');
2968 if ($this->request_method == "POST") {
2971 $this->
debug(
'set cURL POST data');
2972 } else {
2973 }
2974
2975 foreach ($this->ch_options as
$key => $val) {
2977 }
2978
2979 $this->
debug(
'set cURL payload');
2980 return true;
2981 }
2982 }
2983
2991 {
2992 $this->incoming_payload = '';
2993
2995
2997 while (!isset($lb)) {
2998
2999
3000 if (feof($this->fp)) {
3001 $this->incoming_payload =
$data;
3002 $this->
debug(
'found no headers before EOF after length ' . strlen(
$data));
3003 $this->
debug(
"received before EOF:\n" .
$data);
3004 $this->
setError(
'server failed to send headers');
3005 return false;
3006 }
3007
3008 $tmp = fgets($this->fp, 256);
3009 $tmplen = strlen($tmp);
3010 $this->
debug(
"read line of $tmplen bytes: " . trim($tmp));
3011
3012 if ($tmplen == 0) {
3013 $this->incoming_payload =
$data;
3014 $this->
debug(
'socket read of headers timed out after length ' . strlen(
$data));
3015 $this->
debug(
"read before timeout: " .
$data);
3016 $this->
setError(
'socket read of headers timed out');
3017 return false;
3018 }
3019
3021 $pos = strpos(
$data,
"\r\n\r\n");
3022 if ($pos > 1) {
3023 $lb = "\r\n";
3024 } else {
3025 $pos = strpos(
$data,
"\n\n");
3026 if ($pos > 1) {
3027 $lb = "\n";
3028 }
3029 }
3030
3031 if (isset($lb) && preg_match(
'/^HTTP\/1.1 100/',
$data)) {
3032 unset($lb);
3034 }
3035 }
3036
3037 $this->incoming_payload .=
$data;
3038 $this->
debug(
'found end of headers after length ' . strlen(
$data));
3039
3040 $header_data = trim(substr(
$data, 0, $pos));
3041 $header_array = explode($lb, $header_data);
3042 $this->incoming_headers = array();
3043 $this->incoming_cookies = array();
3044 foreach ($header_array as $header_line) {
3045 $arr = explode(':', $header_line, 2);
3046 if (count($arr) > 1) {
3047 $header_name = strtolower(trim($arr[0]));
3048 $this->incoming_headers[$header_name] = trim($arr[1]);
3049 if ($header_name == 'set-cookie') {
3050
3052 if ($cookie) {
3053 $this->incoming_cookies[] = $cookie;
3054 $this->
debug(
'found cookie: ' . $cookie[
'name'] .
' = ' . $cookie[
'value']);
3055 } else {
3056 $this->
debug(
'did not find cookie in ' . trim($arr[1]));
3057 }
3058 }
3059 } elseif (isset($header_name)) {
3060
3061 $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
3062 }
3063 }
3064
3065
3066 if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
3067 $content_length = 2147483647;
3068 $chunked = true;
3069 $this->
debug(
"want to read chunked content");
3070 } elseif (isset($this->incoming_headers['content-length'])) {
3071 $content_length = $this->incoming_headers['content-length'];
3072 $chunked = false;
3073 $this->
debug(
"want to read content of length $content_length");
3074 } else {
3075 $content_length = 2147483647;
3076 $chunked = false;
3077 $this->
debug(
"want to read content to EOF");
3078 }
3080 do {
3081 if ($chunked) {
3082 $tmp = fgets($this->fp, 256);
3083 $tmplen = strlen($tmp);
3084 $this->
debug(
"read chunk line of $tmplen bytes");
3085 if ($tmplen == 0) {
3086 $this->incoming_payload =
$data;
3087 $this->
debug(
'socket read of chunk length timed out after length ' . strlen(
$data));
3088 $this->
debug(
"read before timeout:\n" .
$data);
3089 $this->
setError(
'socket read of chunk length timed out');
3090 return false;
3091 }
3092 $content_length = hexdec(trim($tmp));
3093 $this->
debug(
"chunk length $content_length");
3094 }
3095 $strlen = 0;
3096 while (($strlen < $content_length) && (!feof($this->fp))) {
3097 $readlen = min(8192, $content_length - $strlen);
3098 $tmp = fread($this->fp, $readlen);
3099 $tmplen = strlen($tmp);
3100 $this->
debug(
"read buffer of $tmplen bytes");
3101 if (($tmplen == 0) && (!feof($this->fp))) {
3102 $this->incoming_payload =
$data;
3103 $this->
debug(
'socket read of body timed out after length ' . strlen(
$data));
3104 $this->
debug(
"read before timeout:\n" .
$data);
3105 $this->
setError(
'socket read of body timed out');
3106 return false;
3107 }
3108 $strlen += $tmplen;
3110 }
3111 if ($chunked && ($content_length > 0)) {
3112 $tmp = fgets($this->fp, 256);
3113 $tmplen = strlen($tmp);
3114 $this->
debug(
"read chunk terminator of $tmplen bytes");
3115 if ($tmplen == 0) {
3116 $this->incoming_payload =
$data;
3117 $this->
debug(
'socket read of chunk terminator timed out after length ' . strlen(
$data));
3118 $this->
debug(
"read before timeout:\n" .
$data);
3119 $this->
setError(
'socket read of chunk terminator timed out');
3120 return false;
3121 }
3122 }
3123 } while ($chunked && ($content_length > 0) && (!feof($this->fp)));
3124 if (feof($this->fp)) {
3125 $this->
debug(
'read to EOF');
3126 }
3127 $this->
debug(
'read body of length ' . strlen(
$data));
3128 $this->incoming_payload .=
$data;
3129 $this->
debug(
'received a total of ' . strlen($this->incoming_payload) .
' bytes of data from server');
3130
3131
3132 if (
3133 (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') ||
3134 (! $this->persistentConnection) || feof($this->fp)) {
3135 fclose($this->fp);
3136 $this->fp = false;
3137 $this->
debug(
'closed socket');
3138 }
3139
3140
3141 if ($this->incoming_payload == '') {
3142 $this->
setError(
'no response from server');
3143 return false;
3144 }
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156 } elseif ($this->
io_method() ==
'curl') {
3157
3158 $this->
debug(
'send and receive with cURL');
3159 $this->incoming_payload = curl_exec($this->ch);
3161
3162 $cErr = curl_error($this->ch);
3163 if ($cErr != '') {
3164 $err = 'cURL ERROR: ' . curl_errno($this->ch) . ': ' . $cErr . '<br>';
3165
3166 foreach (curl_getinfo($this->ch) as $k => $v) {
3167 $err .= "$k: $v<br>";
3168 }
3171 curl_close($this->ch);
3172 return false;
3173 } else {
3174
3175
3176
3177 }
3178
3179 $this->
debug(
'No cURL error, closing cURL');
3180 curl_close($this->ch);
3181
3182
3185 $this->
debug(
"Found HTTP header to skip");
3186 if ($pos = strpos(
$data,
"\r\n\r\n")) {
3188 } elseif ($pos = strpos(
$data,
"\n\n")) {
3190 }
3191 }
3192
3194
3196 while (preg_match(
'/^HTTP\/1.1 100/',
$data)) {
3197 if ($pos = strpos(
$data,
"\r\n\r\n")) {
3199 } elseif ($pos = strpos(
$data,
"\n\n")) {
3201 }
3202 }
3203 }
3204
3205
3206 if ($pos = strpos(
$data,
"\r\n\r\n")) {
3207 $lb = "\r\n";
3208 } elseif ($pos = strpos(
$data,
"\n\n")) {
3209 $lb = "\n";
3210 } else {
3211 $this->
debug(
'no proper separation of headers and document');
3212 $this->
setError(
'no proper separation of headers and document');
3213 return false;
3214 }
3215 $header_data = trim(substr(
$data, 0, $pos));
3216 $header_array = explode($lb, $header_data);
3218 $this->
debug(
'found proper separation of headers and document');
3219 $this->
debug(
'cleaned data, stringlen: ' . strlen(
$data));
3220
3221 foreach ($header_array as $header_line) {
3222 $arr = explode(':', $header_line, 2);
3223 if (count($arr) > 1) {
3224 $header_name = strtolower(trim($arr[0]));
3225 $this->incoming_headers[$header_name] = trim($arr[1]);
3226 if ($header_name == 'set-cookie') {
3227
3229 if ($cookie) {
3230 $this->incoming_cookies[] = $cookie;
3231 $this->
debug(
'found cookie: ' . $cookie[
'name'] .
' = ' . $cookie[
'value']);
3232 } else {
3233 $this->
debug(
'did not find cookie in ' . trim($arr[1]));
3234 }
3235 }
3236 } elseif (isset($header_name)) {
3237
3238 $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
3239 }
3240 }
3241 }
3242
3243 $this->response_status_line = $header_array[0];
3244 $arr = explode(' ', $this->response_status_line, 3);
3245 $http_version = $arr[0];
3246 $http_status = intval($arr[1]);
3247 $http_reason = count($arr) > 2 ? $arr[2] : '';
3248
3249
3250 if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
3251 $this->
debug(
"Got $http_status $http_reason with Location: " . $this->incoming_headers[
'location']);
3252 $this->
setURL($this->incoming_headers[
'location']);
3253 $this->tryagain = true;
3254 return false;
3255 }
3256
3257
3258 if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
3259 $this->
debug(
"Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers[
'www-authenticate']);
3260 if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
3261 $this->
debug(
'Server wants digest authentication');
3262
3263 $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
3264
3265
3266 $digestElements = explode(',', $digestString);
3267 foreach ($digestElements as $val) {
3268 $tempElement = explode('=', trim($val), 2);
3269 $digestRequest[$tempElement[0]] = str_replace(
"\"",
'', $tempElement[1]);
3270 }
3271
3272
3275 $this->tryagain = true;
3276 return false;
3277 }
3278 }
3279 $this->
debug(
'HTTP authentication failed');
3280 $this->
setError(
'HTTP authentication failed');
3281 return false;
3282 }
3283
3284 if (
3285 ($http_status >= 300 && $http_status <= 307) ||
3286 ($http_status >= 400 && $http_status <= 417) ||
3287 ($http_status >= 501 && $http_status <= 505)
3288 ) {
3289 $this->
setError(
"Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
3290 return false;
3291 }
3292
3293
3294 if (isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != '') {
3295 if (strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip') {
3296
3297 if (function_exists('gzinflate')) {
3298
3299
3300
3301 $this->
debug(
'The gzinflate function exists');
3302 $datalen = strlen(
$data);
3303 if ($this->incoming_headers['content-encoding'] == 'deflate') {
3304 if ($degzdata = @gzinflate(
$data)) {
3306 $this->
debug(
'The payload has been inflated to ' . strlen(
$data) .
' bytes');
3307 if (strlen(
$data) < $datalen) {
3308
3309 $this->
debug(
'The inflated payload is smaller than the gzipped one; try again');
3310 if ($degzdata = @gzinflate(
$data)) {
3312 $this->
debug(
'The payload has been inflated again to ' . strlen(
$data) .
' bytes');
3313 }
3314 }
3315 } else {
3316 $this->
debug(
'Error using gzinflate to inflate the payload');
3317 $this->
setError(
'Error using gzinflate to inflate the payload');
3318 }
3319 } elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
3320 if ($degzdata = @gzinflate(substr(
$data, 10))) {
3322 $this->
debug(
'The payload has been un-gzipped to ' . strlen(
$data) .
' bytes');
3323 if (strlen(
$data) < $datalen) {
3324
3325 $this->
debug(
'The un-gzipped payload is smaller than the gzipped one; try again');
3326 if ($degzdata = @gzinflate(substr(
$data, 10))) {
3328 $this->
debug(
'The payload has been un-gzipped again to ' . strlen(
$data) .
' bytes');
3329 }
3330 }
3331 } else {
3332 $this->
debug(
'Error using gzinflate to un-gzip the payload');
3333 $this->
setError(
'Error using gzinflate to un-gzip the payload');
3334 }
3335 }
3336
3337
3338
3339 $this->incoming_payload = $header_data . $lb . $lb .
$data;
3340 } else {
3341 $this->
debug(
'The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
3342 $this->
setError(
'The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
3343 }
3344 } else {
3345 $this->
debug(
'Unsupported Content-Encoding ' . $this->incoming_headers[
'content-encoding']);
3346 $this->
setError(
'Unsupported Content-Encoding ' . $this->incoming_headers[
'content-encoding']);
3347 }
3348 } else {
3349 $this->
debug(
'No Content-Encoding header');
3350 }
3351
3352 if (strlen(
$data) == 0) {
3353 $this->
debug(
'no data after headers!');
3354 $this->
setError(
'no data present after HTTP headers');
3355 return false;
3356 }
3357
3359 }
3360
3369 {
3370 $this->
setHeader(
'Content-Type', $type . ($charset ?
'; charset=' . $charset :
''));
3371 }
3372
3380 {
3381 if (isset($this->outgoing_headers['Accept-Encoding'])) {
3382 return false;
3383 }
3384 $this->protocol_version = '1.1';
3385 $this->persistentConnection = true;
3386 $this->
setHeader(
'Connection',
'Keep-Alive');
3387 return true;
3388 }
3389
3397
3398
3399
3401 {
3402 $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
3403
3404
3405 $data = explode(
';', $cookie_str);
3406 $value_str =
$data[0];
3407
3408 $cookie_param = 'domain=';
3409 $start = strpos($cookie_str, $cookie_param);
3410 if ($start > 0) {
3411 $domain = substr($cookie_str, $start + strlen($cookie_param));
3412 $domain = substr($domain, 0, strpos($domain, ';'));
3413 } else {
3414 $domain = '';
3415 }
3416
3417 $cookie_param = 'expires=';
3418 $start = strpos($cookie_str, $cookie_param);
3419 if ($start > 0) {
3420 $expires = substr($cookie_str, $start + strlen($cookie_param));
3421 $expires = substr($expires, 0, strpos($expires, ';'));
3422 } else {
3423 $expires = '';
3424 }
3425
3426 $cookie_param = 'path=';
3427 $start = strpos($cookie_str, $cookie_param);
3428 if ($start > 0) {
3429 $path = substr($cookie_str, $start + strlen($cookie_param));
3431 } else {
3433 }
3434
3435 $cookie_param = ';secure;';
3436 if (strpos($cookie_str, $cookie_param) !== false) {
3437 $secure = true;
3438 } else {
3439 $secure = false;
3440 }
3441
3442 $sep_pos = strpos($value_str, '=');
3443
3444 if ($sep_pos) {
3445 $name = substr($value_str, 0, $sep_pos);
3446 $value = substr($value_str, $sep_pos + 1);
3447 $cookie= array(
'name' =>
$name,
3448 'value' => $value,
3449 'domain' => $domain,
3451 'expires' => $expires,
3452 'secure' => $secure
3453 );
3454 return $cookie;
3455 }
3456 return false;
3457 }
3458
3468 {
3469 $cookie_str = '';
3470 if ((! is_null($cookies)) && (is_array($cookies))) {
3471 foreach ($cookies as $cookie) {
3472 if (! is_array($cookie)) {
3473 continue;
3474 }
3475 $this->
debug(
"check cookie for validity: " . $cookie[
'name'] .
'=' . $cookie[
'value']);
3476 if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
3477 if (strtotime($cookie['expires']) <= time()) {
3478 $this->
debug(
'cookie has expired');
3479 continue;
3480 }
3481 }
3482 if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
3483 $domain = preg_quote($cookie['domain']);
3484 if (! preg_match("'.*$domain$'i", $this->host)) {
3485 $this->
debug(
'cookie has different domain');
3486 continue;
3487 }
3488 }
3489 if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
3490 $path = preg_quote($cookie[
'path']);
3491 if (! preg_match("'^$path.*'i", $this->path)) {
3492 $this->
debug(
'cookie is for a different path');
3493 continue;
3494 }
3495 }
3496 if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
3497 $this->
debug(
'cookie is secure, transport is not');
3498 continue;
3499 }
3500 $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
3501 $this->
debug(
'add cookie to Cookie-String: ' . $cookie[
'name'] .
'=' . $cookie[
'value']);
3502 }
3503 }
3504 return $cookie_str;
3505 }
3506}
3507
3508?><?php
3509
3510
3511
3523{
3596
3644 public $result =
'successful';
3645
3658 public $wsdl =
false;
3671
3672
3681 {
3683
3684 global $debug;
3685 global $HTTP_SERVER_VARS;
3686
3688 $this->
debug(
"_SERVER is defined:");
3690 } elseif (isset($HTTP_SERVER_VARS)) {
3691 $this->
debug(
"HTTP_SERVER_VARS is defined:");
3693 } else {
3694 $this->
debug(
"Neither _SERVER nor HTTP_SERVER_VARS is defined.");
3695 }
3696
3697 if (isset($debug)) {
3698 $this->
debug(
"In nusoap_server, set debug_flag=$debug based on global flag");
3699 $this->debug_flag = $debug;
3700 } elseif (isset(
$_SERVER[
'QUERY_STRING'])) {
3701 $qs = explode(
'&',
$_SERVER[
'QUERY_STRING']);
3702 foreach ($qs as $v) {
3703 if (substr($v, 0, 6) == 'debug=') {
3704 $this->
debug(
"In nusoap_server, set debug_flag=" . substr($v, 6) .
" based on query string #1");
3705 $this->debug_flag = substr($v, 6);
3706 }
3707 }
3708 } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
3709 $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
3710 foreach ($qs as $v) {
3711 if (substr($v, 0, 6) == 'debug=') {
3712 $this->
debug(
"In nusoap_server, set debug_flag=" . substr($v, 6) .
" based on query string #2");
3713 $this->debug_flag = substr($v, 6);
3714 }
3715 }
3716 }
3717
3718
3720 $this->
debug(
"In nusoap_server, WSDL is specified");
3721 if (is_object(
$wsdl) && (get_class(
$wsdl) ==
'wsdl')) {
3723 $this->externalWSDLURL = $this->
wsdl->wsdl;
3724 $this->
debug(
'Use existing wsdl instance from ' . $this->externalWSDLURL);
3725 } else {
3728 $this->externalWSDLURL =
$wsdl;
3729 }
3733 die('WSDL ERROR: ' . $err);
3734 }
3735 }
3736 }
3737
3745 {
3746 global $HTTP_SERVER_VARS;
3747
3748 if (isset(
$_SERVER[
'QUERY_STRING'])) {
3750 } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
3751 $qs = $HTTP_SERVER_VARS['QUERY_STRING'];
3752 } else {
3753 $qs = '';
3754 }
3755 $this->
debug(
"In service, query string=$qs");
3756
3757 if (preg_match('/wsdl/', $qs)) {
3758 $this->
debug(
"In service, this is a request for WSDL");
3759 if ($this->externalWSDLURL) {
3760 if (strpos($this->externalWSDLURL, "://")!==false) {
3761 header('Location: ' . $this->externalWSDLURL);
3762 } else {
3763 header("Content-Type: text/xml\r\n");
3764 $fp = fopen($this->externalWSDLURL, 'r');
3765 fpassthru($fp);
3766 }
3767 } elseif ($this->
wsdl) {
3768 header("Content-Type: text/xml; charset=ISO-8859-1\r\n");
3770 if ($this->debug_flag) {
3771 $this->
debug(
'wsdl:');
3774 }
3775 } else {
3776 header("Content-Type: text/html; charset=ISO-8859-1\r\n");
3777 print "This service does not provide WSDL";
3778 }
3780 $this->
debug(
"In service, there is no data, so return Web description");
3782 } else {
3783 $this->
debug(
"In service, invoke the request");
3785 if (! $this->
fault) {
3787 }
3788 if (! $this->
fault) {
3790 }
3792 }
3793 }
3794
3808 {
3809 global $HTTP_SERVER_VARS;
3810
3811 $this->request = '';
3812 $this->SOAPAction = '';
3813 if (function_exists('getallheaders')) {
3814 $this->
debug(
"In parse_http_headers, use getallheaders");
3815 $headers = getallheaders();
3817 $k = strtolower($k);
3818 $this->headers[$k] = $v;
3819 $this->request .= "$k: $v\r\n";
3820 $this->
debug(
"$k: $v");
3821 }
3822
3823 if (isset($this->headers['soapaction'])) {
3824 $this->SOAPAction = str_replace('"', '', $this->headers['soapaction']);
3825 }
3826
3827 if (isset($this->headers['content-type']) && strpos($this->headers['content-type'], '=')) {
3828 $enc = str_replace('"', '', substr(strstr($this->headers["content-type"], '='), 1));
3829 if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
3830 $this->xml_encoding = strtoupper($enc);
3831 } else {
3832 $this->xml_encoding = 'US-ASCII';
3833 }
3834 } else {
3835
3836 $this->xml_encoding = 'ISO-8859-1';
3837 }
3839 $this->
debug(
"In parse_http_headers, use _SERVER");
3841 if (substr($k, 0, 5) == 'HTTP_') {
3842 $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
3843 } else {
3844 $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
3845 }
3846 if ($k == 'soapaction') {
3847
3848 $k = 'SOAPAction';
3849 $v = str_replace('"', '', $v);
3850 $v = str_replace('\\', '', $v);
3851 $this->SOAPAction = $v;
3852 } elseif ($k == 'content-type') {
3853
3854 if (strpos($v, '=')) {
3855 $enc = substr(strstr($v, '='), 1);
3856 $enc = str_replace('"', '', $enc);
3857 $enc = str_replace('\\', '', $enc);
3858 if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
3859 $this->xml_encoding = strtoupper($enc);
3860 } else {
3861 $this->xml_encoding = 'US-ASCII';
3862 }
3863 } else {
3864
3865 $this->xml_encoding = 'ISO-8859-1';
3866 }
3867 }
3868 $this->headers[$k] = $v;
3869 $this->request .= "$k: $v\r\n";
3870 $this->
debug(
"$k: $v");
3871 }
3872 } elseif (is_array($HTTP_SERVER_VARS)) {
3873 $this->
debug(
"In parse_http_headers, use HTTP_SERVER_VARS");
3874 foreach ($HTTP_SERVER_VARS as $k => $v) {
3875 if (substr($k, 0, 5) == 'HTTP_') {
3876 $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
3877 $k = strtolower(substr($k, 5));
3878 } else {
3879 $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
3880 $k = strtolower($k);
3881 }
3882 if ($k == 'soapaction') {
3883
3884 $k = 'SOAPAction';
3885 $v = str_replace('"', '', $v);
3886 $v = str_replace('\\', '', $v);
3887 $this->SOAPAction = $v;
3888 } elseif ($k == 'content-type') {
3889
3890 if (strpos($v, '=')) {
3891 $enc = substr(strstr($v, '='), 1);
3892 $enc = str_replace('"', '', $enc);
3893 $enc = str_replace('\\', '', $enc);
3894 if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
3895 $this->xml_encoding = strtoupper($enc);
3896 } else {
3897 $this->xml_encoding = 'US-ASCII';
3898 }
3899 } else {
3900
3901 $this->xml_encoding = 'ISO-8859-1';
3902 }
3903 }
3904 $this->headers[$k] = $v;
3905 $this->request .= "$k: $v\r\n";
3906 $this->
debug(
"$k: $v");
3907 }
3908 } else {
3909 $this->
debug(
"In parse_http_headers, HTTP headers not accessible");
3910 $this->
setError(
"HTTP headers not accessible");
3911 }
3912 }
3913
3937 {
3938 $this->
debug(
'entering parse_request()');
3940 $this->
debug(
'got character encoding: ' . $this->xml_encoding);
3941
3942 if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
3943 $this->
debug(
'got content encoding: ' . $this->headers[
'content-encoding']);
3944 if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
3945
3946 if (function_exists('gzuncompress')) {
3947 if ($this->headers[
'content-encoding'] ==
'deflate' && $degzdata = @gzuncompress(
$data)) {
3949 } elseif ($this->headers[
'content-encoding'] ==
'gzip' && $degzdata = gzinflate(substr(
$data, 10))) {
3951 } else {
3952 $this->
fault(
'SOAP-ENV:Client',
'Errors occurred when trying to decode the data');
3953 return;
3954 }
3955 } else {
3956 $this->
fault(
'SOAP-ENV:Client',
'This Server does not support compressed data');
3957 return;
3958 }
3959 }
3960 }
3961 $this->request .=
"\r\n" .
$data;
3963 $this->requestSOAP =
$data;
3964 $this->
debug(
'leaving parse_request');
3965 }
3966
3985 {
3986 $this->
debug(
'in invoke_method, methodname=' . $this->methodname .
' methodURI=' . $this->methodURI .
' SOAPAction=' . $this->SOAPAction);
3987
3990 $this->
debug(
'in invoke_method, found WSDL operation=' . $this->methodname);
3993
3994 $this->
debug(
'in invoke_method, found WSDL soapAction=' . $this->SOAPAction .
' for operation=' . $this->opData[
'name']);
3996 $this->methodname = $this->opData['name'];
3997 } else {
3998 $this->
debug(
'in invoke_method, no WSDL for operation=' . $this->methodname);
3999 $this->
fault(
'SOAP-ENV:Client',
"Operation '" . $this->methodname .
"' is not defined in the WSDL for this service");
4000 return;
4001 }
4002 } else {
4003 $this->
debug(
'in invoke_method, no WSDL to validate method');
4004 }
4005
4006
4007
4008
4009 $class = '';
4010 $method = '';
4011 if (strpos($this->methodname, '..') > 0) {
4012 $delim = '..';
4013 } elseif (strpos($this->methodname, '.') > 0) {
4014 $delim = '.';
4015 } else {
4016 $delim = '';
4017 }
4018
4019 if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1 &&
4020 class_exists(substr($this->methodname, 0, strpos($this->methodname, $delim)))) {
4021
4022 $class = substr($this->methodname, 0, strpos($this->methodname, $delim));
4023 $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
4024 $this->
debug(
"in invoke_method, class=$class method=$method delim=$delim");
4025 }
4026
4027
4028 if ($class == '' && $this->class !='') {
4029 $class = $this->class;
4030 $delim = "..";
4032 }
4033
4034
4035 if ($class == '') {
4036 if (!function_exists($this->methodname)) {
4037 $this->
debug(
"in invoke_method, function '$this->methodname' not found!");
4038 $this->result = 'fault: method not found';
4039 $this->
fault(
'SOAP-ENV:Client',
"method '$this->methodname' not defined in service");
4040 return;
4041 }
4042 } else {
4043 $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
4044 if (!in_array($method_to_compare, get_class_methods($class))) {
4045 $this->
debug(
"in invoke_method, method '$this->methodname' not found in class '$class'!");
4046 $this->result = 'fault: method not found';
4047 $this->
fault(
'SOAP-ENV:Client',
"method '$this->methodname' not defined in service");
4048 return;
4049 }
4050 }
4051
4052
4053
4054 if (! $this->
verify_method($this->methodname, $this->methodparams)) {
4055
4056 $this->
debug(
'ERROR: request not verified against method signature');
4057 $this->result = 'fault: request failed validation against method signature';
4058
4059 $this->
fault(
'SOAP-ENV:Client',
"Operation '$this->methodname' not defined in service.");
4060 return;
4061 }
4062
4063
4064 $this->
debug(
'in invoke_method, params:');
4066 $this->
debug(
"in invoke_method, calling '$this->methodname'");
4067 if (!function_exists('call_user_func_array')) {
4068 if ($class == '') {
4069 $this->
debug(
'in invoke_method, calling function using eval()');
4070 $funcCall = "\$this->methodreturn = $this->methodname(";
4071 } else {
4072 if ($delim == '..') {
4073 $this->
debug(
'in invoke_method, calling class method using eval()');
4074 $funcCall = "\$this->methodreturn = " . $class . "::" . $method . "(";
4075 } else {
4076 $this->
debug(
'in invoke_method, calling instance method using eval()');
4077
4078 $instname = "\$inst_" . time();
4079 $funcCall = $instname . " = new " . $class . "(); ";
4080 $funcCall .= "\$this->methodreturn = " . $instname . "->" . $method . "(";
4081 }
4082 }
4083 if ($this->methodparams) {
4084 foreach ($this->methodparams as
$param) {
4086 $this->
fault(
'SOAP-ENV:Client',
'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
4087 return;
4088 }
4089 $funcCall .= "\"$param\",";
4090 }
4091 $funcCall = substr($funcCall, 0, -1);
4092 }
4093 $funcCall .= ');';
4094 $this->
debug(
'in invoke_method, function call: ' . $funcCall);
4095 @eval($funcCall);
4096 } else {
4097 if ($class == '') {
4098 $this->
debug(
'in invoke_method, calling function using call_user_func_array()');
4099 $call_arg = "$this->methodname";
4100 } elseif ($delim == '..') {
4101 $this->
debug(
'in invoke_method, calling class method using call_user_func_array()');
4102 $call_arg = array($class, $method);
4103 } else {
4104 $this->
debug(
'in invoke_method, calling instance method using call_user_func_array()');
4105 $instance = new $class();
4106 $call_arg = array(&$instance, $method);
4107 }
4108 if (is_array($this->methodparams)) {
4109 $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
4110 } else {
4111 $this->methodreturn = call_user_func_array($call_arg, array());
4112 }
4113 }
4114 $this->
debug(
'in invoke_method, methodreturn:');
4116 $this->
debug(
"in invoke_method, called method $this->methodname, received data of type " . gettype($this->methodreturn));
4117 }
4118
4131 {
4132 $this->
debug(
'Entering serialize_return methodname: ' . $this->methodname .
' methodURI: ' . $this->methodURI);
4133
4134 if (isset($this->methodreturn) && ((get_class((object)$this->methodreturn) == 'soap_fault') || (get_class((object)$this->methodreturn) == 'nusoap_fault'))) {
4135 $this->
debug(
'got a fault object from method');
4137 return;
4138 } elseif ($this->methodreturnisliteralxml) {
4140
4141 } else {
4142 $this->
debug(
'got a(n) ' . gettype($this->methodreturn) .
' from method');
4143 $this->
debug(
'serializing return value');
4145 if (sizeof($this->opData['output']['parts']) > 1) {
4146 $this->
debug(
'more than one output part, so use the method return unchanged');
4148 } elseif (sizeof($this->opData['output']['parts']) == 1) {
4149 $this->
debug(
'exactly one output part, so wrap the method return in a simple array');
4150
4151
4152
4153
4154 $opParams = array($this->methodreturn);
4155 }
4160 $this->
debug(
'got wsdl error: ' . $errstr);
4161 $this->
fault(
'SOAP-ENV:Server',
'unable to serialize result');
4162 return;
4163 }
4164 } else {
4165 if (isset($this->methodreturn)) {
4166 $return_val = $this->
serialize_val($this->methodreturn,
'return');
4167 } else {
4168 $return_val = '';
4169 $this->
debug(
'in absence of WSDL, assume void return for backward compatibility');
4170 }
4171 }
4172 }
4173 $this->
debug(
'return value:');
4175
4176 $this->
debug(
'serializing response');
4178 $this->
debug(
'have WSDL for serialization: style is ' . $this->opData[
'style']);
4179 if ($this->opData['style'] == 'rpc') {
4180 $this->
debug(
'style is rpc for serialization: use is ' . $this->opData[
'output'][
'use']);
4181 if ($this->opData['output']['use'] == 'literal') {
4182
4183 $payload =
'<ns1:' . $this->methodname .
'Response xmlns:ns1="' . $this->methodURI .
'">' . $return_val .
'</ns1:' . $this->methodname .
"Response>";
4184 } else {
4185 $payload =
'<ns1:' . $this->methodname .
'Response xmlns:ns1="' . $this->methodURI .
'">' . $return_val .
'</ns1:' . $this->methodname .
"Response>";
4186 }
4187 } else {
4188 $this->
debug(
'style is not rpc for serialization: assume document');
4190 }
4191 } else {
4192 $this->
debug(
'do not have WSDL for serialization: assume rpc/encoded');
4193 $payload =
'<ns1:' . $this->methodname .
'Response xmlns:ns1="' . $this->methodURI .
'">' . $return_val .
'</ns1:' . $this->methodname .
"Response>";
4194 }
4195 $this->result = 'successful';
4197
4199
4200 if (isset($opData['output']['encodingStyle'])) {
4201 $encodingStyle = $opData['output']['encodingStyle'];
4202 } else {
4203 $encodingStyle = '';
4204 }
4205
4206 $this->responseSOAP = $this->
serializeEnvelope(
$payload, $this->responseHeaders, $this->
wsdl->usedNamespaces, $this->opData[
'style'], $this->opData[
'output'][
'use'], $encodingStyle);
4207 } else {
4209 }
4210 $this->
debug(
"Leaving serialize_return");
4211 }
4212
4224 {
4225 $this->
debug(
'Enter send_response');
4228 $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
4229 $this->outgoing_headers[] = "Status: 500 Internal Server Error";
4230 } else {
4232
4233
4234
4235
4236
4237 }
4238
4239 if (isset($this->debug_flag) && $this->debug_flag) {
4241 }
4242 $this->outgoing_headers[] = "Server: $this->title Server v$this->version";
4243 preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
4244 $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (" . $rev[1] . ")";
4245
4246
4250 $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
4251
4252
4253
4254 if (strlen(
$payload) > 1024 && isset($this->headers) && isset($this->headers[
'accept-encoding'])) {
4255 if (strstr($this->headers['accept-encoding'], 'gzip')) {
4256 if (function_exists('gzencode')) {
4258 $payload .=
"<!-- Content being gzipped -->";
4259 }
4260 $this->outgoing_headers[] = "Content-Encoding: gzip";
4262 } else {
4263 if (isset($this->debug_flag) && $this->debug_flag) {
4264 $payload .=
"<!-- Content will not be gzipped: no gzencode -->";
4265 }
4266 }
4267 } elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
4268
4269
4270
4271 if (function_exists('gzdeflate')) {
4272 if (isset($this->debug_flag) && $this->debug_flag) {
4273 $payload .=
"<!-- Content being deflated -->";
4274 }
4275 $this->outgoing_headers[] = "Content-Encoding: deflate";
4277 } else {
4278 if (isset($this->debug_flag) && $this->debug_flag) {
4279 $payload .=
"<!-- Content will not be deflated: no gzcompress -->";
4280 }
4281 }
4282 }
4283 }
4284
4285 $this->outgoing_headers[] =
"Content-Length: " . strlen(
$payload);
4286 reset($this->outgoing_headers);
4287 foreach ($this->outgoing_headers as $hdr) {
4288 header($hdr, false);
4289 }
4291 $this->response = join(
"\r\n", $this->outgoing_headers) .
"\r\n\r\n" .
$payload;
4292 }
4293
4304 {
4305 if (isset($this->
wsdl) && is_object($this->
wsdl)) {
4307 return true;
4308 }
4309 } elseif (isset($this->operations[$operation])) {
4310 return true;
4311 }
4312 return false;
4313 }
4314
4324 {
4325 $this->
debug(
'Entering parseRequest() for data of length ' . strlen(
$data) .
' and type ' .
$headers[
'content-type']);
4326 if (!strstr(
$headers[
'content-type'],
'text/xml')) {
4327 $this->
setError(
'Request not of type text/xml');
4328 return false;
4329 }
4330 if (strpos(
$headers[
'content-type'],
'=')) {
4331 $enc = str_replace(
'"',
'', substr(strstr(
$headers[
"content-type"],
'='), 1));
4332 $this->
debug(
'Got response encoding: ' . $enc);
4333 if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
4334 $this->xml_encoding = strtoupper($enc);
4335 } else {
4336 $this->xml_encoding = 'US-ASCII';
4337 }
4338 } else {
4339
4340 $this->xml_encoding = 'ISO-8859-1';
4341 }
4342 $this->
debug(
'Use encoding: ' . $this->xml_encoding .
' when creating nusoap_parser');
4343
4345
4346 $this->
debug(
"parser debug: \n" . $parser->getDebug());
4347
4348 if ($err = $parser->getError()) {
4349 $this->result = 'fault: error in msg parsing: ' . $err;
4350 $this->
fault(
'SOAP-ENV:Client',
"error in msg parsing:\n" . $err);
4351
4352 } else {
4353
4354 $this->methodURI = $parser->root_struct_namespace;
4355 $this->methodname = $parser->root_struct_name;
4356 $this->
debug(
'methodname: ' . $this->methodname .
' methodURI: ' . $this->methodURI);
4357 $this->
debug(
'calling parser->get_soapbody()');
4358 $this->methodparams = $parser->get_soapbody();
4359
4360 $this->requestHeaders = $parser->getHeaders();
4361
4362 $this->requestHeader = $parser->get_soapheader();
4363
4364 $this->document = $parser->document;
4365 }
4366 }
4367
4376 {
4377 return $soapmsg;
4378 }
4379
4389 {
4390 return 'text/xml';
4391 }
4392
4403 {
4405 }
4406
4417 {
4419 }
4420
4435 public function register(
$name, $in=array(),
$out=array(),
$namespace=
false, $soapaction=
false, $style=
false, $use=
false, $documentation=
'', $encodingStyle=
'')
4436 {
4437 global $HTTP_SERVER_VARS;
4438
4439 if ($this->externalWSDLURL) {
4440 die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
4441 }
4443 die('You must specify a name when you register an operation');
4444 }
4445 if (!is_array($in)) {
4446 die('You must provide an array for operation inputs');
4447 }
4448 if (!is_array(
$out)) {
4449 die('You must provide an array for operation outputs');
4450 }
4452 }
4453 if (false == $soapaction) {
4455 $SERVER_NAME =
$_SERVER[
'SERVER_NAME'];
4457 $HTTPS = isset(
$_SERVER[
'HTTPS']) ?
$_SERVER[
'HTTPS'] : (isset($HTTP_SERVER_VARS[
'HTTPS']) ? $HTTP_SERVER_VARS[
'HTTPS'] :
'off');
4458 } elseif (isset($HTTP_SERVER_VARS)) {
4459 $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
4460 $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
4461 $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
4462 } else {
4463 $this->
setError(
"Neither _SERVER nor HTTP_SERVER_VARS is available");
4464 }
4465 if ($HTTPS == '1' || $HTTPS == 'on') {
4466 $SCHEME = 'https';
4467 } else {
4468 $SCHEME = 'http';
4469 }
4470 $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
4471 }
4472 if (false == $style) {
4473 $style = "rpc";
4474 }
4475 if (false == $use) {
4476 $use = "encoded";
4477 }
4478 if ($use == 'encoded' && $encodingStyle = '') {
4479 $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
4480 }
4481
4482 $this->operations[
$name] = array(
4484 'in' => $in,
4487 'soapaction' => $soapaction,
4488 'style' => $style);
4491 }
4492 return true;
4493 }
4494
4505 public function fault($faultcode, $faultstring, $faultactor=
'', $faultdetail=
'')
4506 {
4507 if ($faultdetail == '' && $this->debug_flag) {
4509 }
4510 $this->
fault =
new nusoap_fault($faultcode, $faultactor, $faultstring, $faultdetail);
4512 }
4513
4525 public function configureWSDL(
$serviceName,
$namespace =
false, $endpoint =
false, $style=
'rpc', $transport =
'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace =
false)
4526 {
4527 global $HTTP_SERVER_VARS;
4528
4530 $SERVER_NAME =
$_SERVER[
'SERVER_NAME'];
4531 $SERVER_PORT =
$_SERVER[
'SERVER_PORT'];
4533 $HTTPS = isset(
$_SERVER[
'HTTPS']) ?
$_SERVER[
'HTTPS'] : (isset($HTTP_SERVER_VARS[
'HTTPS']) ? $HTTP_SERVER_VARS[
'HTTPS'] :
'off');
4534 } elseif (isset($HTTP_SERVER_VARS)) {
4535 $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
4536 $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
4537 $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
4538 $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
4539 } else {
4540 $this->
setError(
"Neither _SERVER nor HTTP_SERVER_VARS is available");
4541 }
4542
4543 $colon = strpos($SERVER_NAME, ":");
4544 if ($colon) {
4545 $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
4546 }
4547 if ($SERVER_PORT == 80) {
4548 $SERVER_PORT = '';
4549 } else {
4550 $SERVER_PORT = ':' . $SERVER_PORT;
4551 }
4553 $namespace =
"http://$SERVER_NAME/soap/$serviceName";
4554 }
4555
4556 if (false == $endpoint) {
4557 if ($HTTPS == '1' || $HTTPS == 'on') {
4558 $SCHEME = 'https';
4559 } else {
4560 $SCHEME = 'http';
4561 }
4562 $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME";
4563 }
4564
4565 if (false == $schemaTargetNamespace) {
4567 }
4568
4571 $this->
wsdl->endpoint = $endpoint;
4573 $this->
wsdl->namespaces[
'soap'] =
'http://schemas.xmlsoap.org/wsdl/soap/';
4574 $this->
wsdl->namespaces[
'wsdl'] =
'http://schemas.xmlsoap.org/wsdl/';
4576 $this->
wsdl->namespaces[
'types'] = $schemaTargetNamespace;
4577 }
4579 if ($style == 'document') {
4580 $this->
wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo[
'elementFormDefault'] =
'qualified';
4581 }
4582 $this->
wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
4583 $this->
wsdl->schemas[$schemaTargetNamespace][0]->imports[
'http://schemas.xmlsoap.org/soap/encoding/'][0] = array(
'location' =>
'',
'loaded' =>
true);
4584 $this->
wsdl->schemas[$schemaTargetNamespace][0]->imports[
'http://schemas.xmlsoap.org/wsdl/'][0] = array(
'location' =>
'',
'loaded' =>
true);
4587 'style'=>$style,
4588 'transport'=>$transport,
4592 'location'=>$endpoint,
4593 'bindingType'=>'http://schemas.xmlsoap.org/wsdl/soap/');
4594 }
4595}
4596
4601{
4602}
4603
4604?><?php
4605
4606
4607
4618{
4619
4621
4639
4641
4646
4655
4660
4676 {
4678 $this->
debug(
"ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
4687 }
4690 }
4691
4698 {
4699 $this->
debug(
"parse and process WSDL path=$wsdl");
4701
4702 if ($this->
wsdl !=
"") {
4704 }
4705
4706
4707 $imported_urls = array();
4708 $imported = 1;
4709 while ($imported > 0) {
4710 $imported = 0;
4711
4712 foreach ($this->schemas as $ns => $list) {
4713 foreach ($list as $xs) {
4714 $wsdlparts = parse_url($this->
wsdl);
4715 foreach ($xs->imports as $ns2 => $list2) {
4716 for ($ii = 0; $ii < count($list2); $ii++) {
4717 if (! $list2[$ii]['loaded']) {
4718 $this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
4719 $url = $list2[$ii][
'location'];
4721 $urlparts = parse_url(
$url);
4722 if (!isset($urlparts['host'])) {
4723 $url = $wsdlparts[
'scheme'] .
'://' . $wsdlparts[
'host'] . (isset($wsdlparts[
'port']) ?
':' . $wsdlparts[
'port'] :
'') .
4724 substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1) . $urlparts['path'];
4725 }
4726 if (! in_array(
$url, $imported_urls)) {
4728 $imported++;
4729 $imported_urls[] =
$url;
4730 }
4731 } else {
4732 $this->
debug(
"Unexpected scenario: empty URL for unloaded import");
4733 }
4734 }
4735 }
4736 }
4737 }
4738 }
4739
4740 $wsdlparts = parse_url($this->
wsdl);
4741 foreach ($this->import as $ns => $list) {
4742 for ($ii = 0; $ii < count($list); $ii++) {
4743 if (! $list[$ii]['loaded']) {
4744 $this->import[$ns][$ii]['loaded'] = true;
4745 $url = $list[$ii][
'location'];
4747 $urlparts = parse_url(
$url);
4748 if (!isset($urlparts['host'])) {
4749 $url = $wsdlparts[
'scheme'] .
'://' . $wsdlparts[
'host'] . (isset($wsdlparts[
'port']) ?
':' . $wsdlparts[
'port'] :
'') .
4750 substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1) . $urlparts['path'];
4751 }
4752 if (! in_array(
$url, $imported_urls)) {
4754 $imported++;
4755 $imported_urls[] =
$url;
4756 }
4757 } else {
4758 $this->
debug(
"Unexpected scenario: empty URL for unloaded import");
4759 }
4760 }
4761 }
4762 }
4763 }
4764
4765 foreach ($this->bindings as $binding => $bindingData) {
4766 if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
4767 foreach ($bindingData[
'operations'] as $operation =>
$data) {
4768 $this->
debug(
'post-parse data gathering for ' . $operation);
4769 $this->bindings[$binding]['operations'][$operation]['input'] =
4770 isset($this->bindings[$binding]['operations'][$operation]['input']) ?
4771 array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) :
4772 $this->portTypes[ $bindingData['portType'] ][$operation]['input'];
4773 $this->bindings[$binding]['operations'][$operation]['output'] =
4774 isset($this->bindings[$binding]['operations'][$operation]['output']) ?
4775 array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) :
4776 $this->portTypes[ $bindingData['portType'] ][$operation]['output'];
4777 if (isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])) {
4778 $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ];
4779 }
4780 if (isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])) {
4781 $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ];
4782 }
4783
4784 if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
4785 $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style'];
4786 }
4787 $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : '';
4788 $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : '';
4789 $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : '';
4790 }
4791 }
4792 }
4793 }
4794
4802 {
4803 $this->
debug(
"parse WSDL at path=$wsdl");
4804
4805 if ($wsdl == '') {
4806 $this->
debug(
'no wsdl passed to parseWSDL()!!');
4807 $this->
setError(
'no wsdl passed to parseWSDL()!!');
4808 return false;
4809 }
4810
4811
4812 $wsdl_props = parse_url(
$wsdl);
4813
4814 if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) {
4815 $this->
debug(
'getting WSDL http(s) URL ' . $wsdl);
4816
4818 $tr->request_method = 'GET';
4819 $tr->useSOAPAction = false;
4820 if ($this->proxyhost && $this->proxyport) {
4821 $tr->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword);
4822 }
4823 if ($this->authtype != '') {
4824 $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
4825 }
4826 $tr->setEncoding('gzip, deflate');
4827 $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
4828
4829
4831
4832 if ($err = $tr->getError()) {
4833 $errstr = 'HTTP ERROR: ' . $err;
4834 $this->
debug($errstr);
4836 unset($tr);
4837 return false;
4838 }
4839 unset($tr);
4840 $this->
debug(
"got WSDL URL");
4841 } else {
4842
4843 if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
4844 $path = isset($wsdl_props[
'host']) ? ($wsdl_props[
'host'] .
':' . $wsdl_props[
'path']) : $wsdl_props[
'path'];
4845 } else {
4847 }
4849 if ($fp = @fopen(
$path,
'r')) {
4850 $wsdl_string = '';
4851 while (
$data = fread($fp, 32768)) {
4852 $wsdl_string .=
$data;
4853 }
4854 fclose($fp);
4855 } else {
4856 $errstr = "Bad path to WSDL file $path";
4857 $this->
debug($errstr);
4859 return false;
4860 }
4861 }
4862 $this->
debug(
'Parse WSDL');
4863
4864
4865 $this->parser = xml_parser_create();
4866
4867
4868 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
4869
4870 xml_set_object($this->parser, $this);
4871
4872 xml_set_element_handler($this->parser, 'start_element', 'end_element');
4873 xml_set_character_data_handler($this->parser, 'character_data');
4874
4875 if (!xml_parse($this->parser, $wsdl_string, true)) {
4876
4877 $errstr = sprintf(
4878 'XML error parsing WSDL from %s on line %d: %s',
4880 xml_get_current_line_number($this->parser),
4881 xml_error_string(xml_get_error_code($this->parser))
4882 );
4883 $this->
debug($errstr);
4884 $this->
debug(
"XML payload:\n" . $wsdl_string);
4886 return false;
4887 }
4888
4889 xml_parser_free($this->parser);
4890 $this->
debug(
'Parsing WSDL done');
4891
4893 return false;
4894 }
4895 return true;
4896 }
4897
4907 {
4908 if ($this->status == 'schema') {
4909 $this->currentSchema->schemaStartElement(
$parser,
$name, $attrs);
4910 $this->
appendDebug($this->currentSchema->getDebug());
4911 $this->currentSchema->clearDebug();
4912 } elseif (preg_match(
'/schema$/',
$name)) {
4913 $this->
debug(
'Parsing WSDL schema');
4914
4915 $this->status = 'schema';
4917 $this->currentSchema->schemaStartElement(
$parser,
$name, $attrs);
4918 $this->
appendDebug($this->currentSchema->getDebug());
4919 $this->currentSchema->clearDebug();
4920 } else {
4921
4922 $pos = $this->position++;
4924
4925 $this->depth_array[
$depth] = $pos;
4926 $this->message[$pos] = array('cdata' => '');
4927
4928 if (count($attrs) > 0) {
4929
4930 foreach ($attrs as $k => $v) {
4931 if (preg_match('/^xmlns/', $k)) {
4932 if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
4933 $this->namespaces[$ns_prefix] = $v;
4934 } else {
4935 $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
4936 }
4937 if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
4938 $this->XMLSchemaVersion = $v;
4939 $this->namespaces['xsi'] = $v . '-instance';
4940 }
4941 }
4942 }
4943
4944 foreach ($attrs as $k => $v) {
4945 $k = strpos($k,
':') ? $this->
expandQname($k) : $k;
4946 if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') {
4947 $v = strpos($v,
':') ? $this->
expandQname($v) : $v;
4948 }
4949 $eAttrs[$k] = $v;
4950 }
4951 $attrs = $eAttrs;
4952 } else {
4953 $attrs = array();
4954 }
4955
4956 if (preg_match(
'/:/',
$name)) {
4957
4958 $prefix = substr(
$name, 0, strpos(
$name,
':'));
4959
4960 $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] :
'';
4961
4963 }
4964
4965
4966 switch ($this->status) {
4967 case 'message':
4968 if (
$name ==
'part') {
4969 if (isset($attrs['type'])) {
4970 $this->
debug(
"msg " . $this->currentMessage .
": found part (with type) $attrs[name]: " . implode(
',', $attrs));
4972 }
4973 if (isset($attrs['element'])) {
4974 $this->
debug(
"msg " . $this->currentMessage .
": found part (with element) $attrs[name]: " . implode(
',', $attrs));
4976 }
4977 }
4978 break;
4979 case 'portType':
4981 case 'operation':
4982 $this->currentPortOperation = $attrs['name'];
4983 $this->
debug(
"portType $this->currentPortType operation: $this->currentPortOperation");
4984 if (isset($attrs['parameterOrder'])) {
4986 }
4987 break;
4988 case 'documentation':
4989 $this->documentation = true;
4990 break;
4991
4992 default:
4993 $m = isset($attrs[
'message']) ? $this->
getLocalPart($attrs[
'message']) :
'';
4995 break;
4996 }
4997 break;
4998 case 'binding':
5000 case 'binding':
5001
5002 if (isset($attrs['style'])) {
5004 }
5005 $this->bindings[
$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
5006 break;
5007 case 'header':
5009 break;
5010 case 'operation':
5011 if (isset($attrs['soapAction'])) {
5013 }
5014 if (isset($attrs['style'])) {
5016 }
5017 if (isset($attrs['name'])) {
5018 $this->currentOperation = $attrs['name'];
5019 $this->
debug(
"current binding operation: $this->currentOperation");
5023 }
5024 break;
5025 case 'input':
5026 $this->opStatus = 'input';
5027 break;
5028 case 'output':
5029 $this->opStatus = 'output';
5030 break;
5031 case 'body':
5032 if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
5034 } else {
5036 }
5037 break;
5038 }
5039 break;
5040 case 'service':
5042 case 'port':
5043 $this->currentPort = $attrs['name'];
5044 $this->
debug(
'current port: ' . $this->currentPort);
5046
5047 break;
5048 case 'address':
5052 $this->bindings[ $this->ports[
$this->currentPort][
'binding'] ][
'endpoint'] = $attrs[
'location'];
5053 break;
5054 }
5055 break;
5056 }
5057
5059 case 'import':
5060 if (isset($attrs['location'])) {
5061 $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
5062 $this->
debug(
'parsing import ' . $attrs[
'namespace'] .
' - ' . $attrs[
'location'] .
' (' . count($this->
import[$attrs[
'namespace']]) .
')');
5063 } else {
5064 $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
5066 $this->namespaces['ns' . (count($this->namespaces)+1)] = $attrs['namespace'];
5067 }
5068 $this->
debug(
'parsing import ' . $attrs[
'namespace'] .
' - [no location] (' . count($this->
import[$attrs[
'namespace']]) .
')');
5069 }
5070 break;
5071
5072
5073
5074
5075 case 'message':
5076 $this->status = 'message';
5077 $this->messages[$attrs['name']] = array();
5078 $this->currentMessage = $attrs['name'];
5079 break;
5080 case 'portType':
5081 $this->status = 'portType';
5082 $this->portTypes[$attrs['name']] = array();
5083 $this->currentPortType = $attrs['name'];
5084 break;
5085 case "binding":
5086 if (isset($attrs['name'])) {
5087
5088 if (strpos($attrs['name'], ':')) {
5089 $this->currentBinding = $this->
getLocalPart($attrs[
'name']);
5090 } else {
5091 $this->currentBinding = $attrs['name'];
5092 }
5093 $this->status = 'binding';
5095 $this->
debug(
"current binding: $this->currentBinding of portType: " . $attrs[
'type']);
5096 }
5097 break;
5098 case 'service':
5099 $this->serviceName = $attrs['name'];
5100 $this->status = 'service';
5101 $this->
debug(
'current service: ' . $this->serviceName);
5102 break;
5103 case 'definitions':
5104 foreach ($attrs as
$name => $value) {
5105 $this->wsdl_info[
$name] = $value;
5106 }
5107 break;
5108 }
5109 }
5110 }
5111
5120 {
5121
5122 if ( preg_match(
'/schema$/',
$name)) {
5123 $this->status = "";
5124 $this->
appendDebug($this->currentSchema->getDebug());
5125 $this->currentSchema->clearDebug();
5127 $this->
debug(
'Parsing WSDL schema done');
5128 }
5129 if ($this->status == 'schema') {
5130 $this->currentSchema->schemaEndElement(
$parser,
$name);
5131 } else {
5132
5133 $this->depth--;
5134 }
5135
5136 if ($this->documentation) {
5137
5138
5139 $this->documentation = false;
5140 }
5141 }
5142
5151 {
5152 $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[
$this->depth] : 0;
5153 if (isset($this->message[$pos]['cdata'])) {
5154 $this->message[$pos][
'cdata'] .=
$data;
5155 }
5156 if ($this->documentation) {
5157 $this->documentation .=
$data;
5158 }
5159 }
5160
5171 {
5172 $this->
debug(
"setCredentials username=$username authtype=$authtype certRequest=");
5178 }
5179
5181 {
5182 if (is_array($this->bindings[$binding])) {
5183 return $this->bindings[$binding];
5184 }
5185 }
5186
5195 {
5196 $ops = array();
5197 if ($bindingType == 'soap') {
5198 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
5199 } elseif ($bindingType == 'soap12') {
5200 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
5201 }
5202
5203 foreach ($this->ports as $port => $portData) {
5204
5205 if ($portData['bindingType'] == $bindingType) {
5206
5207
5208
5209
5210 if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
5211 $ops = array_merge($ops, $this->bindings[ $portData['binding'] ]['operations']);
5212 }
5213 }
5214 }
5215 return $ops;
5216 }
5217
5227 {
5228 if ($bindingType == 'soap') {
5229 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
5230 } elseif ($bindingType == 'soap12') {
5231 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
5232 }
5233
5234 foreach ($this->ports as $port => $portData) {
5235
5236 if ($portData['bindingType'] == $bindingType) {
5237
5238
5239 foreach (array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
5240
5241 if ($operation == $bOperation) {
5242 $opData = $this->bindings[ $portData[
'binding'] ][
'operations'][$operation];
5244 }
5245 }
5246 }
5247 }
5248 }
5249
5259 {
5260 if ($bindingType == 'soap') {
5261 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
5262 } elseif ($bindingType == 'soap12') {
5263 $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
5264 }
5265
5266 foreach ($this->ports as $port => $portData) {
5267
5268 if ($portData['bindingType'] == $bindingType) {
5269
5270 foreach ($this->bindings[ $portData[
'binding'] ][
'operations'] as $bOperation =>
$opData) {
5271 if (
$opData[
'soapAction'] == $soapAction) {
5273 }
5274 }
5275 }
5276 }
5277 }
5278
5298 {
5299 $this->
debug(
"in getTypeDef: type=$type, ns=$ns");
5300 if ((! $ns) && isset($this->namespaces['tns'])) {
5301 $ns = $this->namespaces['tns'];
5302 $this->
debug(
"in getTypeDef: type namespace forced to $ns");
5303 }
5304 if (!isset($this->schemas[$ns])) {
5305 foreach ($this->schemas as $ns0 => $schema0) {
5306 if (strcasecmp($ns, $ns0) == 0) {
5307 $this->
debug(
"in getTypeDef: replacing schema namespace $ns with $ns0");
5308 $ns = $ns0;
5309 break;
5310 }
5311 }
5312 }
5313 if (isset($this->schemas[$ns])) {
5314 $this->
debug(
"in getTypeDef: have schema for namespace $ns");
5315 for (
$i = 0;
$i < count($this->schemas[$ns]);
$i++) {
5316 $xs = &$this->schemas[$ns][
$i];
5317 $t = $xs->getTypeDef(
$type);
5318
5319
5320 if ($t) {
5321 if (!isset($t['phpType'])) {
5322
5323 $uqType = substr($t['type'], strrpos($t['type'], ':') + 1);
5324 $ns = substr($t['type'], 0, strrpos($t['type'], ':'));
5326 if ($etype) {
5327 $this->
debug(
"found type for [element] $type:");
5329 if (isset($etype['phpType'])) {
5330 $t['phpType'] = $etype['phpType'];
5331 }
5332 if (isset($etype['elements'])) {
5333 $t['elements'] = $etype['elements'];
5334 }
5335 if (isset($etype['attrs'])) {
5336 $t['attrs'] = $etype['attrs'];
5337 }
5338 }
5339 }
5340 return $t;
5341 }
5342 }
5343 } else {
5344 $this->
debug(
"in getTypeDef: do not have schema for namespace $ns");
5345 }
5346 return false;
5347 }
5348
5355 {
5356 global $HTTP_SERVER_VARS;
5357
5360 } elseif (isset($HTTP_SERVER_VARS)) {
5361 $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
5362 } else {
5363 $this->
setError(
"Neither _SERVER nor HTTP_SERVER_VARS is available");
5364 }
5365
5366 $PHP_SELF = filter_var($PHP_SELF, FILTER_SANITIZE_STRING);
5367
5368
5370 <html><head><title>NuSOAP: ' . $this->serviceName . '</title>
5371 <style type="text/css">
5372 body { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
5373 p { font-family: arial; color: #000000; margin-top: 0px; margin-bottom: 12px; }
5374 pre { background-color: silver; padding: 5px; font-family: Courier New; font-size: x-small; color: #000000;}
5375 ul { margin-top: 10px; margin-left: 20px; }
5376 li { list-style-type: none; margin-top: 10px; color: #000000; }
5377 .content{
5378 margin-left: 0px; padding-bottom: 2em; }
5379 .nav {
5380 padding-top: 10px; padding-bottom: 10px; padding-left: 15px; font-size: .70em;
5381 margin-top: 10px; margin-left: 0px; color: #000000;
5382 background-color: #ccccff; width: 20%; margin-left: 20px; margin-top: 20px; }
5383 .title {
5384 font-family: arial; font-size: 26px; color: #ffffff;
5385 background-color: #999999; width: 105%; margin-left: 0px;
5386 padding-top: 10px; padding-bottom: 10px; padding-left: 15px;}
5387 .hidden {
5388 position: absolute; visibility: hidden; z-index: 200; left: 250px; top: 100px;
5389 font-family: arial; overflow: hidden; width: 600;
5390 padding: 20px; font-size: 10px; background-color: #999999;
5391 layer-background-color:#FFFFFF; }
5392 a,a:active { color: charcoal; font-weight: bold; }
5393 a:visited { color: #666666; font-weight: bold; }
5394 a:hover { color: cc3300; font-weight: bold; }
5395 </style>
5396 <script language="JavaScript" type="text/javascript">
5397 <!--
5398 // POP-UP CAPTIONS...
5399 function lib_bwcheck(){ //Browsercheck (needed)
5400 this.ver=navigator.appVersion
5401 this.agent=navigator.userAgent
5402 this.dom=document.getElementById?1:0
5403 this.opera5=this.agent.indexOf("Opera 5")>-1
5404 this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
5405 this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
5406 this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
5407 this.ie=this.ie4||this.ie5||this.ie6
5408 this.mac=this.agent.indexOf("Mac")>-1
5409 this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
5410 this.ns4=(document.layers && !this.dom)?1:0;
5411 this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
5412 return this
5413 }
5414 var bw = new lib_bwcheck()
5415 //Makes crossbrowser object.
5416 function makeObj(obj){
5417 this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj]:0;
5418 if(!this.evnt) return false
5419 this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;
5420 this.wref=bw.dom||bw.ie4?this.evnt:bw.ns4?this.css.document:0;
5421 this.writeIt=b_writeIt;
5422 return this
5423 }
5424 // A unit of measure that will be added when setting the position of a layer.
5425 //var px = bw.ns4||window.opera?"":"px";
5426 function b_writeIt(text){
5427 if (bw.ns4){this.wref.write(text);this.wref.close()}
5428 else this.wref.innerHTML = text
5429 }
5430 //Shows the messages
5431 var oDesc;
5432 function popup(divid){
5433 if(oDesc = new makeObj(divid)){
5434 oDesc.css.visibility = "visible"
5435 }
5436 }
5437 function popout(){ // Hides message
5438 if(oDesc) oDesc.css.visibility = "hidden"
5439 }
5440 //-->
5441 </script>
5442 </head>
5443 <body>
5444 <div class=content>
5445 <br><br>
5446 <div class=title>' . $this->serviceName . '</div>
5447 <div class=nav>
5448 <p>View the <a href="' . $PHP_SELF . '?wsdl">WSDL</a> for the service.
5449 Click on an operation name to view it's details.</p>
5450 <ul>';
5452
5453 if (isset(
$data[
'endpoint'])) {
5454 $data[
'endpoint'] = filter_var(
$data[
'endpoint'], FILTER_SANITIZE_STRING);
5455 }
5456
5457 $b .=
"<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
5458
5459 $b .=
"<div id='$op' class='hidden'>
5460 <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
5461 foreach (
$data as $donnie => $marie) {
5462 if ($donnie == 'input' || $donnie == 'output') {
5463 $b .=
"<font color='white'>" . ucfirst($donnie) .
':</font><br>';
5464 foreach ($marie as $captain => $tenille) {
5465 if ($captain == 'parts') {
5466 $b .=
" $captain:<br>";
5467
5468 foreach ($tenille as $joanie => $chachi) {
5469 $b .=
" $joanie: $chachi<br>";
5470 }
5471
5472 } else {
5473 $b .=
" $captain: $tenille<br>";
5474 }
5475 }
5476 } else {
5477 $b .=
"<font color='white'>" . ucfirst($donnie) .
":</font> $marie<br>";
5478 }
5479 }
5481 }
5483 <ul>
5484 </div>
5485 </div></body></html>';
5487 }
5488
5497 {
5498 $xml =
'<?xml version="1.0" encoding="ISO-8859-1"?>';
5499 $xml .=
"\n<definitions";
5500 foreach ($this->namespaces as $k => $v) {
5501 $xml .=
" xmlns:$k=\"$v\"";
5502 }
5503
5504 if (isset($this->namespaces['wsdl'])) {
5505 $xml .=
" xmlns=\"" . $this->namespaces[
'wsdl'] .
"\"";
5506 }
5507 if (isset($this->namespaces['tns'])) {
5508 $xml .=
" targetNamespace=\"" . $this->namespaces[
'tns'] .
"\"";
5509 }
5511
5512 if (sizeof($this->import) > 0) {
5513 foreach ($this->import as $ns => $list) {
5514 foreach ($list as $ii) {
5515 if ($ii['location'] != '') {
5516 $xml .=
'<import location="' . $ii[
'location'] .
'" namespace="' . $ns .
'" />';
5517 } else {
5518 $xml .=
'<import namespace="' . $ns .
'" />';
5519 }
5520 }
5521 }
5522 }
5523
5524 if (count($this->schemas)>=1) {
5525 $xml .=
"\n<types>\n";
5526 foreach ($this->schemas as $ns => $list) {
5527 foreach ($list as $xs) {
5528 $xml .= $xs->serializeSchema();
5529 }
5530 }
5532 }
5533
5534 if (count($this->messages) >= 1) {
5535 foreach ($this->messages as $msgName => $msgParts) {
5536 $xml .=
"\n<message name=\"" . $msgName .
'">';
5537 if (is_array($msgParts)) {
5538 foreach ($msgParts as $partName => $partType) {
5539
5540 if (strpos($partType, ':')) {
5542 } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
5543
5544 $typePrefix = 'xsd';
5545 } else {
5546 foreach ($this->typemap as $ns => $types) {
5547 if (isset($types[$partType])) {
5549 }
5550 }
5551 if (!isset($typePrefix)) {
5552 die("$partType has no namespace!");
5553 }
5554 }
5557 $typeDef = $this->
getTypeDef($localPart, $ns);
5558 if (($typeDef['typeClass'] ?? '') == 'element') {
5559 $elementortype = 'element';
5560 if (substr($localPart, -1) == '^') {
5561 $localPart = substr($localPart, 0, -1);
5562 }
5563 } else {
5564 $elementortype = 'type';
5565 }
5566 $xml .=
"\n" .
' <part name="' . $partName .
'" ' . $elementortype .
'="' . $typePrefix .
':' . $localPart .
'" />';
5567 }
5568 }
5569 $xml .=
'</message>';
5570 }
5571 }
5572
5573 if (count($this->bindings) >= 1) {
5574 $binding_xml = '';
5575 $portType_xml = '';
5576 foreach ($this->bindings as $bindingName => $attrs) {
5577 $binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
5578 $binding_xml .= "\n" . ' <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
5579 $portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
5580 foreach ($attrs['operations'] as $opName => $opParts) {
5581 $binding_xml .= "\n" . ' <operation name="' . $opName . '">';
5582 $binding_xml .= "\n" . ' <soap:operation soapAction="' . $opParts['soapAction'] . '" style="' . $opParts['style'] . '"/>';
5583 if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
5584 $enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
5585 } else {
5586 $enc_style = '';
5587 }
5588 $binding_xml .= "\n" . ' <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
5589 if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
5590 $enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
5591 } else {
5592 $enc_style = '';
5593 }
5594 $binding_xml .= "\n" . ' <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
5595 $binding_xml .= "\n" . ' </operation>';
5596 $portType_xml .= "\n" . ' <operation name="' . $opParts['name'] . '"';
5597 if (isset($opParts['parameterOrder'])) {
5598 $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
5599 }
5600 $portType_xml .= '>';
5601 if (isset($opParts['documentation']) && $opParts['documentation'] != '') {
5602 $portType_xml .= "\n" . ' <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
5603 }
5604 $portType_xml .= "\n" . ' <input message="tns:' . $opParts['input']['message'] . '"/>';
5605 $portType_xml .= "\n" . ' <output message="tns:' . $opParts['output']['message'] . '"/>';
5606 $portType_xml .= "\n" . ' </operation>';
5607 }
5608 $portType_xml .= "\n" . '</portType>';
5609 $binding_xml .= "\n" . '</binding>';
5610 }
5611 $xml .= $portType_xml . $binding_xml;
5612 }
5613
5614 $xml .=
"\n<service name=\"" . $this->serviceName .
'">';
5615 $has_client = isset(
$_GET[
'client_id']);
5616 if (count($this->ports) >= 1) {
5617 foreach ($this->ports as $pName => $attrs) {
5618 $xml .=
"\n" .
' <port name="' . $pName .
'" binding="tns:' . $attrs[
'binding'] .
'">';
5619 $address = $attrs['location'] . ($debug || $has_client ? "?" : "")
5620 . ($debug ? 'debug=1' : '') . ($debug && $has_client ? "&" : "")
5621 . ($has_client ?
'client_id=' .
$_GET[
'client_id'] :
'');
5622 $xml .=
"\n" .
' <soap:address location="' . $address .
'"/>';
5623 $xml .=
"\n" .
' </port>';
5624 }
5625 }
5626
5627 $xml .=
"\n" .
'</service>';
5628 return $xml .
"\n</definitions>";
5629 }
5630
5641 {
5642 $this->
debug(
"in parametersMatchWrapped type=$type, parameters=");
5644
5645
5646 if (strpos(
$type,
':')) {
5647 $uqType = substr(
$type, strrpos(
$type,
':') + 1);
5649 $this->
debug(
"in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
5652 $this->
debug(
"in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
5653 }
5654 } else {
5655
5656
5657 $this->
debug(
"in parametersMatchWrapped: No namespace for type $type");
5658 $ns = '';
5660 }
5661
5662
5663 if (!$typeDef = $this->
getTypeDef($uqType, $ns)) {
5664 $this->
debug(
"in parametersMatchWrapped: $type ($uqType) is not a supported type.");
5665 return false;
5666 }
5667 $this->
debug(
"in parametersMatchWrapped: found typeDef=");
5669 if (substr($uqType, -1) == '^') {
5670 $uqType = substr($uqType, 0, -1);
5671 }
5672 $phpType = $typeDef['phpType'];
5673 $arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '');
5674 $this->
debug(
"in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
5675
5676
5677 if ($phpType != 'struct') {
5678 $this->
debug(
"in parametersMatchWrapped: not a struct");
5679 return false;
5680 }
5681
5682
5683 if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
5684 $elements = 0;
5685 $matches = 0;
5686 $change = false;
5687 if ($this->
isArraySimpleOrStruct($parameters) ==
'arraySimple' && count($parameters) == count($typeDef[
'elements'])) {
5688 $this->
debug(
"in parametersMatchWrapped: (wrapped return value kludge) correct number of elements in simple array, so change array and wrap");
5689 $change = true;
5690 }
5691 foreach ($typeDef[
'elements'] as
$name => $attrs) {
5692 if ($change) {
5693 $this->
debug(
"in parametersMatchWrapped: change parameter $element to name $name");
5694 $parameters[
$name] = $parameters[$elements];
5695 unset($parameters[$elements]);
5696 $matches++;
5697 } elseif (isset($parameters[
$name])) {
5698 $this->
debug(
"in parametersMatchWrapped: have parameter named $name");
5699 $matches++;
5700 } else {
5701 $this->
debug(
"in parametersMatchWrapped: do not have parameter named $name");
5702 }
5703 $elements++;
5704 }
5705
5706 $this->
debug(
"in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names");
5707 if ($matches == 0) {
5708 return false;
5709 }
5710 return true;
5711 }
5712
5713
5714
5715 $this->
debug(
"in parametersMatchWrapped: no elements type $ns:$uqType");
5716 return count($parameters) == 0;
5717 }
5718
5735 {
5736 $this->
debug(
"in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
5738
5739 if ($direction != 'input' && $direction != 'output') {
5740 $this->
debug(
'The value of the \$direction argument needs to be either "input" or "output"');
5741 $this->
setError(
'The value of the \$direction argument needs to be either "input" or "output"');
5742 return false;
5743 }
5745 $this->
debug(
'Unable to retrieve WSDL data for operation: ' . $operation .
' bindingType: ' . $bindingType);
5746 $this->
setError(
'Unable to retrieve WSDL data for operation: ' . $operation .
' bindingType: ' . $bindingType);
5747 return false;
5748 }
5749 $this->
debug(
'in serializeRPCParameters: opData:');
5751
5752
5753 $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
5754 if (($direction ==
'input') && isset(
$opData[
'output'][
'encodingStyle']) && (
$opData[
'output'][
'encodingStyle'] != $encodingStyle)) {
5755 $encodingStyle =
$opData[
'output'][
'encodingStyle'];
5756 $enc_style = $encodingStyle;
5757 }
5758
5759
5761 if (isset(
$opData[$direction][
'parts']) &&
sizeof(
$opData[$direction][
'parts']) > 0) {
5763 $part_count =
sizeof(
$parts);
5765 $use =
$opData[$direction][
'use'];
5766 $this->
debug(
"have $part_count part(s) to serialize using $style/$use");
5767 if (is_array($parameters)) {
5769 $parameter_count = count($parameters);
5770 $this->
debug(
"have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
5771
5772 if ($style ==
'document' && $use ==
'literal' && $part_count == 1 && isset(
$parts[
'parameters'])) {
5773 $this->
debug(
'check whether the caller has wrapped the parameters');
5774 if ((($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) || ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1)) {
5775 $this->
debug(
'check whether caller\'s parameters match the wrapped ones');
5777 $this->
debug(
'wrap the parameters for the caller');
5778 $parameters = array('parameters' => $parameters);
5779 $parameter_count = 1;
5780 }
5781 }
5782 }
5784 $this->
debug(
"serializing part $name of type $type");
5785
5786 if (isset(
$opData[$direction][
'encodingStyle']) && $encodingStyle !=
$opData[$direction][
'encodingStyle']) {
5787 $encodingStyle =
$opData[$direction][
'encodingStyle'];
5788 $enc_style = $encodingStyle;
5789 } else {
5790 $enc_style = false;
5791 }
5792
5793
5794 if ($parametersArrayType == 'arraySimple') {
5795 $p = array_shift($parameters);
5796 $this->
debug(
'calling serializeType w/indexed param');
5798 } elseif (isset($parameters[
$name])) {
5799 $this->
debug(
'calling serializeType w/named param');
5801 } else {
5802
5803 $this->
debug(
'calling serializeType w/null param');
5805 }
5806 }
5807 } else {
5808 $this->
debug(
'no parameters passed.');
5809 }
5810 }
5811 $this->
debug(
"serializeRPCParameters returning: $xml");
5813 }
5814
5830 {
5831 $this->
debug(
"in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
5833
5834 if ($direction != 'input' && $direction != 'output') {
5835 $this->
debug(
'The value of the \$direction argument needs to be either "input" or "output"');
5836 $this->
setError(
'The value of the \$direction argument needs to be either "input" or "output"');
5837 return false;
5838 }
5840 $this->
debug(
'Unable to retrieve WSDL data for operation: ' . $operation);
5841 $this->
setError(
'Unable to retrieve WSDL data for operation: ' . $operation);
5842 return false;
5843 }
5844 $this->
debug(
'opData:');
5846
5847
5848 $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
5849 if (($direction ==
'input') && isset(
$opData[
'output'][
'encodingStyle']) && (
$opData[
'output'][
'encodingStyle'] != $encodingStyle)) {
5850 $encodingStyle =
$opData[
'output'][
'encodingStyle'];
5851 $enc_style = $encodingStyle;
5852 }
5853
5854
5856 if (isset(
$opData[$direction][
'parts']) &&
sizeof(
$opData[$direction][
'parts']) > 0) {
5857 $use =
$opData[$direction][
'use'];
5858 $this->
debug(
"use=$use");
5859 $this->
debug(
'got ' . count(
$opData[$direction][
'parts']) .
' part(s)');
5860 if (is_array($parameters)) {
5862 $this->
debug(
'have ' . $parametersArrayType .
' parameters');
5864 $this->
debug(
'serializing part "' .
$name .
'" of type "' . $type .
'"');
5865
5866 if (isset(
$opData[$direction][
'encodingStyle']) && $encodingStyle !=
$opData[$direction][
'encodingStyle']) {
5867 $encodingStyle =
$opData[$direction][
'encodingStyle'];
5868 $enc_style = $encodingStyle;
5869 } else {
5870 $enc_style = false;
5871 }
5872
5873
5874 if ($parametersArrayType == 'arraySimple') {
5875 $p = array_shift($parameters);
5876 $this->
debug(
'calling serializeType w/indexed param');
5878 } elseif (isset($parameters[
$name])) {
5879 $this->
debug(
'calling serializeType w/named param');
5881 } else {
5882
5883 $this->
debug(
'calling serializeType w/null param');
5885 }
5886 }
5887 } else {
5888 $this->
debug(
'no parameters passed.');
5889 }
5890 }
5891 $this->
debug(
"serializeParameters returning: $xml");
5893 }
5894
5907 public function serializeType(
$name, $type, $value, $use=
'encoded', $encodingStyle=
false, $unqualified=
false)
5908 {
5909 $this->
debug(
"in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ?
"unqualified" :
"qualified"));
5911 if ($use == 'encoded' && $encodingStyle) {
5912 $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
5913 }
5914
5915
5916 if (is_object($value) && get_class($value) == 'soapval') {
5917 if ($value->type_ns) {
5918 $type = $value->type_ns .
':' . $value->type;
5919 $forceType = true;
5920 $this->
debug(
"in serializeType: soapval overrides type to $type");
5921 } elseif ($value->type) {
5922 $type = $value->type;
5923 $forceType = true;
5924 $this->
debug(
"in serializeType: soapval overrides type to $type");
5925 } else {
5926 $forceType = false;
5927 $this->
debug(
"in serializeType: soapval does not override type");
5928 }
5929 $attrs = $value->attributes;
5930 $value = $value->value;
5931 $this->
debug(
"in serializeType: soapval overrides value to $value");
5932 if ($attrs) {
5933 if (!is_array($value)) {
5934 $value['!'] = $value;
5935 }
5936 foreach ($attrs as $n => $v) {
5937 $value['!' . $n] = $v;
5938 }
5939 $this->
debug(
"in serializeType: soapval provides attributes");
5940 }
5941 } else {
5942 $forceType = false;
5943 }
5944
5946 if (strpos(
$type,
':')) {
5947 $uqType = substr(
$type, strrpos(
$type,
':') + 1);
5949 $this->
debug(
"in serializeType: got a prefixed type: $uqType, $ns");
5952 $this->
debug(
"in serializeType: expanded prefixed type: $uqType, $ns");
5953 }
5954
5955 if ($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/') {
5956 $this->
debug(
'in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
5957 if ($unqualified && $use == 'literal') {
5958 $elementNS = " xmlns=\"\"";
5959 } else {
5960 $elementNS = '';
5961 }
5962 if (is_null($value)) {
5963 if ($use == 'literal') {
5964
5965 $xml =
"<$name$elementNS/>";
5966 } else {
5967
5969 }
5970 $this->
debug(
"in serializeType: returning: $xml");
5972 }
5973 if ($uqType == 'Array') {
5974
5976 }
5977 if ($uqType == 'boolean') {
5978 if ((is_string($value) && $value == 'false') || (! $value)) {
5979 $value = 'false';
5980 } else {
5981 $value = 'true';
5982 }
5983 }
5984 if ($uqType == 'string' && gettype($value) == 'string') {
5986 }
5987 if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') {
5988 $value = sprintf("%.0lf", $value);
5989 }
5990
5991
5992
5994 if ($use == 'literal') {
5995 if ($forceType) {
5997 } else {
5998 $xml =
"<$name$elementNS>$value</$name>";
5999 }
6000 } else {
6002 }
6003 $this->
debug(
"in serializeType: returning: $xml");
6005 }
6006 $this->
debug(
'custom type extends XML Schema or SOAP Encoding namespace (yuck)');
6007 } elseif ($ns == 'http://xml.apache.org/xml-soap') {
6008 $this->
debug(
'in serializeType: appears to be Apache SOAP type');
6009 if ($uqType == 'Map') {
6011 if (! $tt_prefix) {
6012 $this->
debug(
'in serializeType: Add namespace for Apache SOAP type');
6013 $tt_prefix = 'ns' . rand(1000, 9999);
6014 $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
6015
6017 }
6018 $contents = '';
6019 foreach ($value as $k => $v) {
6020 $this->
debug(
"serializing map element: key $k, value $v");
6021 $contents .= '<item>';
6022 $contents .= $this->
serialize_val($k,
'key',
false,
false,
false,
false, $use);
6023 $contents .= $this->
serialize_val($v,
'value',
false,
false,
false,
false, $use);
6024 $contents .= '</item>';
6025 }
6026 if ($use == 'literal') {
6027 if ($forceType) {
6028 $xml =
"<$name xsi:type=\"" . $tt_prefix .
":$uqType\">$contents</$name>";
6029 } else {
6030 $xml =
"<$name>$contents</$name>";
6031 }
6032 } else {
6033 $xml =
"<$name xsi:type=\"" . $tt_prefix .
":$uqType\"$encodingStyle>$contents</$name>";
6034 }
6035 $this->
debug(
"in serializeType: returning: $xml");
6037 }
6038 $this->
debug(
'in serializeType: Apache SOAP type, but only support Map');
6039 }
6040 } else {
6041
6042
6043 $this->
debug(
"in serializeType: No namespace for type $type");
6044 $ns = '';
6046 }
6047 if (!$typeDef = $this->
getTypeDef($uqType, $ns)) {
6048 $this->
setError(
"$type ($uqType) is not a supported type.");
6049 $this->
debug(
"in serializeType: $type ($uqType) is not a supported type.");
6050 return false;
6051 } else {
6052 $this->
debug(
"in serializeType: found typeDef");
6054 if (substr($uqType, -1) == '^') {
6055 $uqType = substr($uqType, 0, -1);
6056 }
6057 }
6058 $phpType = $typeDef['phpType'];
6059 $this->
debug(
"in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef[
'arrayType']) ? $typeDef[
'arrayType'] :
''));
6060
6061 if ($phpType == 'struct') {
6062 if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
6063 $elementName = $uqType;
6064 if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
6065 $elementNS = " xmlns=\"$ns\"";
6066 } else {
6067 $elementNS = " xmlns=\"\"";
6068 }
6069 } else {
6070 $elementName =
$name;
6071 if ($unqualified) {
6072 $elementNS = " xmlns=\"\"";
6073 } else {
6074 $elementNS = '';
6075 }
6076 }
6077 if (is_null($value)) {
6078 if ($use == 'literal') {
6079
6080 $xml =
"<$elementName$elementNS/>";
6081 } else {
6083 }
6084 $this->
debug(
"in serializeType: returning: $xml");
6086 }
6087 if (is_object($value)) {
6088 $value = get_object_vars($value);
6089 }
6090 if (is_array($value)) {
6092 if ($use == 'literal') {
6093 if ($forceType) {
6095 } else {
6096 $xml =
"<$elementName$elementNS$elementAttrs>";
6097 }
6098 } else {
6099 $xml =
"<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\"$encodingStyle>";
6100 }
6101
6103 $xml .=
"</$elementName>";
6104 } else {
6105 $this->
debug(
"in serializeType: phpType is struct, but value is not an array");
6106 $this->
setError(
"phpType is struct, but value is not an array: see debug output for details");
6108 }
6109 } elseif ($phpType == 'array') {
6110 if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
6111 $elementNS = " xmlns=\"$ns\"";
6112 } else {
6113 if ($unqualified) {
6114 $elementNS = " xmlns=\"\"";
6115 } else {
6116 $elementNS = '';
6117 }
6118 }
6119 if (is_null($value)) {
6120 if ($use == 'literal') {
6121
6122 $xml =
"<$name$elementNS/>";
6123 } else {
6124 $xml =
"<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
6126 ":Array\" " .
6128 ':arrayType="' .
6130 ':' .
6131 $this->
getLocalPart($typeDef[
'arrayType']) .
"[0]\"/>";
6132 }
6133 $this->
debug(
"in serializeType: returning: $xml");
6135 }
6136 if (isset($typeDef['multidimensional'])) {
6137 $nv = array();
6138 foreach ($value as $v) {
6139 $cols =
',' .
sizeof($v);
6140 $nv = array_merge($nv, $v);
6141 }
6142 $value = $nv;
6143 } else {
6145 }
6146 if (is_array($value) && sizeof($value) >= 1) {
6147 $rows =
sizeof($value);
6148 $contents = '';
6149 foreach ($value as $k => $v) {
6150 $this->
debug(
"serializing array element: $k, $v of type: $typeDef[arrayType]");
6151
6152 if (!in_array($typeDef['arrayType'], $this->typemap['http://www.w3.org/2001/XMLSchema'])) {
6153 $contents .= $this->
serializeType(
'item', $typeDef[
'arrayType'], $v, $use);
6154 } else {
6155 $contents .= $this->
serialize_val($v,
'item', $typeDef[
'arrayType'],
null, $this->XMLSchemaVersion,
false, $use);
6156 }
6157 }
6158 } else {
6160 $contents = null;
6161 }
6162
6163
6164 if ($use == 'literal') {
6165 $xml =
"<$name$elementNS>"
6166 . $contents
6167 . "</$name>";
6168 } else {
6169 $xml =
"<$name$elementNS xsi:type=\"" . $this->
getPrefixFromNamespace(
'http://schemas.xmlsoap.org/soap/encoding/') .
':Array" ' .
6171 . ':arrayType="'
6173 .
":" . $this->
getLocalPart($typeDef[
'arrayType']) .
"[$rows$cols]\">"
6174 . $contents
6175 . "</$name>";
6176 }
6177 } elseif ($phpType == 'scalar') {
6178 if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
6179 $elementNS = " xmlns=\"$ns\"";
6180 } else {
6181 if ($unqualified) {
6182 $elementNS = " xmlns=\"\"";
6183 } else {
6184 $elementNS = '';
6185 }
6186 }
6187 if ($use == 'literal') {
6188 if ($forceType) {
6190 } else {
6191 $xml =
"<$name$elementNS>$value</$name>";
6192 }
6193 } else {
6195 }
6196 }
6197 $this->
debug(
"in serializeType: returning: $xml");
6199 }
6200
6212 {
6214 if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
6215 $this->
debug(
"serialize attributes for XML Schema type $ns:$uqType");
6216 if (is_array($value)) {
6217 $xvalue = $value;
6218 } elseif (is_object($value)) {
6219 $xvalue = get_object_vars($value);
6220 } else {
6221 $this->
debug(
"value is neither an array nor an object for XML Schema type $ns:$uqType");
6222 $xvalue = array();
6223 }
6224 foreach ($typeDef['attrs'] as $aName => $attrs) {
6225 if (isset($xvalue['!' . $aName])) {
6226 $xname = '!' . $aName;
6227 $this->
debug(
"value provided for attribute $aName with key $xname");
6228 } elseif (isset($xvalue[$aName])) {
6229 $xname = $aName;
6230 $this->
debug(
"value provided for attribute $aName with key $xname");
6231 } elseif (isset($attrs['default'])) {
6232 $xname = '!' . $aName;
6233 $xvalue[$xname] = $attrs['default'];
6234 $this->
debug(
'use default value of ' . $xvalue[$aName] .
' for attribute ' . $aName);
6235 } else {
6236 $xname = '';
6237 $this->
debug(
"no value provided for attribute $aName");
6238 }
6239 if ($xname) {
6241 }
6242 }
6243 } else {
6244 $this->
debug(
"no attributes to serialize for XML Schema type $ns:$uqType");
6245 }
6246 if (isset($typeDef['extensionBase'])) {
6247 $ns = $this->
getPrefix($typeDef[
'extensionBase']);
6248 $uqType = $this->
getLocalPart($typeDef[
'extensionBase']);
6251 }
6252 if ($typeDef = $this->
getTypeDef($uqType, $ns)) {
6253 $this->
debug(
"serialize attributes for extension base $ns:$uqType");
6255 } else {
6256 $this->
debug(
"extension base $ns:$uqType is not a supported type");
6257 }
6258 }
6260 }
6261
6275 {
6277 if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
6278 $this->
debug(
"in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
6279 if (is_array($value)) {
6280 $xvalue = $value;
6281 } elseif (is_object($value)) {
6282 $xvalue = get_object_vars($value);
6283 } else {
6284 $this->
debug(
"value is neither an array nor an object for XML Schema type $ns:$uqType");
6285 $xvalue = array();
6286 }
6287
6288 if (count($typeDef['elements']) != count($xvalue)) {
6289 $optionals = true;
6290 }
6291 foreach ($typeDef['elements'] as $eName => $attrs) {
6292 if (!isset($xvalue[$eName])) {
6293 if (isset($attrs['default'])) {
6294 $xvalue[$eName] = $attrs['default'];
6295 $this->
debug(
'use default value of ' . $xvalue[$eName] .
' for element ' . $eName);
6296 }
6297 }
6298
6299 if (isset($optionals)
6300 && (!isset($xvalue[$eName]))
6301 && ((!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
6302 ) {
6303 if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
6304 $this->
debug(
"apparent error: no value provided for element $eName with minOccurs=" . $attrs[
'minOccurs']);
6305 }
6306
6307 $this->
debug(
"no value provided for complexType element $eName and element is not nillable, so serialize nothing");
6308 } else {
6309
6310 if (isset($xvalue[$eName])) {
6311 $v = $xvalue[$eName];
6312 } else {
6313 $v = null;
6314 }
6315 if (isset($attrs['form'])) {
6316 $unqualified = ($attrs['form'] == 'unqualified');
6317 } else {
6318 $unqualified = false;
6319 }
6320 if (isset($attrs[
'maxOccurs']) && ($attrs[
'maxOccurs'] ==
'unbounded' || $attrs[
'maxOccurs'] > 1) && isset($v) && is_array($v) && $this->
isArraySimpleOrStruct($v) ==
'arraySimple') {
6321 $vv = $v;
6322 foreach ($vv as $k => $v) {
6323 if (isset($attrs['type']) || isset($attrs['ref'])) {
6324
6325 $xml .= $this->
serializeType($eName, isset($attrs[
'type']) ? $attrs[
'type'] : $attrs[
'ref'], $v, $use, $encodingStyle, $unqualified);
6326 } else {
6327
6328 $this->
debug(
"calling serialize_val() for $v, $eName, false, false, false, false, $use");
6330 }
6331 }
6332 } else {
6333 if (isset($attrs['type']) || isset($attrs['ref'])) {
6334
6335 $xml .= $this->
serializeType($eName, isset($attrs[
'type']) ? $attrs[
'type'] : $attrs[
'ref'], $v, $use, $encodingStyle, $unqualified);
6336 } else {
6337
6338 $this->
debug(
"calling serialize_val() for $v, $eName, false, false, false, false, $use");
6340 }
6341 }
6342 }
6343 }
6344 } else {
6345 $this->
debug(
"no elements to serialize for XML Schema type $ns:$uqType");
6346 }
6347 if (isset($typeDef['extensionBase'])) {
6348 $ns = $this->
getPrefix($typeDef[
'extensionBase']);
6349 $uqType = $this->
getLocalPart($typeDef[
'extensionBase']);
6352 }
6353 if ($typeDef = $this->
getTypeDef($uqType, $ns)) {
6354 $this->
debug(
"serialize elements for extension base $ns:$uqType");
6356 } else {
6357 $this->
debug(
"extension base $ns:$uqType is not a supported type");
6358 }
6359 }
6361 }
6362
6377 public function addComplexType(
$name, $typeClass=
'complexType', $phpType=
'array', $compositor=
'', $restrictionBase=
'', $elements=array(), $attrs=array(), $arrayType=
'')
6378 {
6379 if (count($elements) > 0) {
6380 $eElements = array();
6381 foreach ($elements as $n =>
$e) {
6382
6383 $ee = array();
6384 foreach (
$e as $k => $v) {
6385 $k = strpos($k,
':') ? $this->
expandQname($k) : $k;
6386 $v = strpos($v,
':') ? $this->
expandQname($v) : $v;
6387 $ee[$k] = $v;
6388 }
6389 $eElements[$n] = $ee;
6390 }
6391 $elements = $eElements;
6392 }
6393
6394 if (count($attrs) > 0) {
6395 foreach ($attrs as $n =>
$a) {
6396
6397 foreach (
$a as $k => $v) {
6398 $k = strpos($k,
':') ? $this->
expandQname($k) : $k;
6399 $v = strpos($v,
':') ? $this->
expandQname($v) : $v;
6400 $aa[$k] = $v;
6401 }
6402 $eAttrs[$n] = $aa;
6403 }
6404 $attrs = $eAttrs;
6405 }
6406
6407 $restrictionBase = strpos($restrictionBase,
':') ? $this->
expandQname($restrictionBase) : $restrictionBase;
6408 $arrayType = strpos($arrayType,
':') ? $this->
expandQname($arrayType) : $arrayType;
6409
6410 $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
6411 $this->schemas[$typens][0]->addComplexType(
$name, $typeClass, $phpType, $compositor, $restrictionBase, $elements, $attrs, $arrayType);
6412 }
6413
6425 public function addSimpleType(
$name, $restrictionBase=
'', $typeClass=
'simpleType', $phpType=
'scalar', $enumeration=array())
6426 {
6427 $restrictionBase = strpos($restrictionBase,
':') ? $this->
expandQname($restrictionBase) : $restrictionBase;
6428
6429 $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
6430 $this->schemas[$typens][0]->addSimpleType(
$name, $restrictionBase, $typeClass, $phpType, $enumeration);
6431 }
6432
6441 {
6442 $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
6443 $this->schemas[$typens][0]->addElement($attrs);
6444 }
6445
6461 {
6462 if ($use == 'encoded' && $encodingStyle == '') {
6463 $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
6464 }
6465
6466 if ($style == 'document') {
6467 $elements = array();
6468 foreach ($in as $n => $t) {
6469 $elements[$n] = array('name' => $n, 'type' => $t);
6470 }
6471 $this->
addComplexType(
$name .
'RequestType',
'complexType',
'struct',
'all',
'', $elements);
6473 $in = array(
'parameters' =>
'tns:' .
$name .
'^');
6474
6475 $elements = array();
6476 foreach (
$out as $n => $t) {
6477 $elements[$n] = array('name' => $n, 'type' => $t);
6478 }
6479 $this->
addComplexType(
$name .
'ResponseType',
'complexType',
'struct',
'all',
'', $elements);
6480 $this->
addElement(array(
'name' =>
$name .
'Response',
'type' =>
$name .
'ResponseType',
'form' =>
'qualified'));
6481 $out = array(
'parameters' =>
'tns:' .
$name .
'Response' .
'^');
6482 }
6483
6484
6485 $this->bindings[ $this->serviceName .
'Binding' ][
'operations'][
$name] =
6486 array(
6488 'binding' => $this->serviceName . 'Binding',
6489 'endpoint' => $this->endpoint,
6490 'soapAction' => $soapaction,
6491 'style' => $style,
6492 'input' => array(
6493 'use' => $use,
6495 'encodingStyle' => $encodingStyle,
6496 'message' =>
$name .
'Request',
6497 'parts' => $in),
6498 'output' => array(
6499 'use' => $use,
6501 'encodingStyle' => $encodingStyle,
6502 'message' =>
$name .
'Response',
6505 'transport' => 'http://schemas.xmlsoap.org/soap/http',
6507
6508
6509 if ($in) {
6510 foreach ($in as $pName => $pType) {
6511 if (strpos($pType, ':')) {
6513 }
6514 $this->messages[
$name .
'Request'][$pName] = $pType;
6515 }
6516 } else {
6517 $this->messages[
$name .
'Request']=
'0';
6518 }
6520 foreach (
$out as $pName => $pType) {
6521 if (strpos($pType, ':')) {
6523 }
6524 $this->messages[
$name .
'Response'][$pName] = $pType;
6525 }
6526 } else {
6527 $this->messages[
$name .
'Response']=
'0';
6528 }
6529 return true;
6530 }
6531}
6532?><?php
6533
6534
6535
6546{
6555
6573
6574
6575 public $ids = array();
6576
6578
6580
6591 {
6594 $this->xml_encoding = $encoding;
6597
6598
6600
6601 $pos_xml = strpos(
$xml,
'<?xml');
6602 if ($pos_xml !== false) {
6603 $xml_decl = substr(
$xml, $pos_xml, strpos(
$xml,
'?>', $pos_xml + 2) - $pos_xml + 1);
6604 if (preg_match(
"/encoding=[\"']([^\"']*)[\"']/", $xml_decl,
$res)) {
6607 $err =
"Charset from HTTP Content-Type '" . $encoding .
"' does not match encoding from XML declaration '" .
$xml_encoding .
"'";
6609 if ($encoding !=
'ISO-8859-1' || strtoupper(
$xml_encoding) !=
'UTF-8') {
6611 return;
6612 }
6613
6614 } else {
6615 $this->
debug(
'Charset from HTTP Content-Type matches encoding from XML declaration');
6616 }
6617 } else {
6618 $this->
debug(
'No encoding specified in XML declaration');
6619 }
6620 } else {
6621 $this->
debug(
'No XML declaration');
6622 }
6623 $this->
debug(
'Entering nusoap_parser(), length=' . strlen(
$xml) .
', encoding=' . $encoding);
6624
6625 $this->parser = xml_parser_create($this->xml_encoding);
6626
6627
6628 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
6629 xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
6630
6631 xml_set_object($this->parser, $this);
6632
6633 xml_set_element_handler($this->parser, 'start_element', 'end_element');
6634 xml_set_character_data_handler($this->parser, 'character_data');
6635
6636
6637 if (!xml_parse($this->parser,
$xml,
true)) {
6638
6639 $err = sprintf(
6640 'XML error parsing SOAP payload on line %d: %s',
6641 xml_get_current_line_number($this->parser),
6642 xml_error_string(xml_get_error_code($this->parser))
6643 );
6645 $this->
debug(
"XML payload:\n" . $xml);
6647 } else {
6648 $this->
debug(
'parsed successfully, found root struct: ' . $this->root_struct .
' of name ' . $this->root_struct_name);
6649
6651
6652 if ($this->root_header != '' && isset($this->message[$this->root_header]['result'])) {
6654 }
6655
6656 if (sizeof($this->multirefs) > 0) {
6657 foreach ($this->multirefs as
$id => $hrefs) {
6658 $this->
debug(
'resolving multirefs for id: ' .
$id);
6660 if (is_array($idVal) && isset($idVal['!id'])) {
6661 unset($idVal['!id']);
6662 }
6663 foreach ($hrefs as $refPos => $ref) {
6664 $this->
debug(
'resolving href at pos ' . $refPos);
6665 $this->multirefs[
$id][$refPos] = $idVal;
6666 }
6667 }
6668 }
6669 }
6670 xml_parser_free($this->parser);
6671 } else {
6672 $this->
debug(
'xml was empty, didn\'t parse!');
6673 $this->
setError(
'xml was empty, didn\'t parse!');
6674 }
6675 }
6676
6686 {
6687
6688
6689 $pos = $this->position++;
6690
6691 $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>'');
6692
6693
6694 $this->message[$pos]['depth'] = $this->depth++;
6695
6696
6697 if ($pos != 0) {
6699 }
6700
6702
6703 $this->parent = $pos;
6704
6706
6707 if (strpos(
$name,
':')) {
6708
6709 $prefix = substr(
$name, 0, strpos(
$name,
':'));
6710
6712 }
6713
6714 if (
$name ==
'Envelope') {
6715 $this->status = 'envelope';
6716 } elseif (
$name ==
'Header' && $this->status =
'envelope') {
6717 $this->root_header = $pos;
6718 $this->status = 'header';
6719 } elseif (
$name ==
'Body' && $this->status =
'envelope') {
6720 $this->status = 'body';
6721 $this->body_position = $pos;
6722
6723 } elseif ($this->status == 'body' && $pos == ($this->body_position+1)) {
6724 $this->status = 'method';
6725 $this->root_struct_name =
$name;
6726 $this->root_struct = $pos;
6727 $this->message[$pos]['type'] = 'struct';
6728 $this->
debug(
"found root struct $this->root_struct_name, pos $this->root_struct");
6729 }
6730
6732
6733 $this->message[$pos][
'name'] = htmlspecialchars(
$name);
6734
6735 $this->message[$pos]['attrs'] = $attrs;
6736
6737
6738 $attstr = '';
6739 foreach ($attrs as
$key => $value) {
6742
6743 if ($key_prefix == 'xmlns') {
6744 if (preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/', $value)) {
6745 $this->XMLSchemaVersion = $value;
6747 $this->namespaces['xsi'] = $this->XMLSchemaVersion . '-instance';
6748 }
6749 $this->namespaces[$key_localpart] = $value;
6750
6751 if (
$name == $this->root_struct_name) {
6752 $this->methodNamespace = $value;
6753 }
6754
6755 } elseif ($key_localpart == 'type') {
6756 if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') {
6757
6758 } else {
6759 $value_prefix = $this->
getPrefix($value);
6761 $this->message[$pos]['type'] = $value_localpart;
6762 $this->message[$pos]['typePrefix'] = $value_prefix;
6763 if (isset($this->namespaces[$value_prefix])) {
6764 $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
6765 } elseif (isset($attrs['xmlns:' . $value_prefix])) {
6766 $this->message[$pos]['type_namespace'] = $attrs['xmlns:' . $value_prefix];
6767 }
6768
6769 }
6770 } elseif ($key_localpart == 'arrayType') {
6771 $this->message[$pos]['type'] = 'array';
6772
6773
6774
6775
6776
6777
6778
6779
6780 $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
6781 if (preg_match($expr, $value, $regs)) {
6782 $this->message[$pos]['typePrefix'] = $regs[1];
6783 $this->message[$pos]['arrayTypePrefix'] = $regs[1];
6784 if (isset($this->namespaces[$regs[1]])) {
6785 $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
6786 } elseif (isset($attrs['xmlns:' . $regs[1]])) {
6787 $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:' . $regs[1]];
6788 }
6789 $this->message[$pos]['arrayType'] = $regs[2];
6790 $this->message[$pos]['arraySize'] = $regs[3];
6791 $this->message[$pos]['arrayCols'] = $regs[4];
6792 }
6793
6794 } elseif ($key_localpart == 'nil') {
6795 $this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
6796
6797 } elseif (
$key !=
'href' &&
$key !=
'xmlns' && $key_localpart !=
'encodingStyle' && $key_localpart !=
'root') {
6798 $this->message[$pos][
'xattrs'][
'!' .
$key] = $value;
6799 }
6800
6801 if (
$key ==
'xmlns') {
6802 $this->default_namespace = $value;
6803 }
6804
6806 $this->ids[$value] = $pos;
6807 }
6808
6809 if ($key_localpart == 'root' && $value == 1) {
6810 $this->status = 'method';
6811 $this->root_struct_name =
$name;
6812 $this->root_struct = $pos;
6813 $this->
debug(
"found root struct $this->root_struct_name, pos $pos");
6814 }
6815
6816 $attstr .= " $key=\"$value\"";
6817 }
6818
6819 if (isset($prefix)) {
6820 $this->message[$pos]['namespace'] = $this->namespaces[$prefix];
6821 $this->default_namespace = $this->namespaces[$prefix];
6822 } else {
6824 }
6825 if ($this->status == 'header') {
6826 if ($this->root_header != $pos) {
6827 $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
6828 }
6829 } elseif ($this->root_struct_name != '') {
6830 $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
6831 }
6832 }
6833
6842 {
6843
6844 $pos = $this->depth_array[$this->depth--];
6845
6846
6847 if (strpos(
$name,
':')) {
6848
6849 $prefix = substr(
$name, 0, strpos(
$name,
':'));
6850
6852 }
6853
6854
6855 if (isset($this->body_position) && $pos > $this->body_position) {
6856
6857 if (isset($this->message[$pos]['attrs']['href'])) {
6858
6859 $id = substr($this->message[$pos][
'attrs'][
'href'], 1);
6860
6861 $this->multirefs[
$id][$pos] =
'placeholder';
6862
6863 $this->message[$pos][
'result'] =& $this->multirefs[
$id][$pos];
6864
6865 } elseif ($this->message[$pos]['children'] != '') {
6866
6867 if (!isset($this->message[$pos]['result'])) {
6868 $this->message[$pos][
'result'] = $this->
buildVal($pos);
6869 }
6870
6871 } elseif (isset($this->message[$pos]['xattrs'])) {
6872 if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
6873 $this->message[$pos]['xattrs']['!'] = null;
6874 } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
6875 if (isset($this->message[$pos]['type'])) {
6876 $this->message[$pos][
'xattrs'][
'!'] = $this->
decodeSimple($this->message[$pos][
'cdata'], $this->message[$pos][
'type'], isset($this->message[$pos][
'type_namespace']) ? $this->message[$pos][
'type_namespace'] :
'');
6877 } else {
6878 $parent = $this->message[$pos][
'parent'];
6879 if (isset($this->message[
$parent][
'type']) && ($this->message[
$parent][
'type'] ==
'array') && isset($this->message[
$parent][
'arrayType'])) {
6880 $this->message[$pos][
'xattrs'][
'!'] = $this->
decodeSimple($this->message[$pos][
'cdata'], $this->message[
$parent][
'arrayType'], isset($this->message[
$parent][
'arrayTypeNamespace']) ? $this->message[
$parent][
'arrayTypeNamespace'] :
'');
6881 } else {
6882 $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
6883 }
6884 }
6885 }
6886 $this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
6887
6888 } else {
6889
6890 if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
6891 $this->message[$pos]['xattrs']['!'] = null;
6892 } elseif (isset($this->message[$pos]['type'])) {
6893 $this->message[$pos][
'result'] = $this->
decodeSimple($this->message[$pos][
'cdata'], $this->message[$pos][
'type'], isset($this->message[$pos][
'type_namespace']) ? $this->message[$pos][
'type_namespace'] :
'');
6894 } else {
6895 $parent = $this->message[$pos][
'parent'];
6896 if (isset($this->message[
$parent][
'type']) && ($this->message[
$parent][
'type'] ==
'array') && isset($this->message[
$parent][
'arrayType'])) {
6897 $this->message[$pos][
'result'] = $this->
decodeSimple($this->message[$pos][
'cdata'], $this->message[
$parent][
'arrayType'], isset($this->message[
$parent][
'arrayTypeNamespace']) ? $this->message[
$parent][
'arrayTypeNamespace'] :
'');
6898 } else {
6899 $this->message[$pos]['result'] = $this->message[$pos]['cdata'];
6900 }
6901 }
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913 }
6914 }
6915
6916
6917 if ($this->status == 'header') {
6918 if ($this->root_header != $pos) {
6919 $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
6920 }
6921 } elseif ($pos >= $this->root_struct) {
6922 $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
6923 }
6924
6925 if ($pos == $this->root_struct) {
6926 $this->status = 'body';
6927 $this->root_struct_namespace = $this->message[$pos]['namespace'];
6928 } elseif (
$name ==
'Body') {
6929 $this->status = 'envelope';
6930 } elseif (
$name ==
'Header') {
6931 $this->status = 'envelope';
6932 } elseif (
$name ==
'Envelope') {
6933
6934 }
6935
6936 $this->parent = $this->message[$pos]['parent'];
6937 }
6938
6947 {
6949 if ($this->xml_encoding=='UTF-8') {
6950
6951
6952
6953 if ($this->decode_utf8) {
6955 }
6956 }
6957 $this->message[$pos][
'cdata'] .=
$data;
6958
6959 if ($this->status == 'header') {
6960 $this->responseHeaders .=
$data;
6961 } else {
6962 $this->document .=
$data;
6963 }
6964 }
6965
6974 {
6976 }
6977
6985 {
6987 }
6988
6996 {
6998 }
6999
7007 {
7009 }
7010
7021 {
7022
7024 return (string) $value;
7025 }
7027 return (int) $value;
7028 }
7030 return (float) $value;
7031 }
7032 if (
$type ==
'boolean') {
7033 if (strtolower($value) == 'false' || strtolower($value) == 'f') {
7034 return false;
7035 }
7036 return (bool) $value;
7037 }
7038 if (
$type ==
'base64' ||
$type ==
'base64Binary') {
7039 $this->
debug(
'Decode base64 value');
7040 return base64_decode($value);
7041 }
7042
7043 if (
$type ==
'nonPositiveInteger' ||
$type ==
'negativeInteger'
7044 ||
$type ==
'nonNegativeInteger' ||
$type ==
'positiveInteger'
7045 ||
$type ==
'unsignedInt'
7046 ||
$type ==
'unsignedShort' ||
$type ==
'unsignedByte') {
7047 return (int) $value;
7048 }
7049
7050 if (
$type ==
'array') {
7051 return array();
7052 }
7053
7054 return (string) $value;
7055 }
7056
7066 {
7067 if (!isset($this->message[$pos]['type'])) {
7068 $this->message[$pos]['type'] = '';
7069 }
7070 $this->
debug(
'in buildVal() for ' . $this->message[$pos][
'name'] .
"(pos $pos) of type " . $this->message[$pos][
'type']);
7071
7072 if ($this->message[$pos]['children'] != '') {
7073 $this->
debug(
'in buildVal, there are children');
7074 $children = explode('|', $this->message[$pos]['children']);
7075 array_shift($children);
7076
7077 if (isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != '') {
7078 $r=0;
7080 foreach ($children as $child_pos) {
7081 $this->
debug(
"in buildVal, got an MD array element: $r, $c");
7082 $params[$r][] = $this->message[$child_pos][
'result'];
7084 if (
$c == $this->message[$pos][
'arrayCols']) {
7086 $r++;
7087 }
7088 }
7089
7090 } elseif ($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array') {
7091 $this->
debug(
'in buildVal, adding array ' . $this->message[$pos][
'name']);
7092 foreach ($children as $child_pos) {
7093 $params[] = &$this->message[$child_pos][
'result'];
7094 }
7095
7096 } elseif ($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
7097 $this->
debug(
'in buildVal, Java Map ' . $this->message[$pos][
'name']);
7098 foreach ($children as $child_pos) {
7099 $kv = explode("|", $this->message[$child_pos]['children']);
7100 $params[$this->message[$kv[1]][
'result']] = &$this->message[$kv[2]][
'result'];
7101 }
7102
7103
7104 } else {
7105
7106 $this->
debug(
'in buildVal, adding Java Vector or generic compound type ' . $this->message[$pos][
'name']);
7107 if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
7108 $notstruct = 1;
7109 } else {
7110 $notstruct = 0;
7111 }
7112
7113 foreach ($children as $child_pos) {
7114 if ($notstruct) {
7115 $params[] = &$this->message[$child_pos][
'result'];
7116 } else {
7117 if (isset(
$params[$this->message[$child_pos][
'name']])) {
7118
7119 if ((!is_array(
$params[$this->message[$child_pos][
'name']])) || (!isset(
$params[$this->message[$child_pos][
'name']][0]))) {
7120 $params[$this->message[$child_pos][
'name']] = array(
$params[$this->message[$child_pos][
'name']]);
7121 }
7122 $params[$this->message[$child_pos][
'name']][] = &$this->message[$child_pos][
'result'];
7123 } else {
7124 $params[$this->message[$child_pos][
'name']] = &$this->message[$child_pos][
'result'];
7125 }
7126 }
7127 }
7128 }
7129 if (isset($this->message[$pos]['xattrs'])) {
7130 $this->
debug(
'in buildVal, handling attributes');
7131 foreach ($this->message[$pos]['xattrs'] as $n => $v) {
7133 }
7134 }
7135
7136 if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
7137 $this->
debug(
'in buildVal, handling simpleContent');
7138 if (isset($this->message[$pos]['type'])) {
7139 $params[
'!'] = $this->
decodeSimple($this->message[$pos][
'cdata'], $this->message[$pos][
'type'], isset($this->message[$pos][
'type_namespace']) ? $this->message[$pos][
'type_namespace'] :
'');
7140 } else {
7141 $parent = $this->message[$pos][
'parent'];
7142 if (isset($this->message[
$parent][
'type']) && ($this->message[
$parent][
'type'] ==
'array') && isset($this->message[
$parent][
'arrayType'])) {
7143 $params[
'!'] = $this->
decodeSimple($this->message[$pos][
'cdata'], $this->message[
$parent][
'arrayType'], isset($this->message[
$parent][
'arrayTypeNamespace']) ? $this->message[
$parent][
'arrayTypeNamespace'] :
'');
7144 } else {
7145 $params[
'!'] = $this->message[$pos][
'cdata'];
7146 }
7147 }
7148 }
7150 $this->
debug(
'in buildVal, return:');
7152 return $ret;
7153 } else {
7154 $this->
debug(
'in buildVal, no children, building scalar');
7155 $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
7156 if (isset($this->message[$pos]['type'])) {
7157 $ret = $this->
decodeSimple($cdata, $this->message[$pos][
'type'], isset($this->message[$pos][
'type_namespace']) ? $this->message[$pos][
'type_namespace'] :
'');
7158 $this->
debug(
"in buildVal, return: $ret");
7159 return $ret;
7160 }
7161 $parent = $this->message[$pos][
'parent'];
7162 if (isset($this->message[
$parent][
'type']) && ($this->message[
$parent][
'type'] ==
'array') && isset($this->message[
$parent][
'arrayType'])) {
7163 $ret = $this->
decodeSimple($cdata, $this->message[
$parent][
'arrayType'], isset($this->message[
$parent][
'arrayTypeNamespace']) ? $this->message[
$parent][
'arrayTypeNamespace'] :
'');
7164 $this->
debug(
"in buildVal, return: $ret");
7165 return $ret;
7166 }
7167 $ret = $this->message[$pos]['cdata'];
7168 $this->
debug(
"in buildVal, return: $ret");
7169 return $ret;
7170 }
7171 }
7172}
7173
7178{
7179}
7180
7181?><?php
7182
7183
7184
7206{
7237
7238
7239
7240
7261
7277 {
7286
7287 $this->
debug(
"ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
7289
7290
7291 if ($wsdl) {
7294 $this->endpoint = $this->
wsdl->wsdl;
7296 $this->
debug(
'existing wsdl instance created from ' . $this->endpoint);
7298 } else {
7301 $this->
debug(
'will use lazy evaluation of wsdl from ' . $this->endpoint);
7302 }
7303 $this->endpointType = 'wsdl';
7304 } else {
7305 $this->
debug(
"instantiate SOAP with endpoint at $endpoint");
7306 $this->endpointType = 'soap';
7307 }
7308 }
7309
7335 public function call($operation,
$params=array(),
$namespace=
'http://tempuri.org', $soapAction=
'', $headers=
false, $rpcParams=
null, $style=
'rpc', $use=
'encoded')
7336 {
7337 $this->operation = $operation;
7338 $this->fault = false;
7340 $this->request = '';
7341 $this->response = '';
7342 $this->responseData = '';
7343 $this->faultstring = '';
7344 $this->faultcode = '';
7345 $this->opData = array();
7346
7347 $this->
debug(
"call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
7350 if ($headers) {
7351 $this->requestHeaders = $headers;
7352 }
7353 if ($this->endpointType ==
'wsdl' && is_null($this->
wsdl)) {
7356 return false;
7357 }
7358 }
7359
7360 if ($this->endpointType ==
'wsdl' && $opData = $this->
getOperationData($operation)) {
7361
7362 $this->opData = $opData;
7363 $this->
debug(
"found operation");
7365 if (isset($opData['soapAction'])) {
7366 $soapAction = $opData['soapAction'];
7367 }
7368 if (! $this->forceEndpoint) {
7369 $this->endpoint = $opData['endpoint'];
7370 } else {
7372 }
7373 $namespace = isset($opData[
'input'][
'namespace']) ? $opData[
'input'][
'namespace'] :
$namespace;
7374 $style = $opData['style'];
7375 $use = $opData['input']['use'];
7376
7378 $nsPrefix = 'ns' . rand(1000, 9999);
7380 }
7382
7384 $this->
debug(
"serializing param string for WSDL operation $operation");
7386 } elseif (is_array(
$params)) {
7387 $this->
debug(
"serializing param array for WSDL operation $operation");
7389 } else {
7390 $this->
debug(
'params must be array or string');
7391 $this->
setError(
'params must be array or string');
7392 return false;
7393 }
7395 if (isset($opData['input']['encodingStyle'])) {
7396 $encodingStyle = $opData['input']['encodingStyle'];
7397 } else {
7398 $encodingStyle = '';
7399 }
7403 $this->
debug(
'got wsdl error: ' . $errstr);
7404 $this->
setError(
'wsdl error: ' . $errstr);
7405 return false;
7406 }
7407 } elseif ($this->endpointType == 'wsdl') {
7408
7411 $this->
setError(
'operation ' . $operation .
' not present.');
7412 $this->
debug(
"operation '$operation' not present.");
7413 return false;
7414 } else {
7415
7416
7417 $nsPrefix = 'ns' . rand(1000, 9999);
7418
7421 $this->
debug(
"serializing param string for operation $operation");
7423 } elseif (is_array(
$params)) {
7424 $this->
debug(
"serializing param array for operation $operation");
7425 foreach (
$params as $k => $v) {
7427 }
7428 } else {
7429 $this->
debug(
'params must be array or string');
7430 $this->
setError(
'params must be array or string');
7431 return false;
7432 }
7434 if ($use == 'encoded') {
7435 $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
7436 } else {
7437 $encodingStyle = '';
7438 }
7439 }
7440
7441 if ($style == 'rpc') {
7442 if ($use == 'literal') {
7443 $this->
debug(
"wrapping RPC request with literal method element");
7445
7446 $payload =
"<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
7448 "</$nsPrefix:$operation>";
7449 } else {
7451 }
7452 } else {
7453 $this->
debug(
"wrapping RPC request with encoded method element");
7455 $payload =
"<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
7457 "</$nsPrefix:$operation>";
7458 } else {
7461 "</$operation>";
7462 }
7463 }
7464 }
7465
7467 $this->
debug(
"endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
7468 $this->
debug(
'SOAP message length=' . strlen($soapmsg) .
' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
7469
7470 $return = $this->
send($this->
getHTTPBody($soapmsg), $soapAction, $this->timeout, $this->response_timeout);
7472 $this->
debug(
'Error: ' . $errstr);
7473 return false;
7474 } else {
7475 $this->return = $return;
7476 $this->
debug(
'sent message successfully and got a(n) ' . gettype($return));
7478
7479
7480 if (is_array($return) && isset($return['faultcode'])) {
7481 $this->
debug(
'got fault');
7482 $this->
setError($return[
'faultcode'] .
': ' . $return[
'faultstring']);
7483 $this->fault = true;
7484 foreach ($return as $k => $v) {
7485 $this->$k = $v;
7486 $this->
debug(
"$k = $v<br>");
7487 }
7488 return $return;
7489 } elseif ($style == 'document') {
7490
7491
7492 return $return;
7493 } else {
7494
7495 if (is_array($return)) {
7496
7497
7498 if (sizeof($return) > 1) {
7499 return $return;
7500 }
7501
7502 $return = array_shift($return);
7503 $this->
debug(
'return shifted value: ');
7505 return $return;
7506
7507 } else {
7508 return "";
7509 }
7510 }
7511 }
7512 }
7513
7520 {
7523 $this->
debug(
'checkWSDL');
7524
7526 $this->
debug(
'got wsdl error: ' . $errstr);
7527 $this->
setError(
'wsdl error: ' . $errstr);
7529 $this->bindingType = 'soap';
7530 $this->
debug(
'got ' . count($this->operations) .
' operations from wsdl ' . $this->wsdlFile .
' for binding type ' . $this->bindingType);
7532 $this->bindingType = 'soap12';
7533 $this->
debug(
'got ' . count($this->operations) .
' operations from wsdl ' . $this->wsdlFile .
' for binding type ' . $this->bindingType);
7534 $this->
debug(
'**************** WARNING: SOAP 1.2 BINDING *****************');
7535 } else {
7536 $this->
debug(
'getOperations returned false');
7537 $this->
setError(
'no operations defined in the WSDL document!');
7538 }
7539 }
7540
7547 {
7548 $this->
debug(
'instantiating wsdl class with doc: ' . $this->wsdlFile);
7549 $this->
wsdl =
new wsdl(
'', $this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword, $this->timeout, $this->response_timeout, $this->curl_options, $this->use_curl);
7550 $this->
wsdl->
setCredentials($this->username, $this->password, $this->authtype, $this->certRequest);
7553 }
7554
7563 {
7564 if ($this->endpointType ==
'wsdl' && is_null($this->
wsdl)) {
7567 return false;
7568 }
7569 }
7570 if (isset($this->operations[$operation])) {
7571 return $this->operations[$operation];
7572 }
7573 $this->
debug(
"No data for operation: $operation");
7574 }
7575
7591 {
7593
7594 switch (true) {
7595
7596 case preg_match('/^http/', $this->endpoint):
7597 $this->
debug(
'transporting via HTTP');
7598 if ($this->persistentConnection == true && is_object($this->persistentConnection)) {
7600 } else {
7602 if ($this->persistentConnection) {
7603 $http->usePersistentConnection();
7604 }
7605 }
7607 $http->setSOAPAction($soapaction);
7608 if ($this->proxyhost && $this->proxyport) {
7609 $http->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword);
7610 }
7611 if ($this->authtype != '') {
7612 $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
7613 }
7614 if ($this->http_encoding != '') {
7615 $http->setEncoding($this->http_encoding);
7616 }
7617 $this->
debug(
'sending message, length=' . strlen($msg));
7618 if (preg_match('/^http:/', $this->endpoint)) {
7619
7621 } elseif (preg_match('/^https/', $this->endpoint)) {
7622
7623
7624
7625
7626
7627
7629 } else {
7630 $this->
setError(
'no http/s in endpoint url');
7631 }
7632 $this->request =
$http->outgoing_payload;
7633 $this->response =
$http->incoming_payload;
7636
7637
7638 if ($this->persistentConnection) {
7639 $http->clearDebug();
7640 if (!is_object($this->persistentConnection)) {
7641 $this->persistentConnection =
$http;
7642 }
7643 }
7644
7645 if ($err =
$http->getError()) {
7646 $this->
setError(
'HTTP Error: ' . $err);
7647 return false;
7649 return false;
7650 } else {
7651 $this->
debug(
'got response, length=' . strlen($this->responseData) .
' type=' .
$http->incoming_headers[
'content-type']);
7653 }
7654 break;
7655 default:
7656 $this->
setError(
'no transport found, or selected transport is not yet supported!');
7657 return false;
7658 break;
7659 }
7660 }
7661
7671 {
7672 $this->
debug(
'Entering parseResponse() for data of length ' . strlen(
$data) .
' headers:');
7674 if (!strstr($headers['content-type'], 'text/xml')) {
7675 $this->
setError(
'Response not of type text/xml: ' . $headers[
'content-type']);
7676 return false;
7677 }
7678 if (strpos($headers['content-type'], '=')) {
7679 $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
7680 $this->
debug(
'Got response encoding: ' . $enc);
7681 if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
7682 $this->xml_encoding = strtoupper($enc);
7683 } else {
7684 $this->xml_encoding = 'US-ASCII';
7685 }
7686 } else {
7687
7688 $this->xml_encoding = 'ISO-8859-1';
7689 }
7690 $this->
debug(
'Use encoding: ' . $this->xml_encoding .
' when creating nusoap_parser');
7691 $parser =
new nusoap_parser(
$data, $this->xml_encoding, $this->operation, $this->decode_utf8);
7692
7694
7695 if ($errstr = $parser->getError()) {
7697
7698 unset($parser);
7699 return false;
7700 } else {
7701
7702 $this->responseHeaders = $parser->getHeaders();
7703
7704 $this->responseHeader = $parser->get_soapheader();
7705
7706 $return = $parser->get_soapbody();
7707
7708 $this->document = $parser->document;
7709
7710 unset($parser);
7711
7712 return $return;
7713 }
7714 }
7715
7724 {
7725 $this->
debug(
"setCurlOption option=$option, value=");
7727 $this->curl_options[$option] = $value;
7728 }
7729
7737 {
7738 $this->
debug(
"setEndpoint(\"$endpoint\")");
7740 }
7741
7749 {
7750 $this->
debug(
"setHeaders headers=");
7752 $this->requestHeaders = $headers;
7753 }
7754
7762 {
7764 }
7765
7773 {
7775 }
7776
7787 {
7792 }
7793
7804 {
7805 $this->
debug(
"setCredentials username=$username authtype=$authtype certRequest=");
7811 }
7812
7820 {
7821 $this->
debug(
"setHTTPEncoding(\"$enc\")");
7822 $this->http_encoding = $enc;
7823 }
7824
7832 {
7833 $this->
debug(
"setUseCURL($use)");
7834 $this->use_curl = $use;
7835 }
7836
7843 {
7844 $this->
debug(
"useHTTPPersistentConnection");
7845 $this->persistentConnection = true;
7846 }
7847
7860 {
7862 }
7863
7876 {
7877 $this->defaultRpcParams = $rpcParams;
7878 }
7879
7888 {
7889 $r = rand();
7891
7893 $this->
debug(
"Error from _getProxyClassCode, so return NULL");
7894 return null;
7895 }
7896
7897 eval($evalStr);
7898
7899 eval("\$proxy = new nusoap_proxy_$r('');");
7900
7901 $proxy->endpointType = 'wsdl';
7902 $proxy->wsdlFile = $this->wsdlFile;
7903 $proxy->wsdl = $this->wsdl;
7906
7927 return $proxy;
7928 }
7929
7937 {
7938 $this->
debug(
"in getProxy endpointType=$this->endpointType");
7940 if ($this->endpointType != 'wsdl') {
7941 $evalStr = 'A proxy can only be created for a WSDL client';
7943 $evalStr = "echo \"$evalStr\";";
7944 return $evalStr;
7945 }
7946 if ($this->endpointType ==
'wsdl' && is_null($this->
wsdl)) {
7949 return "echo \"" . $this->
getError() .
"\";";
7950 }
7951 }
7952 $evalStr = '';
7953 foreach ($this->operations as $operation => $opData) {
7954 if ($operation != '') {
7955
7956 if (sizeof($opData['input']['parts']) > 0) {
7957 $paramStr = '';
7958 $paramArrayStr = '';
7959 $paramCommentStr = '';
7960 foreach ($opData[
'input'][
'parts'] as
$name =>
$type) {
7961 $paramStr .= "\$$name, ";
7962 $paramArrayStr .= "'$name' => \$$name, ";
7963 $paramCommentStr .= "$type \$$name, ";
7964 }
7965 $paramStr = substr($paramStr, 0, strlen($paramStr)-2);
7966 $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2);
7967 $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2);
7968 } else {
7969 $paramStr = '';
7970 $paramArrayStr = '';
7971 $paramCommentStr = 'void';
7972 }
7973 $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace'];
7974 $evalStr .= "// $paramCommentStr
7975 function " . str_replace('.', '__', $operation) . "($paramStr) {
7976 \$params = array($paramArrayStr);
7977 return \$this->call('$operation', \$params, '" . $opData['namespace'] . "', '" . (isset($opData['soapAction']) ? $opData['soapAction'] : '') . "');
7978 }
7979 ";
7980 unset($paramStr);
7981 unset($paramCommentStr);
7982 }
7983 }
7984 $evalStr = 'class nusoap_proxy_' . $r . ' extends nusoap_client {
7985 ' . $evalStr . '
7986}';
7987 return $evalStr;
7988 }
7989
7997 {
7998 $r = rand();
8000 }
8001
8010 {
8011 return $soapmsg;
8012 }
8013
8023 {
8024 return 'text/xml';
8025 }
8026
8037 {
8039 }
8040
8041
8042
8043
8044
8045
8046
8048 {
8049 $this->decode_utf8 = $bool;
8050 return true;
8051 }
8052
8062 {
8063 if (strlen(
$name) == 0) {
8064 return false;
8065 }
8066 $this->cookies[] = array(
'name' =>
$name,
'value' => $value);
8067 return true;
8068 }
8069
8077 {
8079 }
8080
8088 {
8089 if (sizeof($this->cookies) == 0) {
8090 return true;
8091 }
8092 $this->
debug(
'checkCookie: check ' .
sizeof($this->cookies) .
' cookies');
8094 $this->cookies = array();
8095 foreach ($curr_cookies as $cookie) {
8096 if (! is_array($cookie)) {
8097 $this->
debug(
'Remove cookie that is not an array');
8098 continue;
8099 }
8100 if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
8101 if (strtotime($cookie['expires']) > time()) {
8102 $this->cookies[] = $cookie;
8103 } else {
8104 $this->
debug(
'Remove expired cookie ' . $cookie[
'name']);
8105 }
8106 } else {
8107 $this->cookies[] = $cookie;
8108 }
8109 }
8110 $this->
debug(
'checkCookie: ' .
sizeof($this->cookies) .
' cookies left in array');
8111 return true;
8112 }
8113
8122 {
8123 if (sizeof($this->cookies) == 0) {
8124
8126 $this->
debug(
'Setting new cookie(s)');
8128 }
8129 return true;
8130 }
8132
8133 return true;
8134 }
8135
8137 if (!is_array($newCookie)) {
8138 continue;
8139 }
8140 if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) {
8141 continue;
8142 }
8143 $newName = $newCookie['name'];
8144
8145 $found = false;
8146 for (
$i = 0;
$i < count($this->cookies);
$i++) {
8147 $cookie = $this->cookies[
$i];
8148 if (!is_array($cookie)) {
8149 continue;
8150 }
8151 if (!isset($cookie['name'])) {
8152 continue;
8153 }
8154 if ($newName != $cookie['name']) {
8155 continue;
8156 }
8157 $newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN';
8158 $domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN';
8159 if ($newDomain != $domain) {
8160 continue;
8161 }
8162 $newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH';
8163 $path = isset($cookie[
'path']) ? $cookie[
'path'] :
'NOPATH';
8164 if ($newPath !=
$path) {
8165 continue;
8166 }
8167 $this->cookies[
$i] = $newCookie;
8168 $found = true;
8169 $this->
debug(
'Update cookie ' . $newName .
'=' . $newCookie[
'value']);
8170 break;
8171 }
8172 if (! $found) {
8173 $this->
debug(
'Add cookie ' . $newName .
'=' . $newCookie[
'value']);
8174 $this->cookies[] = $newCookie;
8175 }
8176 }
8177 return true;
8178 }
8179}
8180
8181if (!extension_loaded('soap')) {
8186 {
8187 }
8188}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
getPrefix($str)
returns the prefix part of a prefixed string returns false, if not prefixed
& getDebug()
gets the current debug data for this instance
& getDebugAsXMLComment()
gets the current debug data for this instance as an XML comment this may change the contents of the d...
setError($str)
sets error string
getNamespaceFromPrefix($prefix)
pass it a prefix, it returns a namespace
debug($string)
adds debug data to the instance debug string with formatting
getPrefixFromNamespace($ns)
returns the prefix for a given namespace (or prefix) or false if no prefixes registered for the given...
serialize_val($val, $name=false, $type=false, $name_ns=false, $type_ns=false, $attributes=false, $use='encoded', $soapval=false)
serializes PHP values in accordance w/ section 5.
serializeEnvelope($body, $headers=false, $namespaces=array(), $style='rpc', $use='encoded', $encodingStyle='http://schemas.xmlsoap.org/soap/encoding/')
serializes a message
clearDebug()
clears the current debug data for this instance
expandEntities($val)
expands entities, e.g.
expandQname($qname)
expands (changes prefix to namespace) a qualified name
varDump($data)
Returns a string with the output of var_dump.
getError()
returns error string if present
appendDebug($string)
adds debug data to the instance debug string without formatting
getLocalPart($str)
returns the local part of a prefixed string returns the original string, if not prefixed
isArraySimpleOrStruct($val)
detect if array is a simple array or a struct (associative array)
[nu]soapclient higher level class for easy usage.
setCurlOption($option, $value)
sets user-specified cURL options
setCredentials($username, $password, $authtype='basic', $certRequest=array())
if authenticating, set user credentials here
setHTTPProxy($proxyhost, $proxyport, $proxyusername='', $proxypassword='')
set proxy info here
getProxy()
dynamically creates an instance of a proxy class, allowing user to directly call methods from wsdl
send($msg, $soapaction='', $timeout=0, $response_timeout=30)
send the SOAP message
setUseCURL($use)
Set whether to try to use cURL connections if possible.
call($operation, $params=array(), $namespace='http://tempuri.org', $soapAction='', $headers=false, $rpcParams=null, $style='rpc', $use='encoded')
calls method, returns PHP native type
getProxyClassCode()
dynamically creates proxy class code
checkCookies()
checks all Cookies and delete those which are expired
getHTTPContentType()
gets the HTTP content type for the current request.
setHTTPEncoding($enc='gzip, deflate')
use HTTP encoding
getHeader()
get the SOAP response Header (parsed)
useHTTPPersistentConnection()
use HTTP persistent connections if possible
setCookie($name, $value)
adds a new Cookie into $this->cookies array
getHTTPContentTypeCharset()
gets the HTTP content type charset for the current request.
getOperationData($operation)
get available data pertaining to an operation
getDefaultRpcParams()
gets the default RPC parameter setting.
checkWSDL()
check WSDL passed as an instance or pulled from an endpoint
setHeaders($headers)
set the SOAP headers
loadWSDL()
instantiate wsdl object and parse wsdl file
getHTTPBody($soapmsg)
gets the HTTP body for the current request.
setDefaultRpcParams($rpcParams)
sets the default RPC parameter setting.
setEndpoint($endpoint)
sets the SOAP endpoint, which can override WSDL
UpdateCookies($cookies)
updates the current cookies with a new set
getHeaders()
get the SOAP response headers (namespace resolution incomplete)
_getProxyClassCode($r)
dynamically creates proxy class code
getCookies()
gets all Cookies
parseResponse($headers, $data)
processes SOAP message returned from server
Contains information for a SOAP fault.
serialize()
serialize a fault
nusoap_parser class parses SOAP XML messages into native PHP values
character_data($parser, $data)
element content handler
get_soapbody()
get the parsed SOAP Body (NULL if there was none)
end_element($parser, $name)
end-element handler
getHeaders()
get the unparsed SOAP Header
get_response()
get the parsed message (SOAP Body)
decodeSimple($value, $type, $typens)
decodes simple types into PHP variables
get_soapheader()
get the parsed SOAP Header (NULL if there was none)
start_element($parser, $name, $attrs)
start-element handler
buildVal($pos)
builds response structures for compound values (arrays/structs) and scalars
nusoap_server allows the user to create a SOAP server that is capable of receiving messages and retur...
verify_method($operation, $request)
takes the value that was created by parsing the request and compares to the method's signature,...
$methodreturnisliteralxml
getHTTPBody($soapmsg)
gets the HTTP body for the current response.
invoke_method()
invokes a PHP function for the requested SOAP method
add_to_map($methodname, $in, $out)
add a method to the dispatch map (this has been replaced by the register method)
getHTTPContentType()
gets the HTTP content type for the current response.
parse_request($data='')
parses a request
getHTTPContentTypeCharset()
gets the HTTP content type charset for the current response.
serialize_return()
serializes the return value from a PHP function into a full SOAP Envelope
send_response()
sends an HTTP response
fault($faultcode, $faultstring, $faultactor='', $faultdetail='')
Specify a fault to be returned to the client.
parse_http_headers()
parses HTTP request headers.
service($data)
processes request and returns response
parseRequest($headers, $data)
processes SOAP message received from client
configureWSDL($serviceName, $namespace=false, $endpoint=false, $style='rpc', $transport='http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace=false)
Sets up wsdl object.
parses an XML Schema, allows access to it's data, other utility methods.
schemaCharacterData($parser, $data)
element content handler
getTypeDef($type)
returns an associative array of information about a given type returns false if no type exists by the...
addComplexType($name, $typeClass='complexType', $phpType='array', $compositor='', $restrictionBase='', $elements=array(), $attrs=array(), $arrayType='')
adds a complex type to the schema
typeToForm($name, $type)
returns HTML form elements that allow a user to enter values for creating an instance of the given ty...
addElement($attrs)
adds an element to the schema
getPHPType($type, $ns)
get the PHP type of a user defined type in the schema PHP type is kind of a misnomer since it actuall...
xdebug($string)
adds debug data to the clas level debug string
addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array())
adds a simple type to the schema
serializeSchema()
serialize the schema
parseString($xml, $type)
parse an XML string
schemaEndElement($parser, $name)
end-element handler
schemaStartElement($parser, $name, $attrs)
start-element handler
serializeTypeDef($type)
returns a sample serialization of a given type, or false if no type by the given name
parseFile($xml, $type)
parse an XML file
CreateTypeName($ename)
gets a type name for an unnamed type
transport class for sending/receiving data via HTTP and HTTPS NOTE: PHP must be compiled with the CUR...
sendRequest($data, $cookies=null)
sends the SOAP request via HTTP[S]
setCurlOption($option, $value)
sets a cURL option
getCookiesForRequest($cookies, $secure=false)
sort out cookies for the current request
send($data, $timeout=0, $response_timeout=30, $cookies=null)
sends the SOAP request and gets the SOAP response via HTTP[S]
parseCookie($cookie_str)
parse an incoming Cookie into it's parts
setURL($url)
sets the URL to which to connect
getResponse()
gets the SOAP response via HTTP[S]
setContentType($type, $charset=false)
sets the content-type for the SOAP message to be sent
unsetHeader($name)
unsets an HTTP header
isSkippableCurlHeader(&$data)
Test if the given string starts with a header that is to be skipped.
setSOAPAction($soapaction)
set the soapaction value
setEncoding($enc='gzip, deflate')
use http encoding
usePersistentConnection()
specifies that an HTTP persistent connection should be used
setCredentials($username, $password, $authtype='basic', $digestRequest=array(), $certRequest=array())
if authenticating, set user credentials here
buildPayload($data, $cookie_str='')
Writes the payload, including HTTP headers, to $this->outgoing_payload.
connect($connection_timeout=0, $response_timeout=30)
establish an HTTP connection
setHeader($name, $value)
sets an HTTP header
io_method()
gets the I/O method to use
decodeChunked($buffer, $lb)
decode a string that is encoded w/ "chunked' transfer encoding as defined in RFC2068 19....
setProxy($proxyhost, $proxyport, $proxyusername='', $proxypassword='', $proxyauthtype='basic')
set proxy info here
sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies=null)
sends the SOAP request and gets the SOAP response via HTTPS using CURL
For creating serializable abstractions of native PHP types.
serialize($use='encoded')
return serialized value
decode()
decodes a soapval object into a PHP native type
parses a WSDL file, allows access to it's data, other utility methods.
character_data($parser, $data)
element content handler
serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType)
serializes the attributes for a complexType
serializeRPCParameters($operation, $direction, $parameters, $bindingType='soap')
serialize PHP values according to a WSDL message definition contrary to the method name,...
addElement($attrs)
adds an element to the WSDL types
getTypeDef($type, $ns)
returns an array of information about a given type returns false if no type exists by the given name
getOperations($bindingType='soap')
returns an assoc array of operation names => operation data
setCredentials($username, $password, $authtype='basic', $certRequest=array())
if authenticating, set user credentials here
getOperationData($operation, $bindingType='soap')
returns an associative array of data necessary for calling an operation
serializeParameters($operation, $direction, $parameters)
serialize a PHP value according to a WSDL message definition
fetchWSDL($wsdl)
fetches the WSDL document and parses it
addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array())
adds an XML Schema simple type to the WSDL types
serialize($debug=0)
serialize the parsed wsdl
getOperationDataForSoapAction($soapAction, $bindingType='soap')
returns an associative array of data necessary for calling an operation
webDescription()
prints html description of services
serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false)
serializes a PHP value according a given type definition
parseWSDL($wsdl='')
parses the wsdl document
parametersMatchWrapped($type, &$parameters)
determine whether a set of parameters are unwrapped when they are expect to be wrapped,...
start_element($parser, $name, $attrs)
start-element handler
end_element($parser, $name)
end-element handler
serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false)
serializes the elements for a complexType
addComplexType($name, $typeClass='complexType', $phpType='array', $compositor='', $restrictionBase='', $elements=array(), $attrs=array(), $arrayType='')
adds an XML Schema complex type to the WSDL types
addOperation($name, $in=false, $out=false, $namespace=false, $soapaction=false, $style='rpc', $use='encoded', $documentation='', $encodingStyle='')
register an operation with the server
if($err=$client->getError()) $namespace
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
if(empty($path)) $serviceName
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
if(count($parts) !=3) $payload
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
catch(\Exception $e) $req