/usr/share/doc/python-zsi/zsi.html is in python-zsi 2.1~a1-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="zsi.css" type='text/css' />
<link rel="first" href="zsi.html" title='ZSI: the Zolera soap Infrastructure
<BR> Developer's Guide' />
<link rel='contents' href='zsi.html' title="Contents" />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>ZSI: The Zolera Soap Infrastructure Developer's Guide</title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><img src='previous.png'
border='0' height='32' alt='Previous Page' width='32' /></td>
<td class='online-navigation'><img src='up.png'
border='0' height='32' alt='Up one Level' width='32' /></td>
<td class='online-navigation'><img src='next.png'
border='0' height='32' alt='Next Page' width='32' /></td>
<td align="center" width="100%">ZSI: The Zolera Soap Infrastructure
<br> Developer's Guide</td>
<td class='online-navigation'><img src='blank.png'
border='0' height='32' alt='' width='32' /></td>
<td class='online-navigation'><img src='blank.png'
border='0' height='32' alt='' width='32' /></td>
<td class='online-navigation'><img src='blank.png'
border='0' height='32' alt='' width='32' /></td>
</tr></table>
<div class='online-navigation'>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->
<p>
<div class="titlepage">
<div class='center'>
<h1>ZSI: The Zolera Soap Infrastructure
<br> Developer's Guide</h1>
<p><b><font size="+2">Rich Salz,</font></b></p>
<p>
<span class="email">rsalz@datapower.com
<br>blunck@python.org</span>
</p>
<p><i> Christopher Blunck</i></p>
<p><strong>Release 2.1.0</strong><br />
<strong>November 01, 2007</strong></p>
<p></p>
</div>
</div>
<p>
<div class="centerline" id="par3934" align="CENTER">
<strong>COPYRIGHT</strong></div>
<p>
Copyright © 2001, Zolera Systems, Inc.
<br>All Rights Reserved.
<p>
Copyright © 2002-2003, Rich Salz.
<br>All Rights Reserved.
<p>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, and/or
sell copies of the Software, and to permit persons to whom the Software
is furnished to do so, provided that the above copyright notice(s) and
this permission notice appear in all copies of the Software and that
both the above copyright notice(s) and this permission notice appear in
supporting documentation.
<p>
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
OR PERFORMANCE OF THIS SOFTWARE.
<p>
Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.
<p>
<br>
<br>
<br>
<br>
<p>
<div class="centerline" id="par3935" align="CENTER">
<strong>Acknowledgments</strong></div>
<p>
We are grateful to the members of the <code>soapbuilders</code>
mailing list (see <a class="url" href="http://groups.yahoo.com/soapbuilders">http://groups.yahoo.com/soapbuilders</a>),
Fredrik Lundh for his <code>soaplib</code> package (see
<a class="url" href="http://www.secretlabs.com/downloads/index.htm#soap">http://www.secretlabs.com/downloads/index.htm#soap</a>),
Cayce Ullman and Brian Matthews for their <code>SOAP.py</code> package
(see <a class="url" href="http://sourceforge.net/projects/pywebsvcs">http://sourceforge.net/projects/pywebsvcs</a>).
<p>
We are particularly grateful to Brian Lloyd and the Zope Corporation
(<a class="url" href="http://www.zope.com">http://www.zope.com</a>) for letting us incorporate his ZOPE
WebServices package and documentation into <tt class="module">ZSI</tt>.
<h3>Abstract:</h3>
<div class="ABSTRACT">
<tt class="module">ZSI</tt>, the Zolera SOAP Infrastructure, is a Python package that
provides an implementation of SOAP messaging, as described in
<em class="citetitle"><a
href="http://www.w3.org/TR/soap"
title="The SOAP 1.1 Specification"
>The SOAP 1.1 Specification</a></em>.
In particular, <tt class="module">ZSI</tt> parses and generates SOAP messages, and
converts between native Python datatypes and SOAP syntax.
It can also be used to build applications using
<em class="citetitle"><a
href="http://www.w3.org/TR/SOAP-attachments"
title="SOAP Messages with
Attachments"
>SOAP Messages with
Attachments</a></em>.
<tt class="module">ZSI</tt> is ``transport neutral'', and provides only a simple
I/O and dispatch framework; a more complete solution is the
responsibility of the application using <tt class="module">ZSI</tt>.
As usage patterns emerge, and common application frameworks are
more understood, this may change.
<p>
<tt class="module">ZSI</tt> requires Python 2.3 or later.
<p>
The <tt class="module">ZSI</tt> homepage is at <a class="url" href="http://pywebsvcs.sf.net/">http://pywebsvcs.sf.net/</a>.
<p>
</div>
<p>
<p>
<br><h2><a name="SECTION001000000000000000000">
Contents</a>
</h2>
<!--Table of Contents-->
<ul class="TofC">
<li><a href="zsi.html#SECTION002000000000000000000">1. Introduction</a>
<ul>
<li><a href="zsi.html#SECTION002100000000000000000">1.1 How to Read this Document</a>
</ul>
<li><a href="zsi.html#SECTION003000000000000000000">2. Examples</a>
<ul>
<li><a href="zsi.html#SECTION003100000000000000000">2.1 Server Side Examples</a>
<ul>
<li><a href="zsi.html#SECTION003110000000000000000">2.1.1 Simple example</a>
<li><a href="zsi.html#SECTION003120000000000000000">2.1.2 low level soap processing example</a>
<li><a href="zsi.html#SECTION003130000000000000000">2.1.3 A mod_python example</a>
</ul>
<li><a href="zsi.html#SECTION003200000000000000000">2.2 Client Side Examples</a>
<ul>
<li><a href="zsi.html#SECTION003210000000000000000">2.2.1 Simple Example</a>
<li><a href="zsi.html#SECTION003220000000000000000">2.2.2 Complex Example: pickler.py</a>
</ul>
</ul>
<li><a href="zsi.html#SECTION004000000000000000000">3. Exceptions</a>
<li><a href="zsi.html#SECTION005000000000000000000">4. Utilities</a>
<ul>
<li><a href="zsi.html#SECTION005100000000000000000">4.1 Low-Level Utilities</a>
</ul>
<li><a href="zsi.html#SECTION006000000000000000000">5. The ParsedSoap module -- basic message handling</a>
<li><a href="zsi.html#SECTION007000000000000000000">6. The TypeCode classes -- data conversions</a>
<ul>
<li><a href="zsi.html#SECTION007100000000000000000">6.1 TC.TypeCode</a>
<li><a href="zsi.html#SECTION007200000000000000000">6.2 TC.Any -- the basis of dynamic typing</a>
<ul>
<li><a href="zsi.html#SECTION007210000000000000000">6.2.1 simple data</a>
<li><a href="zsi.html#SECTION007220000000000000000">6.2.2 compound data</a>
<li><a href="zsi.html#SECTION007230000000000000000">6.2.3 class description</a>
<li><a href="zsi.html#SECTION007240000000000000000">6.2.4 Adding new types</a>
</ul>
<li><a href="zsi.html#SECTION007300000000000000000">6.3 TC.SimpleType</a>
<li><a href="zsi.html#SECTION007400000000000000000">6.4 Strings</a>
<li><a href="zsi.html#SECTION007500000000000000000">6.5 Integers</a>
<li><a href="zsi.html#SECTION007600000000000000000">6.6 Floating-point Numbers</a>
<li><a href="zsi.html#SECTION007700000000000000000">6.7 Dates and Times</a>
<li><a href="zsi.html#SECTION007800000000000000000">6.8 Boolean</a>
<li><a href="zsi.html#SECTION007900000000000000000">6.9 XML</a>
<li><a href="zsi.html#SECTION0071000000000000000000">6.10 ComplexType</a>
<li><a href="zsi.html#SECTION0071100000000000000000">6.11 Struct</a>
<li><a href="zsi.html#SECTION0071200000000000000000">6.12 Arrays</a>
<li><a href="zsi.html#SECTION0071300000000000000000">6.13 Apache Datatype</a>
</ul>
<li><a href="zsi.html#SECTION008000000000000000000">7. The SoapWriter module -- serializing data</a>
<li><a href="zsi.html#SECTION009000000000000000000">8. The Fault module -- reporting errors</a>
<li><a href="zsi.html#SECTION0010000000000000000000">9. The resolvers module -- fetching remote data</a>
<li><a href="zsi.html#SECTION0011000000000000000000">10. Dispatching and Invoking</a>
<ul>
<li><a href="zsi.html#SECTION0011100000000000000000">10.1 Dispatching</a>
<ul>
<li><a href="zsi.html#SECTION0011110000000000000000">10.1.1 Dispatch Behaviors</a>
<li><a href="zsi.html#SECTION0011120000000000000000">10.1.2 Special Modules</a>
<li><a href="zsi.html#SECTION0011130000000000000000">10.1.3 Dispatch Mechanisms</a>
<li><a href="zsi.html#SECTION0011140000000000000000">10.1.4 Other Dispatch Stuff</a>
</ul>
<li><a href="zsi.html#SECTION0011200000000000000000">10.2 The client module -- sending SOAP messages</a>
<ul>
<li><a href="zsi.html#SECTION0011210000000000000000">10.2.1 _Binding</a>
<li><a href="zsi.html#SECTION0011220000000000000000">10.2.2 Binding</a>
<li><a href="zsi.html#SECTION0011230000000000000000">10.2.3 NamedParamBinding</a>
</ul>
</ul>
<li><a href="zsi.html#SECTION0012000000000000000000">11. Bibliography</a>
<li><a href="zsi.html#SECTION0013000000000000000000">Bibliography</a>
<li><a href="zsi.html#SECTION0014000000000000000000">A. CGI Script Array</a>
<ul>
<li><a href="zsi.html#SECTION0014100000000000000000">A.1 Intro</a>
<ul>
<li><a href="zsi.html#SECTION0014110000000000000000">A.1.1 rpc wrapper</a>
</ul>
<li><a href="zsi.html#SECTION0014200000000000000000">A.2 CGI Script</a>
<li><a href="zsi.html#SECTION0014300000000000000000">A.3 client test script</a>
<li><a href="zsi.html#SECTION0014400000000000000000">A.4 SOAP Trace</a>
<ul>
<li><a href="zsi.html#SECTION0014410000000000000000">A.4.1 hello</a>
<li><a href="zsi.html#SECTION0014420000000000000000">A.4.2 hello fault</a>
<li><a href="zsi.html#SECTION0014430000000000000000">A.4.3 echo</a>
<li><a href="zsi.html#SECTION0014440000000000000000">A.4.4 sum</a>
<li><a href="zsi.html#SECTION0014450000000000000000">A.4.5 average</a>
</ul>
</ul>
<li><a href="zsi.html#SECTION0015000000000000000000">B. CGI Script Struct</a>
<ul>
<li><a href="zsi.html#SECTION0015100000000000000000">B.1 Intro</a>
<ul>
<li><a href="zsi.html#SECTION0015110000000000000000">B.1.1 rpc wrapper</a>
</ul>
<li><a href="zsi.html#SECTION0015200000000000000000">B.2 CGI Script</a>
<li><a href="zsi.html#SECTION0015300000000000000000">B.3 client test script</a>
<li><a href="zsi.html#SECTION0015400000000000000000">B.4 SOAP Trace</a>
<ul>
<li><a href="zsi.html#SECTION0015410000000000000000">B.4.1 hello</a>
</ul>
</ul>
<li><a href="zsi.html#SECTION0016000000000000000000">C. Complete Low Level Example</a>
<ul>
<li><a href="zsi.html#SECTION0016100000000000000000">C.1 Intro</a>
<li><a href="zsi.html#SECTION0016200000000000000000">C.2 code</a>
<ul>
<li><a href="zsi.html#SECTION0016210000000000000000">C.2.1 httpserver script</a>
<li><a href="zsi.html#SECTION0016220000000000000000">C.2.2 typecode module</a>
<li><a href="zsi.html#SECTION0016230000000000000000">C.2.3 player script</a>
<li><a href="zsi.html#SECTION0016240000000000000000">C.2.4 client test script</a>
</ul>
<li><a href="zsi.html#SECTION0016300000000000000000">C.3 SOAP Trace</a>
<ul>
<li><a href="zsi.html#SECTION0016310000000000000000">C.3.1 GetAverage</a>
<li><a href="zsi.html#SECTION0016320000000000000000">C.3.2 fault</a>
</ul>
</ul>
<li><a href="zsi.html#SECTION0017000000000000000000">D. pickler example</a>
<ul>
<li><a href="zsi.html#SECTION0017100000000000000000">D.1 Intro</a>
<li><a href="zsi.html#SECTION0017200000000000000000">D.2 code</a>
<ul>
<li><a href="zsi.html#SECTION0017210000000000000000">D.2.1 typecode module</a>
<li><a href="zsi.html#SECTION0017220000000000000000">D.2.2 pickler script</a>
<li><a href="zsi.html#SECTION0017230000000000000000">D.2.3 client: invoke savePerson</a>
<li><a href="zsi.html#SECTION0017240000000000000000">D.2.4 client: invoke getPerson 3 different ways</a>
</ul></ul></ul>
<!--End of Table of Contents-->
<h1><a name="SECTION002000000000000000000">
1. Introduction</a>
</h1>
<p>
<tt class="module">ZSI</tt>, the Zolera SOAP Infrastructure, is a Python package that
provides an implementation of the SOAP specification, as described in
<em class="citetitle"><a
href="http://www.w3.org/TR/soap"
title="The SOAP 1.1 Specification"
>The SOAP 1.1 Specification</a></em>.
In particular, <tt class="module">ZSI</tt> parses and generates SOAP messages, and
converts between native Python datatypes and SOAP syntax.
<p>
<tt class="module">ZSI</tt> requires Python 2.3 or later.
<p>
The <tt class="module">ZSI</tt> project is maintained at SourceForge, at
<a class="url" href="http://pywebsvcs.sf.net">http://pywebsvcs.sf.net</a>.
<tt class="module">ZSI</tt> is discussed on the Python web services mailing list, visit
<a class="url" href="http://lists.sourceforge.net/lists/listinfo/pywebsvcs-talk">http://lists.sourceforge.net/lists/listinfo/pywebsvcs-talk</a>to subscribe.
<p>
For those interested in using the <b class="program">wsdl2py</b> tool see the <em>Users
Guide</em>, it contains a detailed example of how to use the code generation
facilities in <tt class="module">ZSI</tt>.
<p>
For those interested in a high-level tutorial covering <tt class="module">ZSI</tt> and why
Python was chosen, see the article
<a class="url" href="http://www.xml.com/pub/a/ws/2002/06/12/soap.html">http://www.xml.com/pub/a/ws/2002/06/12/soap.html</a>,
written by Rich Salz for xml.com.
<p>
SOAP-based processing typically involves several steps.
The following list details the steps of a common processing model naturally
supported by <tt class="module">ZSI</tt> (other models are certainly possible):
<ol>
<li><tt class="module">ZSI</tt> takes data from an input stream and <em>parses</em> it, generating
a DOM-based parse tree as part of creating a <tt class="class">ParsedSoap</tt> object.
At this point the major syntactic elements of a SOAP message -- the
<code>Header</code>, the <code>Body</code>, etc. -- are available.
</li>
<li>The application does <em>header processing</em>.
More specifically, it does local dispatch and processing based on
the elements in the SOAP <code>Header</code>.
The SOAP <code>actor</code> and <code>mustUnderstand</code> attributes are
also handled (or at least recognized) here.
</li>
<li><tt class="module">ZSI</tt> next <em>parses</em> the <code>Body</code>, creating local Python objects
from the data in the SOAP message.
The parsing is often under the control of a list of data descriptions,
known as <em>typecodes</em>, defined by the application because it knows
what type of data it is expecting.
In cases where the SOAP data is known to be completely self-describing,
the parsing can be <em>dynamic</em> through the use of the <tt class="class">TC.Any</tt>
class.
</li>
<li>The application now <em>dispatches</em> to the appropriate handler
in order to do its ``real work.''
As part of its processing it may create <em>output objects</em>
</li>
<li>The application creates a <tt class="class">SoapWriter</tt> instance and outputs
an initial set of namespace entries and header elements.
</li>
<li>Any local data to be sent back to the client is <em>serialized</em>.
As with <code>Body</code> parsing, the datatypes can be described through
typecodes or determined dynamically (here, through introspection).
</li>
<li>In the event of any processing exceptions, a <tt class="class">Fault</tt> object
can be raised, created, and/or serialized.
</li>
</ol>
<p>
Note that <tt class="module">ZSI</tt> is ``transport neutral'', and provides only a simple
I/O and dispatch framework; a more complete solution is available through
the use of included WSDL tools (<b class="program">wsdl2py</b>), but otherwise this is
the responsibility of the application using <tt class="module">ZSI</tt>. As usage patterns
emerge, and common application frameworks are more understood, this may
change.
<p>
Within this document, <code>tns</code> is used as the prefix for the
application's target namespace, and the term
<em>element</em> refers to a DOM element node.)
<p>
<h1><a name="SECTION002100000000000000000">
1.1 How to Read this Document</a>
</h1>
<p>
Readers interested in using WSDL and clients to web services, and those
intending on implementing web services based on existing WSDL should refer
to the <em>Users Guide</em>. Others interested in developing the simplest SOAP
applications, or spending the least amount of time on building a web services
infrastructure should read chapters 2, 3, and 10 of this document. Readers who
are developing complex services, and who are familiar with XML Schema and/or
WSDL, should read this manual in order. This will provide them with enough
information to implement the processing model described above. They can skip
probably skip chapters 2 and 10.
<p>
<tt class="module">ZSI</tt> has the capability to process WSDL definitions and XML Schema documents
(described in <em class="citetitle"><a
href="http://www.w3.org/TR/wsdl"
title="The Web Services Description
Language"
>The Web Services Description
Language</a></em> and <em class="citetitle"><a
href="http://www.w3.org/XML/Schema"
title="XMLSchema 1.0"
>XMLSchema 1.0</a></em>)
and generate typecodes automatically. For more information see the <em>Users
Guide</em>.
<p>
<h1><a name="SECTION003000000000000000000">
2. Examples</a>
</h1>
<p>
This chapter contains a number of examples to show off some of <tt class="module">ZSI</tt>'s
features. It is broken down into client-side and server-side examples, and
explores different implementation options <tt class="module">ZSI</tt> provides.
<p>
<h1><a name="SECTION003100000000000000000">
2.1 Server Side Examples</a>
</h1>
<h2><a name="SECTION003110000000000000000">
2.1.1 Simple example</a>
</h2>
Using the <tt class="module">ZSI.dispatch</tt> module, it is simple to expose Python functions
as web services. Each function is invoked with all the input parameters
specified in the client's SOAP request. Any value returned by the function will
be serialized back to the client; multiple values can be returned by returning a
tuple.
<p>
The following code shows some simple services:
<p>
<div class="verbatim"><pre>
#!/usr/local/bin/python2.4
# SOAP Array
def hello():
return ["Hello, world"]
def echo(*args):
return args
def sum(*args):
sum = 0
for i in args: sum += i
return [sum]
def average(*args):
return [sum(*args) / len(args)]
from ZSI import dispatch
dispatch.AsCGI(rpc=True)
</pre></div>
<p>
Each function defines a SOAP request, so if this script is installed
as a CGI script, a SOAP message can be posted to that script's URL with any of
<code>hello</code>, <code>echo</code>, or <code>average</code> as the request element,
and the value returned by the function will be sent back. These functions
expect and return SOAP-ENC:arrayType instances which are marshalled into python
<tt class="class">list</tt> instances, this script interoperates with the
<tt class="class">client.Binding</tt>. For more information see <em>Appendix A</em>.
<p>
The <tt class="module">ZSI</tt> CGI dispatcher catches exceptions and sends back a SOAP fault.
For example, a fault will be sent if the <code>hello</code> function is given any
arguments, or if the <code>average</code> function is given a non-integer.
<p>
Here is another example but using SOAP-ENC:Struct instances which are marshalled
into python <tt class="class">dict</tt> instances, this script interoperates with the
<tt class="class">client.NamedParamBinding</tt>. For more information see <em>Appendix B</em>.
<p>
<div class="verbatim"><pre>
#!/usr/local/bin/python2.4
# SOAP Struct
def hello():
return {"value":"Hello, world"}
def echo(**kw):
return kw
def sum(**kw):
sum = 0
for i in kw.values(): sum += i
return {"value":sum}
def average(**kw):
d = sum(**kw)
return d["value"] = d["value"]/len(kw)
from ZSI import dispatch
dispatch.AsCGI(rpc=True)
</pre></div>
<p>
<h2><a name="SECTION003120000000000000000">
2.1.2 low level soap processing example</a>
</h2>
<p>
We will now show a more complete example of a robust web service implemented at
the SOAP layer. It takes as input a player name and array of integers, and returns
the average. It is presented in sections, following the steps detailed above.
A complete working example of this service is available in <em>Appendix C</em>.
<p>
The first section reads in a request, and parses the SOAP header.
<p>
<div class="verbatim"><pre>
from ZSI import *
import sys
IN, OUT = sys.stdin, sys.stdout
try:
ps = ParsedSoap(IN)
except ParseException, e:
OUT.write(FaultFromZSIException(e).AsSOAP())
sys.exit(1)
except Exception, e:
# Faulted while processing; we assume it's in the header.
OUT.write(FaultFromException(e, 1).AsSOAP())
sys.exit(1)
# We are not prepared to handle any actors or mustUnderstand elements,
# so we'll arbitrarily fault back with the first one we found.
a = ps.WhatActorsArePresent()
if len(a):
OUT.write(FaultFromActor(a[0]).AsSOAP())
sys.exit(1)
mu = ps.WhatMustIUnderstand()
if len(mu):
uri, localname = mu[0]
OUT.write(FaultFromNotUnderstood(uri, localname).AsSOAP())
sys.exit(1)
</pre></div>
<p>
This section defines the mappings between Python objects and the SOAP
data being transmitted. Recall that according to the SOAP specification, RPC
input and output are modeled as a structure.
<p>
<div class="verbatim"><pre>
class Player:
def __init__(self, *args):
if not len(args): return
self.Name = args[0]
self.Scores = args[1:]
Player.typecode = TC.Struct(Player, [
TC.String('Name'),
TC.Array('Integer', TC.Integer(), 'Scores', undeclared=True),
], 'GetAverage')
class Average:
def __init__(self, average=None):
self.average = average
Average.typecode = TC.Struct(Average, [
TC.Integer('average'),
], 'GetAverageResponse')
</pre></div>
<p>
This section parses the input, performs the application-level
activity, and serializes the response.
<div class="verbatim"><pre>
try:
player = ps.Parse(Player.typecode)
except EvaluateException, e:
OUT.write(FaultFromZSIException(e).AsSOAP())
sys.exit(1)
try:
total = 0
for value in player.Scores: total = total + value
result = Average(total / len(player.Scores))
sw = SoapWriter()
sw.serialize(result, Average.typecode)
sw.close()
OUT.write(str(sw))
except Exception, e:
OUT.write(FaultFromException(e, 0, sys.exc_info()[2]).AsSOAP())
sys.exit(1)
</pre></div>
<p>
In the <tt class="method">serialize()</tt> call above, the second parameter is optional, since
<code>result</code> is an instance of the <tt class="class">Average</tt> class, and the
<code>Average.typecode</code> attribute is the typecode for class instances.
<p>
<h2><a name="SECTION003130000000000000000">
2.1.3 A mod_python example</a>
</h2>
<p>
The Apache module <code>mod_python</code> (see
<a class="url" href="http://www.modpython.org">http://www.modpython.org</a>) embeds Python within the Apache server.
In order to expose operations within a module via mod_python, use the
<tt class="method">dispatch.AsHandler()</tt> function. The <tt class="method">dispatch.AsHandler()</tt>
function will dispatch requests to any operation defined in the module you
pass it, which allows for multiple operations to be defined in a module.
The only trick is to use __import__ to load the XML encodings your service
expects. This is a required workaround to avoid the pitfalls of restricted
execution with respect to XML parsing.
<p>
The following is a complete example of a simple handler. The soap operations
are implemented in the MyHandler module:
<p>
<div class="verbatim"><pre>
def hello():
return {"value":"Hello, world"}
def echo(**kw):
return kw
def sum(**kw):
sum = 0
for i in kw.values(): sum += i
return {"value":sum}
def average(**kw):
d = sum(**kw)
d["value"] = d["value"]/len(kw)
return d
</pre></div>
<p>
Dispatching from within mod_python is achieved by passing the aforementined
MyHandler module to <code>dispatch.AsHandler()</code>. The following code exposes
the operations defined in MyHandler via SOAP:
<p>
<div class="verbatim"><pre>
from ZSI import dispatch
from mod_python import apache
import MyHandler
mod = __import__('encodings.utf_8', globals(), locals(), '*')
mod = __import__('encodings.utf_16_be', globals(), locals(), '*')
def handler(req):
dispatch.AsHandler(modules=(MyHandler,), request=req, rpc=True)
return apache.OK
</pre></div>
<p>
<h1><a name="SECTION003200000000000000000">
2.2 Client Side Examples</a>
</h1>
<p>
<h2><a name="SECTION003210000000000000000">
2.2.1 Simple Example</a>
</h2>
<tt class="module">ZSI</tt> provides two ways for a client to interactive with a server:
the <tt class="class">Binding</tt> or <tt class="class">NamedParamBinding</tt> class and the
<tt class="class">ServiceProxy</tt> class. The first is useful when the operations to be
invoked are not defined in WSDL or when only simple Python datatypes are used;
the <tt class="class">ServiceProxy</tt> class can be used to parse WSDL definitions in order
to determine how to serialize and parse the SOAP messages.
<p>
During development, it is often useful to record ``packet traces'' of
the SOAP messages being exchanged. Both the <tt class="class">Binding</tt> and
<tt class="class">ServiceProxy</tt> classes provide a <code>tracefile</code> parameter to specify an
output stream (such as a file) to capture messages. It can be particularly
useful when debugging unexpected SOAP faults.
<p>
The first example provided below demonstrates how to use the <tt class="class">NamedParamBinding</tt>
class to connect to a remote service and perform an operation.
<p>
<div class="verbatim"><pre>
#!/usr/bin/env python
import sys,time
from ZSI.client import NamedParamBinding as NPBinding
b = NPBinding(url='http://127.0.0.1/cgi-bin/soapstruct', tracefile=sys.stdout)
print "Hello: ", b.hello()
print "Echo: ", b.echo(name="josh", year=2006, pi=3.14, time=time.gmtime())
print "Sum: ", b.sum(one=1, two=2, three=3)
print "Average: ", b.average(one=100, two=200, three=300, four=400)
</pre></div>
<p>
<h2><a name="SECTION003220000000000000000">
2.2.2 Complex Example: pickler.py</a>
</h2>
If the operation invoked returns a ComplexType, typecode information must
be provided in order to tell <tt class="module">ZSI</tt> how to deserialize the response.
Here is a sample server-side implementation (for the complete example see
<em>Appendix D</em>):
<p>
<div class="verbatim"><pre>
class Person:
def __init__(self, name=None, age=0):
self.name = name
self.age = age
Person.typecode = TC.Struct(Person,
[TC.String('name'),
TC.InonNegativeInteger('age')],
'myApp:Person')
# my web service that returns a complex structure
def getPerson(name):
fp = open('%s.person.pickle', % name, 'r')
return pickle.load(fp)
# my web service that accepts a complex structure
def savePerson(person):
fp = open('%s.person.pickle' % person.name, 'w')
pickle(person, fp)
fp.close()
</pre></div>
<p>
In order for <tt class="module">ZSI</tt> to transparently deserialize the returned complex type into
a <tt class="class">Person</tt> instance, a module defining the class and its typecode can be
passed into the <tt class="class">Binding</tt>. It is also possible to explicitly tell <tt class="module">ZSI</tt>
what typecode to use by passing it as a parameter to the <tt class="method">Binding.Receive()</tt>
method.
<p>
The following fragment shows both styles:
<p>
<div class="verbatim"><pre>
import sys
from ZSI.client import Binding
from MyComplexTypes import Person
b = Binding(url='http://localhost/test3/pickler.py', tracefile=sys.stdout)
person = Person('christopher', 26)
rsp = b.savePerson(person)
</pre></div>
<p>
Because the returned complex type is defined in a class present in
<var>typesmodule</var>, transparent deserialization is possible. When sending
complex types to the server, it is not necessary to list the module
in <var>typesmodule</var>:
<p>
<div class="verbatim"><pre>
import sys
import MyComplexTypes
from ZSI.client import NamedParamBinding as NPBinding, Binding
from ZSI import TC
kw = {'url':'http://localhost/test3/pickler.py', 'tracefile':sys.stdout}
b = NPBinding(**kw)
rsp = b.getPerson(name='christopher')
assert type(rsp) is dict, 'expecting a dict'
assert rsp['Person']['name'] == 'christopher', 'wrong person'
b = NPBinding(typesmodule=MyComplexTypes, **kw)
rsp = b.getPerson(name='christopher')
assert isinstance(rsp['Person'], MyComplexTypes.Person), (
'expecting instance of %s' %MyComplexTypes.Person)
b = Binding(typesmodule=MyComplexTypes, **kw)
class Name(str):
typecode = TC.String("name")
rsp = b.getPerson(Name('christopher'))
assert isinstance(rsp['Person'], MyComplexTypes.Person), (
'expecting instance of %s' %MyComplexTypes.Person)
</pre></div>
<p>
<h1><a name="SECTION004000000000000000000">
3. Exceptions</a>
</h1>
<p>
<dl><dt><b><span class="typelabel">exception</span> <tt id='l2h-1' xml:id='l2h-1' class="exception">ZSIException</tt></b></dt>
<dd>
Base class for all ZSI Exceptions, it is a subtype of the Python
<tt class="exception">Exception</tt> class.
</dd></dl>
<p>
<dl><dt><b><span class="typelabel">exception</span> <tt id='l2h-2' xml:id='l2h-2' class="exception">ParseException</tt></b></dt>
<dd>
<tt class="module">ZSI</tt> can raise this exception while creating a <tt class="class">ParsedSoap</tt> object.
It is a subtype of the <tt class="exception">ZSIException</tt> class.
The string form of a <tt class="exception">ParseException</tt> object consists of a
line of human-readable text.
If the backtrace is available, it will be concatenated as a second line.
</dd></dl>
<p>
The following attributes are read-only:
<p>
<dl><dt><b><tt id='l2h-3' xml:id='l2h-3' class="member">inheader</tt></b></dt>
<dd>
A boolean that indicates if the error was detected in the SOAP <code>Header</code>
element.
</dl>
<p>
<dl><dt><b><tt id='l2h-4' xml:id='l2h-4' class="member">str</tt></b></dt>
<dd>
A text string describing the error.
</dl>
<p>
<dl><dt><b><tt id='l2h-5' xml:id='l2h-5' class="member">trace</tt></b></dt>
<dd>
A text string containing a backtrace to the error.
This may be <code>None</code> if it was not possible, such as when there was
a general DOM exception, or when the <code>str</code> text is believed to be
sufficient.
</dl>
<p>
<dl><dt><b><span class="typelabel">exception</span> <tt id='l2h-6' xml:id='l2h-6' class="exception">EvaluateException</tt></b></dt>
<dd>
This exception is similar to <tt class="exception">ParseException</tt>, except
that <tt class="module">ZSI</tt> may raise it while converting between SOAP and local
Python objects.
</dd></dl>
<p>
The following attributes are read-only:
<p>
<dl><dt><b><tt id='l2h-7' xml:id='l2h-7' class="member">str</tt></b></dt>
<dd>
A text string describing the error.
</dl>
<p>
<dl><dt><b><tt id='l2h-8' xml:id='l2h-8' class="member">trace</tt></b></dt>
<dd>
A text backtrace, as described above for <tt class="exception">ParseException</tt>.
</dl>
<h1><a name="SECTION005000000000000000000">
4. Utilities</a>
</h1>
<p>
<tt class="module">ZSI</tt> defines some utility methods that general applications
may want to use.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-9' xml:id='l2h-9' class="function">Version</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns a three-element tuple containing the numbers representing the
major, minor, and release identifying the <tt class="module">ZSI</tt> version.
<span class="versionnote">New in version 1.1.</span>
</dl>
<p>
<h1><a name="SECTION005100000000000000000">
4.1 Low-Level Utilities</a>
</h1>
<p>
<tt class="module">ZSI</tt> also defines some low-level utilities for its own use that
start with a leading underscore and must be imported explicitly.
They are documented here because they can be useful for developing
new typecode classes.
<p>
These functions are mostly used in in <code>parse</code> methods and the
<tt class="class">ParsedSoap</tt> class. The serialization routines use the
<tt class="class">ElementProxy</tt> class to encapsulate common DOM-level operations.
<p>
Some <code>lambda</code>'s are defined so that some DOM accessors
will return an empty list rather than <code>None</code>.
This means that rather than writing:
<div class="verbatim"><pre>
if elt.childNodes:
for N in elt.childNodes:
...
</pre></div>
One can write:
<div class="verbatim"><pre>
for N in _children(elt):
...
</pre></div>
<p>
Other <code>lambda</code>'s return SOAP-related attributes from an element,
or <code>None</code> if not present.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-10' xml:id='l2h-10' class="function">_attrs</tt></b>(</nobr></td>
<td><var>element</var>)</td></tr></table></dt>
<dd>
Returns a list of all attributes of the specified <code>element</code>.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-11' xml:id='l2h-11' class="function">_backtrace</tt></b>(</nobr></td>
<td><var>elt, dom</var>)</td></tr></table></dt>
<dd>
This function returns a text string that traces a ``path'' from <code>dom</code>,
a DOM root, to <code>elt</code>, an element within that document, in
XPath syntax.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-12' xml:id='l2h-12' class="function">_child_elements</tt></b>(</nobr></td>
<td><var>element</var>)</td></tr></table></dt>
<dd>
Returns a list of all children elements of the specified <code>element</code>.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-13' xml:id='l2h-13' class="function">_children</tt></b>(</nobr></td>
<td><var>element</var>)</td></tr></table></dt>
<dd>
Returns a list of all children of the specified <code>element</code>.
</dl>
<p>
_copyright
_empty_nsuri_list
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-14' xml:id='l2h-14' class="function">_find_arraytype</tt></b>(</nobr></td>
<td><var>element</var>)</td></tr></table></dt>
<dd>
The value of the SOAP <code>arrayType</code> attribute.
<span class="versionnote">New in version 1.2.</span>
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-15' xml:id='l2h-15' class="function">_find_attr</tt></b>(</nobr></td>
<td><var>element, name</var>)</td></tr></table></dt>
<dd>
The value of the unqualified <code>name</code> attribute.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-16' xml:id='l2h-16' class="function">_find_attrNS</tt></b>(</nobr></td>
<td><var>element, namespaceURI, localName</var>)</td></tr></table></dt>
<dd>
The value of a <code>name</code> attribute in a namespace <code>namespaceURI</code>.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-17' xml:id='l2h-17' class="function">_find_attrNodeNS</tt></b>(</nobr></td>
<td><var>element, namespaceURI, localName</var>)</td></tr></table></dt>
<dd>
Works just like <code>_find_attrNS</code>, but this function grabs the attribute Node to
distinquish between an unspecified attribute(None) and one set to empty
string("").
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-18' xml:id='l2h-18' class="function">_find_default_namespace</tt></b>(</nobr></td>
<td><var>element</var>)</td></tr></table></dt>
<dd>
Returns the value of the default namespace.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-19' xml:id='l2h-19' class="function">_find_encstyle</tt></b>(</nobr></td>
<td><var>element</var>)</td></tr></table></dt>
<dd>
The value of the SOAP <code>encodingStyle</code> attribute.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-20' xml:id='l2h-20' class="function">_find_href</tt></b>(</nobr></td>
<td><var>element</var>)</td></tr></table></dt>
<dd>
The value of the unqualified <code>href</code> attribute.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-21' xml:id='l2h-21' class="function">_find_type</tt></b>(</nobr></td>
<td><var>element</var>)</td></tr></table></dt>
<dd>
The value of the XML Schema <code>type</code> attribute.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-22' xml:id='l2h-22' class="function">_find_xmlns_prefix</tt></b>(</nobr></td>
<td><var>element, prefix</var>)</td></tr></table></dt>
<dd>
The value of the xmlns:prefix <code>type</code> attribute.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-23' xml:id='l2h-23' class="function">_find_xsi_attr</tt></b>(</nobr></td>
<td><var>element, attribute</var>)</td></tr></table></dt>
<dd>
Find the attribute in any of the XMLSchema namespaces.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-24' xml:id='l2h-24' class="function">_get_element_nsuri_name</tt></b>(</nobr></td>
<td><var>element</var>)</td></tr></table></dt>
<dd>
Returns a <code>(namespace,name)</code> tuple representing the element tag.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-25' xml:id='l2h-25' class="function">_get_idstr</tt></b>(</nobr></td>
<td><var>obj</var>)</td></tr></table></dt>
<dd>
Substitute for <tt class="function">id</tt> function. Python 2.3.x generates a <tt class="class">FutureWarning</tt> for negative
IDs, so we use a different prefix character to ensure uniqueness, and call abs()
to avoid the warning.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-26' xml:id='l2h-26' class="function">_get_postvalue_from_absoluteURI</tt></b>(</nobr></td>
<td><var>url</var>)</td></tr></table></dt>
<dd>
Returns POST value from <code>url</code>, and caches these values.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-27' xml:id='l2h-27' class="function">_resolve_prefix</tt></b>(</nobr></td>
<td><var>element, prefix</var>)</td></tr></table></dt>
<dd>
resolve <code>prefix</code> to a namespaceURI. If <code>None</code> or empty <code>str</code>,
return default namespace or <code>None</code> if not defined.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-28' xml:id='l2h-28' class="function">_valid_encoding</tt></b>(</nobr></td>
<td><var>elt</var>)</td></tr></table></dt>
<dd>
Return true if the element <code>elt</code> has a SOAP encoding
that can be handled by <tt class="module">ZSI</tt>
(currently Section 5 of the SOAP 1.1 specification or an empty encoding
for XML).
</dl>
<h1><a name="SECTION006000000000000000000">
5. The <tt class="module">ParsedSoap</tt> module -- basic message handling</a>
</h1>
<p>
This class represents an input stream that has been parsed as a SOAP
message.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-29' xml:id='l2h-29' class="class">ParsedSoap</tt></b>(</nobr></td>
<td><var>input</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Creates a <tt class="class">ParsedSoap</tt> object from the provided input source.
If <code>input</code> is not a string, then it must be an object with a
<tt class="method">read()</tt> method that supports the standard Python ``file read''
semantics.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>envelope</code></td>
<td class="center"><code>True</code></td>
<td class="left" >expect a SOAP Envelope</td></tr>
<tr><td class="left" valign="baseline"><code>keepdom</code></td>
<td class="center"><code>False</code></td>
<td class="left" >Do not release the DOM when this
object is destroyed. To access the DOM object, use the
<tt class="method">GetDomAndReader()</tt> method. The reader object is necessary to
properly free the DOM structure using <tt class="method">reader.releaseNode(dom)</tt>.
<span class="versionnote">New in version 1.2.</span>
</td></tr>
<tr><td class="left" valign="baseline"><code>readerclass</code></td>
<td class="center"><code>None</code></td>
<td class="left" >Class used to create DOM-creating
XML readers; described below.
<span class="versionnote">New in version 1.2.</span>
</td></tr>
<tr><td class="left" valign="baseline"><code>resolver</code></td>
<td class="center"><code>None</code></td>
<td class="left" >Value for the <code>resolver</code>
attribute; see below.</td></tr>
<tr><td class="left" valign="baseline"><code>trailers</code></td>
<td class="center"><code>False</code></td>
<td class="left" >Allow trailing data elements
to appear after the <code>Body</code>.</td></tr></tbody>
</table></div>
<p>
</dl>
<p>
The following attributes of a <tt class="class">ParsedSoap</tt> are read-only:
<p>
<dl><dt><b><tt id='l2h-30' xml:id='l2h-30' class="member">body</tt></b></dt>
<dd>
The root of the SOAP <code>Body</code> element.
Using the <tt class="method">GetElementNSdict()</tt> method on this attribute can be useful
to get a dictionary to be used with the <tt class="class">SoapWriter</tt> class.
</dl>
<p>
<dl><dt><b><tt id='l2h-31' xml:id='l2h-31' class="member">body_root</tt></b></dt>
<dd>
The element that contains the SOAP serialization root; that is,
the element in the SOAP <code>Body</code> that ``starts off'' the data.
</dl>
<p>
<dl><dt><b><tt id='l2h-32' xml:id='l2h-32' class="member">data_elements</tt></b></dt>
<dd>
A (possibly empty) list of all child elements of the <code>Body</code> other
than the root.
</dl>
<p>
<dl><dt><b><tt id='l2h-33' xml:id='l2h-33' class="member">header</tt></b></dt>
<dd>
The root of the SOAP <code>Header</code> element.
Using the <tt class="method">GetElementNSdict()</tt> method on this attribute can be useful
to get a dictionary to be used with the <tt class="class">SoapWriter</tt> class.
</dl>
<p>
<dl><dt><b><tt id='l2h-34' xml:id='l2h-34' class="member">header_elements</tt></b></dt>
<dd>
A (possibly empty) list of all elements in the SOAP <code>Header</code>.
</dl>
<p>
<dl><dt><b><tt id='l2h-35' xml:id='l2h-35' class="member">trailer_elements</tt></b></dt>
<dd>
Returns a (possibly empty) list of all elements following the <code>Body</code>.
If the <code>trailers</code> keyword was not used when the object was
constructed, this attribute will not be instantiated and retrieving
it will raise an exception.
</dl>
<p>
The following attribute may be modified:
<p>
<dl><dt><b><tt id='l2h-36' xml:id='l2h-36' class="member">resolver</tt></b></dt>
<dd>
If not <code>None</code>,
this attribute can be invoked to handle absolute <code>href</code>'s in the SOAP data.
It will be invoked as follows:
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-37' xml:id='l2h-37' class="method">resolver</tt></b>(</nobr></td>
<td><var>uri, tc, ps, **keywords</var>)</td></tr></table></dt>
<dd>
The <code>uri</code> parameter is the URI to resolve.
The <code>tc</code> parameter is the typecode that needs to resolve <code>href</code>; this
may be needed to properly interpret the content of a MIME bodypart, for example.
The <code>ps</code> parameter is the <tt class="class">ParsedSoap</tt> object that is invoking
the resolution (this allows a single resolver instance to handle multiple
SOAP parsers).
<p>
Failure to resolve the URI should result in an exception being raised.
If there is no content, return <code>None</code>; this is not the same as an
empty string.
If there is content, the data returned should be in a form understandable
by the typecode.
</dl>
</dl>
<p>
The following methods are available:
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-38' xml:id='l2h-38' class="method">Backtrace</tt></b>(</nobr></td>
<td><var>elt</var>)</td></tr></table></dt>
<dd>
Returns a human-readable ``trace'' from the document root to the
specified element.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-39' xml:id='l2h-39' class="method">FindLocalHREF</tt></b>(</nobr></td>
<td><var>href, elt</var>)</td></tr></table></dt>
<dd>
Returns the element that has an <code>id</code> attribute whose value is specified
by the <code>href</code> fragment identifier.
The <code>href</code> <em>must</em> be a fragment reference -- that is, it must
start with a pound sign.
This method raises an <tt class="exception">EvaluateException</tt> exception if the
element isn't found.
It is mainly for use by the parsing methods in the <tt class="module">TypeCode</tt> module.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-40' xml:id='l2h-40' class="method">GetElementNSdict</tt></b>(</nobr></td>
<td><var>elt</var>)</td></tr></table></dt>
<dd>
Return a dictionary for all the namespace entries active at the
current element. Each dictionary key will be the prefix and the value will
be the namespace URI.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-41' xml:id='l2h-41' class="method">GetMyHeaderElements</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>actorlist=None</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Returns a list of all elements in the <code>Header</code> that are intended for
<em>this</em> SOAP processor.
This includes all elements that either have no SOAP <code>actor</code>
attribute, or whose value is either the special ``next actor'' value or
in the <code>actorlist</code> list of URI's.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-42' xml:id='l2h-42' class="method">GetDomAndReader</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns a tuple containing the dom and reader objects, <code>(dom, reader)</code>.
Unless keepdom is true, the dom and reader objects will go out of scope
when the ParsedSoap instance is deleted. If keepdom is true, the reader
object is needed to properly clean up the dom tree with
<tt class="method">reader.releaseNode(dom)</tt>.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-43' xml:id='l2h-43' class="method">IsAFault</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns true if the message is a SOAP fault.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-44' xml:id='l2h-44' class="method">Parse</tt></b>(</nobr></td>
<td><var>how</var>)</td></tr></table></dt>
<dd>
Parses the SOAP <code>Body</code> according to the <code>how</code> parameter,
and returns a Python object.
If <code>how</code> is not a <tt class="class">TC.TypeCode</tt> object, then it should be a
Python class object that has a <code>typecode</code> attribute.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-45' xml:id='l2h-45' class="method">ResolveHREF</tt></b>(</nobr></td>
<td><var>uri, tc</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This method is invoked to resolve an absolute URI.
If the typecode <code>tc</code> has a <code>resolver</code> attribute, it will use it
to resolve the URI specified in the <code>uri</code> parameter,
otherwise it will use its own <code>resolver</code>, or raise an
<tt class="exception">EvaluateException</tt> exception.
<p>
Any <code>keyword</code> parameters will be passed to the chosen resolver.
If no content is available, it will return <code>None</code>.
If unable to resolve the URI it will raise an
<tt class="exception">EvaluateException</tt> exception.
Otherwise, the resolver should return data in a form acceptable to the
specified typecode, <code>tc</code>.
(This will almost always be a file-like object holding opaque data;
for XML, it may be a DOM tree.)
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-46' xml:id='l2h-46' class="method">WhatActorsArePresent</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns a list of the values of all the SOAP <code>actor</code> attributes
found in child elements of the SOAP <code>Header</code>.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-47' xml:id='l2h-47' class="method">WhatMustIUnderstand</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns a list of "<tt class="samp">(uri, localname)</tt>" tuples for all elements in the
SOAP <code>Header</code> that have the SOAP <code>mustUnderstand</code> attribute set
to a non-zero value.
</dl>
<p>
<tt class="module">ZSI</tt> supports multiple DOM implementations.
The <code>readerclass</code> parameter specifies which one to use.
The default is to use minidom, provided through the <tt class="class">DefaultReader</tt> class
in the <tt class="module">ZSI.parse</tt> module.
<p>
The specified reader class must support the following methods:
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-48' xml:id='l2h-48' class="method">fromString</tt></b>(</nobr></td>
<td><var>string</var>)</td></tr></table></dt>
<dd>
Return a DOM object from a string.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-49' xml:id='l2h-49' class="method">fromStream</tt></b>(</nobr></td>
<td><var>stream</var>)</td></tr></table></dt>
<dd>
Return a DOM object from a file-like stream.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-50' xml:id='l2h-50' class="method">releaseNode</tt></b>(</nobr></td>
<td><var>dom</var>)</td></tr></table></dt>
<dd>
Free the specified DOM object.
</dl>
<p>
The DOM object must support the standard Python mapping of the DOM Level 2
specification.
While only a small subset of specification is used, the particular
methods and attributes used by <tt class="module">ZSI</tt> are available only
by inspecting the source.
<p>
To use the <code>cDomlette</code> DOM provided by the 4Suite package, use the
<tt class="class">NonvalidatingReader</tt> class in the <tt class="module">Ft.Xml.Domlette</tt> module.
Due to name changes in the 1.0 version of 4Suite, a simple adapter class
is required to use this DOM implementation.
<p>
<div class="verbatim"><pre>
from 4Suite.Xml.Domlette import NonvalidatingReaderBase
class 4SuiteAdapterReader(NonvalidatingReaderBase):
def fromString(self, str):
return self.parseString(str)
def fromStream(self, stream):
return self.parseStream(stream)
def releaseNode(self, node):
pass
</pre></div>
<h1><a name="SECTION007000000000000000000">
6. The <tt class="module">TypeCode</tt> classes -- data conversions</a>
</h1>
<p>
The <tt class="module">TypeCode</tt> module defines classes used for converting data
between SOAP data and local Python objects.
Python numeric and string types, and sequences and dictionaries, are
supported by <tt class="module">ZSI</tt>.
The <tt class="class">TC.TypeCode</tt> class is the parent class of all datatypes
understood by <tt class="module">ZSI</tt>.
<p>
All typecodes classes have the prefix <code>TC.</code>, to avoid name clashes.
<p>
<tt class="module">ZSI</tt> provides fine-grain control over the names used when parsing and
serializing XML into local Python objects, through the use of two
attributes: the <code>pname</code>, the <code>aname</code>. The <code>pname</code> specifies the
name expected on the XML element being parsed and the name to use for the output element
when serializing. The <code>aname</code> is the name to use for the analogous
attribute in the local Python object.
<p>
The <code>pname</code> is the parameter name. It specifies the incoming
XML element name and the default values for the Python attribute
and serialized names. All typecodes take the <code>pname</code> argument. This name can be
specified as either a list or a string. When specified as a list, it must have
two elements which are interpreted as a ``(namespace-URI, localname)'' pair.
If specified this way, both the namespace and the local element name
must match for the parse to succeed. For the Python attribute, and
when generating output, only the ``localname'' is used. If a namespace-URI is
specified then the full qualified name is used for output, and it is required
for input; this <em>requires</em> the namespace prefix to be specified.
<p>
The <code>aname</code> is the attribute name. This parameter overrides
any value implied by the <code>pname</code>. Typecodes nested in a <tt class="class">TC.Struct</tt>
or <tt class="class">TC.ComplexType</tt> can use this parameter to specify
the tag, dictionary key, or instance attribute to set.
<p>
The <code>nsdict</code> parameter to the <tt class="class">SoapWriter</tt> construct can be used to
specify prefix to namespace-URI mappings, these are otherwise handled automatically.
<p>
<h1><a name="SECTION007100000000000000000">
6.1 <tt class="class">TC.TypeCode</tt></a>
</h1>
<p>
The <tt class="class">TypeCode</tt> class is the parent class of all typecodes.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-51' xml:id='l2h-51' class="class">TypeCode</tt></b>(</nobr></td>
<td><var>**keywords</var>)</td></tr></table></dt>
<dd>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>pname</code></td>
<td class="center"><code>None</code></td>
<td class="left" >parameter name of the object</td></tr>
<tr><td class="left" valign="baseline"><code>aname</code></td>
<td class="center"><code>None</code></td>
<td class="left" >attribute name of the object</td></tr>
<tr><td class="left" valign="baseline"><code>minOccurs</code></td>
<td class="center"><code>1</code></td>
<td class="left" >schema facet minimum occurances</td></tr>
<tr><td class="left" valign="baseline"><code>maxOccurs</code></td>
<td class="center"><code>1</code></td>
<td class="left" >schema facet maximum occurances</td></tr>
<tr><td class="left" valign="baseline"><code>nillable</code></td>
<td class="center"><code>False</code></td>
<td class="left" >schema facet is this nillable (<code>xsi:nil="true"</code>)</td></tr>
<tr><td class="left" valign="baseline"><code>typed</code></td>
<td class="center"><code>True</code></td>
<td class="left" >Output type information (in the <code>xsi:type</code>
attribute) when serializing. By special dispensation, typecodes within a
<tt class="class">TC.Struct</tt> object inherit this from the container.</td></tr>
<tr><td class="left" valign="baseline"><code>unique</code></td>
<td class="center"><code>0</code></td>
<td class="left" >If true, the object is unique and will
never be ``aliased'' with another object, so the <code>id</code> attribute
need not be output.</td></tr><p>
<tr><td class="left" valign="baseline"><code>pyclass</code></td>
<td class="center"><code>None</code></td>
<td class="left" >when parsing data, instances of this class
can be created to store the data. Default behavior is reflective of specific
TypeCode classes.</td></tr>
<tr><td class="left" valign="baseline"><code>attrs_aname</code></td>
<td class="center"><code>'_attrs'</code></td>
<td class="left" >attribute name of the object where
attribute values are stored. Used for serialization and parsing.</td></tr><p>
</tbody>
</table></div>
<p>
Optional elements are those which do not have to be an incoming
message, or which have the XML Schema <code>nil</code> attribute set.
When parsing the message as part of a <code>Struct</code>, then the Python
instance attribute will not be set, or the element will not appear as
a dictionary key.
When being parsed as a simple type, the value <code>None</code> is returned.
When serializing an optional element, a non-existent attribute, or a value
of <code>None</code> is taken to mean not present, and the element is skipped.
<p>
</dl>
<p>
<dl><dt><b><tt id='l2h-52' xml:id='l2h-52' class="member">typechecks</tt></b></dt>
<dd>
This is a class attribute.
If true (the default) then all typecode constructors do more
rigorous type-checking on their parameters.
</dl>
<p>
<dl><dt><b><tt id='l2h-53' xml:id='l2h-53' class="member">tag</tt></b></dt>
<dd>
This is a class attribute.
Specifies the global element declaration this typecode represents, the value is
a "<tt class="samp">(namespace, name)</tt>" tuple.
</dl>
<p>
<dl><dt><b><tt id='l2h-54' xml:id='l2h-54' class="member">type</tt></b></dt>
<dd>
This is a class attribute.
Specifies the global type definition this typecode represents, the value is
a "<tt class="samp">(namespace, name)</tt>" tuple.
</dl>
<p>
<dl><dt><b><tt id='l2h-55' xml:id='l2h-55' class="member">attribute_typecode_dict</tt></b></dt>
<dd>
This is a class attribute.
This is a dict of "<tt class="samp">(URI, NCName)</tt>" tuple keys, the values of each is a
typecode. This is how attribute declarations other than SOAP and XMLSchema
attribute declarations (eg. <code>xsi:type</code>, <code>id</code>, <code>href</code>, etc) are
represented.
</dl>
<p>
<dl><dt><b><tt id='l2h-56' xml:id='l2h-56' class="member">logger</tt></b></dt>
<dd>
This is a class attribute.
logger instance for this class.
</dl>
<p>
The following methods are useful for defining new typecode classes;
see the section on dynamic typing for more details. In all of the following,
the <code>ps</code> parameter is a <tt class="class">ParsedSoap</tt> object.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-57' xml:id='l2h-57' class="method">checkname</tt></b>(</nobr></td>
<td><var>elt, ps</var>)</td></tr></table></dt>
<dd>
Checks if the name and type of the element <code>elt</code> are
correct and raises a <tt class="exception">EvaluateException</tt> if not.
Returns the element's type as a "<tt class="samp">(uri, localname)</tt>" tuple if so.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-58' xml:id='l2h-58' class="method">checktype</tt></b>(</nobr></td>
<td><var>elt, ps</var>)</td></tr></table></dt>
<dd>
Like <tt class="method">checkname()</tt> except that the element name is ignored.
This method is actually invoked by <tt class="method">checkname()</tt> to do the
second half of its processing, but is useful to invoke
directly, such as when resolving multi-reference data.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-59' xml:id='l2h-59' class="method">nilled</tt></b>(</nobr></td>
<td><var>elt, ps</var>)</td></tr></table></dt>
<dd>
If the element <code>elt</code> has data, this returns <code>False</code>.
If it has no data, and the typecode is not optional, an
<tt class="exception">EvaluateException</tt> is raised; if it is optional,
a <code>True</code> is returned.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-60' xml:id='l2h-60' class="method">simple_value</tt></b>(</nobr></td>
<td><var>elt, ps, mixed=False</var>)</td></tr></table></dt>
<dd>
Returns the text content of the element <code>elt</code>.
If no value is present, or the element has non-text children, an
<tt class="exception">EvaluateException</tt> is raised. If <code>mixed</code> is <code>False</code> if
child elements are discovered an <tt class="exception">EvaluateException</tt> is raised, else
join all text nodes and return the result.
<p>
</dl>
<p>
<h1><a name="SECTION007200000000000000000">
6.2 <tt class="class">TC.Any</tt> -- the basis of dynamic typing</a>
</h1>
<p>
SOAP provides a flexible set of serialization rules, ranging from
completely self-describing to completely opaque, requiring an external
schema. For example, the following are all possible ways of encoding an
integer element <code>i</code> with a value of <code>12</code>:
<p>
<h2><a name="SECTION007210000000000000000">
6.2.1 simple data</a>
</h2> - requires type information
<div class="verbatim"><pre>
<tns:i xsi:type="SOAP-ENC:integer">12</tns:i>
<tns:i xsi:type="xsd:nonNegativeInteger">12</tns:i>
<SOAP-ENC:integer>12</SOAP-ENC:integer>
<tns:i>12</tns:i>
</pre></div>
<p>
The first three lines are examples of <em>typed</em> elements.
If <tt class="module">ZSI</tt> is asked to parse any of the above examples, and a
<tt class="class">TC.Any</tt> typecode is given, it will properly create a Python
integer for the first three, and raise a <tt class="exception">EvaluateException</tt>
for the fourth.
<p>
<h2><a name="SECTION007220000000000000000">
6.2.2 compound data</a>
</h2> - Struct or Array
Compound data, such as a <code>struct</code>, may also be self-describing (namespace
are omitted for clarity):
<div class="verbatim"><pre>
<tns:foo>
<tns:i xsi:type="SOAP-ENC:integer">12</tns:i>
<tns:name xsi:type="SOAP-ENC:string">Hello world</tns:name>
</tns:foo>
</pre></div>
<p>
If this is parsed with a <tt class="class">TC.Any</tt> typecode, either a Python <code>dict</code>
is created or if <code>aslist</code> is True a <code>list</code>:
<div class="verbatim"><pre>
ps = ParsedSoap(xml, envelope=False)
print ps.Parse(TC.Any())
{ 'name': u'Hello world', 'i': 12 }
print ps.Parse(TC.Any(aslist=True))
[ 12, u'Hello world' ]
</pre></div>
Note that one preserves order, while the other preserves the element names.
<p>
<h2><a name="SECTION007230000000000000000">
6.2.3 class description</a>
</h2>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-61' xml:id='l2h-61' class="class">Any</tt></b>(</nobr></td>
<td><var>name</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Used for parsing incoming SOAP data (that is typed), and serializing
outgoing Python data.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>aslist</code></td>
<td class="center"><code>False</code></td>
<td class="left" >If true, then the data is (recursively)
treated as a list of values.
The default is a Python dictionary, which preserves parameter names but
loses the ordering.
<span class="versionnote">New in version 1.1.</span>
</td></tr></tbody>
</table></div>
<p>
In addition, if the Python object being serialized with an <tt class="class">Any</tt>
has a <code>typecode</code> attribute, then the <tt class="method">serialize</tt> method of
the typecode will be invoked to do the serialization.
This allows objects to override the default dynamic serialization.
</dl>
<p>
Referring back to the compound XML data above, it is possible to create a new
typecode capable of parsing elements of type <code>mytype</code>.
This class would know that the <code>i</code> element is an integer,
so that the explicit typing becomes optional, rather than required.
<p>
<h2><a name="SECTION007240000000000000000">
6.2.4 Adding new types</a>
</h2> Most of the <tt class="class">TypeCodes</tt> classes in
<tt class="module">TC</tt> are registered with <tt class="class">Any</tt>, making an instance of itself
available for dynamic typing. New <tt class="class">TypeCode</tt> classes can be created and
registered with <tt class="class">Any</tt> by using <tt class="function">RegisterType</tt>. In order to
override an existing entry in the registry call <tt class="function">RegisterType</tt> with
<code>clobber=True</code>. The serialization entries are mappings between builtin
Python types and a <tt class="class">TypeCode</tt> instance, it is not possible to have one
Python type map to multiple typecodes. The parsing entries are mappings
between <code>(namespaceURI,name)</code> tuples, representing the <code>xsi:type</code>
attribute, and a <tt class="class">TypeCode</tt> instance. Thus, only one instance of a
<tt class="class">TypeCode</tt> class can represent a XML Schema type. So this mechanism is
not appropriate for representing XML Schema element information.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-62' xml:id='l2h-62' class="class"><em>NEWTYPECODE</em>(TypeCode)</tt></b>(</nobr></td>
<td><var>...</var>)</td></tr></table></dt>
<dd>
The new typecode should be derived from the <tt class="class">TC.TypeCode</tt> class, and
<tt class="method">TypeCode.__init__()</tt> must be invoked in the new class's constructor.
</dl>
<p>
<dl><dt><b><tt id='l2h-63' xml:id='l2h-63' class="member">parselist</tt></b></dt>
<dd>
This is a class attribute, used when parsing incoming SOAP data.
It should be a sequence of "<tt class="samp">(uri, localname)</tt>" tuples to identify
the datatype.
If <code>uri</code> is <code>None</code>, it is taken to mean either the XML Schema
namespace or the SOAP encoding namespace;
this should only be used if adding support for additional primitive types.
If this list is empty, then the type of the incoming SOAP data is assumed
to be correct; an empty list also means that incoming typed data cannot
by dynamically parsed.
</dl>
<p>
<dl><dt><b><tt id='l2h-64' xml:id='l2h-64' class="member">errorlist</tt></b></dt>
<dd>
This is a class attribute, used when reporting a parsing error.
It is a text string naming the datatype that was expected.
If not defined, <tt class="module">ZSI</tt> will create this attribute from the <code>parselist</code>
attribute when it is needed.
</dl>
<p>
<dl><dt><b><tt id='l2h-65' xml:id='l2h-65' class="member">seriallist</tt></b></dt>
<dd>
This is a class attribute, used when serializing Python objects
dynamically.
It specifies what types of object instances (or Python types) this
typecode can serialize.
It should be a sequence, where each element is a Python class object,
a string naming the class, or a type object from Python's <tt class="module">types</tt>
module (if the
new typecode is serializing a built-in Python type).
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-66' xml:id='l2h-66' class="method">parse</tt></b>(</nobr></td>
<td><var>elt, ps</var>)</td></tr></table></dt>
<dd>
<tt class="module">ZSI</tt> invokes this method to
parse the <code>elt</code> element and return its Python value.
The <code>ps</code> parameter is the <tt class="class">ParsedSoap</tt> object, and can be
used for dereferencing <code>href</code>'s, calling <tt class="method">Backtrace()</tt> to
report errors, etc.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-67' xml:id='l2h-67' class="method">serialize</tt></b>(</nobr></td>
<td><var>sw, pyobj</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
<tt class="module">ZSI</tt> invokes this method to output a Python object to a SOAP stream.
The <code>sw</code> parameter will be a <tt class="class">SoapWriter</tt> object, and
the <code>pyobj</code> parameter is the Python object to serialize.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>attrtext</code></td>
<td class="center"><code>None</code></td>
<td class="left" >Text (with leading space)
to output as an attribute; this is normally used by the <tt class="class">TC.Array</tt> class
to pass down indexing information.</td></tr>
<tr><td class="left" valign="baseline"><code>name</code></td>
<td class="center"><code>None</code></td>
<td class="left" >Name to use for serialization; defaults
to the name specified in the typecode, or a generated name.</td></tr>
<tr><td class="left" valign="baseline"><code>typed</code></td>
<td class="center"><em>per-typecode</em></td>
<td class="left" >Whether or not to output type
information; the default is to use the value in the typecode.</td></tr></tbody>
</table></div>
</dl>
<p>
Once the new typecode class has been defined, it should be registered with
<tt class="module">ZSI</tt>'s dynamic type system by invoking the following function:
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-68' xml:id='l2h-68' class="function">RegisterType</tt></b>(</nobr></td>
<td><var>class</var><big>[</big><var>, clobber=0</var><big>[</big><var>, **keywords</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
By default, it is an error to replace an existing type registration, and
an exception will be raised.
The <code>clobber</code> parameter may be given to allow replacement.
A single instance of the <code>class</code> object will be created, and
the <code>keyword</code> parameters are passed to the constructor.
</dl>
<p>
If the class is not registered, then instances of the class cannot be
processed as dynamic types.
This may be acceptable in some environments.
<p>
<h1><a name="SECTION007300000000000000000">
6.3 <tt class="class">TC.SimpleType</tt></a>
</h1>
Parent class of all simple types.
<p>
<dl><dt><b><tt id='l2h-69' xml:id='l2h-69' class="member">empty_content</tt></b></dt>
<dd>
This is a class attribute.
Value returned when tag or node is present, is not nilled, and without text
content.
</dl>
<p>
<h1><a name="SECTION007400000000000000000">
6.4 Strings</a>
</h1>
<p>
SOAP/XMLSchema Strings are Python strings.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-70' xml:id='l2h-70' class="class">String</tt></b>(</nobr></td>
<td><var>name</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
The parent type of all strings.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>resolver</code></td>
<td class="center"><code>None</code></td>
<td class="left" >A function that can resolve an
absolute URI and return its content as a string, as described in the
<tt class="class">ParsedSoap</tt> description.</td></tr>
<tr><td class="left" valign="baseline"><code>strip</code></td>
<td class="center"><code>True</code></td>
<td class="left" >If true, leading and trailing whitespace
are stripped from the content.</td></tr></tbody>
</table></div>
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-71' xml:id='l2h-71' class="class">Enumeration</tt></b>(</nobr></td>
<td><var>value_list, name</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Like <tt class="class">TC.String</tt>, but the value must be a member of
the <code>choices</code> sequence of text strings
</dl>
<p>
In addition to <tt class="class">TC.String</tt>,
the basic string, several subtypes are provided that transparently
handle common encodings.
These classes create a temporary string object and pass that to
the <tt class="method">serialize()</tt> method.
When doing RPC encoding, and checking for non-unique strings, the
<tt class="class">TC.String</tt> class must have the original Python string, as well
as the new output.
This is done by adding a parameter to the <tt class="method">serialize()</tt> method:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>orig</code></td>
<td class="center"><code>None</code></td>
<td class="left" >If deriving a new typecode from the
string class, and the derivation creates a temporary Python string
(such as by <tt class="class">Base64String</tt>), than this parameter is the
original string being serialized.</td></tr></tbody>
</table></div>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-72' xml:id='l2h-72' class="class">Base64String</tt></b>(</nobr></td>
<td><var>name</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
The value is encoded in Base-64.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-73' xml:id='l2h-73' class="class">HexBinaryString</tt></b>(</nobr></td>
<td><var>name</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Each byte is encoded as its printable version.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-74' xml:id='l2h-74' class="class">URI</tt></b>(</nobr></td>
<td><var>name</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
The value is URL quoted (e.g., <code>%20</code> for the space character).
</dl>
<p>
It is often the case that a parameter will be typed as a string for
transport purposes, but will in fact have special syntax and processing
requirements.
For example, a string could be used for an XPath expression, but it is
more convenient for the Python value to
actually be the compiled expression. Here is how to do that:
<p>
<div class="verbatim"><pre>
import xml.xpath.pyxpath
import xml.xpath.pyxpath.Compile as _xpath_compile
class XPathString(TC.String):
def __init__(self, name, **kw):
TC.String.__init__(self, name, **kw)
def parse(self, elt, ps):
val = TC.String.parse(self, elt, ps)
try:
val = _xpath_compile(val)
except:
raise EvaluateException("Invalid XPath expression",
ps.Backtrace(elt))
return val
</pre></div>
<p>
In particular, it is common to send XML as a string, using entity
encoding to protect the ampersand and less-than characters.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-75' xml:id='l2h-75' class="class">XMLString</tt></b>(</nobr></td>
<td><var>name</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Parses the data as a string, but returns an XML DOM object.
For serialization, takes an XML DOM (or element node), and outputs
it as a string.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>readerclass</code></td>
<td class="center"><code>None</code></td>
<td class="left" >Class used to create DOM-creating
XML readers; described in the <tt class="class">ParsedSoap</tt> chapter.</td></tr></tbody>
</table></div>
<p>
</dl>
<p>
<h1><a name="SECTION007500000000000000000">
6.5 Integers</a>
</h1>
<p>
SOAP/XMLSchema integers are Python integers.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-76' xml:id='l2h-76' class="class">Integer</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
The parent type of all integers.
This class handles any of the several types (and ranges) of SOAP integers.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>format</code></td>
<td class="center"><code>%d</code></td>
<td class="left" >Format string for serializing.
<span class="versionnote">New in version 1.2.</span>
</td></tr></tbody>
</table></div>
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-77' xml:id='l2h-77' class="class">IEnumeration</tt></b>(</nobr></td>
<td><var>choices</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Like <tt class="class">TC.Integer</tt>, but the value must be a member of
the <code>choices</code> sequence.
</dl>
<p>
A number of sub-classes are defined to handle smaller-ranged numbers.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-78' xml:id='l2h-78' class="class">Ibyte</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A signed eight-bit value.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-79' xml:id='l2h-79' class="class">IunsignedByte</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
An unsigned eight-bit value.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-80' xml:id='l2h-80' class="class">Ishort</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A signed 16-bit value.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-81' xml:id='l2h-81' class="class">IunsignedShort</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
An unsigned 16-bit value.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-82' xml:id='l2h-82' class="class">Iint</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A signed 32-bit value.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-83' xml:id='l2h-83' class="class">IunsignedInt</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
An unsigned 32-bit value.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-84' xml:id='l2h-84' class="class">Ilong</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
An signed 64-bit value.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-85' xml:id='l2h-85' class="class">IunsignedLong</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
An unsigned 64-bit value.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-86' xml:id='l2h-86' class="class">IpositiveInteger</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A value greater than zero.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-87' xml:id='l2h-87' class="class">InegativeInteger</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A value less than zero.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-88' xml:id='l2h-88' class="class">InonPositiveInteger</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A value less than or equal to zero.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-89' xml:id='l2h-89' class="class">InonNegativeInteger</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A value greater than or equal to zero.
</dl>
<p>
<h1><a name="SECTION007600000000000000000">
6.6 Floating-point Numbers</a>
</h1>
<p>
SOAP/XMLSchema floating point numbers are Python floats.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-90' xml:id='l2h-90' class="class">Decimal</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
The parent type of all floating point numbers.
This class handles any of the several types (and ranges) of SOAP
floating point numbers.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>format</code></td>
<td class="center"><code>%f</code></td>
<td class="left" >Format string for serializing.
<span class="versionnote">New in version 1.2.</span>
</td></tr></tbody>
</table></div>
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-91' xml:id='l2h-91' class="class">FPEnumeration</tt></b>(</nobr></td>
<td><var>value_list, name</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Like <tt class="class">TC.Decimal</tt>, but the value must be a member of
the <code>value_list</code> sequence.
Be careful of round-off errors if using this class.
</dl>
<p>
Two sub-classes are defined to handle smaller-ranged numbers.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-92' xml:id='l2h-92' class="class">FPfloat</tt></b>(</nobr></td>
<td><var>name</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
An IEEE single-precision 32-bit floating point value.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-93' xml:id='l2h-93' class="class">FPdouble</tt></b>(</nobr></td>
<td><var>name</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
An IEEE double-precision 64-bit floating point value.
</dl>
<p>
<h1><a name="SECTION007700000000000000000">
6.7 Dates and Times</a>
</h1>
<p>
SOAP dates and times are Python time tuples in UTC (GMT), as documented
in the Python <tt class="module">time</tt> module.
Time is tricky, and processing anything other than a simple absolute time
can be difficult.
(Even then, timezones lie in wait to trip up the unwary.)
A few caveats are in order:
<p>
<ol>
<li>Some date and time formats will be parsed into tuples that are
not valid time values.
For example, 75 minutes is a valid duration, although not a legal value
for the minutes element of a time tuple.
<p>
</li>
<li>Fractional parts of a second may be lost when parsing, and may have
extra trailing zero's when serializing.
<p>
</li>
<li>Badly-formed time tuples may result in non-sensical values being serialized;
the first six values are taken directly as year, month, day, hour, minute,
second in UTC.
<p>
</li>
<li>Although the classes <tt class="class">Duration</tt> and <tt class="class">Gregorian</tt> are defined, they
are for internal use only and should not be included in any <tt class="class">TypeCode</tt>
you define. Instead, use the classes beginning with a lower case g in your
typecodes.
<p>
</li>
</ol>
<p>
In addition, badly-formed values may result in non-sensical serializations.
<p>
When serializing, an integral or floating point number is taken as
the number of seconds since the epoch, in UTC.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-94' xml:id='l2h-94' class="class">Duration</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A relative time period.
Negative durations have all values less than zero; this makes
it easy to add a duration to a Python time tuple.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-95' xml:id='l2h-95' class="class">Gregorian</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
An absolute time period.
This class should not be instantiated directly; use one of the <code>gXXX</code>
classes instead.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-96' xml:id='l2h-96' class="class">gDateTime</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A date and time.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-97' xml:id='l2h-97' class="class">gDate</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A date.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-98' xml:id='l2h-98' class="class">gYearMonth</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A year and month.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-99' xml:id='l2h-99' class="class">gYear</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A year.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-100' xml:id='l2h-100' class="class">gMonthDay</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A month and day.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-101' xml:id='l2h-101' class="class">gDay</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A day.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-102' xml:id='l2h-102' class="class">gTime</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
A time.
</dl>
<p>
<h1><a name="SECTION007800000000000000000">
6.8 Boolean</a>
</h1>
<p>
SOAP Booleans are Python integers.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-103' xml:id='l2h-103' class="class">Boolean</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
When marshaling zero or the word ``false'' is returned as <code>0</code>
and any non-zero value or the word ``true'' is returned as <code>1</code>.
When serializing, the number <code>0</code> or <code>1</code> will be generated.
</dl>
<p>
<h1><a name="SECTION007900000000000000000">
6.9 XML</a>
</h1>
<p>
XML is a Python DOM element node.
If the value to be serialized is a Python string, then an <code>href</code>
is generated, with the value used as the URI.
This can be used, for example, when generating SOAP with attachments.
Otherwise, the XML is typically put inside a wrapper element that sets
the proper SOAP encoding style.
<p>
For efficiency, incoming XML is returend as a ``pointer'' into the
DOM tree maintained within the <tt class="class">ParsedSoap</tt> object.
If that object is going to go out of scope, the data will be destroyed
and any XML objects will become empty elements.
The class instance variable <code>copyit</code>, if non-zero indicates that a
deep copy of the XML subtree will be made and returned as the value.
Note that it is generally more efficient to keep the <tt class="class">ParsedSoap</tt>
object alive until the XML data is no longerneeded.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-104' xml:id='l2h-104' class="class">XML</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This typecode represents a portion of an XML document embedded in a SOAP
message.
The value is the element node.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>copyit</code></td>
<td class="center">TC.XML.copyit</td>
<td class="left" >Return a copy of the parsed data.</td></tr>
<tr><td class="left" valign="baseline"><code>comments</code></td>
<td class="center"><code>0</code></td>
<td class="left" >Preserve comments in output.</td></tr>
<tr><td class="left" valign="baseline"><code>inline</code></td>
<td class="center"><code>0</code></td>
<td class="left" >The XML sub-tree is single-reference,
so can be output in-place.</td></tr>
<tr><td class="left" valign="baseline"><code>resolver</code></td>
<td class="center"><code>None</code></td>
<td class="left" >A function that can resolve an
absolute URI and return its content as an element node, as described in the
<tt class="class">ParsedSoap</tt> description.</td></tr>
<tr><td class="left" valign="baseline"><code>wrapped</code></td>
<td class="center"><code>1</code></td>
<td class="left" >If zero, the XML is output directly,
and not within a SOAP wrapper element.
<span class="versionnote">New in version 1.2.</span>
</td></tr></tbody>
</table></div>
</dl>
<p>
When serializing, it may be necessary to specify which namespace prefixes
are ``active'' in the XML.
This is done by using the <code>unsuppressedPrefixes</code> parameter when
calling the <tt class="method">serialize()</tt> method.
(This will only work when XML is the top-level item being serialized,
such as when using typecodes and document-style interfaces.)
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>unsuppressedPrefixes</code></td>
<td class="center">[]</td>
<td class="left" >An array of strings
identifying the namespace prefixes that should be output.</td></tr></tbody>
</table></div>
<p>
<h1><a name="SECTION0071000000000000000000">
6.10 ComplexType</a>
</h1>
<p>
Represents the XMLSchema ComplexType .
<span class="versionnote">New in version 2.0.</span>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-105' xml:id='l2h-105' class="class">ComplexType</tt></b>(</nobr></td>
<td><var>pyclass, ofwhat</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This class defines a compound data structure.
If <code>pyclass</code> is <code>None</code>, then the data will be marshaled
into a Python dictionary, and each item in the <code>ofwhat</code> sequence
specifies a (possible) dictionary entry.
Otherwise, <code>pyclass</code> must be a Python class object.
The data is then marshaled into the object, and each item in the
<code>ofwhat</code>
sequence specifies an attribute of the instance to set.
<p>
Note that each typecode in <code>ofwhat</code> must have a name.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>inorder</code></td>
<td class="center"><code>False</code></td>
<td class="left" >Items within the structure must appear
in the order specified in the <code>ofwhat</code> sequence.</td></tr>
<tr><td class="left" valign="baseline"><code>inline</code></td>
<td class="center"><code>False</code></td>
<td class="left" >The structure is single-reference,
so ZSI does not have to use <code>href/id</code> encodings.</td></tr>
<tr><td class="left" valign="baseline"><code>mutable</code></td>
<td class="center"><code>False</code></td>
<td class="left" >If an object is going to be serialized
multiple times, and its state may be modified between serializations,
then this keyword should be used, otherwise a single instance will be
serialized, with multiple references to it.
This argument implies the <code>inline</code> argument.
<span class="versionnote">New in version 1.2.</span>
</td></tr>
<tr><td class="left" valign="baseline"><code>type</code></td>
<td class="center"><code>None</code></td>
<td class="left" >A "<tt class="samp">(uri, localname)</tt>" tuple that
defines the type of the structure.
If present, and if the input data has a <code>xsi:type</code> attribute, then the
namespace-qualified value of that attribute must match the value
specified by this parameter.
By default, type-checking is not done for structures; matching child element
names is usually sufficient and senders rarely provide type information.</td></tr>
<tr><td class="left" valign="baseline"><code>mixed</code></td>
<td class="center"><code>False</code></td>
<td class="left" >using a mixed content model, allow text and
element content.</td></tr>
<tr><td class="left" valign="baseline"><code>mixed_aname</code></td>
<td class="center"><code>'_text'</code></td>
<td class="left" >if mixed is True, text
content is set in this attribute (key).</td></tr></tbody>
</table></div>
<p>
If the <code>typed</code> keyword is used, then its value is assigned to
all typecodes in the <code>ofwhat</code> parameter.
If any of the typecodes in <code>ofwhat</code> are repeatable, then the
<code>inorder</code> keyword should not be used and the <code>hasextras</code> parameter
<em>must</em> be used.
<p>
For example, the following C structure:
<div class="verbatim"><pre>
struct foo {
int i;
char* text;
};
</pre></div>
could be declared as follows:
<div class="verbatim"><pre>
class foo:
def __init__(self, name):
self.name = name
def __str__(self):
return str((self.name, self.i, self.text))
foo.typecode = TC.Struct(foo,
( TC.Integer('i'), TC.String('text') ),
'foo')
</pre></div>
</dl>
<p>
<h1><a name="SECTION0071100000000000000000">
6.11 Struct</a>
</h1>
<p>
SOAP Struct is a complex type for accessors identified by name. No element may
have the same name as any other, nor may any element have a maxOccurs > 1.
SOAP Structs are either Python dictionaries or instances of application-specified classes.
<p>
<h1><a name="SECTION0071200000000000000000">
6.12 Arrays</a>
</h1>
<p>
SOAP arrays are Python lists; multi-dimensional arrays are
lists of lists and are indistinguishable from a SOAP array of arrays.
Arrays may be <em>sparse</em>, in which case each element in the
array is a tuple of "<tt class="samp">(subscript, data)</tt>" pairs.
If an array is not sparse, a specified <em>fill</em> element will be
used for the missing values.
<p>
<strong>Currently only singly-dimensioned arrays are supported.</strong>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-106' xml:id='l2h-106' class="class">Array</tt></b>(</nobr></td>
<td><var>atype, ofwhat</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
The <code>atype</code> parameter is a <code>(URI,NCName)</code> tuple representing the SOAP
array type. The <code>ofwhat</code> parameter is a typecode describing the array elements.
</dl>
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>childnames</code></td>
<td class="center"><code>None</code></td>
<td class="left" >Default name to use for the child
elements.</td></tr>
<tr><td class="left" valign="baseline"><code>dimensions</code></td>
<td class="center"><code>1</code></td>
<td class="left" >The number of dimensions in
the array.</td></tr>
<tr><td class="left" valign="baseline"><code>fill</code></td>
<td class="center"><code>None</code></td>
<td class="left" >The value to use when an array
element is omitted.</td></tr>
<tr><td class="left" valign="baseline"><code>mutable</code></td>
<td class="center"><code>False</code></td>
<td class="left" >If an object is going to be serialized
multiple times, and its state may be modified between serializations,
then this keyword should be used, otherwise a single instance will be
serialized, with multiple references to it.</td></tr>
<tr><td class="left" valign="baseline"><code>nooffset</code></td>
<td class="center"><code>0</code></td>
<td class="left" >Do not use the SOAP <code>offset</code>
attribute so skip leading elements with the same value as <code>fill</code>.</td></tr>
<tr><td class="left" valign="baseline"><code>sparse</code></td>
<td class="center"><code>False</code></td>
<td class="left" >The array is sparse.</td></tr>
<tr><td class="left" valign="baseline"><code>size</code></td>
<td class="center"><code>None</code></td>
<td class="left" >An integer or list of integers that
specifies the maximum array dimensions.</td></tr>
<tr><td class="left" valign="baseline"><code>undeclared</code></td>
<td class="center"><code>False</code></td>
<td class="left" >The SOAP "<tt class="samp">arrayType</tt>" attribute
need not appear.</td></tr></tbody>
</table></div>
<p>
<h1><a name="SECTION0071300000000000000000">
6.13 Apache Datatype</a>
</h1>
<p>
The Apache SOAP project, urlhttp://xml.apache.org/soap/index.html,
has defined a popular SOAP datatype in the
<code>http://xml.apache.org/xml-soap</code> namespace, a
<tt class="class">Map</tt>.
<p>
The <code>Map</code> type is encoded as a list of <code>item</code> elements.
Each <code>item</code> has a <code>key</code> and <code>value</code> child element; these
children must have SOAP type information.
An Apache Map is either a Python dictionary or a list of two-element
tuples.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-107' xml:id='l2h-107' class="class">Apache.Map</tt></b>(</nobr></td>
<td><var>name</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
An Apache map.
Note that the class name is dotted.
</dl>
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>aslist</code></td>
<td class="center"><code>0</code></td>
<td class="left" >Use a list of tuples rather than
a dictionary.</td></tr></tbody>
</table></div>
<h1><a name="SECTION008000000000000000000">
7. The <tt class="module">SoapWriter</tt> module -- serializing data</a>
</h1>
<p>
The SoapWriter class is used to output SOAP messages.
Note that its output is encoded as UTF-8; when transporting SOAP over
HTTP it is therefore important to set the <code>charset</code> attribute
of the <code>Content-Type</code> header.
<p>
The <tt class="class">SoapWriter</tt> class reserves some namespace prefixes:
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Prefix</th>
<th class="left" >URI</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>SOAP-ENV</code></td>
<td class="left" ><code>http://schemas.xmlsoap.org/soap/envelope/</code></td></tr>
<tr><td class="left" valign="baseline"><code>SOAP-ENC</code></td>
<td class="left" ><code>http://schemas.xmlsoap.org/soap/encoding/</code></td></tr>
<tr><td class="left" valign="baseline"><code>ZSI</code></td>
<td class="left" ><code>http://www.zolera.com/schemas/ZSI/</code></td></tr>
<tr><td class="left" valign="baseline"><code>xsd</code></td>
<td class="left" ><code>http://www.w3.org/2001/XMLSchema</code></td></tr>
<tr><td class="left" valign="baseline"><code>xsi</code></td>
<td class="left" ><code>http://www.w3.org/2001/XMLSchema-instance</code></td></tr></tbody>
</table></div>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-108' xml:id='l2h-108' class="class">SoapWriter</tt></b>(</nobr></td>
<td><var>optional**keywords</var>)</td></tr></table></dt>
<dd>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>encodingStyle</code></td>
<td class="center">None</td>
<td class="left" >If not <code>None</code>, then
use the specified value as the value for the SOAP <code>encodingStyle</code>
attribute.
<span class="versionnote">New in version 1.2.</span>
</td></tr>
<tr><td class="left" valign="baseline"><code>envelope</code></td>
<td class="center"><code>True</code></td>
<td class="left" >Create a SOAP Envelope
<span class="versionnote">New in version 1.2.</span>
</td></tr>
<tr><td class="left" valign="baseline"><code>nsdict</code></td>
<td class="center"><code>{}</code></td>
<td class="left" >Dictionary of namespaces to declare
in the SOAP <code>Envelope</code></td></tr>
<tr><td class="left" valign="baseline"><code>header</code></td>
<td class="center"><code>True</code></td>
<td class="left" >create a SOAP <code>Header</code> element</td></tr>
<tr><td class="left" valign="baseline"><code>outputclass</code></td>
<td class="center"><code>ElementProxy</code></td>
<td class="left" >wrapper around DOM or other
XML library.</td></tr></tbody>
</table></div>
</dl>
<p>
Creating a <tt class="class">SoapWriter</tt> object with <code>envelope</code> set to <code>False</code>
results in an object that can be used for serializing objects into a string.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-109' xml:id='l2h-109' class="method">serialize</tt></b>(</nobr></td>
<td><var>pyobj</var><big>[</big><var>, typecode=None</var><big>[</big><var>,
root=None</var><big>[</big><var>, header_pyobjs=None</var><big>[</big><var>, **keywords</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This method serializes the <code>pyobj</code> Python object as directed
by the <code>typecode</code> typecode object.
If <code>typecode</code> is omitted, then <code>pyobj</code> should be a Python
object instance of a class that has a <code>typecode</code> attribute.
It returns <code>self</code>, so that serializations can be chained together, or
so that the <tt class="method">close()</tt> method can be invoked.
The <code>root</code> parameter may be used to explicitly indicate the root
(main element) of a SOAP encoding, or indicate that the item is not the
root.
If specified, it should have the numeric value of zero or one.
Any other keyword parameters are passed to the typecode's <code>serialize</code>
method.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-110' xml:id='l2h-110' class="method">close</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Invokes all the callbacks, if any. The <tt class="function">close</tt> operations can only
happen once, if invoked a second time it will just return. This method will be
invoked automatically if the object is deleted.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-111' xml:id='l2h-111' class="method">__str__</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Invokes the <tt class="function">close</tt> method, and returns a string representation of the
serialized object. Assumes that <tt class="function">serialize</tt> has been invoked.
</dl>
<p>
The following methods are primarily useful for those writing new typecodes.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-112' xml:id='l2h-112' class="method">AddCallback</tt></b>(</nobr></td>
<td><var>func, arg</var>)</td></tr></table></dt>
<dd>
Used by typecodes when serializing, allows them to add output after
the SOAP <code>Body</code> is written but before the SOAP <code>Envelope</code> is closed.
The function <tt class="method">func()</tt>
will be called with the <tt class="class">SoapWriter</tt> object and the specified <code>arg</code>
argument, which may be a tuple.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-113' xml:id='l2h-113' class="method">Forget</tt></b>(</nobr></td>
<td><var>obj</var>)</td></tr></table></dt>
<dd>
Forget that <code>obj</code> has been seen before.
This is useful when repeatedly serializing a mutable object.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-114' xml:id='l2h-114' class="method">Known</tt></b>(</nobr></td>
<td><var>obj</var>)</td></tr></table></dt>
<dd>
If <code>obj</code> has been seen before (based on its Python <code>id</code>), return
<code>1</code>. Otherwise, remember <code>obj</code> and return <code>0</code>.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-115' xml:id='l2h-115' class="method">ReservedNS</tt></b>(</nobr></td>
<td><var>prefix, uri</var>)</td></tr></table></dt>
<dd>
Returns true if the specified namespace <code>prefix</code> and <code>uri</code> collide
with those used by the implementation.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-116' xml:id='l2h-116' class="method">writeNSDict</tt></b>(</nobr></td>
<td><var>nsdict</var>)</td></tr></table></dt>
<dd>
Outputs <code>nsdict</code> as a namespace dictionary.
It is assumed that an XML start-element is pending on the output
stream.
</dl>
<h1><a name="SECTION009000000000000000000">
8. The <tt class="module">Fault</tt> module -- reporting errors</a>
</h1>
<p>
SOAP defines a <em>fault</em> message as the way for a recipient to
indicate it was unable to process a message.
The <tt class="module">ZSI</tt> <tt class="class">Fault</tt> class encapsulates this.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-117' xml:id='l2h-117' class="class">Fault</tt></b>(</nobr></td>
<td><var>code, string</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
The <var>code</var> parameter is a text string identifying the SOAP fault
code, a namespace-qualified name.
The class attribute <code>Fault.Client</code> can be used to indicate a problem with
an incoming message, <code>Fault.Server</code> can be used to
indicate a problem occurred while processing the request, or <code>Fault.MU</code>
can be used to indicate a problem with the SOAP <code>mustUnderstand</code>
attribute.
The <var>string</var> parameter is a human-readable text string describing the
fault.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><var>actor</var></td>
<td class="center"><code>None</code></td>
<td class="left" >A string identifying the <code>actor</code>
attribute that caused the problem (usually because it is unknown).</td></tr>
<tr><td class="left" valign="baseline"><var>detail</var></td>
<td class="center"><code>None</code></td>
<td class="left" >A sequence
of elements to output in the <code>detail</code> element; it may also
be a text string, in which case it is output as-is, and should
therefore be XML text.</td></tr>
<tr><td class="left" valign="baseline"><var>headerdetail</var></td>
<td class="center"><code>None</code></td>
<td class="left" >Data, treated the same as
the <code>detail</code> keyword, to be output in the SOAP header. See
the following paragraph.</td></tr></tbody>
</table></div>
<p>
If the fault occurred in the SOAP <code>Header</code>, the specification
requires that the detail be sent back as an element within
the SOAP <code>Header</code> element.
Unfortunately, the SOAP specification does not describe how to encode
this; <tt class="module">ZSI</tt> defines and uses a
<code>ZSI:detail</code> element, which is analogous to the SOAP <code>detail</code>
element.
</dl>
<p>
The following attributes are read-only:
<p>
<dl><dt><b><tt id='l2h-118' xml:id='l2h-118' class="member">actor</tt></b></dt>
<dd>
A text string holding the value of the SOAP <code>faultactor</code> element.
</dl>
<p>
<dl><dt><b><tt id='l2h-119' xml:id='l2h-119' class="member">code</tt></b></dt>
<dd>
A text string holding the value of the SOAP <code>faultcode</code> element.
</dl>
<p>
<dl><dt><b><tt id='l2h-120' xml:id='l2h-120' class="member">detail</tt></b></dt>
<dd>
A text string or sequence of elements containing holding the value of the
SOAP <code>detail</code> element, when available.
</dl>
<p>
<dl><dt><b><tt id='l2h-121' xml:id='l2h-121' class="member">headerdetail</tt></b></dt>
<dd>
A text string or sequence of elements containing holding the value of the
<tt class="module">ZSI</tt> header detail element, when available.
</dl>
<p>
<dl><dt><b><tt id='l2h-122' xml:id='l2h-122' class="member">string</tt></b></dt>
<dd>
A text string holding the value of the SOAP <code>faultstring</code> element.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-123' xml:id='l2h-123' class="method">AsSOAP</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>, **kw</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This method serializes the <tt class="class">Fault</tt> object into a SOAP message.
The message is returned as a string.
Any keyword arguments are passed to the <tt class="class">SoapWriter</tt> constructor.
<span class="versionnote">New in version 1.1; the old <tt class="method">AsSoap()</tt> method is still available.</span>
</dl>
<p>
If other data is going to be sent with the fault, the following
two methods can be used.
Because some data might need to be output in the SOAP <code>Header</code>,
serializing a fault is a two-step process.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-124' xml:id='l2h-124' class="method">DataForSOAPHeader</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
This method returns a text string that can be included as the
<code>header</code> parameter for constructing a <tt class="class">SoapWriter</tt> object.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-125' xml:id='l2h-125' class="method">serialize</tt></b>(</nobr></td>
<td><var>sw</var>)</td></tr></table></dt>
<dd>
This method outputs the fault object onto the <var>sw</var> object, which is a
<tt class="class">SoapWriter</tt> instance.
</dl>
<p>
Some convenience functions are available to create a <tt class="class">Fault</tt>
from common conditions.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-126' xml:id='l2h-126' class="function">FaultFromActor</tt></b>(</nobr></td>
<td><var>uri</var><big>[</big><var>, actor</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This function could be used when an application receives a message
that has a SOAP <code>Header</code> element directed to an actor that
cannot be processed.
The <var>uri</var> parameter identifies the actor.
The <var>actor</var> parameter can be used to specify a URI that identifies the
application, if it is not the ultimate recipient of the SOAP message.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-127' xml:id='l2h-127' class="function">FaultFromException</tt></b>(</nobr></td>
<td><var>ex, inheader</var><big>[</big><var>,
tb</var><big>[</big><var>, actor</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This function creates a <tt class="class">Fault</tt> from a general Python exception.
A SOAP ``server'' fault is created.
The <var>ex</var> parameter should be the Python exception.
The <var>inheader</var> parameter should be true if the error was
found on a SOAP <code>Header</code> element.
The optional <var>tb</var> parameter may be a Python traceback
object, as returned by "<tt class="samp">sys.exc_info()[2]</tt>".
The <var>actor</var> parameter can be used to specify a URI that identifies the
application, if it is not the ultimate recipient of the SOAP message.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-128' xml:id='l2h-128' class="function">FaultFromFaultMessage</tt></b>(</nobr></td>
<td><var>ps</var>)</td></tr></table></dt>
<dd>
This function creates a <tt class="class">Fault</tt> from a <tt class="class">ParsedSoap</tt> object
passed in as <var>ps</var>.
It should only be used if the <tt class="method">IsAFault()</tt> method returned true.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-129' xml:id='l2h-129' class="function">FaultFromNotUnderstood</tt></b>(</nobr></td>
<td><var>uri, localname,</var><big>[</big><var>, actor</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This function could be used when an application receives a message with
the SOAP <code>mustUnderstand</code> attribute that it does not understand.
The <var>uri</var> and <var>localname</var> parameters should identify
the unknown element.
The <var>actor</var> parameter can be used to specify a URI that identifies the
application, if it is not the ultimate recipient of the SOAP message.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-130' xml:id='l2h-130' class="function">FaultFromZSIException</tt></b>(</nobr></td>
<td><var>ex</var><big>[</big><var>, actor</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This function creates a <tt class="class">Fault</tt> object from a <tt class="module">ZSI</tt> exception,
<tt class="exception">ParseException</tt> or <tt class="exception">EvaluateException</tt>, passed in
as <var>ex</var>.
A SOAP ``client'' fault is created.
The <var>actor</var> parameter can be used to specify a URI that identifies the
application, if it is not the ultimate recipient of the SOAP message.
</dl>
<h1><a name="SECTION0010000000000000000000">
9. The <tt class="module">resolvers</tt> module -- fetching remote data</a>
</h1>
<p>
The <tt class="module">resolvers</tt> module provides some functions and classes
that can be used as the <code>resolver</code> attribute for <tt class="class">TC.String</tt>
or <tt class="class">TC.XML</tt> typecodes.
They process an absolute URL, as described above, and return the
content.
Because the <tt class="module">resolvers</tt> module can import a number of other
large modules, it must be imported directly, as in
"<tt class="samp">from ZSI import resolvers</tt>".
<p>
These first two functions pass the URI directly to the <tt class="method">urlopen</tt>
function in the <tt class="module">urllib</tt> module.
Therefore, if used directly as resolvers, a client could direct the
SOAP application to fetch any file on the network or local disk.
Needless to say, this could pose a security risks.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-131' xml:id='l2h-131' class="function">Opaque</tt></b>(</nobr></td>
<td><var>uri, tc, ps</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This function returns the data contained at the specified <code>uri</code>
as a Python string.
Base-64 decoding will be done if necessary.
The <code>tc</code> and <code>ps</code> parameters are ignored; the <code>keywords</code>
are passed to the <tt class="method">urlopen</tt> method.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-132' xml:id='l2h-132' class="function">XML</tt></b>(</nobr></td>
<td><var>uri, tc, ps</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This function returns a list of the child element nodes of the XML
document at the specified <code>uri</code>.
The <code>tc</code> and <code>ps</code> parameters are ignored; the <code>keywords</code>
are passed to the <tt class="method">urlopen</tt> method.
</dl>
<p>
The <tt class="class">NetworkResolver</tt> class provides a simple-minded way to limit
the URI's that will be resolved.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-133' xml:id='l2h-133' class="class">NetworkResolver</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>prefixes=None</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
The <code>prefixes</code> parameter is a list of strings defining the allowed
prefixes of any URI's.
If asked to fetch the content for a URI that does start with one of
the prefixes, it will raise an exception.
<p>
In addition to <code>Opaque</code> and <code>XML</code> methods, this class
provides a <code>Resolve</code> method that examines the typecode to determine
what type of data is desired.
</dl>
<p>
If the SOAP application is given a multi-part MIME document, the
<tt class="class">MIMEResolver</tt> class can be used to process SOAP with Attachments.
<p>
The <tt class="class">MIMEResolver</tt> class will read the entire multipart MIME document,
noting any <code>Content-ID</code> or <code>Content-Location</code> headers that appear
on the headers of any of the message parts, and use them to resolve
any <code>href</code> attributes that appear in the SOAP message.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-134' xml:id='l2h-134' class="class">MIMEResolver</tt></b>(</nobr></td>
<td><var>ct, f</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
The <code>ct</code> parameter is a string that contains the value of the
MIME <code>Content-Type</code> header.
The <code>f</code> parameter is the input stream, which should be positioned just
after the message headers.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>seekable</code></td>
<td class="center"><code>0</code></td>
<td class="left" >Whether or not the input stream is
seekable; passed to the constructor for the internal <tt class="class">multifile</tt>
object.
<span class="versionnote">Changed in version 2.0:
default had been 1.</span>
</td></tr>
<tr><td class="left" valign="baseline"><code>next</code></td>
<td class="center"><code>None</code></td>
<td class="left" >A resolver object that will be
asked to resolve the URI if it is not found in the MIME document.
<span class="versionnote">New in version 1.1.</span>
</td></tr>
<tr><td class="left" valign="baseline"><code>uribase</code></td>
<td class="center"><code>None</code></td>
<td class="left" >The base URI to be used when
resolving relative URI's; this will typically be the value of the
<code>Content-Location</code> header, if present.
<span class="versionnote">New in version 1.1.</span>
</td></tr></tbody>
</table></div>
</dl>
<p>
In addition to to the <code>Opaque</code>, <code>Resolve</code>, and <code>XML</code> methods
as described above, the following method is available:
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-135' xml:id='l2h-135' class="method">GetSOAPPart</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
This method returns a stream containing the SOAP message text.
</dl>
<p>
The following attributes are read-only:
<p>
<dl><dt><b><tt id='l2h-136' xml:id='l2h-136' class="member">parts</tt></b></dt>
<dd>
An array of tuples, one for each MIME bodypart found.
Each tuple has two elements, a <tt class="class">mimetools.Message</tt> object
which contains the headers for the bodypart, and a
<tt class="class">StringIO</tt> object containing the data.
</dl>
<p>
<dl><dt><b><tt id='l2h-137' xml:id='l2h-137' class="member">id_dict</tt></b></dt>
<dd>
A dictionary whose keys are the values of any <code>Content-ID</code>
headers, and whose value is the appropriate <code>parts</code> tuple.
</dl>
<p>
<dl><dt><b><tt id='l2h-138' xml:id='l2h-138' class="member">loc_dict</tt></b></dt>
<dd>
A dictionary whose keys are the values of any <code>Content-Location</code>
headers, and whose value is the appropriate <code>parts</code> tuple.
</dl>
<h1><a name="SECTION0011000000000000000000">
10. Dispatching and Invoking</a>
</h1>
<p>
<span class="versionnote">New in version 1.1.</span>
<p>
<tt class="module">ZSI</tt> is focused on parsing and generating SOAP messages, and provides
limited facilities for dispatching to the appropriate message handler.
This is because <tt class="module">ZSI</tt> works within many client and server environments,
and the dispatching styles for these different environments can be
very different.
<p>
Nevertheless, <tt class="module">ZSI</tt> includes some dispatch and invocation functions.
To use them, they must be explicitly imported, as shown in the example
at the start of this document.
<p>
The implementation (and names) of the these classes reflects the orientation
of using SOAP for remote procedure calls (RPC).
<p>
Both client and server share a class that defines the mechanism a
client uses to authenticate itself.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-139' xml:id='l2h-139' class="class">AUTH</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
This class defines constants used to identify how the client
authenticated: <code>none</code> if no authentication was provided;
<code>httpbasic</code> if HTTP basic authentication was used, or
<code>zsibasic</code> if <tt class="module">ZSI</tt> basic authentication (see below)) was used.
</dl>
<p>
The <tt class="module">ZSI</tt> schema (see the last chapter of this manual)
defines a SOAP header element, <code>BasicAuth</code>, that
contains a name and password.
This is similar to the HTTP basic authentication header, except
that it can be used independently from an HTTP transport.
<p>
<h1><a name="SECTION0011100000000000000000">
10.1 Dispatching</a>
</h1>
<p>
The <tt class="module">ZSI.dispatch</tt> module allows you to expose Python functions as a web
service. The module provides the infrastructure to parse the request, dispatch
to the appropriate handler, and then serialize any return value back to the
client. The value returned by the function will be serialized back to the
client. If an exception occurs, a SOAP fault will be sent back to the client.
<p>
<h2><a name="SECTION0011110000000000000000">
10.1.1 Dispatch Behaviors</a>
</h2> By default the callback is invoked with the
pyobj representation of the body root element, and it is expected to return a
self-describing request (w/typecode). Parsing is done via a typecode from
typesmodule, or Any. Other keyword options are available in dispatch mechanisms
(see below) that result in different behavior.
<p>
<h3><a name="SECTION0011111000000000000000">
10.1.1.1 rpc</a>
</h3> An rpc service will ignore the body root (RPC Wrapper) of
the request, and parse all "parts" of message via individual typecodes. The
callback function is expected to return the parts of the message in a dict or a
list. The dispatch mechanism will try to serialize it as a Struct but if this
is not possible it will be serialized as an Array. Parsing done via a typecode
from typesmodule, or Any. Not compatible with <var>docstyle</var>.
<p>
<h3><a name="SECTION0011112000000000000000">
10.1.1.2 docstyle</a>
</h3> Callback is invoked with a ParsedSoap instance
representing the request, and the return value is serialized with an XML
typecode (DOM). The result in wrapped as an rpc-style message, with
<em>Response</em> appended to the request wrapper. Not compatible with <var>rpc</var>.
<p>
<h2><a name="SECTION0011120000000000000000">
10.1.2 Special Modules</a>
</h2> These are keyword options available to all
dispatch mechansism (see below).
<p>
<h3><a name="SECTION0011121000000000000000">
10.1.2.1 modules</a>
</h3>Dispatch is based solely on the name of the root element in the
incoming SOAP request; the request URL is ignored. These modules will be search
for a matching function. If no modules are specified, only the
<tt class="module">__main__</tt> module will be searched.
<p>
<h3><a name="SECTION0011122000000000000000">
10.1.2.2 typesmodule</a>
</h3>Used for parsing. This module should contain class
definitions with the <code>typecode</code> attribute set to a <tt class="class">TypeCode</tt>
instance. By default, a class definition matching the root element name will be
retrieved or the Any typecode will be used. If using <em>rpc</em>, each child of
the root element will be used to retrieve a class definition of the same name.
<p>
<h2><a name="SECTION0011130000000000000000">
10.1.3 Dispatch Mechanisms</a>
</h2>
Three dispatch mechanisms are provided: one supports standard CGI
scripts, one runs a dedicated server based on the
<tt class="module">BaseHTTPServer</tt> module, and the third uses the JonPY package,
<a class="url" href="http://jonpy.sourceforge.net">http://jonpy.sourceforge.net</a>, to support FastCGI.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-140' xml:id='l2h-140' class="method">AsServer</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This creates a <tt class="class">HTTPServer</tt> object with a request handler that only
supports the ``POST'' method.
Dispatch is based solely on the name of the root element in the
incoming SOAP request;
the request URL is ignored.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>port</code></td>
<td class="center"><code>80</code></td>
<td class="left" >Port to listen on.</td></tr>
<tr><td class="left" valign="baseline"><code>addr</code></td>
<td class="center"><code>''</code></td>
<td class="left" >Address to listen on.</td></tr>
<tr><td class="left" valign="baseline"><code>docstyle</code></td>
<td class="center"><code>False</code></td>
<td class="left" >Exhibit the <em>docstyle</em> behavior.</td></tr>
<tr><td class="left" valign="baseline"><code>rpc</code></td>
<td class="center"><code>False</code></td>
<td class="left" >Exhibit the <em>rpc</em> behavior.</td></tr>
<tr><td class="left" valign="baseline"><code>modules</code></td>
<td class="center"><code>(__main__,)</code></td>
<td class="left" >List of modules containing
functions that can be invoked.</td></tr>
<tr><td class="left" valign="baseline"><code>typesmodule</code></td>
<td class="center"><code>(__main__,)</code></td>
<td class="left" >This module is used for
parsing, it contains class definitions that specify the <code>typecode</code>
attribute.</td></tr>
<tr><td class="left" valign="baseline"><code>nsdict</code></td>
<td class="center"><code>{}</code></td>
<td class="left" >Namespace dictionary to send in the SOAP
<code>Envelope</code></td></tr></tbody>
</table></div>
<p>
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-141' xml:id='l2h-141' class="method">AsCGI</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This method parses the CGI input and invokes a function that has the
same name as the top-level SOAP request element.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>rpc</code></td>
<td class="center"><code>False</code></td>
<td class="left" >Exhibit the <em>rpc</em> behavior.</td></tr>
<tr><td class="left" valign="baseline"><code>modules</code></td>
<td class="center"><code>(__main__,)</code></td>
<td class="left" >List of modules containing
functions that can be invoked.</td></tr>
<tr><td class="left" valign="baseline"><code>typesmodule</code></td>
<td class="center"><code>(__main__,)</code></td>
<td class="left" >This module is used for
parsing, it contains class definitions that specify the <code>typecode</code>
attribute.</td></tr>
<tr><td class="left" valign="baseline"><code>nsdict</code></td>
<td class="center"><code>{}</code></td>
<td class="left" >Namespace dictionary to send in the SOAP
<code>Envelope</code></td></tr></tbody>
</table></div>
<p>
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-142' xml:id='l2h-142' class="method">AsHandler</tt></b>(</nobr></td>
<td><var>request=None</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
<p>
This method is used within a JonPY handler to do dispatch.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>request</code></td>
<td class="center"><code>None</code></td>
<td class="left" >modpython HTTPRequest instance.</td></tr>
<tr><td class="left" valign="baseline"><code>modules</code></td>
<td class="center"><code>(__main__,)</code></td>
<td class="left" >List of modules containing
functions that can be invoked.</td></tr>
<tr><td class="left" valign="baseline"><code>docstyle</code></td>
<td class="center"><code>False</code></td>
<td class="left" >Exhibit the <em>docstyle</em> behavior.</td></tr>
<tr><td class="left" valign="baseline"><code>rpc</code></td>
<td class="center"><code>False</code></td>
<td class="left" >Exhibit the <em>rpc</em> behavior.</td></tr>
<tr><td class="left" valign="baseline"><code>typesmodule</code></td>
<td class="center"><code>(__main__,)</code></td>
<td class="left" >This module is used for
parsing, it contains class definitions that specify the <code>typecode</code>
attribute.</td></tr>
<tr><td class="left" valign="baseline"><code>nsdict</code></td>
<td class="center"><code>{}</code></td>
<td class="left" >Namespace dictionary to send in the SOAP
<code>Envelope</code></td></tr></tbody>
</table></div>
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-143' xml:id='l2h-143' class="method">AsJonPy</tt></b>(</nobr></td>
<td><var>request=None</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
<p>
This method is used within a JonPY handler to do dispatch.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>request</code></td>
<td class="center"><code>None</code></td>
<td class="left" >jonpy Request instance.</td></tr>
<tr><td class="left" valign="baseline"><code>modules</code></td>
<td class="center"><code>(__main__,)</code></td>
<td class="left" >List of modules containing
functions that can be invoked.</td></tr>
<tr><td class="left" valign="baseline"><code>docstyle</code></td>
<td class="center"><code>False</code></td>
<td class="left" >Exhibit the <em>docstyle</em> behavior.</td></tr>
<tr><td class="left" valign="baseline"><code>rpc</code></td>
<td class="center"><code>False</code></td>
<td class="left" >Exhibit the <em>rpc</em> behavior.</td></tr>
<tr><td class="left" valign="baseline"><code>typesmodule</code></td>
<td class="center"><code>(__main__,)</code></td>
<td class="left" >This module is used for
parsing, it contains class definitions that specify the <code>typecode</code>
attribute.</td></tr>
<tr><td class="left" valign="baseline"><code>nsdict</code></td>
<td class="center"><code>{}</code></td>
<td class="left" >Namespace dictionary to send in the SOAP
<code>Envelope</code></td></tr></tbody>
</table></div>
<p>
The following code shows a sample use:
<p>
<div class="verbatim"><pre>
import jon.fcgi
from ZSI import dispatch
import MyHandler
class Handler(cgi.Handler):
def process(self, req):
dispatch.AsJonPy(modules=(MyHandler,), request=req)
jon.fcgi.Server({jon.fcgi.FCGI_RESPONDER: Handler}).run()
</pre></div>
<p>
</dl>
<p>
<h2><a name="SECTION0011140000000000000000">
10.1.4 Other Dispatch Stuff</a>
</h2>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-144' xml:id='l2h-144' class="method">GetClientBinding</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
More sophisticated scripts may want to use access the client binding object,
which encapsulates all information about the client invoking the script.
This function returns <code>None</code> or the binding information, an
object of type <tt class="class">ClientBinding</tt>, described below.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-145' xml:id='l2h-145' class="class">ClientBinding</tt></b>(</nobr></td>
<td><var>...</var>)</td></tr></table></dt>
<dd>
This object contains information about the client.
It is created internally by <tt class="module">ZSI</tt>.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-146' xml:id='l2h-146' class="method">GetAuth</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
This returns a tuple containing information about the client identity.
The first element will be one of the constants from the <code>AUTH</code> class
described above.
For HTTP or <tt class="module">ZSI</tt> basic authentication, the next two elements will be
the name and password provided by the client.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-147' xml:id='l2h-147' class="method">GetNS</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns the namespace URI that the client is using, or an empty string.
This can be useful for versioning.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-148' xml:id='l2h-148' class="method">GetRequest</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns the <tt class="class">ParsedSoap</tt> object of the incoming request.
</dl>
<p>
The following attribute is read-only:
<p>
<dl><dt><b><tt id='l2h-149' xml:id='l2h-149' class="member">environ</tt></b></dt>
<dd>
A dictionary of the environment variables.
This is most useful when <tt class="method">AsCGI()</tt> is used.
</dl>
<p>
<h1><a name="SECTION0011200000000000000000">
10.2 The <tt class="module">client</tt> module -- sending SOAP messages</a>
</h1>
<p>
<tt class="module">ZSI</tt> includes a module to connect to a SOAP server over HTTP, send requests,
and parse the response.
It is built on the standard Python <tt class="module">httplib</tt> and <tt class="module">Cookie</tt>
modules.
It must be explicitly imported, as in
"<tt class="samp">from ZSI.client import AUTH,Binding</tt>".
<p>
<h2><a name="SECTION0011210000000000000000">
10.2.1 _Binding</a>
</h2>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-150' xml:id='l2h-150' class="class">_Binding</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This class encapsulates a connection to a server, known as a <em>binding</em>.
A single binding may be used for multiple RPC calls.
Between calls, modifiers may be used to change the URL being posted to,
etc.
<p>
Cookies are also supported; if a response comes back with a <code>Set-Cookie</code>
header, it will be parsed and used in subsequent interactions.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>auth</code></td>
<td class="center"><code>(AUTH.none,)</code></td>
<td class="left" >A tuple with authentication
information; the first value should be one of the constants
from the <tt class="class">AUTH</tt> class.</td></tr>
<tr><td class="left" valign="baseline"><code>nsdict</code></td>
<td class="center"><code>{}</code></td>
<td class="left" >Namespace dictionary to send in the
SOAP <code>Envelope</code></td></tr>
<tr><td class="left" valign="baseline"><code>soapaction</code></td>
<td class="center"><code>''</code></td>
<td class="left" >Value for the
<code>SOAPAction</code> HTTP header.</td></tr>
<tr><td class="left" valign="baseline"><code>readerclass</code></td>
<td class="center"><code>None</code></td>
<td class="left" >Class used to create DOM-creating
XML readers; see the description in the <tt class="class">ParsedSoap</tt> class.</td></tr>
<tr><td class="left" valign="baseline"><code>writerclass</code></td>
<td class="center"><code>None</code></td>
<td class="left" >ElementProxy Class used to create
XML writers; see the description in the <tt class="class">SoapWriter</tt> class.</td></tr>
<tr><td class="left" valign="baseline"><code>tracefile</code></td>
<td class="center"><code>None</code></td>
<td class="left" >An object with a <code>write</code>
method, where packet traces will be recorded.</td></tr>
<tr><td class="left" valign="baseline"><code>transport</code></td>
<td class="center">HTTPConnection/HTTPSConnection</td>
<td class="left" >transport class</td></tr>
<tr><td class="left" valign="baseline"><code>transdict</code></td>
<td class="center">{}</td>
<td class="left" >keyword arguments for connection initialization</td></tr>
<tr><td class="left" valign="baseline"><code>url</code></td>
<td class="center">n/a</td>
<td class="left" >URL to post to.</td></tr>
<tr><td class="left" valign="baseline"><code>wsAddressURI</code></td>
<td class="center">None</td>
<td class="left" >URI, identifies the WS-Address specification
to use. By default it's not used.</td></tr>
<tr><td class="left" valign="baseline"><code>sig_handler</code></td>
<td class="center">None</td>
<td class="left" >XML Signature handler, must sign and verify.</td></tr></tbody>
</table></div>
<p>
If using SSL, the <code>cert_file</code> and <code>key_file</code> keyword parameters may
be passed to the transport's constructor via the <code>transdict</code>. For details
about HTTPSConnection see the documentation for the <tt class="module">httplib</tt> module.
<p>
</dl>
<p>
Once a <tt class="class">_Binding</tt> object has been created, the following modifiers are
available. All of them return the binding object, so that multiple modifiers
can be chained together.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-151' xml:id='l2h-151' class="method">AddHeader</tt></b>(</nobr></td>
<td><var>header, value</var>)</td></tr></table></dt>
<dd>
Output the specified <code>header</code> and <code>value</code> with the HTTP
headers.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-152' xml:id='l2h-152' class="method">SetAuth</tt></b>(</nobr></td>
<td><var>style, name, password</var>)</td></tr></table></dt>
<dd>
The <code>style</code> should be one of the constants from the <code>AUTH</code>
class described above.
The remaining parameters will vary depending on the <code>style</code>.
Currently only basic authentication data of name and password are
supported.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-153' xml:id='l2h-153' class="method">SetNS</tt></b>(</nobr></td>
<td><var>uri</var>)</td></tr></table></dt>
<dd>
Set the default namespace for the request to the specified <code>uri</code>.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-154' xml:id='l2h-154' class="method">SetURL</tt></b>(</nobr></td>
<td><var>url</var>)</td></tr></table></dt>
<dd>
Set the URL where the post is made to <code>url</code>.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-155' xml:id='l2h-155' class="method">ResetHeaders</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Remove any headers that were added by <tt class="method">AddHeader()</tt>.
</dl>
<p>
The following attribute may also be modified:
<p>
<dl><dt><b><tt id='l2h-156' xml:id='l2h-156' class="member">trace</tt></b></dt>
<dd>
If this attribute is not <code>None</code>, it should be an object with a
<code>write</code> method, where packet traces will be recorded.
</dl>
<p>
Once the necessary parameters have been specified (at a minimum, the URL
must have been given in the constructor are through <code>SetURL</code>),
invocations can be made.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-157' xml:id='l2h-157' class="method">RPC</tt></b>(</nobr></td>
<td><var>url, opname, pyobj, replytype=None</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This is the highest-level invocation method.
It calls <tt class="method">Send()</tt> to send <code>pyobj</code> to the specified <code>url</code>
to perform the <code>opname</code> operation,
and calls <tt class="method">Receive()</tt> expecting to get a reply of the specified
<code>replytype</code>.
<p>
This method will raise a <tt class="exception">TypeError</tt> if the response does not
appear to be a SOAP message, or if is valid SOAP but contains a fault.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-158' xml:id='l2h-158' class="method">Send</tt></b>(</nobr></td>
<td><var>url, opname, pyboj</var><big>[</big><var>, **keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This sends the specified <code>pyobj</code> to the specified <code>url</code>, invoking
the <code>opname</code> method.
The <code>url</code> can be <code>None</code> if it was specified in the <tt class="class">Binding</tt>
constructor or if <code>SetURL</code> has been called.
See below for a shortcut version of this method.
<p>
The following keyword arguments may be used:
<p>
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>auth_header</code></td>
<td class="center"><code>None</code></td>
<td class="left" >String (containing presumably
serialized XML) to output as an authentication header.</td></tr>SOAP <code>Envelope</code>
<tr><td class="left" valign="baseline"><code>nsdict</code></td>
<td class="center"><code>{}</code></td>
<td class="left" >Namespace dictionary to send in the
SOAP <code>Envelope</code></td></tr>
<tr><td class="left" valign="baseline"><code>requesttypecode</code></td>
<td class="center">n/a</td>
<td class="left" >Typecode specifying how to serialize
the data.</td></tr>
<tr><td class="left" valign="baseline"><code>soapaction</code></td>
<td class="center">Obtained from the <tt class="class">Binding</tt></td>
<td class="left" >Value for the
<code>SOAPAction</code> HTTP header.</td></tr></tbody>
</table></div>
<p>
</dl>
<p>
Methods are available to determine the type of response that came back:
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-159' xml:id='l2h-159' class="method">IsSOAP</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns true if the message appears to be a SOAP message.
(Some servers return an HTML page under certain error conditions.)
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-160' xml:id='l2h-160' class="method">IsAFault</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns true if the message is a SOAP fault.
</dl>
<p>
Having determined the type of the message (or, more likely, assuming
it was good and catching an exception if not), the following methods
are available to actually parse the data.
They will continue to return the same value until
another message is sent.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-161' xml:id='l2h-161' class="method">ReceiveRaw</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns the unparsed message body.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-162' xml:id='l2h-162' class="method">ReceiveSoap</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns a <tt class="class">ParsedSOAP</tt> object containing the parsed message.
Raises a <tt class="exception">TypeError</tt> if the message wasn't SOAP.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-163' xml:id='l2h-163' class="method">ReceiveFault</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns a <tt class="class">Fault</tt> object containing the SOAP fault message.
Raises a <tt class="exception">TypeError</tt> if the message did not contain a fault.
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-164' xml:id='l2h-164' class="method">Receive</tt></b>(</nobr></td>
<td><var>replytype=None</var>)</td></tr></table></dt>
<dd>
Parses a SOAP message.
The <code>replytype</code> specifies how to parse the data.
If it s <code>None</code>, dynamic parsing will be used, usually resulting
in a Python list.
If <code>replytype</code> is a Python class, then the class's <code>typecode</code>
attribute will be used, otherwise <code>replytype</code> is taken to be
the typecode to use for parsing the data.
</dl>
<p>
Once a reply has been parsed (or its type examined), the following
read-only attributes are available.
Their values will remain unchanged until another reply is parsed.
<p>
<dl><dt><b><tt id='l2h-165' xml:id='l2h-165' class="member">reply_code</tt></b></dt>
<dd>
The HTTP reply code, a number.
</dl>
<p>
<dl><dt><b><tt id='l2h-166' xml:id='l2h-166' class="member">reply_headers</tt></b></dt>
<dd>
The HTTP headers, as a <tt class="class">mimetools</tt> object.
</dl>
<p>
<dl><dt><b><tt id='l2h-167' xml:id='l2h-167' class="member">reply_msg</tt></b></dt>
<dd>
A text string containing the HTTP reply text.
</dl>
<p>
<h2><a name="SECTION0011220000000000000000">
10.2.2 Binding</a>
</h2>
If an attribute is fetched other than one of those described in
<tt class="class">_Binding</tt>, it is taken to be the <code>opname</code> of a remote procedure, and
a callable object is returned. This object dynamically parses its arguments,
receives the reply, and parses that.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-168' xml:id='l2h-168' class="class">Binding</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
For other keyword arguments see <tt class="class">_Binding</tt>.
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>typesmodule</code></td>
<td class="center"><code>None</code></td>
<td class="left" >See explanation in Dispatching</td></tr></tbody>
</table></div>
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-169' xml:id='l2h-169' class="method">opname</tt></b>(</nobr></td>
<td><var>*args</var>)</td></tr></table></dt>
<dd>
Using this shortcut requires that the <var>url</var> attribute is set, either
throught the constructor or <tt class="method">SetURL()</tt>.
</dl>
<p>
<h2><a name="SECTION0011230000000000000000">
10.2.3 NamedParamBinding</a>
</h2>
If an attribute is fetched other than one of those described
in <tt class="class">_Binding</tt>, it is taken to be the <code>opname</code> of a remote procedure, and a callable
object is returned. This object dynamically parses its arguments, receives the
reply, and parses that.
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><span class="typelabel">class</span> <tt id='l2h-170' xml:id='l2h-170' class="class">NamedParamBinding</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>**keywords</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
For other keyword arguments see <tt class="class">_Binding</tt>.
<div class="center"><table class="realtable">
<thead>
<tr>
<th class="left" >Keyword</th>
<th class="center">Default</th>
<th class="left" >Description</th>
</tr>
</thead>
<tbody>
<tr><td class="left" valign="baseline"><code>typesmodule</code></td>
<td class="center"><code>None</code></td>
<td class="left" >See explanation in Dispatching</td></tr></tbody>
</table></div>
</dl>
<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-171' xml:id='l2h-171' class="method">opname</tt></b>(</nobr></td>
<td><var>**kwargs</var>)</td></tr></table></dt>
<dd>
Using this shortcut requires that the <var>url</var> attribute is set, either
throught the constructor or <tt class="method">SetURL()</tt>.
</dl>
<p>
<h1><a name="SECTION0012000000000000000000">
11. Bibliography</a>
</h1>
<h2><a name="SECTION0013000000000000000000">
Bibliography</a>
</h2><dl compact><dd><p></p><dt><a name="ref1">1</a>
<dd> This is the first item in the Bibliography.
<p></p><dt><a name="ref2">2</a>
<dd> This is the second item in the Bibliography.
</dl>
<h1><a name="SECTION0014000000000000000000">
A. CGI Script Array</a>
</h1>
<p>
<h1><a name="SECTION0014100000000000000000">
A.1 Intro</a>
</h1> This is an example of a simple web service CGI Script. The
service returns and expects SOAP Arrays (python <tt class="class">list</tt>). A sample soap
trace is provided below. In this example the CGI script is dispatched as a
<em>rpc</em> service.
<p>
<h2><a name="SECTION0014110000000000000000">
A.1.1 rpc wrapper</a>
</h2> The wrapper element of the request is the dispatch key
to the callback function, the child elements are passes as a <tt class="class">list</tt> or
<tt class="class">dict</tt> of values to the callback function. The callback function is
expected to return a <tt class="class">list</tt> or <tt class="class">dict</tt> of values, the response
wrapper is by default set to the request wrapper name appended <em>Response</em>.
<p>
<h1><a name="SECTION0014200000000000000000">
A.2 CGI Script</a>
</h1>
<p>
<div class="verbatim"><pre>
#!/usr/local/bin/python2.4
# SOAP Array
def hello():
return ["Hello, world"]
def echo(*args):
return args
def sum(*args):
sum = 0
for i in args: sum += i
return [sum]
def average(*args):
return [sum(*args) / len(args)]
from ZSI import dispatch
dispatch.AsCGI(rpc=True)
</pre></div>
<p>
<h1><a name="SECTION0014300000000000000000">
A.3 client test script</a>
</h1>
<div class="verbatim"><pre>
#!/usr/bin/env python
# client.py
import sys
from ZSI.client import Binding
b = Binding(url='http://127.0.0.1/cgi-bin/simple', tracefile=sys.stdout)
print b.hello()
try:
print b.hello(1)
except Exception, ex:
print "Fault: ", ex
print b.echo("whatever", "hi", 1, 2)
print b.sum(*[2*i for i in range(5)])
print b.average(*[2*i for i in range(5)])
</pre></div>
<p>
<h1><a name="SECTION0014400000000000000000">
A.4 SOAP Trace</a>
</h1>
<h2><a name="SECTION0014410000000000000000">
A.4.1 hello</a>
</h2>
<div class="verbatim"><pre>
$ ./client.py
Hello: _________________________________ Wed Oct 4 17:36:33 2006 REQUEST:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<hello SOAP-ENC:arrayType="xsd:anyType[0]"></hello>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
_________________________________ Wed Oct 4 17:36:34 2006 RESPONSE:
200
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<helloResponse SOAP-ENC:arrayType="xsd:anyType[1]">
<element id="o671b0" xsi:type="xsd:string">Hello, world</element>
</helloResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
[u'Hello, world']
</pre></div>
<p>
<h2><a name="SECTION0014420000000000000000">
A.4.2 hello fault</a>
</h2>
<div class="verbatim"><pre>
_________________________________ Wed Oct 4 17:36:34 2006 REQUEST:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<hello SOAP-ENC:arrayType="xsd:anyType[1]">
<element id="o1803988" xsi:type="xsd:int">1</element>
</hello>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
_________________________________ Wed Oct 4 17:36:35 2006 RESPONSE:
500
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>Processing Failure</faultstring>
<detail>
<ZSI:FaultDetail>
<ZSI:string>exceptions:TypeError hello() takes no arguments (1 given)</ZSI:string>
<ZSI:trace>build/bdist.darwin-8.8.0-Power_Macintosh/egg/ZSI/dispatch.py:86:_Dispatch</ZSI:trace>
</ZSI:FaultDetail>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Fault: Processing Failure
exceptions:TypeError
hello() takes no arguments (1 given)
[trace: build/bdist.darwin-8.8.0-Power_Macintosh/egg/ZSI/dispatch.py:86:_Dispatch]
</pre></div>
<p>
<h2><a name="SECTION0014430000000000000000">
A.4.3 echo</a>
</h2>
<div class="verbatim"><pre>
_________________________________ Wed Oct 4 17:36:35 2006 REQUEST:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<echo SOAP-ENC:arrayType="xsd:anyType[4]">
<element id="o644c0" xsi:type="xsd:string">whatever</element>
<element id="o644e0" xsi:type="xsd:string">hi</element>
<element id="o1803988" xsi:type="xsd:int">1</element>
<element id="o180397c" xsi:type="xsd:int">2</element>
</echo>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
_________________________________ Wed Oct 4 17:36:36 2006 RESPONSE:
200
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<echoResponse SOAP-ENC:arrayType="xsd:anyType[4]">
<element id="o4f4290" xsi:type="xsd:string">whatever</element>
<element id="o4f4338" xsi:type="xsd:string">hi</element>
<element id="o1803988" xsi:type="xsd:int">1</element>
<element id="o180397c" xsi:type="xsd:int">2</element>
</echoResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
[u'whatever', u'hi', 1, 2]
</pre></div>
<p>
<h2><a name="SECTION0014440000000000000000">
A.4.4 sum</a>
</h2>
<div class="verbatim"><pre>
_________________________________ Wed Oct 4 17:36:36 2006 REQUEST:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<sum SOAP-ENC:arrayType="xsd:anyType[5]">
<element id="o1803994" xsi:type="xsd:int">0</element>
<element id="o180397c" xsi:type="xsd:int">2</element>
<element id="o1803964" xsi:type="xsd:int">4</element>
<element id="o180394c" xsi:type="xsd:int">6</element>
<element id="o1803934" xsi:type="xsd:int">8</element>
</sum>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
_________________________________ Wed Oct 4 17:36:37 2006 RESPONSE:
200
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<sumResponse SOAP-ENC:arrayType="xsd:anyType[1]">
<element id="o18038a4" xsi:type="xsd:int">20</element>
</sumResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
[20]
</pre></div>
<p>
<h2><a name="SECTION0014450000000000000000">
A.4.5 average</a>
</h2>
<div class="verbatim"><pre>
_________________________________ Wed Oct 4 17:36:37 2006 REQUEST:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<average SOAP-ENC:arrayType="xsd:anyType[5]">
<element id="o1803994" xsi:type="xsd:int">0</element>
<element id="o180397c" xsi:type="xsd:int">2</element>
<element id="o1803964" xsi:type="xsd:int">4</element>
<element id="o180394c" xsi:type="xsd:int">6</element>
` <element id="o1803934" xsi:type="xsd:int">8</element>
</average>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
_________________________________ Wed Oct 4 17:36:38 2006 RESPONSE:
200
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<averageResponse SOAP-ENC:arrayType="xsd:anyType[1]">
<element id="o1803964" xsi:type="xsd:int">4</element>
</averageResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
[4]
</pre></div>
<h1><a name="SECTION0015000000000000000000">
B. CGI Script Struct</a>
</h1>
<p>
<h1><a name="SECTION0015100000000000000000">
B.1 Intro</a>
</h1> This is an example of a simple web service CGI Script. The service
returns and expects SOAP Structs (python <tt class="class">dict</tt>). A sample soap trace is
provided below. In this example the CGI script is dispatched as a <em>rpc</em>
service.
<p>
<h2><a name="SECTION0015110000000000000000">
B.1.1 rpc wrapper</a>
</h2> The wrapper element of the request is the dispatch key
to the callback function, the child elements are passes as a <tt class="class">list</tt> or
<tt class="class">dict</tt> of values to the callback function. The callback function is
expected to return a <tt class="class">list</tt> or <tt class="class">dict</tt> of values, the response
wrapper is by default set to the request wrapper name appended <em>Response</em>.
<p>
<h1><a name="SECTION0015200000000000000000">
B.2 CGI Script</a>
</h1>
<div class="verbatim"><pre>
#!/usr/local/bin/python2.4
# SOAP Struct
def hello():
return {"value":"Hello, world"}
def echo(**kw):
return kw
def sum(**kw):
sum = 0
for i in kw.values(): sum += i
return {"value":sum}
def average(**kw):
d = sum(**kw)
return d["value"] = d["value"]/len(kw)
from ZSI import dispatch
dispatch.AsCGI(rpc=True)
</pre></div>
<p>
<h1><a name="SECTION0015300000000000000000">
B.3 client test script</a>
</h1>
<div class="verbatim"><pre>
#!/usr/bin/env python
import sys,time
from ZSI.client import NamedParamBinding as NPBinding
b = NPBinding(url='http://127.0.0.1/cgi-bin/soapstruct', tracefile=sys.stdout)
print "Hello: ", b.hello()
print "Echo: ", b.echo(name="josh", year=2006, pi=3.14, time=time.gmtime())
print "Sum: ", b.sum(one=1, two=2, three=3)
print "Average: ", b.average(one=100, two=200, three=300, four=400)
</pre></div>
<p>
<h1><a name="SECTION0015400000000000000000">
B.4 SOAP Trace</a>
</h1>
<h2><a name="SECTION0015410000000000000000">
B.4.1 hello</a>
</h2>
<div class="verbatim"><pre>
</pre></div>
<h1><a name="SECTION0016000000000000000000">
C. Complete Low Level Example</a>
</h1>
<p>
<h1><a name="SECTION0016100000000000000000">
C.1 Intro</a>
</h1> This is a complete example of using the low level soap utilities
in <tt class="module">ZSI</tt> to implement a web service.
<p>
<h1><a name="SECTION0016200000000000000000">
C.2 code</a>
</h1>
<h2><a name="SECTION0016210000000000000000">
C.2.1 httpserver script</a>
</h2> Minimal http server example, opens up a new
process to do the SOAP processing.
<div class="verbatim"><pre>
#!/usr/bin/env python
# file: httpserver.py
import os
from subprocess import Popen, PIPE
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
class RequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
length = int(self.headers['content-length'])
xml_in = self.rfile.read(length)
p = Popen(os.path.join(os.path.curdir, 'player.py'),
shell=True, stdin=PIPE, stdout=PIPE)
(stdout, stderr) = p.communicate(xml_in)
code = 200
if stdout.find('Fault') >= 0: code = 500
self.send_response(code)
self.send_header('Content-type', 'text/xml; charset="utf-8"')
self.send_header('Content-Length', str(len(stdout)))
self.end_headers()
self.wfile.write(stdout)
self.wfile.flush()
if __name__ == '__main__':
server = HTTPServer(('localhost', 8080), RequestHandler)
server.serve_forever()
</pre></div>
<p>
<h2><a name="SECTION0016220000000000000000">
C.2.2 typecode module</a>
</h2>
<div class="verbatim"><pre>
# file: typecode.py
# CHECK PYTHONPATH: Must be able to import
class Player:
def __init__(self, *args):
if not len(args): return
self.Name = args[0]
self.Scores = args[1:]
Player.typecode = TC.Struct(Player, [
TC.String('Name'),
TC.Array('Integer', TC.Integer(), 'Scores', undeclared=True),
], 'GetAverage')
class Average:
def __init__(self, average=None):
self.average = average
Average.typecode = TC.Struct(Average, [
TC.Integer('average'),
], 'GetAverageResponse')
</pre></div>
<h2><a name="SECTION0016230000000000000000">
C.2.3 player script</a>
</h2>
<div class="verbatim"><pre>
#!/usr/bin/env python
# file: player.py
from ZSI import *
import sys
IN, OUT = sys.stdin, sys.stdout
try:
ps = ParsedSoap(IN)
except ParseException, e:
OUT.write(FaultFromZSIException(e).AsSOAP())
sys.exit(1)
except Exception, e:
# Faulted while processing; we assume it's in the header.
OUT.write(FaultFromException(e, 1).AsSOAP())
sys.exit(1)
# We are not prepared to handle any actors or mustUnderstand elements,
# so we'll arbitrarily fault back with the first one we found.
a = ps.WhatActorsArePresent()
if len(a):
OUT.write(FaultFromActor(a[0]).AsSOAP())
sys.exit(1)
mu = ps.WhatMustIUnderstand()
if len(mu):
uri, localname = mu[0]
OUT.write(FaultFromNotUnderstood(uri, localname).AsSOAP())
sys.exit(1)
from typecode import Player, Average
try:
player = ps.Parse(Player.typecode)
except EvaluateException, e:
OUT.write(FaultFromZSIException(e).AsSOAP())
sys.exit(1)
try:
total = 0
for value in player.Scores: total = total + value
result = Average(total / len(player.Scores))
sw = SoapWriter()
sw.serialize(result, Average.typecode)
sw.close()
OUT.write(str(sw))
except Exception, e:
OUT.write(FaultFromException(e, 0, sys.exc_info()[2]).AsSOAP())
sys.exit(1)
</pre></div>
<p>
<h2><a name="SECTION0016240000000000000000">
C.2.4 client test script</a>
</h2>
<div class="verbatim"><pre>
#!/usr/bin/env python2.4
#file: client.py
from ZSI import *
from ZSI.wstools.Namespaces import SCHEMA
from typecode import Player, Average
if __name__ == '__main__':
import sys
from ZSI.client import Binding
b = Binding(url='http://localhost:8080', tracefile=sys.stdout)
pyobj = b.RPC(None, None, Player("Josh",10,20,30), replytype=Average)
print pyobj
print pyobj.__dict__
</pre></div>
<p>
<h1><a name="SECTION0016300000000000000000">
C.3 SOAP Trace</a>
</h1>
<p>
<h2><a name="SECTION0016310000000000000000">
C.3.1 GetAverage</a>
</h2>
<div class="verbatim"><pre>
$./client.py
_________________________________ Thu Oct 5 14:57:39 2006 REQUEST:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<GetAverage>
<Name xsi:type="xsd:string">Josh</Name>
<Scores>
<element>10</element>
<element>20</element>
<element>30</element>
</Scores>
</GetAverage>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
_________________________________ Thu Oct 5 14:57:39 2006 RESPONSE:
200
OK
-------
Server: BaseHTTP/0.3 Python/2.5
Date: Thu, 05 Oct 2006 21:57:39 GMT
Content-type: text/xml; charset="utf-8"
Content-Length: 431
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<GetAverageResponse>
<average>20</average>
</GetAverageResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<__main__.Average instance at 0x5f9760>
{'average': 20}
</pre></div>
<p>
<h2><a name="SECTION0016320000000000000000">
C.3.2 fault</a>
</h2> Purposely send a incorrect <em>Nae</em> element for the
<em>Name</em>.
<div class="verbatim"><pre>
$./client.py
_________________________________ Thu Oct 5 14:33:25 2006 REQUEST:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<GetAverage>
<Nae xsi:type="xsd:string">Josh</Nae>
<Scores>
<element>10</element>
<element>20</element>
<element>30</element>
</Scores>
</GetAverage>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
_________________________________ Thu Oct 5 14:33:26 2006 RESPONSE:
500
Internal Server Error
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Unparseable message</faultstring>
<detail><Eoe440>&lt;ZSI:ParseFaultDetail&gt;
&lt;ZSI:string&gt;Element "Name" missing from complexType&lt;/ZSI:string&gt;
&lt;ZSI:trace&gt;/SOAP-ENV:Envelope/SOAP-ENV:Body/GetAverage&lt;/ZSI:trace&gt;
&lt;/ZSI:ParseFaultDetail&gt;</Eoe440></detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Traceback (most recent call last):
File "./player_client.py", line 25, in ?
pyobj = b.RPC(None, None, Player("Josh",10,20,30), replytype=Average)
File "/private/var/www/htdocs/guide/client.py", line 176, in RPC
File "/private/var/www/htdocs/guide/client.py", line 420, in Receive
ZSI.FaultException: Unparseable message
<Element Node at 5f9f58: Name='Eoe440' with 0 attributes and 1 children>
</pre></div>
<h1><a name="SECTION0017000000000000000000">
D. pickler example</a>
</h1>
<p>
<h1><a name="SECTION0017100000000000000000">
D.1 Intro</a>
</h1> This is an example of a stateful mod_python web service.
<p>
<h1><a name="SECTION0017200000000000000000">
D.2 code</a>
</h1>
<h2><a name="SECTION0017210000000000000000">
D.2.1 typecode module</a>
</h2> Module containing complex type typecode.
<div class="verbatim"><pre>
# Complex type definition
from ZSI import *
class Person:
def __init__(self, name=None, age=0):
self.name = name
self.age = age
Person.typecode = TC.Struct(Person,
[TC.String('name'),
TC.InonNegativeInteger('age')],
pname=('urn:MyApp','Person'))
</pre></div>
<h2><a name="SECTION0017220000000000000000">
D.2.2 pickler script</a>
</h2> Configure appache to use this script with mod_python
PythonHandler.
<div class="verbatim"><pre>
# pickler.py
import pickle, new
from mod_python import apache
from ZSI import dispatch
import MyComplexTypes
# my web service that returns a complex structure
def getPerson(name=None):
#fp = open('/tmp/%s.person.pickle'%Person.name, 'r')
fp = open('/tmp/%s.person.pickle'%name, 'r')
#return pickle.load(fp)
p = pickle.load(fp)
print "PERSON: ", p
print "typecode: ", p.typecode
return p
# my web service that accepts a complex structure
def savePerson(Person):
print "PERSON: ", Person
fp = open('/tmp/%s.person.pickle'%Person.name, 'w')
pickle.dump(Person, fp)
fp.close()
return {}
mod = __import__('encodings.utf_8', globals(), locals(), '*')
mod = __import__('encodings.utf_16_be', globals(), locals(), '*')
handles = new.module('handles')
handles.getPerson = getPerson
handles.savePerson = savePerson
def handler(req):
dispatch.AsHandler(modules=(handles,), request=req, typesmodule=MyComplexTypes, rpc=True)
return apache.OK
</pre></div>
<p>
<h2><a name="SECTION0017230000000000000000">
D.2.3 client: invoke savePerson</a>
</h2>
<h3><a name="SECTION0017231000000000000000">
D.2.3.1 script</a>
</h3>
<div class="verbatim"><pre>
import sys
from ZSI.client import Binding
from MyComplexTypes import Person
b = Binding(url='http://localhost/test3/pickler.py', tracefile=sys.stdout)
person = Person('christopher', 26)
b.savePerson(person)
</pre></div>
<p>
<h3><a name="SECTION0017232000000000000000">
D.2.3.2 SOAP Trace</a>
</h3>
<div class="verbatim"><pre>
_________________________________ Wed Oct 11 13:10:05 2006 REQUEST:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<savePerson xmlns:ns1="urn:MyApp">
<ns1:Person><name xsi:type="xsd:string">christopher</name>
<age xsi:type="xsd:nonNegativeInteger">26</age>
</ns1:Person>
</savePerson>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
_________________________________ Wed Oct 11 13:10:05 2006 RESPONSE:
Server: Apache/2.0.53-dev (Unix) mod_ruby/1.2.4 Ruby/1.8.2(2004-12-25)
mod_python/3.1.4 Python/2.4.1
Transfer-Encoding: chunked
Content-Type: text/xml
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<savePersonResponse></savePersonResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</pre></div>
<p>
<h2><a name="SECTION0017240000000000000000">
D.2.4 client: invoke getPerson 3 different ways</a>
</h2>
<h3><a name="SECTION0017241000000000000000">
D.2.4.1 script</a>
</h3>
<div class="verbatim"><pre>
import sys
import MyComplexTypes
from ZSI.client import NamedParamBinding as NPBinding, Binding
from ZSI import TC
kw = {'url':'http://localhost/test3/pickler.py', 'tracefile':sys.stdout}
b = NPBinding(**kw)
rsp = b.getPerson(name='christopher')
assert type(rsp) is dict, 'expecting a dict'
assert rsp['Person']['name'] == 'christopher', 'wrong person'
b = NPBinding(typesmodule=MyComplexTypes, **kw)
rsp = b.getPerson(name='christopher')
assert isinstance(rsp['Person'], MyComplexTypes.Person), (
'expecting instance of %s' %MyComplexTypes.Person)
b = Binding(typesmodule=MyComplexTypes, **kw)
class Name(str):
typecode = TC.String("name")
rsp = b.getPerson(Name('christopher'))
assert isinstance(rsp['Person'], MyComplexTypes.Person), (
'expecting instance of %s' %MyComplexTypes.Person)
</pre></div>
<p>
<h3><a name="SECTION0017242000000000000000">
D.2.4.2 SOAP Trace</a>
</h3> All responses are exactly the same, for comparison
the three requests are presented first and only the last response is included.
<div class="verbatim"><pre>
_________________________________ Wed Oct 11 13:19:00 2006 REQUEST:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<getPerson>
<name id="o6c2a0" xsi:type="xsd:string">christopher</name>
</getPerson>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
** OMIT RESPONSE **
_________________________________ Wed Oct 11 13:19:00 2006 REQUEST:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<getPerson>
<name id="o6c2a0" xsi:type="xsd:string">christopher</name>
</getPerson>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
** OMIT RESPONSE **
_________________________________ Wed Oct 11 13:19:00 2006 REQUEST:
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<getPerson>
<name xsi:type="xsd:string">christopher</name>
</getPerson>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
_________________________________ Wed Oct 11 13:19:00 2006 RESPONSE:
Server: Apache/2.0.53-dev (Unix) mod_ruby/1.2.4 Ruby/1.8.2(2004-12-25)
mod_python/3.1.4 Python/2.4.1
Transfer-Encoding: chunked
Content-Type: text/xml
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body>
<getPersonResponse xmlns:ns1="urn:MyApp">
<ns1:Person>
<name xsi:type="xsd:string">christopher</name>
<age xsi:type="xsd:nonNegativeInteger">26</age>
</ns1:Person>
</getPersonResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</pre></div>
<h1><a name="SECTION0018000000000000000000">
About this document ...</a>
</h1>
<strong>ZSI: The Zolera Soap Infrastructure
<br> Developer's Guide</strong>,
November 01, 2007, Release 2.1.0
<p> This document was generated using the <a
href="http://saftsack.fs.uni-bayreuth.de/~latex2ht/">
<strong>LaTeX</strong>2<tt>HTML</tt></a> translator.
</p>
<p> <a
href="http://saftsack.fs.uni-bayreuth.de/~latex2ht/">
<strong>LaTeX</strong>2<tt>HTML</tt></a> is Copyright ©
1993, 1994, 1995, 1996, 1997, <a
href="http://cbl.leeds.ac.uk/nikos/personal.html">Nikos
Drakos</a>, Computer Based Learning Unit, University of
Leeds, and Copyright © 1997, 1998, <a
href="http://www.maths.mq.edu.au/~ross/">Ross
Moore</a>, Mathematics Department, Macquarie University,
Sydney.
</p>
<p> The application of <a
href="http://saftsack.fs.uni-bayreuth.de/~latex2ht/">
<strong>LaTeX</strong>2<tt>HTML</tt></a> to the Python
documentation has been heavily tailored by Fred L. Drake,
Jr. Original navigation icons were contributed by Christopher
Petrilli.
</p>
<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><img src='previous.png'
border='0' height='32' alt='Previous Page' width='32' /></td>
<td class='online-navigation'><img src='up.png'
border='0' height='32' alt='Up one Level' width='32' /></td>
<td class='online-navigation'><img src='next.png'
border='0' height='32' alt='Next Page' width='32' /></td>
<td align="center" width="100%">ZSI: The Zolera Soap Infrastructure
<br> Developer's Guide</td>
<td class='online-navigation'><img src='blank.png'
border='0' height='32' alt='' width='32' /></td>
<td class='online-navigation'><img src='blank.png'
border='0' height='32' alt='' width='32' /></td>
<td class='online-navigation'><img src='blank.png'
border='0' height='32' alt='' width='32' /></td>
</tr></table>
<div class='online-navigation'>
</div>
</div>
<hr />
<span class="release-info">Release 2.1.0, documentation updated on November 01, 2007.</span>
</div>
<!--End of Navigation Panel-->
</body>
</html>
|