summaryrefslogtreecommitdiff
path: root/0001-ksoap2-update.patch
blob: d0c9fdafe506699cdc9622c0b576575195a71571 (plain)
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
From b5b548a4be9f1ced6f5599b62765216f9ab8af00 Mon Sep 17 00:00:00 2001
From: Ecco Park <eccopark@google.com>
Date: Tue, 8 May 2018 13:44:14 -0700
Subject: [PATCH 1/1] ksoap2 update

Change-Id: Iace4c0f3cb31c9532c5fa0c44c2dc863bd81b23e
Signed-off-by: Ecco Park <eccopark@google.com>
---
 .../main/java/org/ksoap2/SoapEnvelope.java    |  17 +-
 .../src/main/java/org/ksoap2/SoapFault12.java |  13 +-
 .../serialization/AttributeContainer.java     | 128 +++++-
 .../java/org/ksoap2/serialization/DM.java     |  57 ++-
 .../ksoap2/serialization/HasAttributes.java   |  16 +
 .../ksoap2/serialization/HasInnerText.java    |  17 +
 .../ksoap2/serialization/KvmSerializable.java |  25 +-
 .../org/ksoap2/serialization/Marshal.java     |   3 +-
 .../ksoap2/serialization/MarshalBase64.java   |   3 +-
 .../org/ksoap2/serialization/MarshalDate.java |   3 +-
 .../serialization/MarshalHashtable.java       |   8 +-
 .../org/ksoap2/serialization/SoapObject.java  | 340 +++++++++++++-
 .../ksoap2/serialization/SoapPrimitive.java   |  20 +-
 .../SoapSerializationEnvelope.java            | 419 ++++++++++++------
 .../org/ksoap2/serialization/ValueWriter.java |  13 +
 .../ksoap2/transport/ServiceConnection.java   |  13 +-
 .../java/org/ksoap2/transport/Transport.java  | 131 ++++--
 .../ksoap2/serialization/MarshalFloat.java    |   3 +-
 .../transport/HttpResponseException.java      |  60 +++
 .../org/ksoap2/transport/HttpTransportSE.java | 348 +++++++--------
 .../transport/HttpsServiceConnectionSE.java   |  58 ++-
 .../ksoap2/transport/HttpsTransportSE.java    |  81 ++--
 .../transport/KeepAliveHttpsTransportSE.java  |  20 +-
 .../ksoap2/transport/ServiceConnectionSE.java |  44 +-
 24 files changed, 1298 insertions(+), 542 deletions(-)
 create mode 100644 ksoap2-base/src/main/java/org/ksoap2/serialization/HasAttributes.java
 create mode 100644 ksoap2-base/src/main/java/org/ksoap2/serialization/HasInnerText.java
 create mode 100644 ksoap2-base/src/main/java/org/ksoap2/serialization/ValueWriter.java
 create mode 100644 ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpResponseException.java

diff --git a/ksoap2-base/src/main/java/org/ksoap2/SoapEnvelope.java b/ksoap2-base/src/main/java/org/ksoap2/SoapEnvelope.java
index 8a0b894..1c43656 100644
--- a/ksoap2-base/src/main/java/org/ksoap2/SoapEnvelope.java
+++ b/ksoap2-base/src/main/java/org/ksoap2/SoapEnvelope.java
@@ -54,10 +54,8 @@ public class SoapEnvelope {
     /** Namespace constant: http://www.w3.org/1999/XMLSchema */
     public static final String XSI1999 = "http://www.w3.org/1999/XMLSchema-instance";
 
-    //public static final String NS20 = "http://www.wi-fi-org/specifications/hotspot2dot0/spp/1.0/";
     public static final String NS20 = "http://www.wi-fi.org/specifications/hotspot2dot0/v1.0/spp";
 
-    //public static final String OMADM12 = "http://www.openmobilealliance.org/tech/DTD/dm_ddf-v1_2.dtd";
 
     /**
      * Returns true for the string values "1" and "true", ignoring upper/lower
@@ -105,9 +103,8 @@ public class SoapEnvelope {
     /** Xml Schema data namespace, set by the constructor */
     public String xsd;
 
-    ///M: HS20 Add by Jungo
+    // HS20 change
     public String ns;
-    public String omadm;
 
     /**
      * Initializes a SOAP Envelope. The version parameter must be set to one of
@@ -129,10 +126,8 @@ public class SoapEnvelope {
             enc = SoapEnvelope.ENC2003;
             env = SoapEnvelope.ENV2003;
         }
-
+        // HS20 change
         ns = SoapEnvelope.NS20;
-        //omadm = SoapEnvelope.OMADM12;
-
     }
 
     /** Parses the SOAP envelope from the given parser */
@@ -206,13 +201,9 @@ public class SoapEnvelope {
      * given XML writer.
      */
     public void write(XmlSerializer writer) throws IOException {
-        ///M: HS20 modify by Jungo
-        //writer.setPrefix("i", xsi);
-        //writer.setPrefix("d", xsd);
-        //writer.setPrefix("c", enc);
-        writer.setPrefix("soap", env);//the prefix for namespace env in xml output
+        // HS 2.0 changes
+        writer.setPrefix("soap", env); //the prefix for namespace env in xml output
         writer.setPrefix("spp", ns);
-        //writer.setPrefix("omadm", omadm);
 
         writer.startTag(env, "Envelope");
         writer.startTag(env, "Header");
diff --git a/ksoap2-base/src/main/java/org/ksoap2/SoapFault12.java b/ksoap2-base/src/main/java/org/ksoap2/SoapFault12.java
index 5667cb4..3f39147 100644
--- a/ksoap2-base/src/main/java/org/ksoap2/SoapFault12.java
+++ b/ksoap2-base/src/main/java/org/ksoap2/SoapFault12.java
@@ -72,27 +72,28 @@ public class SoapFault12 extends SoapFault {
 
         while (parser.nextTag() == XmlPullParser.START_TAG) {
             String name = parser.getName();
+            String namespace = parser.getNamespace();
             parser.nextTag();
-            if (name.equals("Code")) {
+            if (name.toLowerCase().equals("Code".toLowerCase())) {
                 this.Code = new Node();
                 this.Code.parse(parser);
-            } else if (name.equals("Reason")) {
+            } else if (name.toLowerCase().equals("Reason".toLowerCase())) {
                 this.Reason = new Node();
                 this.Reason.parse(parser);
-            } else if (name.equals("Node")) {
+            } else if (name.toLowerCase().equals("Node".toLowerCase())) {
                 this.Node = new Node();
                 this.Node.parse(parser);
-            } else if (name.equals("Role")) {
+            } else if (name.toLowerCase().equals("Role".toLowerCase())) {
                 this.Role = new Node();
                 this.Role.parse(parser);
-            } else if (name.equals("Detail")) {
+            } else if (name.toLowerCase().equals("Detail".toLowerCase())) {
                 this.Detail = new Node();
                 this.Detail.parse(parser);
             } else {
                 throw new RuntimeException("unexpected tag:" + name);
             }
 
-            parser.require(XmlPullParser.END_TAG, SoapEnvelope.ENV2003, name);
+            parser.require(XmlPullParser.END_TAG, namespace, name);
         }
         parser.require(XmlPullParser.END_TAG, SoapEnvelope.ENV2003, "Fault");
         parser.nextTag();
diff --git a/ksoap2-base/src/main/java/org/ksoap2/serialization/AttributeContainer.java b/ksoap2-base/src/main/java/org/ksoap2/serialization/AttributeContainer.java
index 6b83847..34d2723 100644
--- a/ksoap2-base/src/main/java/org/ksoap2/serialization/AttributeContainer.java
+++ b/ksoap2-base/src/main/java/org/ksoap2/serialization/AttributeContainer.java
@@ -3,8 +3,8 @@ package org.ksoap2.serialization;
 
 import java.util.Vector;
 
-public class AttributeContainer {
-    private Vector attributes = new Vector();
+public class AttributeContainer implements HasAttributes{
+    protected Vector attributes = new Vector();
 
     /**
      * Places AttributeInfo of desired attribute into a designated AttributeInfo object
@@ -29,9 +29,9 @@ public class AttributeContainer {
         return ((AttributeInfo) attributes.elementAt(index)).getValue();
     }
 
-    /**
-    * Get the attribute's toString value.
-    */
+     /**
+     * Get the attribute's toString value.
+     */
     public String getAttributeAsString(int index) {
         AttributeInfo attributeInfo = (AttributeInfo) attributes.elementAt(index);
         return attributeInfo.getValue().toString();
@@ -51,6 +51,20 @@ public class AttributeContainer {
         }
     }
 
+    /**
+     * Get the attribute with the given name
+     *
+     * @throws RuntimeException if the attribute does not exist
+     */
+    public Object getAttribute(String namespace,String name) {
+        Integer i = attributeIndex(namespace,name);
+        if (i != null) {
+            return getAttribute(i.intValue());
+        } else {
+            throw new RuntimeException("illegal property: " + name);
+        }
+    }
+
     /**
      * Get the toString value of the attribute with the given name.
      *
@@ -65,6 +79,19 @@ public class AttributeContainer {
         }
     }
 
+    /**
+     * Get the toString value of the attribute with the given name.
+     *
+     * @throws RuntimeException if the attribute does not exist
+     */
+    public String getAttributeAsString(String namespace,String name) {
+        Integer i = attributeIndex(namespace,name);
+        if (i != null) {
+            return getAttribute(i.intValue()).toString();
+        } else {
+            throw new RuntimeException("illegal property: " + name);
+        }
+    }
     /**
      * Knows whether the given attribute exists
      */
@@ -76,6 +103,16 @@ public class AttributeContainer {
         }
     }
 
+    /**
+     * Knows whether the given attribute exists
+     */
+    public boolean hasAttribute(final String namespace,final String name) {
+        if (attributeIndex(namespace,name) != null) {
+            return true;
+        } else {
+            return false;
+        }
+    }
     /**
      * Get an attribute without chance of throwing an exception
      *
@@ -91,6 +128,21 @@ public class AttributeContainer {
         }
     }
 
+    /**
+     * Get an attribute without chance of throwing an exception
+     *
+     * @param name the name of the attribute to retrieve
+     * @return the value of the attribute if it exists; {@code null} if it does not exist
+     */
+    public Object getAttributeSafely(String namespace,String name) {
+        Integer i = attributeIndex(namespace,name);
+        if (i != null) {
+            return getAttribute(i.intValue());
+        } else {
+            return null;
+        }
+    }
+
     /**
      * Get an attributes' toString value without chance of throwing an
      * exception.
@@ -108,6 +160,23 @@ public class AttributeContainer {
         }
     }
 
+    /**
+     * Get an attributes' toString value without chance of throwing an
+     * exception.
+
+     * @param name
+     * @return the value of the attribute,s toString method if it exists; ""
+     * if it does not exist
+     */
+    public Object getAttributeSafelyAsString(String namespace,String name) {
+        Integer i = attributeIndex(namespace,name);
+        if (i != null) {
+            return getAttribute(i.intValue()).toString();
+        } else {
+            return "";
+        }
+    }
+
     private Integer attributeIndex(String name) {
         for (int i = 0; i < attributes.size(); i++) {
             if (name.equals(((AttributeInfo) attributes.elementAt(i)).getName())) {
@@ -117,6 +186,16 @@ public class AttributeContainer {
         return null;
     }
 
+    private Integer attributeIndex(String namespace,String name) {
+        for (int i = 0; i < attributes.size(); i++) {
+            AttributeInfo attrInfo=(AttributeInfo) attributes.elementAt(i);
+            if (name.equals(attrInfo.getName()) && namespace.equals(attrInfo.getNamespace())) {
+                return new Integer(i);
+            }
+        }
+        return null;
+    }
+
     /**
      * Returns the number of attributes
      *
@@ -160,13 +239,25 @@ public class AttributeContainer {
      * @return {@code this} object.
      */
     public void addAttribute(String name, Object value) {
+        addAttribute(null,name,value);
+    }
+
+    /**
+     * Adds a attribute (parameter) to the object.
+     *
+     * @param namespace  The namespace of the attribute
+     * @param name  The name of the attribute
+     * @param value the value of the attribute
+     * @return {@code this} object.
+     */
+    public void addAttribute(String namespace,String name, Object value) {
         AttributeInfo attributeInfo = new AttributeInfo();
         attributeInfo.name = name;
+        attributeInfo.namespace = namespace;
         attributeInfo.type = value == null ? PropertyInfo.OBJECT_CLASS : value.getClass();
         attributeInfo.value = value;
         addAttribute(attributeInfo);
     }
-
     /**
      * Add an attribute if the value is not null.
      * @param name
@@ -178,6 +269,18 @@ public class AttributeContainer {
         }
     }
 
+    /**
+     * Add an attribute if the value is not null.
+     * @param namespace  The namespace of the attribute
+     * @param name
+     * @param value
+     */
+    public void addAttributeIfValue(String namespace,String name, Object value) {
+        if (value != null) {
+            addAttribute(namespace,name, value);
+        }
+    }
+
     /**
      * Add a new attribute by providing an {@link AttributeInfo} object.  {@code AttributeInfo}
      * contains all data about the attribute, including name and value.}
@@ -198,4 +301,17 @@ public class AttributeContainer {
             attributes.addElement(attributeInfo);
         }
     }
+
+
+    public void setAttribute(AttributeInfo info) {
+
+
+    }
+
+
+    public void getAttribute(int index, AttributeInfo info) {
+
+
+    }
+
 }
diff --git a/ksoap2-base/src/main/java/org/ksoap2/serialization/DM.java b/ksoap2-base/src/main/java/org/ksoap2/serialization/DM.java
index 78d4449..255126e 100644
--- a/ksoap2-base/src/main/java/org/ksoap2/serialization/DM.java
+++ b/ksoap2-base/src/main/java/org/ksoap2/serialization/DM.java
@@ -20,9 +20,12 @@
 
 package org.ksoap2.serialization;
 
-import java.io.*;
-import org.xmlpull.v1.*;
-import org.ksoap2.*;
+import java.io.IOException;
+
+import org.ksoap2.SoapEnvelope;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlSerializer;
 
 /**
  * This class is not public, so save a few bytes by using a short class name (DM
@@ -30,8 +33,7 @@ import org.ksoap2.*;
  */
 class DM implements Marshal {
 
-    public Object readInstance(XmlPullParser parser, String namespace, String name,
-            PropertyInfo expected)
+    public Object readInstance(XmlPullParser parser, String namespace, String name, PropertyInfo excepted)
             throws IOException, XmlPullParserException {
         String text = parser.nextText();
         switch (name.charAt(0)) {
@@ -49,9 +51,10 @@ class DM implements Marshal {
     }
 
     /**
-     * Write the instance out. In case it is an AttributeContainer write those our first though.
-     * @param writer
-     *            the xml serializer.
+     * Write the instance out. In case it is an AttributeContainer write those our first though. 
+     * If it HasAttributes then write the attributes and values.
+     *
+     * @param writer   the xml serializer.
      * @param instance
      * @throws IOException
      */
@@ -62,11 +65,43 @@ class DM implements Marshal {
             for (int counter = 0; counter < cnt; counter++) {
                 AttributeInfo attributeInfo = new AttributeInfo();
                 attributeContainer.getAttributeInfo(counter, attributeInfo);
-                writer.attribute(attributeInfo.getNamespace(), attributeInfo.getName(),
-                        attributeInfo.getValue().toString());
+                try {
+                    attributeContainer.getAttribute(counter, attributeInfo);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                if (attributeInfo.getValue() != null) {
+                    writer.attribute(attributeInfo.getNamespace(), attributeInfo.getName(),
+                            (attributeInfo.getValue() != null) ? attributeInfo.getValue().toString() : "");
+                }
+            }
+        } else if (instance instanceof HasAttributes) {
+            HasAttributes soapObject = (HasAttributes) instance;
+            int cnt = soapObject.getAttributeCount();
+            for (int counter = 0; counter < cnt; counter++) {
+                AttributeInfo attributeInfo = new AttributeInfo();
+                soapObject.getAttributeInfo(counter, attributeInfo);
+                try {
+                    soapObject.getAttribute(counter, attributeInfo);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                if (attributeInfo.getValue() != null) {
+                    writer.attribute(attributeInfo.getNamespace(), attributeInfo.getName(),
+                            attributeInfo.getValue() != null ? attributeInfo.getValue().toString() : "");
+                }
             }
         }
-        writer.text(instance.toString());
+
+        if(instance  instanceof ValueWriter)
+        {
+            ((ValueWriter)instance).write(writer);
+        }
+        else
+        {
+            writer.text(instance.toString());
+        }
+
     }
 
     public void register(SoapSerializationEnvelope cm) {
diff --git a/ksoap2-base/src/main/java/org/ksoap2/serialization/HasAttributes.java b/ksoap2-base/src/main/java/org/ksoap2/serialization/HasAttributes.java
new file mode 100644
index 0000000..b513138
--- /dev/null
+++ b/ksoap2-base/src/main/java/org/ksoap2/serialization/HasAttributes.java
@@ -0,0 +1,16 @@
+package org.ksoap2.serialization;
+
+/**
+ * Common inteface for classes which want to serialize attributes to outgoing soap message
+ *
+ * @author robocik
+ */
+public interface HasAttributes {
+    int getAttributeCount();
+
+    void getAttributeInfo(int index, AttributeInfo info);
+
+    void getAttribute(int index, AttributeInfo info);
+
+    void setAttribute(AttributeInfo info);
+}
diff --git a/ksoap2-base/src/main/java/org/ksoap2/serialization/HasInnerText.java b/ksoap2-base/src/main/java/org/ksoap2/serialization/HasInnerText.java
new file mode 100644
index 0000000..b35c35b
--- /dev/null
+++ b/ksoap2-base/src/main/java/org/ksoap2/serialization/HasInnerText.java
@@ -0,0 +1,17 @@
+package org.ksoap2.serialization;
+/**
+ * Interface for classes requiring inner text of xml  tags
+ *
+ * @author satansly
+ */
+public interface HasInnerText {
+     /**
+     * Gets the inner text of xml tags
+     */
+    Object getInnerText();
+
+    /**
+     * @param s String to be set as inner text for an outgoing soap object
+     */
+    void setInnerText(Object s);
+}
diff --git a/ksoap2-base/src/main/java/org/ksoap2/serialization/KvmSerializable.java b/ksoap2-base/src/main/java/org/ksoap2/serialization/KvmSerializable.java
index bded0c0..09d7b32 100644
--- a/ksoap2-base/src/main/java/org/ksoap2/serialization/KvmSerializable.java
+++ b/ksoap2-base/src/main/java/org/ksoap2/serialization/KvmSerializable.java
@@ -39,31 +39,26 @@ public interface KvmSerializable {
      */
     Object getProperty(int index);
 
-    /** 
-     * @return the number of serializable properties 
+    /**
+     * @return the number of serializable properties
      */
     int getPropertyCount();
 
     /**
      * Sets the property with the given index to the given value.
-     * 
-     * @param index
-     *            the index to be set
-     * @param value
-     *            the value of the property
+     *
+     * @param index the index to be set
+     * @param value the value of the property
      */
     void setProperty(int index, Object value);
 
     /**
      * Fills the given property info record.
-     * 
-     * @param index
-     *            the index to be queried
-     * @param properties
-     *            information about the (de)serializer.  Not frequently used.
-     * @param info
-     *            The return parameter, to be filled with information about the
-     *            property with the given index.
+     *
+     * @param index      the index to be queried
+     * @param properties information about the (de)serializer.  Not frequently used.
+     * @param info       The return parameter, to be filled with information about the
+     *                   property with the given index.
      */
     void getPropertyInfo(int index, Hashtable properties, PropertyInfo info);
 
diff --git a/ksoap2-base/src/main/java/org/ksoap2/serialization/Marshal.java b/ksoap2-base/src/main/java/org/ksoap2/serialization/Marshal.java
index cfa9d81..100f107 100644
--- a/ksoap2-base/src/main/java/org/ksoap2/serialization/Marshal.java
+++ b/ksoap2-base/src/main/java/org/ksoap2/serialization/Marshal.java
@@ -41,8 +41,7 @@ public interface Marshal {
      *            the namespace.
      * @return the object read from the xml stream.
      */
-    public Object readInstance(XmlPullParser parser, String namespace, String name,
-            PropertyInfo expected)
+    public Object readInstance(XmlPullParser parser, String namespace, String name, PropertyInfo expected)
             throws IOException, XmlPullParserException;
 
     /**
diff --git a/ksoap2-base/src/main/java/org/ksoap2/serialization/MarshalBase64.java b/ksoap2-base/src/main/java/org/ksoap2/serialization/MarshalBase64.java
index 2f8420c..2239027 100644
--- a/ksoap2-base/src/main/java/org/ksoap2/serialization/MarshalBase64.java
+++ b/ksoap2-base/src/main/java/org/ksoap2/serialization/MarshalBase64.java
@@ -31,8 +31,7 @@ import org.xmlpull.v1.*;
 public class MarshalBase64 implements Marshal {
     public static Class BYTE_ARRAY_CLASS = new byte[0].getClass();
 
-    public Object readInstance(XmlPullParser parser, String namespace, String name,
-            PropertyInfo expected)
+    public Object readInstance(XmlPullParser parser, String namespace, String name, PropertyInfo expected)
             throws IOException, XmlPullParserException {
         return Base64.decode(parser.nextText());
     }
diff --git a/ksoap2-base/src/main/java/org/ksoap2/serialization/MarshalDate.java b/ksoap2-base/src/main/java/org/ksoap2/serialization/MarshalDate.java
index 3e4fa06..489ba3b 100644
--- a/ksoap2-base/src/main/java/org/ksoap2/serialization/MarshalDate.java
+++ b/ksoap2-base/src/main/java/org/ksoap2/serialization/MarshalDate.java
@@ -31,8 +31,7 @@ import org.ksoap2.kobjects.isodate.*;
 public class MarshalDate implements Marshal {
     public static Class DATE_CLASS = new Date().getClass();
 
-    public Object readInstance(XmlPullParser parser, String namespace, String name,
-            PropertyInfo expected)
+    public Object readInstance(XmlPullParser parser, String namespace, String name, PropertyInfo expected)
             throws IOException, XmlPullParserException {
         return IsoDate.stringToDate(parser.nextText(), IsoDate.DATE_TIME);
     }
diff --git a/ksoap2-base/src/main/java/org/ksoap2/serialization/MarshalHashtable.java b/ksoap2-base/src/main/java/org/ksoap2/serialization/MarshalHashtable.java
index d2367e9..0c6b53e 100644
--- a/ksoap2-base/src/main/java/org/ksoap2/serialization/MarshalHashtable.java
+++ b/ksoap2-base/src/main/java/org/ksoap2/serialization/MarshalHashtable.java
@@ -46,8 +46,7 @@ public class MarshalHashtable implements Marshal {
     public static final Class HASHTABLE_CLASS = new Hashtable().getClass();
     SoapSerializationEnvelope envelope;
 
-    public Object readInstance(XmlPullParser parser, String namespace, String name,
-            PropertyInfo expected)
+    public Object readInstance(XmlPullParser parser, String namespace, String name, PropertyInfo expected)
             throws IOException, XmlPullParserException {
         Hashtable instance = new Hashtable();
         String elementName = parser.getName();
@@ -81,7 +80,7 @@ public class MarshalHashtable implements Marshal {
             Object key = keys.nextElement();
             item.setProperty(0, key);
             item.setProperty(1, h.get(key));
-            envelope.writeObjectBody(writer, item);
+            envelope.writeObjectBodyWithAttributes(writer, item);
             writer.endTag("", "item");
         }
     }
@@ -89,7 +88,6 @@ public class MarshalHashtable implements Marshal {
     class ItemSoapObject extends SoapObject {
         Hashtable h;
         int resolvedIndex = -1;
-
         ItemSoapObject(Hashtable h) {
             super(null, null);
             this.h = h;
@@ -107,7 +105,7 @@ public class MarshalHashtable implements Marshal {
                 Object resolved = resolvedIndex == 0 ? getProperty(0) : getProperty(1);
                 if (index == 0) {
                     h.put(value, resolved);
-                } else {
+                } else  {
                     h.put(resolved, value);
                 }
             }
diff --git a/ksoap2-base/src/main/java/org/ksoap2/serialization/SoapObject.java b/ksoap2-base/src/main/java/org/ksoap2/serialization/SoapObject.java
index 24a1ffe..f11210a 100644
--- a/ksoap2-base/src/main/java/org/ksoap2/serialization/SoapObject.java
+++ b/ksoap2-base/src/main/java/org/ksoap2/serialization/SoapObject.java
@@ -38,7 +38,7 @@ import java.util.*;
  * KvmSerializable interface.
  */
 
-public class SoapObject extends AttributeContainer implements KvmSerializable {
+public class SoapObject extends AttributeContainer implements KvmSerializable, HasInnerText {
 
     private static final String EMPTY_STRING = "";
     /**
@@ -54,6 +54,8 @@ public class SoapObject extends AttributeContainer implements KvmSerializable {
      */
     protected Vector properties = new Vector();
 
+    protected Object innerText;
+
     // TODO: accessing properties and attributes would work much better if we
     // kept a list of known properties instead of iterating through the list
     // each time
@@ -181,6 +183,230 @@ public class SoapObject extends AttributeContainer implements KvmSerializable {
         }
     }
 
+    /**
+     * Get the property with the given name
+     *
+     * return null
+     *             if the property does not exist
+     */
+    public Object getProperty(String namespace,String name) {
+        Integer index = propertyIndex(namespace,name);
+        if (index != null) {
+            return getProperty(index.intValue());
+        }
+        else {
+            throw new RuntimeException("illegal property: " + name);
+        }
+    }
+
+    /**
+     * Get a property using namespace and name without chance of throwing an exception
+     *
+     * @return the property if it exists; if not, {@link NullSoapObject} is
+     *         returned
+     */
+    public Object getPropertyByNamespaceSafely(final String namespace, final String name) {
+        Integer i = propertyIndex(namespace,name);
+        if (i != null) {
+            return getProperty(i.intValue());
+        } else {
+            return new NullSoapObject();
+        }
+    }
+
+    /**
+     * Get the toString value of a property without chance of throwing an
+     * exception
+     *
+     * @return the string value of the property if it exists; if not, #EMPTY_STRING is
+     *         returned
+     */
+    public String getPropertyByNamespaceSafelyAsString(final String namespace,final String name) {
+        Integer i = propertyIndex(namespace,name);
+        if (i != null) {
+            Object foo = getProperty(i.intValue());
+            if (foo == null) {
+                return EMPTY_STRING;
+            } else {
+                return foo.toString();
+            }
+        } else {
+            return EMPTY_STRING;
+        }
+    }
+
+    /**
+     * Get a property without chance of throwing an exception. An object can be
+     * provided to this method; if the property is not found, this object will
+     * be returned.
+     *
+     * @param defaultThing
+     *            the object to return if the property is not found
+     * @return the property if it exists; defaultThing if the property does not
+     *         exist
+     */
+    public Object getPropertySafely(final String namespace,final String name, final Object defaultThing) {
+        Integer i = propertyIndex(namespace,name);
+        if (i != null) {
+            return getProperty(i.intValue());
+        } else {
+            return defaultThing;
+        }
+    }
+
+    /**
+     * Get the toString value of a property without chance of throwing an
+     * exception. An object can be provided to this method; if the property is
+     * not found, this object's string representation will be returned.
+     *
+     * @param defaultThing
+     *            toString of the object to return if the property is not found
+     * @return the property toString if it exists; defaultThing toString if the
+     *         property does not exist, if the defaultThing is null #EMPTY_STRING
+     *         is returned
+     */
+    public String getPropertySafelyAsString(final String namespace,final String name,
+                                            final Object defaultThing) {
+        Integer i = propertyIndex(namespace,name);
+        if (i != null) {
+            Object property = getProperty(i.intValue());
+            if (property != null) {
+                return property.toString();
+            } else {
+                return EMPTY_STRING;
+            }
+        } else {
+            if (defaultThing != null) {
+                return defaultThing.toString();
+            } else {
+                return EMPTY_STRING;
+            }
+        }
+    }
+
+    /**
+     * Get the primitive property with the given name.
+     *
+     * @param name
+     * @return PropertyInfo containing an empty string if property either complex or empty
+     */
+    public Object getPrimitiveProperty(final String namespace,final String name){
+        Integer index = propertyIndex(namespace,name);
+        if (index != null){
+            PropertyInfo propertyInfo = (PropertyInfo) properties.elementAt(index.intValue());
+            if (propertyInfo.getType()!=SoapObject.class && propertyInfo.getValue()!=null){
+                return propertyInfo.getValue();
+            } else {
+                propertyInfo = new PropertyInfo();
+                propertyInfo.setType(String.class);
+                propertyInfo.setValue(EMPTY_STRING);
+                propertyInfo.setName(name);
+                propertyInfo.setNamespace(namespace);
+                return (Object) propertyInfo.getValue();
+            }
+        } else {
+            throw new RuntimeException("illegal property: " + name);
+        }
+    }
+
+    /**
+     * Get the toString value of the primitive property with the given name.
+     * Returns empty string if property either complex or empty
+     *
+     * @param name
+     * @return the string value of the property
+     */
+    public String getPrimitivePropertyAsString(final String namespace,final String name){
+        Integer index = propertyIndex(namespace,name);
+        if (index != null){
+            PropertyInfo propertyInfo = (PropertyInfo) properties.elementAt(index.intValue());
+            if (propertyInfo.getType()!=SoapObject.class && propertyInfo.getValue()!=null){
+                return propertyInfo.getValue().toString();
+            } else {
+                return EMPTY_STRING;
+            }
+        } else {
+            throw new RuntimeException("illegal property: " + name);
+        }
+    }
+
+    /**
+     * Get the toString value of a primitive property without chance of throwing an
+     * exception
+     *
+     * @param name
+     * @return the string value of the property if it exists and is primitive; if not, #EMPTY_STRING is
+     *         returned
+     */
+    public Object getPrimitivePropertySafely(final String namespace,final String name) {
+        Integer index = propertyIndex(namespace,name);
+        if (index != null){
+            PropertyInfo propertyInfo = (PropertyInfo) properties.elementAt(index.intValue());
+            if (propertyInfo.getType()!=SoapObject.class && propertyInfo.getValue()!=null){
+                return propertyInfo.getValue().toString();
+            } else {
+                propertyInfo = new PropertyInfo();
+                propertyInfo.setType(String.class);
+                propertyInfo.setValue(EMPTY_STRING);
+                propertyInfo.setName(name);
+                propertyInfo.setNamespace(namespace);
+                return (Object) propertyInfo.getValue();
+            }
+        } else {
+            return new NullSoapObject();
+        }
+    }
+
+    /**
+     * Get the toString value of a primitive property without chance of throwing an
+     * exception
+     *
+     * @param name
+     * @return the string value of the property if it exists and is primitive; if not, #EMPTY_STRING is
+     *         returned
+     */
+    public String getPrimitivePropertySafelyAsString(final String namespace,final String name) {
+        Integer index = propertyIndex(namespace,name);
+        if (index != null){
+            PropertyInfo propertyInfo = (PropertyInfo) properties.elementAt(index.intValue());
+            if (propertyInfo.getType()!=SoapObject.class && propertyInfo.getValue()!=null){
+                return propertyInfo.getValue().toString();
+            } else {
+                return EMPTY_STRING;
+            }
+        } else {
+            return EMPTY_STRING;
+        }
+    }
+
+    /**
+     * Knows whether the given property exists
+     */
+    public boolean hasProperty(final String namespace,final String name) {
+        if (propertyIndex(namespace,name) != null) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Get the toString value of the property.
+     *
+     * @param namespace
+     * @param name
+     * @return
+     */
+
+    public String getPropertyAsString(String namespace,String name) {
+        Integer index = propertyIndex(namespace,name);
+        if (index != null) {
+            return getProperty(index.intValue()).toString();
+        } else {
+            throw new RuntimeException("illegal property: " + name);
+        }
+    }
+
     /**
      * Get the toString value of the property.
      *
@@ -301,9 +527,9 @@ public class SoapObject extends AttributeContainer implements KvmSerializable {
      */
     public Object getPrimitiveProperty(final String name) {
         Integer index = propertyIndex(name);
-        if (index != null) {
+        if (index != null){
             PropertyInfo propertyInfo = (PropertyInfo) properties.elementAt(index.intValue());
-            if (propertyInfo.getType() != SoapObject.class) {
+            if (propertyInfo.getType()!=SoapObject.class && propertyInfo.getValue()!=null){
                 return propertyInfo.getValue();
             } else {
                 propertyInfo = new PropertyInfo();
@@ -326,9 +552,9 @@ public class SoapObject extends AttributeContainer implements KvmSerializable {
      */
     public String getPrimitivePropertyAsString(final String name) {
         Integer index = propertyIndex(name);
-        if (index != null) {
+        if (index != null){
             PropertyInfo propertyInfo = (PropertyInfo) properties.elementAt(index.intValue());
-            if (propertyInfo.getType() != SoapObject.class) {
+            if (propertyInfo.getType()!=SoapObject.class && propertyInfo.getValue()!=null){
                 return propertyInfo.getValue().toString();
             } else {
                 return EMPTY_STRING;
@@ -348,9 +574,9 @@ public class SoapObject extends AttributeContainer implements KvmSerializable {
      */
     public Object getPrimitivePropertySafely(final String name) {
         Integer index = propertyIndex(name);
-        if (index != null) {
+        if (index != null){
             PropertyInfo propertyInfo = (PropertyInfo) properties.elementAt(index.intValue());
-            if (propertyInfo.getType() != SoapObject.class) {
+            if (propertyInfo.getType()!=SoapObject.class && propertyInfo.getValue()!=null){
                 return propertyInfo.getValue().toString();
             } else {
                 propertyInfo = new PropertyInfo();
@@ -374,9 +600,9 @@ public class SoapObject extends AttributeContainer implements KvmSerializable {
      */
     public String getPrimitivePropertySafelyAsString(final String name) {
         Integer index = propertyIndex(name);
-        if (index != null) {
+        if (index != null){
             PropertyInfo propertyInfo = (PropertyInfo) properties.elementAt(index.intValue());
-            if (propertyInfo.getType() != SoapObject.class) {
+            if (propertyInfo.getType()!=SoapObject.class && propertyInfo.getValue()!=null){
                 return propertyInfo.getValue().toString();
             } else {
                 return EMPTY_STRING;
@@ -397,6 +623,18 @@ public class SoapObject extends AttributeContainer implements KvmSerializable {
         return null;
     }
 
+
+    private Integer propertyIndex(String namespace,String name) {
+        if (name != null && namespace!=null) {
+            for (int i = 0; i < properties.size(); i++) {
+                PropertyInfo info= (PropertyInfo) properties.elementAt(i);
+                if (name.equals(info.getName()) && namespace.equals(info.getNamespace())) {
+                    return new Integer(i);
+                }
+            }
+        }
+        return null;
+    }
     /**
      * Returns the number of properties
      *
@@ -453,6 +691,17 @@ public class SoapObject extends AttributeContainer implements KvmSerializable {
         }
     }
 
+    public PropertyInfo getPropertyInfo(int index) {
+        Object element = properties.elementAt(index);
+        if (element instanceof PropertyInfo) {
+            PropertyInfo p = (PropertyInfo) element;
+            return p;
+        } else {
+            // SoapObject
+            return null;
+        }
+    }
+
     /**
      * Creates a new SoapObject based on this, allows usage of SoapObjects as
      * templates. One application is to set the expected return type of a soap
@@ -466,17 +715,17 @@ public class SoapObject extends AttributeContainer implements KvmSerializable {
             Object prop = properties.elementAt(propIndex);
             if (prop instanceof PropertyInfo) {
                 PropertyInfo propertyInfo = (PropertyInfo) properties.elementAt(propIndex);
-                PropertyInfo propertyInfoClonned = (PropertyInfo) propertyInfo.clone();
-                o.addProperty(propertyInfoClonned);
-            } else if (prop instanceof SoapObject) {
-                o.addSoapObject(((SoapObject) prop).newInstance());
+                PropertyInfo propertyInfoClonned = (PropertyInfo)propertyInfo.clone();
+                o.addProperty( propertyInfoClonned );
+            } else if(prop instanceof SoapObject) {
+                o.addSoapObject(((SoapObject)prop).newInstance());
             }
         }
         for (int attribIndex = 0; attribIndex < getAttributeCount(); attribIndex++) {
             AttributeInfo newAI = new AttributeInfo();
             getAttributeInfo(attribIndex, newAI);
             AttributeInfo attributeInfo = newAI; // (AttributeInfo)
-                                                 // attributes.elementAt(attribIndex);
+                                                    // attributes.elementAt(attribIndex);
             o.addAttribute(attributeInfo);
         }
         return o;
@@ -513,11 +762,49 @@ public class SoapObject extends AttributeContainer implements KvmSerializable {
         propertyInfo.type = value == null ? PropertyInfo.OBJECT_CLASS : value
                 .getClass();
         propertyInfo.value = value;
+        return addProperty(propertyInfo);
+    }
+
+    /**
+     * Adds a property (parameter) to the object. This is essentially a sub
+     * element.
+     *
+     * @param namespace
+     *            The namespace of the property
+     * @param name
+     *            The name of the property
+     * @param value
+     *            the value of the property
+     */
+    public SoapObject addProperty(String namespace,String name, Object value) {
+        PropertyInfo propertyInfo = new PropertyInfo();
+        propertyInfo.name = name;
         propertyInfo.namespace = namespace;
-        ///M: HS20 modify by Jungo
+        propertyInfo.type = value == null ? PropertyInfo.OBJECT_CLASS : value
+                .getClass();
+        propertyInfo.value = value;
         return addProperty(propertyInfo);
     }
 
+    /**
+     * Add a property only if the value is not null.
+     *
+     * @param namespace
+     *            The namespace of the property
+     * @param name
+     *            The name of the property
+     * @param value
+     *            the value of the property
+     * @return
+     */
+    public SoapObject addPropertyIfValue(String namespace,String name, Object value) {
+        if (value != null) {
+            return addProperty(namespace,name, value);
+        } else {
+            return this;
+        }
+    }
+
     /**
      * Add a property only if the value is not null.
      *
@@ -597,12 +884,12 @@ public class SoapObject extends AttributeContainer implements KvmSerializable {
         StringBuffer buf = new StringBuffer(EMPTY_STRING + name + "{");
         for (int i = 0; i < getPropertyCount(); i++) {
             Object prop = properties.elementAt(i);
-            if (prop instanceof PropertyInfo) {
+            if(prop instanceof PropertyInfo) {
                 buf.append(EMPTY_STRING)
-                        .append(((PropertyInfo) prop).getName())
-                        .append("=")
-                        .append(getProperty(i))
-                        .append("; ");
+                    .append(((PropertyInfo) prop).getName())
+                    .append("=")
+                    .append(getProperty(i))
+                    .append("; ");
             } else {
                 buf.append(((SoapObject) prop).toString());
             }
@@ -610,4 +897,17 @@ public class SoapObject extends AttributeContainer implements KvmSerializable {
         buf.append("}");
         return buf.toString();
     }
+    public Object getInnerText() {
+         return innerText;
+    }
+
+    public void setInnerText(Object innerText)
+    {
+        this.innerText=innerText;
+    }
+
+    public void removePropertyInfo(Object info)
+    {
+        properties.remove(info);
+    }
 }
diff --git a/ksoap2-base/src/main/java/org/ksoap2/serialization/SoapPrimitive.java b/ksoap2-base/src/main/java/org/ksoap2/serialization/SoapPrimitive.java
index d09f7a7..32fe333 100644
--- a/ksoap2-base/src/main/java/org/ksoap2/serialization/SoapPrimitive.java
+++ b/ksoap2-base/src/main/java/org/ksoap2/serialization/SoapPrimitive.java
@@ -34,11 +34,14 @@ package org.ksoap2.serialization;
  */
 
 public class SoapPrimitive extends AttributeContainer {
-    String namespace;
-    String name;
-    String value;
+    protected String namespace;
+    protected String name;
+    protected Object value;
 
-    public SoapPrimitive(String namespace, String name, String value) {
+    public  static final Object NullSkip = new Object();
+    public  static final Object NullNilElement = new Object();
+
+    public SoapPrimitive(String namespace, String name, Object value) {
         this.namespace = namespace;
         this.name = name;
         this.value = value;
@@ -50,7 +53,7 @@ public class SoapPrimitive extends AttributeContainer {
         }
         SoapPrimitive p = (SoapPrimitive) o;
         boolean varsEqual = name.equals(p.name)
-                && (namespace == null ? p.namespace == null : namespace.equals(p.namespace))
+                && (namespace == null ? p.namespace == null:namespace.equals(p.namespace))
                 && (value == null ? (p.value == null) : value.equals(p.value));
         return varsEqual && attributesAreEqual(p);
     }
@@ -60,7 +63,7 @@ public class SoapPrimitive extends AttributeContainer {
     }
 
     public String toString() {
-        return value;
+        return value != null ? value.toString() : null;
     }
 
     public String getNamespace() {
@@ -70,4 +73,9 @@ public class SoapPrimitive extends AttributeContainer {
     public String getName() {
         return name;
     }
+
+    public Object getValue() {
+        return value;
+    }
+
 }
diff --git a/ksoap2-base/src/main/java/org/ksoap2/serialization/SoapSerializationEnvelope.java b/ksoap2-base/src/main/java/org/ksoap2/serialization/SoapSerializationEnvelope.java
index dae09d2..ceeb3f4 100644
--- a/ksoap2-base/src/main/java/org/ksoap2/serialization/SoapSerializationEnvelope.java
+++ b/ksoap2-base/src/main/java/org/ksoap2/serialization/SoapSerializationEnvelope.java
@@ -27,9 +27,9 @@ import org.xmlpull.v1.XmlPullParserException;
 import org.xmlpull.v1.XmlSerializer;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.Vector;
-import java.io.ByteArrayOutputStream;
 
 import org.kxml2.io.*;
 
@@ -43,29 +43,29 @@ public class SoapSerializationEnvelope extends SoapEnvelope
     protected static final int QNAME_TYPE = 1;
     protected static final int QNAME_NAMESPACE = 0;
     protected static final int QNAME_MARSHAL = 3;
+    protected static final String NULL_LABEL = "null";
+    protected static final String NIL_LABEL = "nil";
+    static final Marshal DEFAULT_MARSHAL = new DM();
     private static final String ANY_TYPE_LABEL = "anyType";
     private static final String ARRAY_MAPPING_NAME = "Array";
-    private static final String NULL_LABEL = "null";
-    private static final String NIL_LABEL = "nil";
     private static final String HREF_LABEL = "href";
     private static final String ID_LABEL = "id";
     private static final String ROOT_LABEL = "root";
     private static final String TYPE_LABEL = "type";
     private static final String ITEM_LABEL = "item";
     private static final String ARRAY_TYPE_LABEL = "arrayType";
-    static final Marshal DEFAULT_MARSHAL = new DM();
     public Hashtable properties = new Hashtable();
-
-    Hashtable idMap = new Hashtable();
-    Vector multiRef; // = new Vector();
-
     /**
      * Set this variable to true if you don't want that type definitions for complex types/objects
      * are automatically generated (with type "anyType") in the XML-Request, if you don't call the
      * Method addMapping. This is needed by some Servers which have problems with these type-definitions.
      */
     public boolean implicitTypes;
-
+    /**
+     * If set to true then all properties with null value will be skipped from the soap message.
+     * If false then null properties will be sent as <element nil="true" />
+     */
+    public boolean skipNullProperties;
     /**
      * Set this variable to true for compatibility with what seems to be the default encoding for
      * .Net-Services. This feature is an extremely ugly hack. A much better option is to change the
@@ -96,9 +96,10 @@ public class SoapSerializationEnvelope extends SoapEnvelope
      * Set to true to add and ID and ROOT label to the envelope. Change to false for compatibility with WSDL.
      */
     protected boolean addAdornments = true;
+    Hashtable idMap = new Hashtable();
+    Vector multiRef; // = new Vector();
 
-    public SoapSerializationEnvelope(int version)
-    {
+    public SoapSerializationEnvelope(int version) {
         super(version);
         addMapping(enc, ARRAY_MAPPING_NAME, PropertyInfo.VECTOR_CLASS);
         DEFAULT_MARSHAL.register(this);
@@ -107,23 +108,21 @@ public class SoapSerializationEnvelope extends SoapEnvelope
     /**
      * @return the addAdornments
      */
-    public boolean isAddAdornments()
-    {
+    public boolean isAddAdornments() {
         return addAdornments;
     }
 
     /**
-     * @param addAdornments
-     *            the addAdornments to set
+     * @param addAdornments the addAdornments to set
      */
-    public void setAddAdornments(boolean addAdornments)
-    {
+    public void setAddAdornments(boolean addAdornments) {
         this.addAdornments = addAdornments;
     }
 
     /**
      * Set the bodyOut to be empty so that no un-needed xml is create. The null value for bodyOut will
      * cause #writeBody to skip writing anything redundant.
+     *
      * @param emptyBody
      * @see "http://code.google.com/p/ksoap2-android/issues/detail?id=77"
      */
@@ -133,8 +132,7 @@ public class SoapSerializationEnvelope extends SoapEnvelope
         }
     }
 
-    public void parseBody(XmlPullParser parser) throws IOException, XmlPullParserException
-    {
+    public void parseBody(XmlPullParser parser) throws IOException, XmlPullParserException {
         bodyIn = null;
         parser.nextTag();
         if (parser.getEventType() == XmlPullParser.START_TAG && parser.getNamespace().equals(env)
@@ -161,10 +159,11 @@ public class SoapSerializationEnvelope extends SoapEnvelope
         }
     }
 
-    /** Read a SoapObject. This extracts any attributes and then reads the object as a KvmSerializable. */
+    /**
+     * Read a SoapObject. This extracts any attributes and then reads the object as a KvmSerializable.
+     */
     protected void readSerializable(XmlPullParser parser, SoapObject obj) throws IOException,
-            XmlPullParserException
-    {
+            XmlPullParserException {
         for (int counter = 0; counter < parser.getAttributeCount(); counter++) {
             String attributeName = parser.getAttributeName(counter);
             String value = parser.getAttributeValue(counter);
@@ -173,11 +172,21 @@ public class SoapSerializationEnvelope extends SoapEnvelope
         readSerializable(parser, (KvmSerializable) obj);
     }
 
-    /** Read a KvmSerializable. */
+    /**
+     * Read a KvmSerializable.
+     */
     protected void readSerializable(XmlPullParser parser, KvmSerializable obj) throws IOException,
-            XmlPullParserException
-    {
-        while (parser.nextTag() != XmlPullParser.END_TAG) {
+            XmlPullParserException {
+        int tag = 0;
+        try {
+            tag = parser.nextTag();
+        } catch (XmlPullParserException e) {
+            if(obj instanceof HasInnerText){
+                 ((HasInnerText)obj).setInnerText((parser.getText() != null) ? parser.getText() : "");
+            }
+            tag = parser.nextTag();
+        }
+        while (tag != XmlPullParser.END_TAG) {
             String name = parser.getName();
             if (!implicitTypes || !(obj instanceof SoapObject)) {
                 PropertyInfo info = new PropertyInfo();
@@ -188,8 +197,7 @@ public class SoapSerializationEnvelope extends SoapEnvelope
                     info.clear();
                     obj.getPropertyInfo(i, properties, info);
 
-                    if ((name.equals(info.name) && info.namespace == null)
-                            ||
+                    if ((name.equals(info.name) && info.namespace == null) ||
                             (name.equals(info.name) && parser.getNamespace().equals(info.namespace))) {
                         propertyFound = true;
                         obj.setProperty(i, read(parser, obj, i, null, null, info));
@@ -199,21 +207,42 @@ public class SoapSerializationEnvelope extends SoapEnvelope
                 if (!propertyFound) {
                     if (avoidExceptionForUnknownProperty) {
                         // Dummy loop to read until corresponding END tag
-                        while (parser.next() != XmlPullParser.END_TAG
-                                || !name.equals(parser.getName())) {
+                        while (parser.next() != XmlPullParser.END_TAG || !name.equals(parser.getName())) {
                         }
                         ;
                     } else {
                         throw new RuntimeException("Unknown Property: " + name);
                     }
+                } else {
+                    if (obj instanceof HasAttributes) {
+                        HasAttributes soapObject = (HasAttributes) obj;
+                        int cnt = parser.getAttributeCount();
+                        for (int counter = 0; counter < cnt; counter++) {
+                            AttributeInfo attributeInfo = new AttributeInfo();
+                            attributeInfo.setName(parser.getAttributeName(counter));
+                            attributeInfo.setValue(parser.getAttributeValue(counter));
+                            attributeInfo.setNamespace(parser.getAttributeNamespace(counter));
+                            attributeInfo.setType(parser.getAttributeType(counter));
+                            soapObject.setAttribute(attributeInfo);
+
+                        }
+                    }
                 }
             } else {
                 // I can only make this work for SoapObjects - hence the check above
                 // I don't understand namespaces well enough to know whether it is correct in the next line...
-                ((SoapObject) obj).addProperty(parser.getName(),
-                        read(parser, obj, obj.getPropertyCount(),
-                                ((SoapObject) obj).getNamespace(), name, PropertyInfo.OBJECT_TYPE));
+                ((SoapObject) obj).addProperty(parser.getName(), read(parser, obj, obj.getPropertyCount(),
+                        ((SoapObject) obj).getNamespace(), name, PropertyInfo.OBJECT_TYPE));
+            }
+            try {
+                tag = parser.nextTag();
+            } catch (XmlPullParserException e) {
+                if(obj instanceof HasInnerText){
+                    ((HasInnerText)obj).setInnerText((parser.getText() != null) ? parser.getText() : "");
+                }
+                tag = parser.nextTag();
             }
+
         }
         parser.require(XmlPullParser.END_TAG, null, null);
     }
@@ -278,9 +307,8 @@ public class SoapSerializationEnvelope extends SoapEnvelope
             }
 
             while (parser.getEventType() != XmlPullParser.END_TAG) {
-                so.addProperty(parser.getName(),
-                        read(parser, so, so.getPropertyCount(), null, null,
-                                PropertyInfo.OBJECT_TYPE));
+                so.addProperty(parser.getNamespace(),parser.getName(), read(parser, so, so.getPropertyCount(),
+                        null, null, PropertyInfo.OBJECT_TYPE));
                 parser.nextTag();
             }
             result = so;
@@ -293,12 +321,15 @@ public class SoapSerializationEnvelope extends SoapEnvelope
         if (value == null) {
             return dflt;
         }
-        return value.length() - start < 3 ? dflt : Integer.parseInt(value.substring(start + 1,
-                value.length() - 1));
+        try {
+            return value.length() - start < 3 ? dflt : Integer.parseInt(value.substring(start + 1,
+                    value.length() - 1));
+        } catch (Exception ex) {
+            return dflt;
+        }
     }
 
-    protected void readVector(XmlPullParser parser, Vector v, PropertyInfo elementType)
-            throws IOException,
+    protected void readVector(XmlPullParser parser, Vector v, PropertyInfo elementType) throws IOException,
             XmlPullParserException {
         String namespace = null;
         String name = null;
@@ -337,14 +368,23 @@ public class SoapSerializationEnvelope extends SoapEnvelope
         parser.require(XmlPullParser.END_TAG, null, null);
     }
 
+    /**
+     * This method returns id from the href attribute value.
+     * By default we assume that href value looks like this: #id so we basically have to remove the first character.
+     * But in theory there could be a different value format, like cid:value, etc...
+     */
+    protected String getIdFromHref(String hrefValue) {
+        return hrefValue.substring(1);
+    }
+
     /**
      * Builds an object from the XML stream. This method is public for usage in conjuction with Marshal
      * subclasses. Precondition: On the start tag of the object or property, so href can be read.
      */
 
-    public Object read(XmlPullParser parser, Object owner, int index, String namespace,
-            String name,
-            PropertyInfo expected) throws IOException, XmlPullParserException {
+    public Object read(XmlPullParser parser, Object owner, int index, String namespace, String name, 
+            PropertyInfo expected) 
+            throws IOException, XmlPullParserException {
         String elementName = parser.getName();
         String href = parser.getAttributeValue(null, HREF_LABEL);
         Object obj;
@@ -352,7 +392,7 @@ public class SoapSerializationEnvelope extends SoapEnvelope
             if (owner == null) {
                 throw new RuntimeException("href at root level?!?");
             }
-            href = href.substring(1);
+            href = getIdFromHref(href);
             obj = idMap.get(href);
             if (obj == null || obj instanceof FwdRef) {
                 FwdRef f = new FwdRef();
@@ -402,21 +442,8 @@ public class SoapSerializationEnvelope extends SoapEnvelope
             }
             // finally, care about the id....
             if (id != null) {
-                Object hlp = idMap.get(id);
-                if (hlp instanceof FwdRef) {
-                    FwdRef f = (FwdRef) hlp;
-                    do {
-                        if (f.obj instanceof KvmSerializable) {
-                            ((KvmSerializable) f.obj).setProperty(f.index, obj);
-                        } else {
-                            ((Vector) f.obj).setElementAt(obj, f.index);
-                        }
-                        f = f.next;
-                    } while (f != null);
-                } else if (hlp != null) {
-                    throw new RuntimeException("double ID");
-                }
-                idMap.put(id, obj);
+                resolveReference(id, obj);
+
             }
         }
 
@@ -424,12 +451,30 @@ public class SoapSerializationEnvelope extends SoapEnvelope
         return obj;
     }
 
+    protected void resolveReference(String id, Object obj) {
+        Object hlp = idMap.get(id);
+        if (hlp instanceof FwdRef) {
+            FwdRef f = (FwdRef) hlp;
+            do {
+                if (f.obj instanceof KvmSerializable) {
+                    ((KvmSerializable) f.obj).setProperty(f.index, obj);
+                } else {
+                    ((Vector) f.obj).setElementAt(obj, f.index);
+                }
+                f = f.next;
+            }
+            while (f != null);
+        } else if (hlp != null) {
+            throw new RuntimeException("double ID");
+        }
+        idMap.put(id, obj);
+    }
+
     /**
      * Returns a new object read from the given parser. If no mapping is found, null is returned. This method
      * is used by the SoapParser in order to convert the XML code to Java objects.
      */
-    public Object readInstance(XmlPullParser parser, String namespace, String name,
-            PropertyInfo expected)
+    public Object readInstance(XmlPullParser parser, String namespace, String name, PropertyInfo expected)
             throws IOException, XmlPullParserException {
         Object obj = qNameToClass.get(new SoapPrimitive(namespace, name, null));
         if (obj == null) {
@@ -448,10 +493,30 @@ public class SoapSerializationEnvelope extends SoapEnvelope
                 throw new RuntimeException(e.toString());
             }
         }
+        if (obj instanceof HasAttributes) {
+            HasAttributes soapObject = (HasAttributes) obj;
+            int cnt = parser.getAttributeCount();
+            for (int counter = 0; counter < cnt; counter++) {
+
+                AttributeInfo attributeInfo = new AttributeInfo();
+                attributeInfo.setName(parser.getAttributeName(counter));
+                attributeInfo.setValue(parser.getAttributeValue(counter));
+                attributeInfo.setNamespace(parser.getAttributeNamespace(counter));
+                attributeInfo.setType(parser.getAttributeType(counter));
+
+                soapObject.setAttribute(attributeInfo);
+
+            }
+        }
+
         // ok, obj is now the instance, fill it....
         if (obj instanceof SoapObject) {
             readSerializable(parser, (SoapObject) obj);
         } else if (obj instanceof KvmSerializable) {
+
+            if(obj instanceof HasInnerText){
+                ((HasInnerText)obj).setInnerText((parser.getText() != null) ? parser.getText() : "");
+            }
             readSerializable(parser, (KvmSerializable) obj);
         } else if (obj instanceof Vector) {
             readVector(parser, (Vector) obj, expected.elementType);
@@ -476,15 +541,11 @@ public class SoapSerializationEnvelope extends SoapEnvelope
         }
         if (type instanceof SoapObject) {
             SoapObject so = (SoapObject) type;
-            return new Object[] {
-                    so.getNamespace(), so.getName(), null, null
-            };
+            return new Object[]{so.getNamespace(), so.getName(), null, null};
         }
         if (type instanceof SoapPrimitive) {
             SoapPrimitive sp = (SoapPrimitive) type;
-            return new Object[] {
-                    sp.getNamespace(), sp.getName(), null, DEFAULT_MARSHAL
-            };
+            return new Object[]{sp.getNamespace(), sp.getName(), null, DEFAULT_MARSHAL};
         }
         if ((type instanceof Class) && type != PropertyInfo.OBJECT_CLASS) {
             Object[] tmp = (Object[]) classToQName.get(((Class) type).getName());
@@ -492,9 +553,7 @@ public class SoapSerializationEnvelope extends SoapEnvelope
                 return tmp;
             }
         }
-        return new Object[] {
-                xsd, ANY_TYPE_LABEL, null, null
-        };
+        return new Object[]{xsd, ANY_TYPE_LABEL, null, null};
     }
 
     /**
@@ -503,11 +562,8 @@ public class SoapSerializationEnvelope extends SoapEnvelope
      */
     public void addMapping(String namespace, String name, Class clazz, Marshal marshal) {
         qNameToClass
-                .put(new SoapPrimitive(namespace, name, null), marshal == null ? (Object) clazz
-                        : marshal);
-        classToQName.put(clazz.getName(), new Object[] {
-                namespace, name, null, marshal
-        });
+                .put(new SoapPrimitive(namespace, name, null), marshal == null ? (Object) clazz : marshal);
+        classToQName.put(clazz.getName(), new Object[]{namespace, name, null, marshal});
     }
 
     /**
@@ -528,11 +584,14 @@ public class SoapSerializationEnvelope extends SoapEnvelope
     /**
      * Response from the soap call. Pulls the object from the wrapper object and returns it.
      *
-     * @since 2.0.3
      * @return response from the soap call.
      * @throws SoapFault
+     * @since 2.0.3
      */
     public Object getResponse() throws SoapFault {
+        if (bodyIn == null) {
+            return null;
+        }
         if (bodyIn instanceof SoapFault) {
             throw (SoapFault) bodyIn;
         }
@@ -554,8 +613,7 @@ public class SoapSerializationEnvelope extends SoapEnvelope
     /**
      * Serializes the request object to the given XmlSerliazer object
      *
-     * @param writer
-     *            XmlSerializer object to write the body into.
+     * @param writer XmlSerializer object to write the body into.
      */
     public void writeBody(XmlSerializer writer) throws IOException {
         // allow an empty body without any tags in it
@@ -564,36 +622,48 @@ public class SoapSerializationEnvelope extends SoapEnvelope
             multiRef = new Vector();
             multiRef.addElement(bodyOut);
             Object[] qName = getInfo(null, bodyOut);
-            writer.startTag((dotNet) ? "" : (String) qName[QNAME_NAMESPACE],
-                    (String) qName[QNAME_TYPE]); //<spp:sppPostDevData
-            if (dotNet) {
-                writer.attribute(null, "xmlns", (String) qName[QNAME_NAMESPACE]);
-            }
+            
+            writer.startTag((dotNet) ? "" : (String) qName[QNAME_NAMESPACE], (String) qName[QNAME_TYPE]);
+            
+                if (dotNet) {
+                    writer.attribute(null, "xmlns", (String) qName[QNAME_NAMESPACE]);
+                }
+
             if (addAdornments) {
                 writer.attribute(null, ID_LABEL, qName[2] == null ? ("o" + 0) : (String) qName[2]);
                 writer.attribute(enc, ROOT_LABEL, "1");
             }
-            writeElement(writer, bodyOut, null, qName[QNAME_MARSHAL]); //....
-            writer.endTag((dotNet) ? "" : (String) qName[QNAME_NAMESPACE],
-                    (String) qName[QNAME_TYPE]);//</spp:sppPostDevData>
+            writeElement(writer, bodyOut, null, qName[QNAME_MARSHAL]);
+            writer.endTag((dotNet) ? "" : (String) qName[QNAME_NAMESPACE], (String) qName[QNAME_TYPE]);
         }
     }
 
-    /**
-     * Writes the body of an SoapObject. This method write the attributes and then calls
-     * "writeObjectBody (writer, (KvmSerializable)obj);"
-     */
-    public void writeObjectBody(XmlSerializer writer, SoapObject obj) throws IOException {
-        SoapObject soapObject = (SoapObject) obj;
+    private void writeAttributes(XmlSerializer writer, HasAttributes obj) throws IOException {
+        HasAttributes soapObject = (HasAttributes) obj;
         int cnt = soapObject.getAttributeCount();
         for (int counter = 0; counter < cnt; counter++) {
             AttributeInfo attributeInfo = new AttributeInfo();
             soapObject.getAttributeInfo(counter, attributeInfo);
-            writer.attribute(attributeInfo.getNamespace(), attributeInfo.getName(), attributeInfo
-                    .getValue()
-                    .toString());
+            soapObject.getAttribute(counter, attributeInfo);
+            if (attributeInfo.getValue() != null) {
+                writer.attribute(attributeInfo.getNamespace(), attributeInfo.getName(),
+                        attributeInfo.getValue().toString());
+            }
+        }
+    }
+
+    public void writeArrayListBodyWithAttributes(XmlSerializer writer, KvmSerializable obj) throws IOException {
+        if (obj instanceof HasAttributes) {
+            writeAttributes(writer, (HasAttributes) obj);
         }
-        writeObjectBody(writer, (KvmSerializable) obj);
+        writeArrayListBody(writer, (ArrayList) obj);
+    }
+
+    public void writeObjectBodyWithAttributes(XmlSerializer writer, KvmSerializable obj) throws IOException {
+        if (obj instanceof HasAttributes) {
+            writeAttributes(writer, (HasAttributes) obj);
+        }
+        writeObjectBody(writer, obj);
     }
 
     /**
@@ -614,9 +684,12 @@ public class SoapSerializationEnvelope extends SoapEnvelope
             if (!(prop instanceof SoapObject)) {
                 // prop is a PropertyInfo
                 if ((propertyInfo.flags & PropertyInfo.TRANSIENT) == 0) {
-                    writer.startTag(propertyInfo.namespace, propertyInfo.name);
-                    writeProperty(writer, obj.getProperty(i), propertyInfo);
-                    writer.endTag(propertyInfo.namespace, propertyInfo.name);
+                    Object objValue = obj.getProperty(i);
+                    if ((prop != null || !skipNullProperties) && (objValue != SoapPrimitive.NullSkip)) {
+                        writer.startTag(propertyInfo.namespace, propertyInfo.name);
+                        writeProperty(writer, objValue, propertyInfo);
+                        writer.endTag(propertyInfo.namespace, propertyInfo.name);
+                    }
                 }
             } else {
                 // prop is a SoapObject
@@ -633,46 +706,47 @@ public class SoapSerializationEnvelope extends SoapEnvelope
                     name = (String) qName[QNAME_TYPE];
                 }
 
-                // treat MO data as CDATA
-                if (name.equals("DevInfo") || name.equals("DevDetail")
-                        || name.equals("PerProviderSubscription") || // format v4
-                        name.equals("MgmtTree") // format v6
-                ) {
-                    ByteArrayOutputStream bos = new ByteArrayOutputStream();
-                    XmlSerializer xw = new KXmlSerializer();
-                    xw.setOutput(bos, "UTF-8");
-                    xw.startTag((dotNet) ? "" : namespace, name);
-                    if (!implicitTypes) {
-                        String prefix = writer.getPrefix(namespace, true);
-                        writer.attribute(xsi, TYPE_LABEL, prefix + ":" + type);
-                    }
-                    writeObjectBody(xw, nestedSoap);
-                    xw.endTag((dotNet) ? "" : namespace, name);
-                    xw.flush();
-                    //bos.write('\r');
-                    //bos.write('\n');
-                    bos.flush();
-                    writer.cdsect(bos.toString());
+                // prefer the namespace from the property info
+                if (propertyInfo.namespace != null && propertyInfo.namespace.length() > 0) {
+                    namespace = propertyInfo.namespace;
+                } else {
+                    namespace = (String) qName[QNAME_NAMESPACE];
+                }
+
+                writer.startTag(namespace, name);
+                if (!implicitTypes) {
+                    String prefix = writer.getPrefix(namespace, true);
+                    writer.attribute(xsi, TYPE_LABEL, prefix + ":" + type);
+                }
+                writeObjectBodyWithAttributes(writer, nestedSoap);
+                writer.endTag(namespace, name);
+            }
+        }
+        writeInnerText(writer, obj);
+
+    }
+
+    private void writeInnerText(XmlSerializer writer, KvmSerializable obj) throws IOException {
+        if(obj instanceof HasInnerText){
+
+            Object value=((HasInnerText)obj).getInnerText();
+            if (value != null) {
+                if(value instanceof ValueWriter)
+                {
+                    ((ValueWriter)value).write(writer);
                 }
                 else
                 {
-                    writer.startTag((dotNet) ? "" : namespace, name);
-                    if (!implicitTypes) {
-                        String prefix = writer.getPrefix(namespace, true);
-                        writer.attribute(xsi, TYPE_LABEL, prefix + ":" + type);
-                    }
-                    writeObjectBody(writer, nestedSoap);
-                    writer.endTag((dotNet) ? "" : namespace, name);
+                    writer.cdsect(value.toString());
                 }
+
             }
         }
     }
 
-    protected void writeProperty(XmlSerializer writer, Object obj, PropertyInfo type)
-            throws IOException {
-        if (obj == null) {
-            ///M: Modify for HS20
-            //writer.attribute(xsi, version >= VER12 ? NIL_LABEL : NULL_LABEL, "true");
+    protected void writeProperty(XmlSerializer writer, Object obj, PropertyInfo type) throws IOException {
+        if (obj == null || obj == SoapPrimitive.NullNilElement) {
+            writer.attribute(xsi, version >= VER12 ? NIL_LABEL : NULL_LABEL, "true");
             return;
         }
         Object[] qName = getInfo(null, obj);
@@ -692,15 +766,19 @@ public class SoapSerializationEnvelope extends SoapEnvelope
         }
     }
 
-    private void writeElement(XmlSerializer writer, Object element, PropertyInfo type,
-            Object marshal)
+    protected void writeElement(XmlSerializer writer, Object element, PropertyInfo type, Object marshal)
             throws IOException {
         if (marshal != null) {
             ((Marshal) marshal).writeInstance(writer, element);
-        } else if (element instanceof SoapObject) {
-            writeObjectBody(writer, (SoapObject) element);
-        } else if (element instanceof KvmSerializable) {
-            writeObjectBody(writer, (KvmSerializable) element);
+        } else if (element instanceof KvmSerializable || element == SoapPrimitive.NullNilElement
+                || element == SoapPrimitive.NullSkip) {
+            if (element instanceof ArrayList) {
+                writeArrayListBodyWithAttributes(writer, (KvmSerializable) element);
+            } else {
+                writeObjectBodyWithAttributes(writer, (KvmSerializable) element);
+            }
+        } else if (element instanceof HasAttributes) {
+            writeAttributes(writer, (HasAttributes) element);
         } else if (element instanceof Vector) {
             writeVectorBody(writer, (Vector) element, type.elementType);
         } else {
@@ -708,6 +786,65 @@ public class SoapSerializationEnvelope extends SoapEnvelope
         }
     }
 
+    protected void writeArrayListBody(XmlSerializer writer, ArrayList list)
+            throws IOException {
+        KvmSerializable obj = (KvmSerializable) list;
+        int cnt = list.size();
+        PropertyInfo propertyInfo = new PropertyInfo();
+        String namespace;
+        String name;
+        String type;
+        for (int i = 0; i < cnt; i++) {
+            // get the property
+            Object prop = obj.getProperty(i);
+            // and importantly also get the property info which holds the name potentially!
+            obj.getPropertyInfo(i, properties, propertyInfo);
+
+            if (!(prop instanceof SoapObject)) {
+                // prop is a PropertyInfo
+                if ((propertyInfo.flags & PropertyInfo.TRANSIENT) == 0) {
+                    Object objValue = obj.getProperty(i);
+                    if ((prop != null || !skipNullProperties) && (objValue != SoapPrimitive.NullSkip)) {
+                        writer.startTag(propertyInfo.namespace, propertyInfo.name);
+                        writeProperty(writer, objValue, propertyInfo);
+                        writer.endTag(propertyInfo.namespace, propertyInfo.name);
+                    }
+                }
+            } else {
+
+                // prop is a SoapObject
+                SoapObject nestedSoap = (SoapObject) prop;
+                // lets get the info from the soap object itself
+                Object[] qName = getInfo(null, nestedSoap);
+                namespace = (String) qName[QNAME_NAMESPACE];
+                type = (String) qName[QNAME_TYPE];
+
+                // prefer the name from the property info
+                if (propertyInfo.name != null && propertyInfo.name.length() > 0) {
+                    name = propertyInfo.name;
+                } else {
+                    name = (String) qName[QNAME_TYPE];
+                }
+
+                // prefer the namespace from the property info
+                if (propertyInfo.namespace != null && propertyInfo.namespace.length() > 0) {
+                    namespace = propertyInfo.namespace;
+                } else {
+                    namespace = (String) qName[QNAME_NAMESPACE];
+                }
+
+                writer.startTag(namespace, name);
+                if (!implicitTypes) {
+                    String prefix = writer.getPrefix(namespace, true);
+                    writer.attribute(xsi, TYPE_LABEL, prefix + ":" + type);
+                }
+                writeObjectBodyWithAttributes(writer, nestedSoap);
+                writer.endTag(namespace, name);
+            }
+        }
+        writeInnerText(writer, obj);
+    }
+
     protected void writeVectorBody(XmlSerializer writer, Vector vector, PropertyInfo elementType)
             throws IOException {
         String itemsTagName = ITEM_LABEL;
@@ -727,9 +864,13 @@ public class SoapSerializationEnvelope extends SoapEnvelope
 
         // This removes the arrayType attribute from the xml for arrays(required for most .Net services to work)
         if (!implicitTypes) {
-            writer.attribute(enc, ARRAY_TYPE_LABEL, writer.getPrefix((String) arrType[0], false)
-                    + ":"
+            writer.attribute(enc, ARRAY_TYPE_LABEL, writer.getPrefix((String) arrType[0], false) + ":"
                     + arrType[1] + "[" + cnt + "]");
+        } else {
+            // Get the namespace from mappings if available when arrayType is removed for .Net
+            if (itemsNamespace == null) {
+                itemsNamespace = (String) arrType[0];
+            }
         }
 
         boolean skipped = false;
diff --git a/ksoap2-base/src/main/java/org/ksoap2/serialization/ValueWriter.java b/ksoap2-base/src/main/java/org/ksoap2/serialization/ValueWriter.java
new file mode 100644
index 0000000..fdbaa21
--- /dev/null
+++ b/ksoap2-base/src/main/java/org/ksoap2/serialization/ValueWriter.java
@@ -0,0 +1,13 @@
+package org.ksoap2.serialization;
+
+import org.xmlpull.v1.XmlSerializer;
+
+import java.io.IOException;
+
+/**
+ * Created by robocik on 2015-09-25.
+ */
+public interface ValueWriter
+{
+    void write(XmlSerializer writer) throws IOException;
+}
diff --git a/ksoap2-base/src/main/java/org/ksoap2/transport/ServiceConnection.java b/ksoap2-base/src/main/java/org/ksoap2/transport/ServiceConnection.java
index 8e14ee7..9dd3837 100644
--- a/ksoap2-base/src/main/java/org/ksoap2/transport/ServiceConnection.java
+++ b/ksoap2-base/src/main/java/org/ksoap2/transport/ServiceConnection.java
@@ -21,8 +21,10 @@
 
 package org.ksoap2.transport;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.List;
-import java.io.*;
 
 /**
  * Interface to allow the abstraction of the raw transport information
@@ -58,6 +60,13 @@ public interface ServiceConnection {
      */
     public List getResponseProperties() throws IOException;
 
+    /**
+     * Returns the numerical HTTP status to the caller
+     * @return an integer status value
+     * @throws IOException
+     */
+    public int getResponseCode() throws IOException;
+
     /**
      * Set properties on the outgoing connection.
      * 
@@ -88,6 +97,8 @@ public interface ServiceConnection {
      **/
     public void setFixedLengthStreamingMode(int contentLength);
 
+    public void setChunkedStreamingMode();
+
     /**
      * Open and return the outputStream to the endpoint.
      * 
diff --git a/ksoap2-base/src/main/java/org/ksoap2/transport/Transport.java b/ksoap2-base/src/main/java/org/ksoap2/transport/Transport.java
index b2f6587..2f3d523 100644
--- a/ksoap2-base/src/main/java/org/ksoap2/transport/Transport.java
+++ b/ksoap2-base/src/main/java/org/ksoap2/transport/Transport.java
@@ -23,9 +23,13 @@
 
 package org.ksoap2.transport;
 
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.io.*;
+import java.net.MalformedURLException;
 import java.net.Proxy;
+import java.net.URL;
 
 import org.ksoap2.*;
 import org.kxml2.io.*;
@@ -40,9 +44,9 @@ import org.xmlpull.v1.*;
 abstract public class Transport {
 
     /**
-     * Added to enable web service interactions on the emulator
-     * to be debugged with Fiddler2 (Windows) but provides utility
-     * for other proxy requirements.
+     * Added to enable web service interactions on the emulator to be debugged
+     * with Fiddler2 (Windows) but provides utility for other proxy
+     * requirements.
      */
     protected Proxy proxy;
     protected String url;
@@ -61,6 +65,12 @@ abstract public class Transport {
 
     private int bufferLength = ServiceConnection.DEFAULT_BUFFER_SIZE;
 
+    private HashMap prefixes = new HashMap();
+
+    public HashMap getPrefixes() {
+        return prefixes;
+    }
+
     public Transport() {
     }
 
@@ -82,9 +92,12 @@ abstract public class Transport {
     /**
      * Construct the transport object
      * 
-     * @param proxy Specifies the proxy server to use for 
-     * accessing the web service or <code>null</code> if a direct connection is available
-     * @param url Specifies the web service url
+     * @param proxy
+     *            Specifies the proxy server to use for accessing the web
+     *            service or <code>null</code> if a direct connection is
+     *            available
+     * @param url
+     *            Specifies the web service url
      * 
      */
     public Transport(Proxy proxy, String url) {
@@ -114,23 +127,30 @@ abstract public class Transport {
         xp.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
         xp.setInput(is, null);
         envelope.parse(xp);
+        /*
+         * Fix memory leak when running on android in strict mode. Issue 133
+         */
+        is.close();
     }
 
     /**
      * Serializes the request.
      */
-    protected byte[] createRequestData(SoapEnvelope envelope, String encoding) throws IOException {
-        System.out.println("createRequestData");
+    protected byte[] createRequestData(SoapEnvelope envelope, String encoding)
+            throws IOException {
         ByteArrayOutputStream bos = new ByteArrayOutputStream(bufferLength);
         byte result[] = null;
         bos.write(xmlVersionTag.getBytes());
-        System.out.println("bos.write");
         XmlSerializer xw = new KXmlSerializer();
-        System.out.println("new KXmlSerializer");
+
+        final Iterator keysIter = prefixes.keySet().iterator();
+
         xw.setOutput(bos, encoding);
-        System.out.println("xw.setOutput");
+        while (keysIter.hasNext()) {
+            String key = (String) keysIter.next();
+            xw.setPrefix(key, (String) prefixes.get(key));
+        }
         envelope.write(xw);
-        System.out.println("envelope.write");
         xw.flush();
         bos.write('\r');
         bos.write('\n');
@@ -138,14 +158,14 @@ abstract public class Transport {
         result = bos.toByteArray();
         xw = null;
         bos = null;
-        System.out.println("createRequestData end");
         return result;
     }
 
     /**
      * Serializes the request.
      */
-    protected byte[] createRequestData(SoapEnvelope envelope) throws IOException {
+    protected byte[] createRequestData(SoapEnvelope envelope)
+            throws IOException {
         return createRequestData(envelope, null);
     }
 
@@ -159,6 +179,12 @@ abstract public class Transport {
         this.url = url;
     }
 
+    public String getUrl()
+    {
+        return url;
+    }
+
+
     /**
      * Sets the version tag for the outgoing soap call. Example <?xml
      * version=\"1.0\" encoding=\"UTF-8\"?>
@@ -177,57 +203,94 @@ abstract public class Transport {
     }
 
     /**
-     * Perform a soap call with a given namespace and the given envelope providing
-     * any extra headers that the user requires such as cookies. Headers that are
-     * returned by the web service will be returned to the caller in the form of a
-     * <code>List</code> of <code>HeaderProperty</code> instances.
+     * Perform a soap call with a given namespace and the given envelope
+     * providing any extra headers that the user requires such as cookies.
+     * Headers that are returned by the web service will be returned to the
+     * caller in the form of a <code>List</code> of <code>HeaderProperty</code>
+     * instances.
+     * 
+     * @param soapAction
+     *            the namespace with which to perform the call in.
+     * @param envelope
+     *            the envelope the contains the information for the call.
+     * @param headers
+     *            <code>List</code> of <code>HeaderProperty</code> headers to
+     *            send with the SOAP request.
+     * 
+     * @return Headers returned by the web service as a <code>List</code> of
+     *         <code>HeaderProperty</code> instances.
+     */
+    abstract public List call(String soapAction, SoapEnvelope envelope,
+            List headers) throws IOException, XmlPullParserException;
+
+    /**
+     * Perform a soap call with a given namespace and the given envelope
+     * providing any extra headers that the user requires such as cookies.
+     * Headers that are returned by the web service will be returned to the
+     * caller in the form of a <code>List</code> of <code>HeaderProperty</code>
+     * instances.
      * 
-     * @param targetNamespace
+     * @param soapAction
      *            the namespace with which to perform the call in.
      * @param envelope
      *            the envelope the contains the information for the call.
      * @param headers
-     *   <code>List</code> of <code>HeaderProperty</code> headers to send with the SOAP request.
+     *            <code>List</code> of <code>HeaderProperty</code> headers to
+     *            send with the SOAP request.
+     * @param outputFile
+     *            a file to stream the response into rather than parsing it,
+     *            streaming happens when file is not null
      * 
      * @return Headers returned by the web service as a <code>List</code> of
-     * <code>HeaderProperty</code> instances.
+     *         <code>HeaderProperty</code> instances.
      */
-    abstract public List call(String targetNamespace, SoapEnvelope envelope, List headers)
-            throws IOException, XmlPullParserException;
+    abstract public List call(String soapAction, SoapEnvelope envelope,
+            List headers, File outputFile) throws IOException,
+            XmlPullParserException;
 
     /**
      * Perform a soap call with a given namespace and the given envelope.
      * 
-     * @param targetNamespace
+     * @param soapAction
      *            the namespace with which to perform the call in.
      * @param envelope
      *            the envelope the contains the information for the call.
      */
-    public void call(String targetNamespace, SoapEnvelope envelope) throws IOException,
-            XmlPullParserException {
-        call(targetNamespace, envelope, null);
+    public void call(String soapAction, SoapEnvelope envelope)
+            throws IOException, XmlPullParserException {
+        call(soapAction, envelope, null);
     }
 
     /**
      * Return the name of the host that is specified as the web service target
-     *
+     * 
      * @return Host name
      */
-    abstract public String getHost();
+    public String getHost() throws MalformedURLException {
+
+        return new URL(url).getHost();
+    }
 
     /**
-     * Return the port number of the host that is specified as the web service target
-     *
+     * Return the port number of the host that is specified as the web service
+     * target
+     * 
      * @return Port number
      */
-    abstract public int getPort();
+    public int getPort() throws MalformedURLException {
+
+        return new URL(url).getPort();
+    }
 
     /**
      * Return the path to the web service target
-     *
+     * 
      * @return The URL's path
      */
-    abstract public String getPath();
+    public String getPath() throws MalformedURLException {
+
+        return new URL(url).getPath();
+    }
 
     abstract public ServiceConnection getServiceConnection() throws IOException;
 }
diff --git a/ksoap2-j2se/src/main/java/org/ksoap2/serialization/MarshalFloat.java b/ksoap2-j2se/src/main/java/org/ksoap2/serialization/MarshalFloat.java
index 71c8caa..61a5e2c 100644
--- a/ksoap2-j2se/src/main/java/org/ksoap2/serialization/MarshalFloat.java
+++ b/ksoap2-j2se/src/main/java/org/ksoap2/serialization/MarshalFloat.java
@@ -27,8 +27,7 @@ import org.xmlpull.v1.*;
 
 public class MarshalFloat implements Marshal {
 
-    public Object readInstance(XmlPullParser parser, String namespace, String name,
-            PropertyInfo propertyInfo)
+    public Object readInstance(XmlPullParser parser, String namespace, String name, PropertyInfo propertyInfo)
             throws IOException, XmlPullParserException {
         String stringValue = parser.nextText();
         Object result;
diff --git a/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpResponseException.java b/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpResponseException.java
new file mode 100644
index 0000000..f7fb866
--- /dev/null
+++ b/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpResponseException.java
@@ -0,0 +1,60 @@
+package org.ksoap2.transport;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * HttpResponseException is an IOException that is to be thrown when a Http response code is different from 200.
+ * It allows for easier retrieval of the Http response code from the connection.
+ *
+ * @author Rui Pereira <syshex@gmail.com>
+ */
+public class HttpResponseException extends IOException {
+
+    private int statusCode;
+    private List responseHeaders;
+
+    public HttpResponseException(int statusCode) {
+        super();
+        this.statusCode = statusCode;
+    }
+
+    public HttpResponseException(String detailMessage, int statusCode) {
+        super(detailMessage);
+        this.statusCode = statusCode;
+    }
+
+    public HttpResponseException(String detailMessage, int statusCode,List responseHeaders) {
+        super(detailMessage);
+        this.statusCode = statusCode;
+        this.responseHeaders=responseHeaders;
+    }
+
+    public HttpResponseException(String message, Throwable cause, int statusCode) {
+        super(message, cause);
+        this.statusCode = statusCode;
+    }
+
+    public HttpResponseException(Throwable cause, int statusCode) {
+        super(cause);
+        this.statusCode = statusCode;
+    }
+
+    /**
+     * Returns the unexpected Http response code
+     *
+     * @return response code
+     */
+    public int getStatusCode() {
+        return statusCode;
+    }
+
+    /**
+     * Returns all http headers from this response
+     *
+     * @return response code
+     */
+    public List getResponseHeaders() {
+        return responseHeaders;
+    }
+}
diff --git a/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpTransportSE.java b/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpTransportSE.java
index d92ac09..920ca60 100644
--- a/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpTransportSE.java
+++ b/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpTransportSE.java
@@ -25,24 +25,21 @@
 
 package org.ksoap2.transport;
 
-import java.util.List;
-import java.util.zip.GZIPInputStream;
+import org.ksoap2.HeaderProperty;
+import org.ksoap2.SoapEnvelope;
+import org.ksoap2.serialization.*;
+import org.xmlpull.v1.XmlPullParserException;
+
 import java.io.*;
-import java.net.MalformedURLException;
 import java.net.Proxy;
-import java.net.URL;
-
-import org.ksoap2.*;
-import org.ksoap2.serialization.SoapSerializationEnvelope;
-import org.xmlpull.v1.*;
+import java.util.*;
+import java.util.zip.GZIPInputStream;
 
 /**
  * A J2SE based HttpTransport layer.
  */
 public class HttpTransportSE extends Transport {
 
-    private ServiceConnection serviceConnection;
-
     /**
      * Creates instance of HttpTransportSE with set url
      * 
@@ -107,249 +104,254 @@ public class HttpTransportSE extends Transport {
      *            the desired soapAction
      * @param envelope
      *            the envelope containing the information for the soap call.
+     * @throws HttpResponseException
      * @throws IOException
      * @throws XmlPullParserException
      */
-    public void call(String soapAction, SoapEnvelope envelope) throws IOException,
-            XmlPullParserException {
-
+    public void call(String soapAction, SoapEnvelope envelope)
+            throws HttpResponseException, IOException, XmlPullParserException {
+            
         call(soapAction, envelope, null);
     }
 
+    public List call(String soapAction, SoapEnvelope envelope, List headers)
+            throws HttpResponseException, IOException, XmlPullParserException {
+        return call(soapAction, envelope, headers, null);
+    }
+
     /**
-     * 
-     * set the desired soapAction header field
-     * 
+     * Perform a soap call with a given namespace and the given envelope providing
+     * any extra headers that the user requires such as cookies. Headers that are
+     * returned by the web service will be returned to the caller in the form of a
+     * <code>List</code> of <code>HeaderProperty</code> instances.
+     *
      * @param soapAction
-     *            the desired soapAction
+     *            the namespace with which to perform the call in.
      * @param envelope
-     *            the envelope containing the information for the soap call.
+     *            the envelope the contains the information for the call.
      * @param headers
-     *              a list of HeaderProperties to be http header properties when establishing the connection
+     *   <code>List</code> of <code>HeaderProperty</code> headers to send with the SOAP request.
+     * @param outputFile
+     *              a file to stream the response into rather than parsing it, streaming happens when file is not null
      *
-     * @return <code>CookieJar</code> with any cookies sent by the server
-     * @throws IOException
-     * @throws XmlPullParserException
+     * @return Headers returned by the web service as a <code>List</code> of
+     * <code>HeaderProperty</code> instances.
+     *
+     * @throws HttpResponseException
+     *              an IOException when Http response code is different from 200
      */
-    public List call(String soapAction, SoapEnvelope envelope, List headers)
-            throws IOException, XmlPullParserException {
+    public List call(String soapAction, SoapEnvelope envelope, List headers, File outputFile)
+        throws HttpResponseException, IOException, XmlPullParserException {
 
         if (soapAction == null) {
             soapAction = "\"\"";
         }
 
-        System.out.println("call action:" + soapAction);
         byte[] requestData = createRequestData(envelope, "UTF-8");
 
-        if (requestData != null) {
-            requestDump = debug ? new String(requestData) : null;
-        }
-        else {
-            requestDump = null;
-        }
+        requestDump = debug ? new String(requestData) : null;
         responseDump = null;
-
-        System.out.println("requestDump:" + requestDump);
+        System.out.println("requestDump: " + requestDump);
         ServiceConnection connection = getServiceConnection();
-        System.out.println("connection:" + connection);
 
         connection.setRequestProperty("User-Agent", USER_AGENT);
         // SOAPAction is not a valid header for VER12 so do not add
         // it
         // @see "http://code.google.com/p/ksoap2-android/issues/detail?id=67
-        System.out.println("envelope:" + envelope);
-        if (envelope != null) {
-            if (envelope.version != SoapSerializationEnvelope.VER12) {
-                connection.setRequestProperty("SOAPAction", soapAction);
-            }
+        if (envelope.version != SoapSerializationEnvelope.VER12) {
+            connection.setRequestProperty("SOAPAction", soapAction);
+        }
 
-            if (envelope.version == SoapSerializationEnvelope.VER12) {
-                connection.setRequestProperty("Content-Type", CONTENT_TYPE_SOAP_XML_CHARSET_UTF_8);
-            } else {
-                connection.setRequestProperty("Content-Type", CONTENT_TYPE_XML_CHARSET_UTF_8);
-            }
+        if (envelope.version == SoapSerializationEnvelope.VER12) {
+            connection.setRequestProperty("Content-Type", CONTENT_TYPE_SOAP_XML_CHARSET_UTF_8);
+        } else {
+            connection.setRequestProperty("Content-Type", CONTENT_TYPE_XML_CHARSET_UTF_8);
+        }
 
-            connection.setRequestProperty("Connection", "close");
-            connection.setRequestProperty("Accept-Encoding", "gzip");
-            connection.setRequestProperty("Content-Length", "" + requestData.length);
+        // this seems to cause issues so we are removing it
+        //connection.setRequestProperty("Connection", "close");
+        connection.setRequestProperty("Accept-Encoding", "gzip");
 
-            //M: Retry for HTTP Authentication
-            //connection.setFixedLengthStreamingMode(requestData.length);
 
-            // Pass the headers provided by the user along with the call
-            if (headers != null) {
-                for (int i = 0; i < headers.size(); i++) {
-                    HeaderProperty hp = (HeaderProperty) headers.get(i);
-                    connection.setRequestProperty(hp.getKey(), hp.getValue());
-                }
+        // Pass the headers provided by the user along with the call
+        if (headers != null) {
+            for (int i = 0; i < headers.size(); i++) {
+                HeaderProperty hp = (HeaderProperty) headers.get(i);
+                connection.setRequestProperty(hp.getKey(), hp.getValue());
             }
-
-            connection.setRequestMethod("POST");
-
-        }
-        else {
-            connection.setRequestProperty("Connection", "close");
-            connection.setRequestProperty("Accept-Encoding", "gzip");
-            connection.setRequestMethod("GET");
         }
 
-        if (requestData != null) {
-            OutputStream os = connection.openOutputStream();
-
-            os.write(requestData, 0, requestData.length);
-            os.flush();
-            os.close();
-            requestData = null;
-        }
-        InputStream is;
+        connection.setRequestMethod("POST");
+        sendData(requestData, connection,envelope);
+        requestData = null;
+        InputStream is = null;
         List retHeaders = null;
+        byte[] buf = null; // To allow releasing the resource after used
+        int contentLength = 8192; // To determine the size of the response and adjust buffer size
         boolean gZippedContent = false;
-        boolean bcaCert = false;
+        boolean xmlContent = false;
+        int status = connection.getResponseCode();
 
         try {
             retHeaders = connection.getResponseProperties();
-            System.out.println("[HttpTransportSE] retHeaders = " + retHeaders);
+
             for (int i = 0; i < retHeaders.size(); i++) {
-                HeaderProperty hp = (HeaderProperty) retHeaders.get(i);
+                HeaderProperty hp = (HeaderProperty)retHeaders.get(i);
                 // HTTP response code has null key
                 if (null == hp.getKey()) {
                     continue;
                 }
+
+                // If we know the size of the response, we should use the size to initiate vars
+                if (hp.getKey().equalsIgnoreCase("content-length") ) {
+                    if ( hp.getValue() != null ) {
+                        try {
+                            contentLength = Integer.parseInt( hp.getValue() );
+                        } catch ( NumberFormatException nfe ) {
+                            contentLength = 8192;
+                        }
+                    }
+                }
+
+
+                // Check the content-type header to see if we're getting back XML, in case of a
+                // SOAP fault on 500 codes
+                if (hp.getKey().equalsIgnoreCase("Content-Type")
+                        && hp.getValue().contains("xml")) {
+                    xmlContent = true;
+                }
+
+
                 // ignoring case since users found that all smaller case is used on some server
                 // and even if it is wrong according to spec, we rather have it work..
                 if (hp.getKey().equalsIgnoreCase("Content-Encoding")
-                        && hp.getValue().equalsIgnoreCase("gzip")) {
+                     && hp.getValue().equalsIgnoreCase("gzip")) {
                     gZippedContent = true;
                 }
             }
-            if (gZippedContent) {
-                is = getUnZippedInputStream(connection.openInputStream());
-            } else {
-                is = connection.openInputStream();
-            }
-        } catch (IOException e) {
-            if (gZippedContent) {
-                is = getUnZippedInputStream(connection.getErrorStream());
-            } else {
-                is = connection.getErrorStream();
-            }
 
-            if (is == null) {
-                connection.disconnect();
-                throw (e);
+            //first check the response code....
+            if (status != 200 && status != 202) {
+                //202 is a correct status returned by WCF OneWay operation
+                throw new HttpResponseException("HTTP request failed, HTTP status: " + status, status,retHeaders);
             }
-        }
-
-        if (debug) {
-            ByteArrayOutputStream bos = new ByteArrayOutputStream();
-            byte[] buf = new byte[8192];
 
-            while (true) {
-                int rd = is.read(buf, 0, 8192);
-                if (rd == -1) {
-                    break;
+            if (contentLength > 0) {
+                if (gZippedContent) {
+                    is = getUnZippedInputStream(
+                            new BufferedInputStream(connection.openInputStream(),contentLength));
+                } else {
+                    is = new BufferedInputStream(connection.openInputStream(),contentLength);
+                }
+            }
+        } catch (IOException e) {
+            if (contentLength > 0) {
+                if(gZippedContent) {
+                    is = getUnZippedInputStream(
+                            new BufferedInputStream(connection.getErrorStream(),contentLength));
+                } else {
+                    is = new BufferedInputStream(connection.getErrorStream(),contentLength);
                 }
-                bos.write(buf, 0, rd);
             }
 
-            bos.flush();
-            buf = bos.toByteArray();
+            if ( e instanceof HttpResponseException) {
+                if (!xmlContent) {
+                    if (debug && is != null) {
+                        //go ahead and read the error stream into the debug buffers/file if needed.
+                        readDebug(is, contentLength, outputFile);
+                    }
 
-            responseDump = new String(buf);
+                    //we never want to drop through to attempting to parse the HTTP error stream as a SOAP response.
+                    connection.disconnect();
+                    throw e;
+                }
+            }
+        }
 
-            System.out.println("responseDump:" + responseDump);
-            is.close();
-            is = new ByteArrayInputStream(buf);
+        if (debug) {
+            is = readDebug(is, contentLength, outputFile);
         }
 
-        if (envelope != null) {
-            parseResponse(envelope, is);
+        if(is!=null)
+        {
+            parseResponse(envelope, is,retHeaders);
         }
 
+        // release all resources 
+        // input stream is will be released inside parseResponse
+        is = null;
+        buf = null;
+        //This fixes Issue 173 read my explanation here: https://code.google.com/p/ksoap2-android/issues/detail?id=173
+        connection.disconnect();
+        connection = null;
         return retHeaders;
     }
 
-    private InputStream getUnZippedInputStream(InputStream inputStream) throws IOException {
-        /* workaround for Android 2.3 
-           (see http://stackoverflow.com/questions/5131016/)
-        */
-        try {
-            return (GZIPInputStream) inputStream;
-        } catch (ClassCastException e) {
-            return new GZIPInputStream(inputStream);
-        }
-    }
+    protected void sendData(byte[] requestData, ServiceConnection connection, SoapEnvelope envelope)
+            throws IOException
+    {
+        connection.setRequestProperty("Content-Length", "" + requestData.length);
+        connection.setFixedLengthStreamingMode(requestData.length);
 
-    public ServiceConnection getServiceConnection() throws IOException {
-        if (serviceConnection == null) {
-            System.out.println("new ServiceConnectionSE:" + proxy + " " + url + " " + timeout);
-            serviceConnection = new ServiceConnectionSE(proxy, url, timeout);
-        }
-        return serviceConnection;
+        OutputStream os = connection.openOutputStream();
+        os.write(requestData, 0, requestData.length);
+        os.flush();
+        os.close();
     }
 
-    public String getHost() {
-
-        String retVal = null;
-
-        try {
-            retVal = new URL(url).getHost();
-        } catch (MalformedURLException e) {
-            e.printStackTrace();
-        }
-
-        return retVal;
+    protected void parseResponse(SoapEnvelope envelope, InputStream is,List returnedHeaders)
+            throws XmlPullParserException, IOException
+    {
+        parseResponse(envelope, is);
     }
 
-    public int getPort() {
-
-        int retVal = -1;
 
-        try {
-            retVal = new URL(url).getPort();
-        } catch (MalformedURLException e) {
-            e.printStackTrace();
+    private InputStream readDebug(InputStream is, int contentLength, File outputFile) throws IOException {
+        OutputStream bos;
+        if (outputFile != null) {
+            bos = new FileOutputStream(outputFile);
+        } else {
+            // If known use the size if not use default value
+            bos = new ByteArrayOutputStream( (contentLength > 0 ) ? contentLength : 256*1024);
         }
 
-        return retVal;
-    }
-
-    public String getPath() {
-
-        String retVal = null;
+        byte[] buf = new byte[256];
 
-        try {
-            retVal = new URL(url).getPath();
-        } catch (MalformedURLException e) {
-            e.printStackTrace();
+        while (true) {
+            int rd = is.read(buf, 0, 256);
+            if (rd == -1) {
+                break;
+            }
+            bos.write(buf, 0, rd);
         }
 
-        return retVal;
-    }
-
-    public String getQuery() {
-
-        String retVal = null;
-
-        try {
-            retVal = new URL(url).getQuery();
-        } catch (MalformedURLException e) {
-            e.printStackTrace();
+        bos.flush();
+        if (bos instanceof ByteArrayOutputStream) {
+            buf = ((ByteArrayOutputStream) bos).toByteArray();
+        }
+        bos = null;
+        responseDump = new String(buf);
+        is.close();
+        System.out.println("responseDump: " + requestDump);
+        if (outputFile != null) {
+            return new FileInputStream(outputFile);
+        } else {
+            return new ByteArrayInputStream(buf);
         }
-
-        return retVal;
     }
 
-    /**
-     * @hide
-     */
-    public byte[] getRequestData(SoapEnvelope envelope, String encoding) {
+    private InputStream getUnZippedInputStream(InputStream inputStream) throws IOException {
+        /* workaround for Android 2.3 
+           (see http://stackoverflow.com/questions/5131016/)
+        */
         try {
-            return createRequestData(envelope, encoding);
-        } catch (Exception e) {
-            e.printStackTrace();
+            return (GZIPInputStream) inputStream;
+        } catch (ClassCastException e) {
+            return new GZIPInputStream(inputStream);
         }
+    }
 
-        return null;
+    public ServiceConnection getServiceConnection() throws IOException {
+        return new ServiceConnectionSE(proxy, url, timeout);
     }
 }
diff --git a/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpsServiceConnectionSE.java b/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpsServiceConnectionSE.java
index 9ad9ba9..376c7d8 100644
--- a/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpsServiceConnectionSE.java
+++ b/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpsServiceConnectionSE.java
@@ -1,21 +1,16 @@
 
 package org.ksoap2.transport;
 
+import org.ksoap2.HeaderProperty;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSocketFactory;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.Proxy;
 import java.net.URL;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.List;
-import java.util.Set;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.HttpsURLConnection;
-//import com.android.okhttp.internal.http.HttpsURLConnectionImpl;
-import org.ksoap2.HeaderProperty;
+import java.util.*;
 
 /**
  * HttpsServiceConnectionSE is a service connection that uses a https url connection and requires explicit setting of
@@ -49,10 +44,29 @@ public class HttpsServiceConnectionSE implements ServiceConnection {
      * @param timeout the timeout for the connection in milliseconds
      * @throws IOException
      */
-    public HttpsServiceConnectionSE(String host, int port, String file,
-            int timeout) throws IOException {
-        connection = (HttpsURLConnection) new URL(HttpsTransportSE.PROTOCOL, host, port, file)
-                .openConnection();
+    public HttpsServiceConnectionSE(String host, int port, String file, int timeout) throws IOException {
+        this(null, host, port, file, timeout);
+    }
+
+    /**
+     * Create the transport with the supplied parameters.
+     * @param proxy proxy server to use
+     * @param host the name of the host e.g. webservices.somewhere.com
+     * @param port the http port to connect on
+     * @param file the path to the file on the webserver that represents the
+     * webservice e.g. /api/services/myservice.jsp
+     * @param timeout the timeout for the connection in milliseconds
+     * @throws IOException
+     */
+    public HttpsServiceConnectionSE(Proxy proxy, String host, int port, String file, int timeout) throws IOException {
+
+        if (proxy == null) {
+            connection = (HttpsURLConnection) new URL(HttpsTransportSE.PROTOCOL, host, port, file).openConnection();
+        } else {
+            connection =
+                    (HttpsURLConnection) new URL(HttpsTransportSE.PROTOCOL, host, port, file).openConnection(proxy);
+        }
+
         updateConnectionParameters(timeout);
     }
 
@@ -89,6 +103,10 @@ public class HttpsServiceConnectionSE implements ServiceConnection {
         return retList;
     }
 
+    public int getResponseCode() throws IOException {
+        return connection.getResponseCode();
+    }
+
     public void setRequestProperty(String key, String value) {
         connection.setRequestProperty(key, value);
     }
@@ -101,6 +119,11 @@ public class HttpsServiceConnectionSE implements ServiceConnection {
         connection.setFixedLengthStreamingMode(contentLength);
     }
 
+    public void setChunkedStreamingMode() {
+        connection.setChunkedStreamingMode(0);
+    }
+
+
     public OutputStream openOutputStream() throws IOException {
         return connection.getOutputStream();
     }
@@ -128,9 +151,4 @@ public class HttpsServiceConnectionSE implements ServiceConnection {
     public void setSSLSocketFactory(SSLSocketFactory sf) {
         connection.setSSLSocketFactory(sf);
     }
-
-    public void setHostnameVerifier(HostnameVerifier v) {
-        connection.setHostnameVerifier(v);
-    }
-
 }
diff --git a/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpsTransportSE.java b/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpsTransportSE.java
index d220ac9..a7d7023 100644
--- a/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpsTransportSE.java
+++ b/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpsTransportSE.java
@@ -1,8 +1,8 @@
-
 package org.ksoap2.transport;
 
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.net.Proxy;
 import java.net.URL;
 
 /**
@@ -14,17 +14,31 @@ import java.net.URL;
 public class HttpsTransportSE extends HttpTransportSE {
 
     static final String PROTOCOL = "https";
+    private static final String PROTOCOL_FULL = PROTOCOL + "://";
+    
+    //connection instance, used for setting the SSLSocketFactory
+    private HttpsServiceConnectionSE connection;
 
-    private ServiceConnection serviceConnection = null;
-    private final String host;
-    private final int port;
-    private final String file;
-    private final int timeout;
+    protected final String host;
+    protected final int port;
+    protected final String file;
 
-    public HttpsTransportSE(String host, int port, String file, int timeout) {
-        super(HttpsTransportSE.PROTOCOL + "://" + host + ":" + port + file);
-        System.out.println("Establistion connection to: " + HttpsTransportSE.PROTOCOL + "://"
-                + host + ":" + port + file);
+    public HttpsTransportSE (String host, int port, String file, int timeout) {
+        super(HttpsTransportSE.PROTOCOL_FULL + host + ":" + port + file, timeout);
+        this.host = host;
+        this.port = port;
+        this.file = file;
+    }
+
+    /**
+     * Creates instance of HttpTransportSE with set url and defines a
+     * proxy server to use to access it
+     *
+     * @param proxy
+     * Proxy information or <code>null</code> for direct access
+     */
+    public HttpsTransportSE(Proxy proxy, String host, int port, String file, int timeout) {
+        super(proxy, HttpsTransportSE.PROTOCOL_FULL + host + ":" + port + file);
         this.host = host;
         this.port = port;
         this.file = file;
@@ -37,48 +51,11 @@ public class HttpsTransportSE extends HttpTransportSE {
      */
     public ServiceConnection getServiceConnection() throws IOException
     {
-        if (serviceConnection == null) {
-            serviceConnection = new HttpsServiceConnectionSE(host, port, file, timeout);
-        }
-        return serviceConnection;
-    }
-
-    public String getHost() {
-
-        String retVal = null;
-
-        try {
-            retVal = new URL(url).getHost();
-        } catch (MalformedURLException e) {
-            e.printStackTrace();
+        if(connection != null) {
+            return connection;
+        } else {
+            connection = new HttpsServiceConnectionSE(proxy, host, port, file, timeout);
+            return connection;
         }
-
-        return retVal;
-    }
-
-    public int getPort() {
-
-        int retVal = -1;
-
-        try {
-            retVal = new URL(url).getPort();
-        } catch (MalformedURLException e) {
-            e.printStackTrace();
-        }
-
-        return retVal;
-    }
-
-    public String getPath() {
-
-        String retVal = null;
-
-        try {
-            retVal = new URL(url).getPath();
-        } catch (MalformedURLException e) {
-            e.printStackTrace();
-        }
-
-        return retVal;
     }
 }
diff --git a/ksoap2-j2se/src/main/java/org/ksoap2/transport/KeepAliveHttpsTransportSE.java b/ksoap2-j2se/src/main/java/org/ksoap2/transport/KeepAliveHttpsTransportSE.java
index 287fed1..65ba582 100644
--- a/ksoap2-j2se/src/main/java/org/ksoap2/transport/KeepAliveHttpsTransportSE.java
+++ b/ksoap2-j2se/src/main/java/org/ksoap2/transport/KeepAliveHttpsTransportSE.java
@@ -24,18 +24,8 @@ import java.io.IOException;
  */
 public class KeepAliveHttpsTransportSE extends HttpsTransportSE
 {
-    private final String host;
-    private final int port;
-    private final String file;
-    private final int timeout;
-    private ServiceConnection serviceConnection;
-
-    public KeepAliveHttpsTransportSE(String host, int port, String file, int timeout) {
+    public KeepAliveHttpsTransportSE (String host, int port, String file, int timeout) {
         super(host, port, file, timeout);
-        this.host = host;
-        this.port = port;
-        this.file = file;
-        this.timeout = timeout;
     }
 
     /**
@@ -47,11 +37,9 @@ public class KeepAliveHttpsTransportSE extends HttpsTransportSE
     //@Override
     public ServiceConnection getServiceConnection() throws IOException
     {
-        if (serviceConnection == null) {
-            serviceConnection = new HttpsServiceConnectionSEIgnoringConnectionClose(host, port,
-                    file, timeout);
-            serviceConnection.setRequestProperty("Connection", "keep-alive");
-        }
+        ServiceConnection serviceConnection = 
+                new HttpsServiceConnectionSEIgnoringConnectionClose(host, port, file, timeout);
+        serviceConnection.setRequestProperty("Connection", "keep-alive");
         return serviceConnection;
     }
 
diff --git a/ksoap2-j2se/src/main/java/org/ksoap2/transport/ServiceConnectionSE.java b/ksoap2-j2se/src/main/java/org/ksoap2/transport/ServiceConnectionSE.java
index 029ee9a..bfdfe11 100644
--- a/ksoap2-j2se/src/main/java/org/ksoap2/transport/ServiceConnectionSE.java
+++ b/ksoap2-j2se/src/main/java/org/ksoap2/transport/ServiceConnectionSE.java
@@ -21,16 +21,16 @@
 
 package org.ksoap2.transport;
 
-import java.io.*;
-import java.net.*;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.ksoap2.HeaderProperty;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.Proxy;
+import java.net.URL;
+import java.util.*;
+
 /**
  * Connection for J2SE environments.
  */
@@ -80,23 +80,29 @@ public class ServiceConnectionSE implements ServiceConnection {
         connection.disconnect();
     }
 
-    public List getResponseProperties() {
-        Map properties = connection.getHeaderFields();
-        Set keys = properties.keySet();
+    public List getResponseProperties() throws IOException {
         List retList = new LinkedList();
 
-        for (Iterator i = keys.iterator(); i.hasNext();) {
-            String key = (String) i.next();
-            List values = (List) properties.get(key);
-
-            for (int j = 0; j < values.size(); j++) {
-                retList.add(new HeaderProperty(key, (String) values.get(j)));
+        Map properties = connection.getHeaderFields();
+        if(properties != null) {
+            Set keys = properties.keySet();
+            for (Iterator i = keys.iterator(); i.hasNext();) {
+                String key = (String) i.next();
+                List values = (List) properties.get(key);
+
+                for (int j = 0; j < values.size(); j++) {
+                    retList.add(new HeaderProperty(key, (String) values.get(j)));
+                }
             }
         }
 
         return retList;
     }
 
+    public int getResponseCode() throws IOException {
+        return connection.getResponseCode();
+    }
+
     public void setRequestProperty(String string, String soapAction) {
         connection.setRequestProperty(string, soapAction);
     }
@@ -116,6 +122,10 @@ public class ServiceConnectionSE implements ServiceConnection {
         connection.setFixedLengthStreamingMode(contentLength);
     }
 
+    public void setChunkedStreamingMode() {
+        connection.setChunkedStreamingMode(0);
+    }
+
     public OutputStream openOutputStream() throws IOException {
         return connection.getOutputStream();
     }
-- 
2.17.0.441.gb46fe60e1d-goog