class.wsdl.php
68.7 KB
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
<?php
/**
* parses a WSDL file, allows access to it's data, other utility methods
*
* @author Dietrich Ayala <dietrich@ganx4.com>
* @version $Id: class.wsdl.php,v 1.56 2005/08/04 01:27:42 snichol Exp $
* @access public
*/
class wsdl extends nusoap_base {
// URL or filename of the root of this WSDL
var $wsdl;
// define internal arrays of bindings, ports, operations, messages, etc.
var $schemas = array();
var $currentSchema;
var $message = array();
var $complexTypes = array();
var $messages = array();
var $currentMessage;
var $currentOperation;
var $portTypes = array();
var $currentPortType;
var $bindings = array();
var $currentBinding;
var $ports = array();
var $currentPort;
var $opData = array();
var $status = '';
var $documentation = false;
var $endpoint = '';
// array of wsdl docs to import
var $import = array();
// parser vars
var $parser;
var $position = 0;
var $depth = 0;
var $depth_array = array();
// for getting wsdl
var $proxyhost = '';
var $proxyport = '';
var $proxyusername = '';
var $proxypassword = '';
var $timeout = 0;
var $response_timeout = 30;
/**
* constructor
*
* @param string $wsdl WSDL document URL
* @param string $proxyhost
* @param string $proxyport
* @param string $proxyusername
* @param string $proxypassword
* @param integer $timeout set the connection timeout
* @param integer $response_timeout set the response timeout
* @access public
*/
function wsdl($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30){
parent::nusoap_base();
$this->wsdl = $wsdl;
$this->proxyhost = $proxyhost;
$this->proxyport = $proxyport;
$this->proxyusername = $proxyusername;
$this->proxypassword = $proxypassword;
$this->timeout = $timeout;
$this->response_timeout = $response_timeout;
// parse wsdl file
if ($wsdl != "") {
$this->debug('initial wsdl URL: ' . $wsdl);
$this->parseWSDL($wsdl);
}
// imports
// TODO: handle imports more properly, grabbing them in-line and nesting them
$imported_urls = array();
$imported = 1;
while ($imported > 0) {
$imported = 0;
// Schema imports
foreach ($this->schemas as $ns => $list) {
foreach ($list as $xs) {
$wsdlparts = parse_url($this->wsdl); // this is bogusly simple!
foreach ($xs->imports as $ns2 => $list2) {
for ($ii = 0; $ii < count($list2); $ii++) {
if (! $list2[$ii]['loaded']) {
$this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
$url = $list2[$ii]['location'];
if ($url != '') {
$urlparts = parse_url($url);
if (!isset($urlparts['host'])) {
$url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') .
substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
}
if (! in_array($url, $imported_urls)) {
$this->parseWSDL($url);
$imported++;
$imported_urls[] = $url;
}
} else {
$this->debug("Unexpected scenario: empty URL for unloaded import");
}
}
}
}
}
}
// WSDL imports
$wsdlparts = parse_url($this->wsdl); // this is bogusly simple!
foreach ($this->import as $ns => $list) {
for ($ii = 0; $ii < count($list); $ii++) {
if (! $list[$ii]['loaded']) {
$this->import[$ns][$ii]['loaded'] = true;
$url = $list[$ii]['location'];
if ($url != '') {
$urlparts = parse_url($url);
if (!isset($urlparts['host'])) {
$url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
}
if (! in_array($url, $imported_urls)) {
$this->parseWSDL($url);
$imported++;
$imported_urls[] = $url;
}
} else {
$this->debug("Unexpected scenario: empty URL for unloaded import");
}
}
}
}
}
// add new data to operation data
foreach($this->bindings as $binding => $bindingData) {
if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
foreach($bindingData['operations'] as $operation => $data) {
$this->debug('post-parse data gathering for ' . $operation);
$this->bindings[$binding]['operations'][$operation]['input'] =
isset($this->bindings[$binding]['operations'][$operation]['input']) ?
array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) :
$this->portTypes[ $bindingData['portType'] ][$operation]['input'];
$this->bindings[$binding]['operations'][$operation]['output'] =
isset($this->bindings[$binding]['operations'][$operation]['output']) ?
array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) :
$this->portTypes[ $bindingData['portType'] ][$operation]['output'];
if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){
$this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ];
}
if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){
$this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ];
}
if (isset($bindingData['style'])) {
$this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style'];
}
$this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : '';
$this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : '';
$this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : '';
}
}
}
}
/**
* parses the wsdl document
*
* @param string $wsdl path or URL
* @access private
*/
function parseWSDL($wsdl = '')
{
if ($wsdl == '') {
$this->debug('no wsdl passed to parseWSDL()!!');
$this->setError('no wsdl passed to parseWSDL()!!');
return false;
}
// parse $wsdl for url format
$wsdl_props = parse_url($wsdl);
if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) {
$this->debug('getting WSDL http(s) URL ' . $wsdl);
// get wsdl
$tr = new soap_transport_http($wsdl);
$tr->request_method = 'GET';
$tr->useSOAPAction = false;
if($this->proxyhost && $this->proxyport){
$tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
}
$tr->setEncoding('gzip, deflate');
$wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
//$this->debug("WSDL request\n" . $tr->outgoing_payload);
//$this->debug("WSDL response\n" . $tr->incoming_payload);
$this->appendDebug($tr->getDebug());
// catch errors
if($err = $tr->getError() ){
$errstr = 'HTTP ERROR: '.$err;
$this->debug($errstr);
$this->setError($errstr);
unset($tr);
return false;
}
unset($tr);
$this->debug("got WSDL URL");
} else {
// $wsdl is not http(s), so treat it as a file URL or plain file path
if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
$path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path'];
} else {
$path = $wsdl;
}
$this->debug('getting WSDL file ' . $path);
if ($fp = @fopen($path, 'r')) {
$wsdl_string = '';
while ($data = fread($fp, 32768)) {
$wsdl_string .= $data;
}
fclose($fp);
} else {
$errstr = "Bad path to WSDL file $path";
$this->debug($errstr);
$this->setError($errstr);
return false;
}
}
$this->debug('Parse WSDL');
// end new code added
// Create an XML parser.
$this->parser = xml_parser_create();
// Set the options for parsing the XML data.
// xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
// Set the object for the parser.
xml_set_object($this->parser, $this);
// Set the element handlers for the parser.
xml_set_element_handler($this->parser, 'start_element', 'end_element');
xml_set_character_data_handler($this->parser, 'character_data');
// Parse the XML file.
if (!xml_parse($this->parser, $wsdl_string, true)) {
// Display an error message.
$errstr = sprintf(
'XML error parsing WSDL from %s on line %d: %s',
$wsdl,
xml_get_current_line_number($this->parser),
xml_error_string(xml_get_error_code($this->parser))
);
$this->debug($errstr);
$this->debug("XML payload:\n" . $wsdl_string);
$this->setError($errstr);
return false;
}
// free the parser
xml_parser_free($this->parser);
$this->debug('Parsing WSDL done');
// catch wsdl parse errors
if($this->getError()){
return false;
}
return true;
}
/**
* start-element handler
*
* @param string $parser XML parser object
* @param string $name element name
* @param string $attrs associative array of attributes
* @access private
*/
function start_element($parser, $name, $attrs)
{
if ($this->status == 'schema') {
$this->currentSchema->schemaStartElement($parser, $name, $attrs);
$this->appendDebug($this->currentSchema->getDebug());
$this->currentSchema->clearDebug();
} elseif (ereg('schema$', $name)) {
$this->debug('Parsing WSDL schema');
// $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")");
$this->status = 'schema';
$this->currentSchema = new xmlschema('', '', $this->namespaces);
$this->currentSchema->schemaStartElement($parser, $name, $attrs);
$this->appendDebug($this->currentSchema->getDebug());
$this->currentSchema->clearDebug();
} else {
// position in the total number of elements, starting from 0
$pos = $this->position++;
$depth = $this->depth++;
// set self as current value for this depth
$this->depth_array[$depth] = $pos;
$this->message[$pos] = array('cdata' => '');
// process attributes
if (count($attrs) > 0) {
// register namespace declarations
foreach($attrs as $k => $v) {
if (ereg("^xmlns", $k)) {
if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
$this->namespaces[$ns_prefix] = $v;
} else {
$this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
}
if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
$this->XMLSchemaVersion = $v;
$this->namespaces['xsi'] = $v . '-instance';
}
}
}
// expand each attribute prefix to its namespace
foreach($attrs as $k => $v) {
$k = strpos($k, ':') ? $this->expandQname($k) : $k;
if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') {
$v = strpos($v, ':') ? $this->expandQname($v) : $v;
}
$eAttrs[$k] = $v;
}
$attrs = $eAttrs;
} else {
$attrs = array();
}
// get element prefix, namespace and name
if (ereg(':', $name)) {
// get ns prefix
$prefix = substr($name, 0, strpos($name, ':'));
// get ns
$namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : '';
// get unqualified name
$name = substr(strstr($name, ':'), 1);
}
// process attributes, expanding any prefixes to namespaces
// find status, register data
switch ($this->status) {
case 'message':
if ($name == 'part') {
if (isset($attrs['type'])) {
$this->debug("msg " . $this->currentMessage . ": found part $attrs[name]: " . implode(',', $attrs));
$this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
}
if (isset($attrs['element'])) {
$this->debug("msg " . $this->currentMessage . ": found part $attrs[name]: " . implode(',', $attrs));
$this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'];
}
}
break;
case 'portType':
switch ($name) {
case 'operation':
$this->currentPortOperation = $attrs['name'];
$this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
if (isset($attrs['parameterOrder'])) {
$this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
}
break;
case 'documentation':
$this->documentation = true;
break;
// merge input/output data
default:
$m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
$this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
break;
}
break;
case 'binding':
switch ($name) {
case 'binding':
// get ns prefix
if (isset($attrs['style'])) {
$this->bindings[$this->currentBinding]['prefix'] = $prefix;
}
$this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
break;
case 'header':
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs;
break;
case 'operation':
if (isset($attrs['soapAction'])) {
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction'];
}
if (isset($attrs['style'])) {
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style'];
}
if (isset($attrs['name'])) {
$this->currentOperation = $attrs['name'];
$this->debug("current binding operation: $this->currentOperation");
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name'];
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding;
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : '';
}
break;
case 'input':
$this->opStatus = 'input';
break;
case 'output':
$this->opStatus = 'output';
break;
case 'body':
if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs);
} else {
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs;
}
break;
}
break;
case 'service':
switch ($name) {
case 'port':
$this->currentPort = $attrs['name'];
$this->debug('current port: ' . $this->currentPort);
$this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
break;
case 'address':
$this->ports[$this->currentPort]['location'] = $attrs['location'];
$this->ports[$this->currentPort]['bindingType'] = $namespace;
$this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
$this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
break;
}
break;
}
// set status
switch ($name) {
case 'import':
if (isset($attrs['location'])) {
$this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
$this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')');
} else {
$this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
$this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
}
$this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')');
}
break;
//wait for schema
//case 'types':
// $this->status = 'schema';
// break;
case 'message':
$this->status = 'message';
$this->messages[$attrs['name']] = array();
$this->currentMessage = $attrs['name'];
break;
case 'portType':
$this->status = 'portType';
$this->portTypes[$attrs['name']] = array();
$this->currentPortType = $attrs['name'];
break;
case "binding":
if (isset($attrs['name'])) {
// get binding name
if (strpos($attrs['name'], ':')) {
$this->currentBinding = $this->getLocalPart($attrs['name']);
} else {
$this->currentBinding = $attrs['name'];
}
$this->status = 'binding';
$this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
$this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
}
break;
case 'service':
$this->serviceName = $attrs['name'];
$this->status = 'service';
$this->debug('current service: ' . $this->serviceName);
break;
case 'definitions':
foreach ($attrs as $name => $value) {
$this->wsdl_info[$name] = $value;
}
break;
}
}
}
/**
* end-element handler
*
* @param string $parser XML parser object
* @param string $name element name
* @access private
*/
function end_element($parser, $name){
// unset schema status
if (/*ereg('types$', $name) ||*/ ereg('schema$', $name)) {
$this->status = "";
$this->appendDebug($this->currentSchema->getDebug());
$this->currentSchema->clearDebug();
$this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
$this->debug('Parsing WSDL schema done');
}
if ($this->status == 'schema') {
$this->currentSchema->schemaEndElement($parser, $name);
} else {
// bring depth down a notch
$this->depth--;
}
// end documentation
if ($this->documentation) {
//TODO: track the node to which documentation should be assigned; it can be a part, message, etc.
//$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation;
$this->documentation = false;
}
}
/**
* element content handler
*
* @param string $parser XML parser object
* @param string $data element content
* @access private
*/
function character_data($parser, $data)
{
$pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
if (isset($this->message[$pos]['cdata'])) {
$this->message[$pos]['cdata'] .= $data;
}
if ($this->documentation) {
$this->documentation .= $data;
}
}
function getBindingData($binding)
{
if (is_array($this->bindings[$binding])) {
return $this->bindings[$binding];
}
}
/**
* returns an assoc array of operation names => operation data
*
* @param string $bindingType eg: soap, smtp, dime (only soap is currently supported)
* @return array
* @access public
*/
function getOperations($bindingType = 'soap')
{
$ops = array();
if ($bindingType == 'soap') {
$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
}
// loop thru ports
foreach($this->ports as $port => $portData) {
// binding type of port matches parameter
if ($portData['bindingType'] == $bindingType) {
//$this->debug("getOperations for port $port");
//$this->debug("port data: " . $this->varDump($portData));
//$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
// merge bindings
if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
$ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']);
}
}
}
return $ops;
}
/**
* returns an associative array of data necessary for calling an operation
*
* @param string $operation , name of operation
* @param string $bindingType , type of binding eg: soap
* @return array
* @access public
*/
function getOperationData($operation, $bindingType = 'soap')
{
if ($bindingType == 'soap') {
$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
}
// loop thru ports
foreach($this->ports as $port => $portData) {
// binding type of port matches parameter
if ($portData['bindingType'] == $bindingType) {
// get binding
//foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
// note that we could/should also check the namespace here
if ($operation == $bOperation) {
$opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
return $opData;
}
}
}
}
}
/**
* returns an associative array of data necessary for calling an operation
*
* @param string $soapAction soapAction for operation
* @param string $bindingType type of binding eg: soap
* @return array
* @access public
*/
function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') {
if ($bindingType == 'soap') {
$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
}
// loop thru ports
foreach($this->ports as $port => $portData) {
// binding type of port matches parameter
if ($portData['bindingType'] == $bindingType) {
// loop through operations for the binding
foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
if ($opData['soapAction'] == $soapAction) {
return $opData;
}
}
}
}
}
/**
* returns an array of information about a given type
* returns false if no type exists by the given name
*
* typeDef = array(
* 'elements' => array(), // refs to elements array
* 'restrictionBase' => '',
* 'phpType' => '',
* 'order' => '(sequence|all)',
* 'attrs' => array() // refs to attributes array
* )
*
* @param $type string the type
* @param $ns string namespace (not prefix) of the type
* @return mixed
* @access public
* @see xmlschema
*/
function getTypeDef($type, $ns) {
$this->debug("in getTypeDef: type=$type, ns=$ns");
if ((! $ns) && isset($this->namespaces['tns'])) {
$ns = $this->namespaces['tns'];
$this->debug("in getTypeDef: type namespace forced to $ns");
}
if (isset($this->schemas[$ns])) {
$this->debug("in getTypeDef: have schema for namespace $ns");
for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
$xs = &$this->schemas[$ns][$i];
$t = $xs->getTypeDef($type);
$this->appendDebug($xs->getDebug());
$xs->clearDebug();
if ($t) {
if (!isset($t['phpType'])) {
// get info for type to tack onto the element
$uqType = substr($t['type'], strrpos($t['type'], ':') + 1);
$ns = substr($t['type'], 0, strrpos($t['type'], ':'));
$etype = $this->getTypeDef($uqType, $ns);
if ($etype) {
$this->debug("found type for [element] $type:");
$this->debug($this->varDump($etype));
if (isset($etype['phpType'])) {
$t['phpType'] = $etype['phpType'];
}
if (isset($etype['elements'])) {
$t['elements'] = $etype['elements'];
}
if (isset($etype['attrs'])) {
$t['attrs'] = $etype['attrs'];
}
}
}
return $t;
}
}
} else {
$this->debug("in getTypeDef: do not have schema for namespace $ns");
}
return false;
}
/**
* prints html description of services
*
* @access private
*/
function webDescription(){
global $HTTP_SERVER_VARS;
if (isset($_SERVER)) {
$PHP_SELF = $_SERVER['PHP_SELF'];
} elseif (isset($HTTP_SERVER_VARS)) {
$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
} else {
$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
}
$b = '
<html><head><title>NuSOAP: '.$this->serviceName.'</title>
<style type="text/css">
body { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
p { font-family: arial; color: #000000; margin-top: 0px; margin-bottom: 12px; }
pre { background-color: silver; padding: 5px; font-family: Courier New; font-size: x-small; color: #000000;}
ul { margin-top: 10px; margin-left: 20px; }
li { list-style-type: none; margin-top: 10px; color: #000000; }
.content{
margin-left: 0px; padding-bottom: 2em; }
.nav {
padding-top: 10px; padding-bottom: 10px; padding-left: 15px; font-size: .70em;
margin-top: 10px; margin-left: 0px; color: #000000;
background-color: #ccccff; width: 20%; margin-left: 20px; margin-top: 20px; }
.title {
font-family: arial; font-size: 26px; color: #ffffff;
background-color: #999999; width: 105%; margin-left: 0px;
padding-top: 10px; padding-bottom: 10px; padding-left: 15px;}
.hidden {
position: absolute; visibility: hidden; z-index: 200; left: 250px; top: 100px;
font-family: arial; overflow: hidden; width: 600;
padding: 20px; font-size: 10px; background-color: #999999;
layer-background-color:#FFFFFF; }
a,a:active { color: charcoal; font-weight: bold; }
a:visited { color: #666666; font-weight: bold; }
a:hover { color: cc3300; font-weight: bold; }
</style>
<script language="JavaScript" type="text/javascript">
<!--
// POP-UP CAPTIONS...
function lib_bwcheck(){ //Browsercheck (needed)
this.ver=navigator.appVersion
this.agent=navigator.userAgent
this.dom=document.getElementById?1:0
this.opera5=this.agent.indexOf("Opera 5")>-1
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
this.ie=this.ie4||this.ie5||this.ie6
this.mac=this.agent.indexOf("Mac")>-1
this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
return this
}
var bw = new lib_bwcheck()
//Makes crossbrowser object.
function makeObj(obj){
this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj]:0;
if(!this.evnt) return false
this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;
this.wref=bw.dom||bw.ie4?this.evnt:bw.ns4?this.css.document:0;
this.writeIt=b_writeIt;
return this
}
// A unit of measure that will be added when setting the position of a layer.
//var px = bw.ns4||window.opera?"":"px";
function b_writeIt(text){
if (bw.ns4){this.wref.write(text);this.wref.close()}
else this.wref.innerHTML = text
}
//Shows the messages
var oDesc;
function popup(divid){
if(oDesc = new makeObj(divid)){
oDesc.css.visibility = "visible"
}
}
function popout(){ // Hides message
if(oDesc) oDesc.css.visibility = "hidden"
}
//-->
</script>
</head>
<body>
<div class=content>
<br><br>
<div class=title>'.$this->serviceName.'</div>
<div class=nav>
<p>View the <a href="'.$PHP_SELF.'?wsdl">WSDL</a> for the service.
Click on an operation name to view it's details.</p>
<ul>';
foreach($this->getOperations() as $op => $data){
$b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
// create hidden div
$b .= "<div id='$op' class='hidden'>
<a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
foreach($data as $donnie => $marie){ // loop through opdata
if($donnie == 'input' || $donnie == 'output'){ // show input/output data
$b .= "<font color='white'>".ucfirst($donnie).':</font><br>';
foreach($marie as $captain => $tenille){ // loop through data
if($captain == 'parts'){ // loop thru parts
$b .= " $captain:<br>";
//if(is_array($tenille)){
foreach($tenille as $joanie => $chachi){
$b .= " $joanie: $chachi<br>";
}
//}
} else {
$b .= " $captain: $tenille<br>";
}
}
} else {
$b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>";
}
}
$b .= '</div>';
}
$b .= '
<ul>
</div>
</div></body></html>';
return $b;
}
/**
* serialize the parsed wsdl
*
* @param mixed $debug whether to put debug=1 in endpoint URL
* @return string serialization of WSDL
* @access public
*/
function serialize($debug = 0)
{
$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
$xml .= "\n<definitions";
foreach($this->namespaces as $k => $v) {
$xml .= " xmlns:$k=\"$v\"";
}
// 10.9.02 - add poulter fix for wsdl and tns declarations
if (isset($this->namespaces['wsdl'])) {
$xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
}
if (isset($this->namespaces['tns'])) {
$xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
}
$xml .= '>';
// imports
if (sizeof($this->import) > 0) {
foreach($this->import as $ns => $list) {
foreach ($list as $ii) {
if ($ii['location'] != '') {
$xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />';
} else {
$xml .= '<import namespace="' . $ns . '" />';
}
}
}
}
// types
if (count($this->schemas)>=1) {
$xml .= "\n<types>";
foreach ($this->schemas as $ns => $list) {
foreach ($list as $xs) {
$xml .= $xs->serializeSchema();
}
}
$xml .= '</types>';
}
// messages
if (count($this->messages) >= 1) {
foreach($this->messages as $msgName => $msgParts) {
$xml .= "\n<message name=\"" . $msgName . '">';
if(is_array($msgParts)){
foreach($msgParts as $partName => $partType) {
// print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
if (strpos($partType, ':')) {
$typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
} elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
// print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
$typePrefix = 'xsd';
} else {
foreach($this->typemap as $ns => $types) {
if (isset($types[$partType])) {
$typePrefix = $this->getPrefixFromNamespace($ns);
}
}
if (!isset($typePrefix)) {
die("$partType has no namespace!");
}
}
$ns = $this->getNamespaceFromPrefix($typePrefix);
$typeDef = $this->getTypeDef($this->getLocalPart($partType), $ns);
if ($typeDef['typeClass'] == 'element') {
$elementortype = 'element';
} else {
$elementortype = 'type';
}
$xml .= '<part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $this->getLocalPart($partType) . '" />';
}
}
$xml .= '</message>';
}
}
// bindings & porttypes
if (count($this->bindings) >= 1) {
$binding_xml = '';
$portType_xml = '';
foreach($this->bindings as $bindingName => $attrs) {
$binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
$binding_xml .= '<soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
$portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
foreach($attrs['operations'] as $opName => $opParts) {
$binding_xml .= '<operation name="' . $opName . '">';
$binding_xml .= '<soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>';
if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
$enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
} else {
$enc_style = '';
}
$binding_xml .= '<input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
$enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
} else {
$enc_style = '';
}
$binding_xml .= '<output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
$binding_xml .= '</operation>';
$portType_xml .= '<operation name="' . $opParts['name'] . '"';
if (isset($opParts['parameterOrder'])) {
$portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
}
$portType_xml .= '>';
if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
$portType_xml .= '<documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
}
$portType_xml .= '<input message="tns:' . $opParts['input']['message'] . '"/>';
$portType_xml .= '<output message="tns:' . $opParts['output']['message'] . '"/>';
$portType_xml .= '</operation>';
}
$portType_xml .= '</portType>';
$binding_xml .= '</binding>';
}
$xml .= $portType_xml . $binding_xml;
}
// services
$xml .= "\n<service name=\"" . $this->serviceName . '">';
if (count($this->ports) >= 1) {
foreach($this->ports as $pName => $attrs) {
$xml .= '<port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
$xml .= '<soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
$xml .= '</port>';
}
}
$xml .= '</service>';
return $xml . "\n</definitions>";
}
/**
* serialize PHP values according to a WSDL message definition
*
* TODO
* - multi-ref serialization
* - validate PHP values against type definitions, return errors if invalid
*
* @param string $operation operation name
* @param string $direction (input|output)
* @param mixed $parameters parameter value(s)
* @return mixed parameters serialized as XML or false on error (e.g. operation not found)
* @access public
*/
function serializeRPCParameters($operation, $direction, $parameters)
{
$this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
$this->appendDebug('parameters=' . $this->varDump($parameters));
if ($direction != 'input' && $direction != 'output') {
$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
$this->setError('The value of the \$direction argument needs to be either "input" or "output"');
return false;
}
if (!$opData = $this->getOperationData($operation)) {
$this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
$this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
return false;
}
$this->debug('opData:');
$this->appendDebug($this->varDump($opData));
// Get encoding style for output and set to current
$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
$encodingStyle = $opData['output']['encodingStyle'];
$enc_style = $encodingStyle;
}
// set input params
$xml = '';
if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
$use = $opData[$direction]['use'];
$this->debug('have ' . count($opData[$direction]['parts']) . ' part(s) to serialize');
if (is_array($parameters)) {
$parametersArrayType = $this->isArraySimpleOrStruct($parameters);
$this->debug('have ' . count($parameters) . ' parameter(s) provided as ' . $parametersArrayType . ' to serialize');
foreach($opData[$direction]['parts'] as $name => $type) {
$this->debug('serializing part "'.$name.'" of type "'.$type.'"');
// Track encoding style
if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
$encodingStyle = $opData[$direction]['encodingStyle'];
$enc_style = $encodingStyle;
} else {
$enc_style = false;
}
// NOTE: add error handling here
// if serializeType returns false, then catch global error and fault
if ($parametersArrayType == 'arraySimple') {
$p = array_shift($parameters);
$this->debug('calling serializeType w/indexed param');
$xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
} elseif (isset($parameters[$name])) {
$this->debug('calling serializeType w/named param');
$xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
} else {
// TODO: only send nillable
$this->debug('calling serializeType w/null param');
$xml .= $this->serializeType($name, $type, null, $use, $enc_style);
}
}
} else {
$this->debug('no parameters passed.');
}
}
$this->debug("serializeRPCParameters returning: $xml");
return $xml;
}
/**
* serialize a PHP value according to a WSDL message definition
*
* TODO
* - multi-ref serialization
* - validate PHP values against type definitions, return errors if invalid
*
* @param string $ type name
* @param mixed $ param value
* @return mixed new param or false if initial value didn't validate
* @access public
* @deprecated
*/
function serializeParameters($operation, $direction, $parameters)
{
$this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
$this->appendDebug('parameters=' . $this->varDump($parameters));
if ($direction != 'input' && $direction != 'output') {
$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
$this->setError('The value of the \$direction argument needs to be either "input" or "output"');
return false;
}
if (!$opData = $this->getOperationData($operation)) {
$this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
$this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
return false;
}
$this->debug('opData:');
$this->appendDebug($this->varDump($opData));
// Get encoding style for output and set to current
$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
$encodingStyle = $opData['output']['encodingStyle'];
$enc_style = $encodingStyle;
}
// set input params
$xml = '';
if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
$use = $opData[$direction]['use'];
$this->debug("use=$use");
$this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
if (is_array($parameters)) {
$parametersArrayType = $this->isArraySimpleOrStruct($parameters);
$this->debug('have ' . $parametersArrayType . ' parameters');
foreach($opData[$direction]['parts'] as $name => $type) {
$this->debug('serializing part "'.$name.'" of type "'.$type.'"');
// Track encoding style
if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
$encodingStyle = $opData[$direction]['encodingStyle'];
$enc_style = $encodingStyle;
} else {
$enc_style = false;
}
// NOTE: add error handling here
// if serializeType returns false, then catch global error and fault
if ($parametersArrayType == 'arraySimple') {
$p = array_shift($parameters);
$this->debug('calling serializeType w/indexed param');
$xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
} elseif (isset($parameters[$name])) {
$this->debug('calling serializeType w/named param');
$xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
} else {
// TODO: only send nillable
$this->debug('calling serializeType w/null param');
$xml .= $this->serializeType($name, $type, null, $use, $enc_style);
}
}
} else {
$this->debug('no parameters passed.');
}
}
$this->debug("serializeParameters returning: $xml");
return $xml;
}
/**
* serializes a PHP value according a given type definition
*
* @param string $name name of value (part or element)
* @param string $type XML schema type of value (type or element)
* @param mixed $value a native PHP value (parameter value)
* @param string $use use for part (encoded|literal)
* @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
* @param boolean $unqualified a kludge for what should be XML namespace form handling
* @return string value serialized as an XML string
* @access private
*/
function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false)
{
$this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
$this->appendDebug("value=" . $this->varDump($value));
if($use == 'encoded' && $encodingStyle) {
$encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
}
// if a soapval has been supplied, let its type override the WSDL
if (is_object($value) && get_class($value) == 'soapval') {
if ($value->type_ns) {
$type = $value->type_ns . ':' . $value->type;
$forceType = true;
$this->debug("in serializeType: soapval overrides type to $type");
} elseif ($value->type) {
$type = $value->type;
$forceType = true;
$this->debug("in serializeType: soapval overrides type to $type");
} else {
$forceType = false;
$this->debug("in serializeType: soapval does not override type");
}
$attrs = $value->attributes;
$value = $value->value;
$this->debug("in serializeType: soapval overrides value to $value");
if ($attrs) {
if (!is_array($value)) {
$value['!'] = $value;
}
foreach ($attrs as $n => $v) {
$value['!' . $n] = $v;
}
$this->debug("in serializeType: soapval provides attributes");
}
} else {
$forceType = false;
}
$xml = '';
if (strpos($type, ':')) {
$uqType = substr($type, strrpos($type, ':') + 1);
$ns = substr($type, 0, strrpos($type, ':'));
$this->debug("in serializeType: got a prefixed type: $uqType, $ns");
if ($this->getNamespaceFromPrefix($ns)) {
$ns = $this->getNamespaceFromPrefix($ns);
$this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
}
if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
$this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
if ($unqualified && $use == 'literal') {
$elementNS = " xmlns=\"\"";
} else {
$elementNS = '';
}
if (is_null($value)) {
if ($use == 'literal') {
// TODO: depends on minOccurs
$xml = "<$name$elementNS/>";
} else {
// TODO: depends on nillable, which should be checked before calling this method
$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
}
$this->debug("in serializeType: returning: $xml");
return $xml;
}
if ($uqType == 'boolean') {
if ((is_string($value) && $value == 'false') || (! $value)) {
$value = 'false';
} else {
$value = 'true';
}
}
if ($uqType == 'string' && gettype($value) == 'string') {
$value = $this->expandEntities($value);
}
if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') {
$value = sprintf("%.0lf", $value);
}
// it's a scalar
// TODO: what about null/nil values?
// check type isn't a custom type extending xmlschema namespace
if (!$this->getTypeDef($uqType, $ns)) {
if ($use == 'literal') {
if ($forceType) {
$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
} else {
$xml = "<$name$elementNS>$value</$name>";
}
} else {
$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
}
$this->debug("in serializeType: returning: $xml");
return $xml;
}
$this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
} else if ($ns == 'http://xml.apache.org/xml-soap') {
$this->debug('in serializeType: appears to be Apache SOAP type');
if ($uqType == 'Map') {
$tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
if (! $tt_prefix) {
$this->debug('in serializeType: Add namespace for Apache SOAP type');
$tt_prefix = 'ns' . rand(1000, 9999);
$this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
// force this to be added to usedNamespaces
$tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
}
$contents = '';
foreach($value as $k => $v) {
$this->debug("serializing map element: key $k, value $v");
$contents .= '<item>';
$contents .= $this->serialize_val($k,'key',false,false,false,false,$use);
$contents .= $this->serialize_val($v,'value',false,false,false,false,$use);
$contents .= '</item>';
}
if ($use == 'literal') {
if ($forceType) {
$xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>";
} else {
$xml = "<$name>$contents</$name>";
}
} else {
$xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>";
}
$this->debug("in serializeType: returning: $xml");
return $xml;
}
$this->debug('in serializeType: Apache SOAP type, but only support Map');
}
} else {
// TODO: should the type be compared to types in XSD, and the namespace
// set to XSD if the type matches?
$this->debug("in serializeType: No namespace for type $type");
$ns = '';
$uqType = $type;
}
if(!$typeDef = $this->getTypeDef($uqType, $ns)){
$this->setError("$type ($uqType) is not a supported type.");
$this->debug("in serializeType: $type ($uqType) is not a supported type.");
return false;
} else {
$this->debug("in serializeType: found typeDef");
$this->appendDebug('typeDef=' . $this->varDump($typeDef));
}
$phpType = $typeDef['phpType'];
$this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
// if php type == struct, map value to the <all> element names
if ($phpType == 'struct') {
if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
$elementName = $uqType;
if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
$elementNS = " xmlns=\"$ns\"";
} else {
$elementNS = " xmlns=\"\"";
}
} else {
$elementName = $name;
if ($unqualified) {
$elementNS = " xmlns=\"\"";
} else {
$elementNS = '';
}
}
if (is_null($value)) {
if ($use == 'literal') {
// TODO: depends on minOccurs
$xml = "<$elementName$elementNS/>";
} else {
$xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
}
$this->debug("in serializeType: returning: $xml");
return $xml;
}
if (is_object($value)) {
$value = get_object_vars($value);
}
if (is_array($value)) {
$elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
if ($use == 'literal') {
if ($forceType) {
$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
} else {
$xml = "<$elementName$elementNS$elementAttrs>";
}
} else {
$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
}
$xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
$xml .= "</$elementName>";
} else {
$this->debug("in serializeType: phpType is struct, but value is not an array");
$this->setError("phpType is struct, but value is not an array: see debug output for details");
$xml = '';
}
} elseif ($phpType == 'array') {
if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
$elementNS = " xmlns=\"$ns\"";
} else {
if ($unqualified) {
$elementNS = " xmlns=\"\"";
} else {
$elementNS = '';
}
}
if (is_null($value)) {
if ($use == 'literal') {
// TODO: depends on minOccurs
$xml = "<$name$elementNS/>";
} else {
$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
":Array\" " .
$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
':arrayType="' .
$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
':' .
$this->getLocalPart($typeDef['arrayType'])."[0]\"/>";
}
$this->debug("in serializeType: returning: $xml");
return $xml;
}
if (isset($typeDef['multidimensional'])) {
$nv = array();
foreach($value as $v) {
$cols = ',' . sizeof($v);
$nv = array_merge($nv, $v);
}
$value = $nv;
} else {
$cols = '';
}
if (is_array($value) && sizeof($value) >= 1) {
$rows = sizeof($value);
$contents = '';
foreach($value as $k => $v) {
$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
//if (strpos($typeDef['arrayType'], ':') ) {
if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
$contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
} else {
$contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
}
}
} else {
$rows = 0;
$contents = null;
}
// TODO: for now, an empty value will be serialized as a zero element
// array. Revisit this when coding the handling of null/nil values.
if ($use == 'literal') {
$xml = "<$name$elementNS>"
.$contents
."</$name>";
} else {
$xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '.
$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
.':arrayType="'
.$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
.":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">"
.$contents
."</$name>";
}
} elseif ($phpType == 'scalar') {
if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
$elementNS = " xmlns=\"$ns\"";
} else {
if ($unqualified) {
$elementNS = " xmlns=\"\"";
} else {
$elementNS = '';
}
}
if ($use == 'literal') {
if ($forceType) {
$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
} else {
$xml = "<$name$elementNS>$value</$name>";
}
} else {
$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
}
}
$this->debug("in serializeType: returning: $xml");
return $xml;
}
/**
* serializes the attributes for a complexType
*
* @param array $typeDef our internal representation of an XML schema type (or element)
* @param mixed $value a native PHP value (parameter value)
* @param string $ns the namespace of the type
* @param string $uqType the local part of the type
* @return string value serialized as an XML string
* @access private
*/
function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
$xml = '';
if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
$this->debug("serialize attributes for XML Schema type $ns:$uqType");
if (is_array($value)) {
$xvalue = $value;
} elseif (is_object($value)) {
$xvalue = get_object_vars($value);
} else {
$this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
$xvalue = array();
}
foreach ($typeDef['attrs'] as $aName => $attrs) {
if (isset($xvalue['!' . $aName])) {
$xname = '!' . $aName;
$this->debug("value provided for attribute $aName with key $xname");
} elseif (isset($xvalue[$aName])) {
$xname = $aName;
$this->debug("value provided for attribute $aName with key $xname");
} elseif (isset($attrs['default'])) {
$xname = '!' . $aName;
$xvalue[$xname] = $attrs['default'];
$this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
} else {
$xname = '';
$this->debug("no value provided for attribute $aName");
}
if ($xname) {
$xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
}
}
} else {
$this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
}
if (isset($typeDef['extensionBase'])) {
$ns = $this->getPrefix($typeDef['extensionBase']);
$uqType = $this->getLocalPart($typeDef['extensionBase']);
if ($this->getNamespaceFromPrefix($ns)) {
$ns = $this->getNamespaceFromPrefix($ns);
}
if ($typeDef = $this->getTypeDef($uqType, $ns)) {
$this->debug("serialize attributes for extension base $ns:$uqType");
$xml .= $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
} else {
$this->debug("extension base $ns:$uqType is not a supported type");
}
}
return $xml;
}
/**
* serializes the elements for a complexType
*
* @param array $typeDef our internal representation of an XML schema type (or element)
* @param mixed $value a native PHP value (parameter value)
* @param string $ns the namespace of the type
* @param string $uqType the local part of the type
* @param string $use use for part (encoded|literal)
* @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
* @return string value serialized as an XML string
* @access private
*/
function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
$xml = '';
if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
$this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
if (is_array($value)) {
$xvalue = $value;
} elseif (is_object($value)) {
$xvalue = get_object_vars($value);
} else {
$this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
$xvalue = array();
}
// toggle whether all elements are present - ideally should validate against schema
if (count($typeDef['elements']) != count($xvalue)){
$optionals = true;
}
foreach ($typeDef['elements'] as $eName => $attrs) {
if (!isset($xvalue[$eName])) {
if (isset($attrs['default'])) {
$xvalue[$eName] = $attrs['default'];
$this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
}
}
// if user took advantage of a minOccurs=0, then only serialize named parameters
if (isset($optionals)
&& (!isset($xvalue[$eName]))
&& ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
){
if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
$this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
}
// do nothing
$this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
} else {
// get value
if (isset($xvalue[$eName])) {
$v = $xvalue[$eName];
} else {
$v = null;
}
if (isset($attrs['form'])) {
$unqualified = ($attrs['form'] == 'unqualified');
} else {
$unqualified = false;
}
if (isset($attrs['maxOccurs']) && ($attrs['maxOccurs'] == 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruct($v) == 'arraySimple') {
$vv = $v;
foreach ($vv as $k => $v) {
if (isset($attrs['type']) || isset($attrs['ref'])) {
// serialize schema-defined type
$xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
} else {
// serialize generic type (can this ever really happen?)
$this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
$xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
}
}
} else {
if (isset($attrs['type']) || isset($attrs['ref'])) {
// serialize schema-defined type
$xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
} else {
// serialize generic type (can this ever really happen?)
$this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
$xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
}
}
}
}
} else {
$this->debug("no elements to serialize for XML Schema type $ns:$uqType");
}
if (isset($typeDef['extensionBase'])) {
$ns = $this->getPrefix($typeDef['extensionBase']);
$uqType = $this->getLocalPart($typeDef['extensionBase']);
if ($this->getNamespaceFromPrefix($ns)) {
$ns = $this->getNamespaceFromPrefix($ns);
}
if ($typeDef = $this->getTypeDef($uqType, $ns)) {
$this->debug("serialize elements for extension base $ns:$uqType");
$xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
} else {
$this->debug("extension base $ns:$uqType is not a supported type");
}
}
return $xml;
}
/**
* adds an XML Schema complex type to the WSDL types
*
* @param string name
* @param string typeClass (complexType|simpleType|attribute)
* @param string phpType: currently supported are array and struct (php assoc array)
* @param string compositor (all|sequence|choice)
* @param string restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
* @param array elements = array ( name => array(name=>'',type=>'') )
* @param array attrs = array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
* @param string arrayType: namespace:name (xsd:string)
* @see xmlschema
* @access public
*/
function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') {
if (count($elements) > 0) {
foreach($elements as $n => $e){
// expand each element
foreach ($e as $k => $v) {
$k = strpos($k,':') ? $this->expandQname($k) : $k;
$v = strpos($v,':') ? $this->expandQname($v) : $v;
$ee[$k] = $v;
}
$eElements[$n] = $ee;
}
$elements = $eElements;
}
if (count($attrs) > 0) {
foreach($attrs as $n => $a){
// expand each attribute
foreach ($a as $k => $v) {
$k = strpos($k,':') ? $this->expandQname($k) : $k;
$v = strpos($v,':') ? $this->expandQname($v) : $v;
$aa[$k] = $v;
}
$eAttrs[$n] = $aa;
}
$attrs = $eAttrs;
}
$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
$arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType;
$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
$this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType);
}
/**
* adds an XML Schema simple type to the WSDL types
*
* @param string $name
* @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
* @param string $typeClass (should always be simpleType)
* @param string $phpType (should always be scalar)
* @param array $enumeration array of values
* @see xmlschema
* @access public
*/
function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
$this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration);
}
/**
* adds an element to the WSDL types
*
* @param array $attrs attributes that must include name and type
* @see xmlschema
* @access public
*/
function addElement($attrs) {
$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
$this->schemas[$typens][0]->addElement($attrs);
}
/**
* register an operation with the server
*
* @param string $name operation (method) name
* @param array $in assoc array of input values: key = param name, value = param type
* @param array $out assoc array of output values: key = param name, value = param type
* @param string $namespace optional The namespace for the operation
* @param string $soapaction optional The soapaction for the operation
* @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically
* @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now)
* @param string $documentation optional The description to include in the WSDL
* @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
* @access public
*/
function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
if ($use == 'encoded' && $encodingStyle == '') {
$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
}
if ($style == 'document') {
$elements = array();
foreach ($in as $n => $t) {
$elements[$n] = array('name' => $n, 'type' => $t);
}
$this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
$this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
$in = array('parameters' => 'tns:' . $name);
$elements = array();
foreach ($out as $n => $t) {
$elements[$n] = array('name' => $n, 'type' => $t);
}
$this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
$this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType'));
$out = array('parameters' => 'tns:' . $name . 'Response');
}
// get binding
$this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] =
array(
'name' => $name,
'binding' => $this->serviceName . 'Binding',
'endpoint' => $this->endpoint,
'soapAction' => $soapaction,
'style' => $style,
'input' => array(
'use' => $use,
'namespace' => $namespace,
'encodingStyle' => $encodingStyle,
'message' => $name . 'Request',
'parts' => $in),
'output' => array(
'use' => $use,
'namespace' => $namespace,
'encodingStyle' => $encodingStyle,
'message' => $name . 'Response',
'parts' => $out),
'namespace' => $namespace,
'transport' => 'http://schemas.xmlsoap.org/soap/http',
'documentation' => $documentation);
// add portTypes
// add messages
if($in)
{
foreach($in as $pName => $pType)
{
if(strpos($pType,':')) {
$pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
}
$this->messages[$name.'Request'][$pName] = $pType;
}
} else {
$this->messages[$name.'Request']= '0';
}
if($out)
{
foreach($out as $pName => $pType)
{
if(strpos($pType,':')) {
$pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
}
$this->messages[$name.'Response'][$pName] = $pType;
}
} else {
$this->messages[$name.'Response']= '0';
}
return true;
}
}
?>