This repository has been archived by the owner on Jun 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
WsdlToPhpGenerator.php
executable file
·3610 lines (3610 loc) · 166 KB
/
WsdlToPhpGenerator.php
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
<?php
/**
* File for class WsdlToPhpGenerator
* @package WsdlToPhpGenerator
* @date 19/12/2012
*/
/**
* Class WsdlToPhpGenerator
* This class replaces the original WsdlToPhp class.
* It uses the WsdlToPhpModel's classes (WsdlToPhpStruct, WsdlToPhpService, WsdlToPhpFunction, WsdlToPhpStructAttribute, WsdlToPhpStructValue) in order to rationalize informations.
* From now, each class is clearly identified depending on its behaviour :
* <ul>
* <li>{PackageName}Service* : class which gathers the operations/functions (based on their name)</li>
* <li>{PackageName}Struct* : class which represents a struct type which can be used either for requesting or catching response</li>
* <li>{PackageName}Enum* : class which represents an enumeration of values. Each value is defined with a constant</li>
* <li>{PackageName}WsdlClass : mother class of all generated class if enabled. This class defines all the generic methods and the needed configurations/methods to call the SOAP WS</li>
* <li>{PackageName}ClassMap : class that constains one final public static method which returns the array to map structs/enums to generated classes</li>
* </ul>
* Test case examples
* <ul>
* <li>
* "Full" documentation (functions, structs, enumerations, values) with "virual" structs inheritance documentation :
* <ul>
* <li>{@link http://developer.ebay.com/webservices/latest/ebaySvc.wsdl}</li>
* <li>{@link https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl}</li>
* <li>{@link http://queue.amazonaws.com/doc/2012-11-05/QueueService.wsdl}</li>
* <li>{@link https://xhi.venere.com/xhi-1.0/services/OTA_ReadNotifReport.soap?wsdl}</li>
* </ul>
* </li>
* <li>Restriction on struct attributes :
* <ul>
* <li>{@link https://services.pwsdemo.com/WSDL/PwsDemo_creditcardtransactionservice.xml}</li>
* <li>{@link http://api.temando.com/schema/2009_06/server.wsdl}</li>
* <li>{@link http://info.portaldasfinancas.gov.pt/NR/rdonlyres/02357996-29FC-4F11-9F1D-6EA2B9210D60/0/factemiws.wsdl}</li>
* </ul>
* </li>
* <li>Operations or struct attributes with an illegal character (ex : ., -) :
* <ul>
* <li>{@link http://api.fromdoppler.com/Default.asmx?WSDL}</li>
* <li>{@link https://webapi.aukro.cz/uploader.php?wsdl}</li>
* <li>{@link https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl}</li>
* </ul>
* </li>
* <li>Simple function parameter (not a struct) :
* <ul>
* <li>{@link http://traveltek-importer.planetcruiseluxury.co.uk/region.wsdl}</li>
* </ul>
* </li>
* <li>Enumerations with two similar values (ex : y and Y in RecurringFlagType) :
* <ul>
* <li>{@link https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl}</li>
* </ul>
* </li>
* <li>Enumerations embedded in an element :
* <ul>
* <li>{@link http://92.70.240.139/webservices_test/?WSDL}</li>
* </ul>
* </li>
* <li>Lots of import tags :
* <ul>
* <li>{@link http://secapp.euroconsumers.org/partnerservice/PartnerService.svc?wsdl}</li>
* <li>{@link https://webservices.netsuite.com/wsdl/v2012_2_0/netsuite.wsdl}</li>
* <li>{@link http://mobile.esseginformatica.com:8704/?wsdl}</li>
* <li>{@link https://api.bullhornstaffing.com/webservices-2.5/?wsdl}</li>
* <li>{@link http://46.31.56.162/abertis/Sos.asmx?WSDL}</li>
* <li>{@link http://www.reservationfactory.com/wsdls/air_v21_0/Air.wsdl} with relative paths like ../ which causes bugs</li>
* </ul>
* </li>
* <li>"Deep", numerous inheritance in struct classes :
* <ul>
* <li>{@link https://moa.mazdaeur.com/mud-services/ws/PartnerService?wsdl}</li>
* <li>{@link http://developer.ebay.com/webservices/latest/ebaySvc.wsdl}</li>
* <li>{@link https://www.tipsport.cz/webtip/CommonBettingWS?WSDL}</li>
* <li>{@link https://www.tipsport.cz/webtip/LiveBettingWS?WSDL}</li>
* <li>{@link https://webservices.netsuite.com/wsdl/v2012_2_0/netsuite.wsdl}</li>
* <li>{@link https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl}</li>
* <li>{@link http://mobile.esseginformatica.com:8704/?wsdl}</li>
* <li>{@link https://api.bullhornstaffing.com/webservices-2.5/?wsdl}</li>
* <li>{@link http://46.31.56.162/abertis/Sos.asmx?WSDL} (real deep inheritance from AbstractGMLType)</li>
* <li>{@link http://securedev.sedagroup.com.au/ws/jadehttp.dll?SOS&listName=SedaWebService&serviceName=SedaWebServiceProvider&wsdl=wsdl}</li>
* <li>{@link https://raw.github.com/jkinred/psphere/master/psphere/wsdl/vimService.wsdl}</li>
* <li>{@link http://staging.timatic.aero/timaticwebservices/timatic3.WSDL}</li>
* <li>{@link http://www.reservationfactory.com/wsdls/air_v21_0/Air.wsdl}</li>
* <li>{@link http://voipnow2demo.4psa.com//soap2/schema/3.0.0/voipnowservice.wsdl}</li>
* </ul>
* </li>
* <li>Multiple service operations returns the same response type (getResult() doc comment must return one type of each) :
* <ul>
* <li>{@link https://secure.dev.logalty.es/lgt/logteca/emisor/services/IncomingServiceWSI?wsdl}</li>
* <li>{@link http://partners.a2zinc.net/dataservices/public/exhibitorprovider.asmx?WSDL}</li>
* </ul>
* </li>
* <li>Documentation on WSDL (must be found in the generated *WsdlClass) doc comment :
* <ul>
* <li>{@link http://iplaypen.globelabs.com.ph:1881/axis2/services/Platform?wsdl}</li>
* <li>{@link https://oivs.mvtrip.alabama.gov/service/XMLExchangeServiceCore.asmx?WSDL}</li>
* </ul>
* </li>
* <li>PHP reserved keyword in operation name (ex : list, add), replaced by _{keyword} :
* <ul>
* <li>{@link https://api5.successfactors.eu/sfapi/v1/soap12?wsdl}</li>
* <li>{@link https://webservices.netsuite.com/wsdl/v2012_2_0/netsuite.wsdl}</li>
* </ul>
* </li>
* <li>Send ArrayAsParameter and ParametersAsArray case :
* <ul>
* <li>{@link http://api.bing.net/search.wsdl}</li>
* </ul>
* </li>
* <li>Send parameters separately :
* <ul>
* <li>{@link http://www.ovh.com/soapi/soapi-dlw-1.54.wsdl}</li>
* </ul>
* </li>
* <li>Struct attribute named _ :
* <ul>
* <li>{@link http://46.31.56.162/abertis/Sos.asmx?WSDL} (DirectPositionType, StringOrRefType, AreaType, etc.)</li>
* </ul>
* </li>
* <li>From now, it can generate service function from RPC style SOAP WS. RPC style :
* <ul>
* <li>{@link http://www.ovh.com/soapi/soapi-re-1.54.wsdl}</li>
* <li>{@link http://postlinks.com/api/soap/v1.1/postlinks.wsdl}</li>
* <li>{@link http://psgsa.dyndns.org:8020/gana/crm/service/v4_1/soap.php?wsdl}</li>
* <li>{@link http://www.electre.com/WebService/search.asmx?WSDL}</li>
* <li>{@link http://www.mobilefish.com/services/web_service/countries.php?wsdl}</li>
* <li>{@link http://webservices.seek.com.au/FastLanePlus.asmx?WSDL}</li>
* <li>{@link https://webapi.aukro.cz/uploader.php?wsdl}</li>
* <li>{@link http://castonclients.com/fuelcircle/api/member.php?wsdl}</li>
* <li>{@link https://www.fieldnation.com/api/v3.5/fieldnation.wsdl}</li>
* <li>{@link https://gateway2.pagosonline.net/ws/WebServicesClientesUT?wsdl}</li>
* <li>{@link http://webservices.seek.com.au/webserviceauthenticator.asmx?WSDL}</li>
* <li>{@link http://webservices.seek.com.au/fastlaneplus.asmx?WSDL}</li>
* <li>{@link https://80.77.87.229:2443/soap?wsdl}</li>
* <li>{@link http://www.mantisbt.org/demo/api/soap/mantisconnect.php?wsdl}</li>
* <li>{@link http://mira.16.1.t1.connectivegames.com/axis/services/RemoteAffiliateService?wsdl}</li>
* <li>{@link http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl}</li>
* <li>{@link https://www.mygate.co.za/enterprise/4x0x0/ePayService.cfc?wsdl}</li>
* <li>{@link http://59.162.33.102/HotelXML_V1.2/services/HotelAvailSearch?wsdl}</li>
* <li>{@link http://api.4shared.com/jax2/DesktopApp?wsdl}</li>
* <li>{@link http://www.eaglepictures.com/services.php/Eagle.wsdl}</li>
* <li>{@link http://online.axiomtelecom.com/staging/api/v2_soap/?wsdl}</li>
* <li>{@link http://www.konakart.com/konakart/services/KKWebServiceEng?wsdl}</li>
* <li>{@link http://soamoa.org:9292/artistRegistry?WSDL}</li>
* <li>{@link http://pgw-dev.aora.tv/trio/index.php?wsdl}</li>
* <li>{@link http://npg.dl.ac.uk/MIDAS/MIDASWebServices/MIDASWebServices/VMEAccessServer.wsdl}</li>
* </ul>
* </li>
* <li>From now, method without any parameter are generated well. A method without any parameter :
* <ul>
* <li>{@link http://verkopen.marktplaats.nl/soap/mpplt.php?wsdl} (GetCategoryList, GetCategoryListRevision, GetPriceTypeList, GetPriceTypeListRevision, GetAttributeListRevision, GetSystemTimestamp)</li>
* <li>{@link https://gateway2.pagosonline.net/ws/WebServicesClientesUT?wsdl} (doInit(), TestServiceGet, TestServiceLeer)</li>
* </ul>
* </li>
* <li>Operation name with illegal characters :
* <ul>
* <li>{@link https://raw.github.com/Sn3b/Omniture-API/master/Solution%20Items/OmnitureAdminServices.wsdl} (. in the operation name, so __soapCall method is used)</li>
* </ul>
* </li>
* <li>Struct attributes with same but different case (ProcStat and Procstat) should have distinct method to set and get (getProcStat/setProcStat and getProcstat_1/setProcstat_1) the value.</li>
* <li>The contruct method must also define the key in the associative array with the corresponding method name. Plus, the operation/function which use ths attribute must call the distinct method (getProcStat and getProcstat_1). See {@link http://the-echoplex.net/log/php-case-sensitivity}</li>
* <li>Catch SOAPHeader definitions :
* <ul>
* <li>{@link http://164.9.104.198/dhlexpress4youservice/Express4YouService.svc?wsdl}</li>
* <li>{@link http://api.atinternet-solutions.com/toolbox/reporting.asmx?WSDL}</li>
* <li>{@link http://developer.ebay.com/webservices/latest/ebaySvc.wsdl}</li>
* <li>{@link https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl}</li>
* <li>{@link https://webservices.netsuite.com/wsdl/v2012_2_0/netsuite.wsdl}</li>
* <li>{@link http://securedev.sedagroup.com.au/ws/jadehttp.dll?SOS&listName=SedaWebService&serviceName=SedaWebServiceProvider&wsdl=wsdl}</li>
* <li>{@link http://api.actonsoftware.com/soap/services/ActonService2?wsdl}, multiple header for a given operation</li>
* <li>{@link http://webservices.eurotaxglass.com/wsdl/forecast.wsdl}</li>
* <li>{@link http://s7ips1.scene7.com/scene7/webservice/IpsApi.wsdl}</li>
* <li>{@link https://ewus.nfz.gov.pl/ws-broker-server-ewus/services/ServiceBroker?wsdl}</li>
* <li>{@link http://webservices.micros.com/ows/5.1/Security.wsdl}</li>
* <li>{@link https://oivs.mvtrip.alabama.gov/service/XMLExchangeServiceCore.asmx?WSDL}</li>
* <li>{@link http://91.93.143.3/bbmvoice/VoiceRecService.asmx?WSDL}</li>
* <li>{@link http://92.45.22.83/CLZMobileWebService/MobileWebService.asmx?WSDL}</li>
* <li>{@link http://87.106.12.100:9090/schemas/order-service.wsdl}</li>
* <li>{@link http://destservices.touricoholidays.com/DestinationsService.svc?wsdl}</li>
* <li>{@link http://partners.a2zinc.net/dataservices/public/exhibitorprovider.asmx?WSDL}</li>
* <li>{@link http://sharepoint-wsdl.googlecode.com/svn/trunk/WSDL/dspsts.asmx.xml}, multiple header for a given operation</li>
* <li>{@link http://eit.ebscohost.com/Services/SearchService.asmx?WSDL}</li>
* <li>{@link http://drachenklasse.hosted-application.de/WebService.asmx?WSDL}</li>
* <li>{@link https://api.cvent.com/soap/V200611.asmx?WSDL&debug=1}</li>
* <li>{@link http://www.xignite.com/xIndices.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xCurrencies.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xInsider.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xCompensation.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xGlobalHistorical.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xRealTime.asmx?WSDL}</li>
* <li>{@link https://adwords.google.com/api/adwords/cm/v201209/CampaignService?wsdl}</li>
* <li>{@link https://americommerce.com/store/ws/AmeriCommerceDb.asmx?wsdl}</li>
* <li>{@link http://www.relaiscolis.com/wsInfoRelaisTest/wsInfoRelais.asmx?WSDL}</li>
* <li>{@link https://api.channeladvisor.com/ChannelAdvisorAPI/v3/MarketplaceAdService.asmx?WSDL}</li>
* <li>{@link http://ws1.ems6.net/subscribers.asmx?WSDL}</li>
* <li>{@link http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xVWAP.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xScreener.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xChart.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xStatistics.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xHousing.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xExchanges.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xCalendar.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xIndexComponents.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xMetals.asmx?WSDL}</li>
* <li>{@link http://globalrealtimeoptions.xignite.com/xglobalrealtimeoptions.asmx?WSDL}</li>
* <li>{@link http://globaloptions.xignite.com/xglobaloptions.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xEnergy.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xFutures.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xMoneyMarkets.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xInterBanks.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xRates.asmx?WSDL}</li>
* <li>{@link http://bondsrealtime.xignite.com/xBondsRealTime.asmx?WSDL}</li>
* <li>{@link http://bonds.xignite.com/xBonds.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xFundHoldings.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xFundData.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xFunds.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xNews.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xOFAC.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xTranscripts.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xReleases.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xLogos.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xHoldings.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xEarningsCalendar.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xEstimates.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xEdgar.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xAnalysts.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xGlobalFundamentals.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xFundamentals.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xFinancials.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xHistorical.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xNASDAQLastSale.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xBATSLastSale.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xBATSRealTime.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xQuotes.asmx?WSDL}</li>
* <li>{@link http://globalquotes.xignite.com/xglobalquotes.asmx?WSDL}</li>
* <li>{@link http://globalrealtime.xignite.com/xglobalrealtime.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xWatchLists.asmx?WSDL}</li>
* <li>{@link http://www.xignite.com/xSecurity.asmx?WSDL}</li>
* <li>{@link http://globalbondmaster.xignite.com/xGlobalBondMaster.asmx?WSDL}</li>
* <li>{@link http://globalmaster.xignite.com/xglobalmaster.asmx?WSDL}</li>
* <li>{@link http://bondmaster.xignite.com/xBondMaster.asmx?WSDL}</li>
* <li>{@link http://radiopilatusadmin.showare.sta.v-1.ch/WebServices/MemberDataServiceProvider.asmx?WSDL}</li>
* <li>{@link http://mail.yahooapis.com/ws/mail/v1.1/wsdl}</li>
* <li>{@link https://xhi.venere.com/xhi-1.0/services/OTA_ReadNotifReport.soap?wsdl}, multiple header for a given operation</li>
* <li>{@link http://demo.braingroup.ch/financial-kernel-ws/b2c/1?wsdl}</li>
* <li>{@link http://demo.braingroup.ch/financial-kernel-ws/tax/1?wsdl}</li>
* <li>{@link http://commonwebservices.saralee-de.com/mcdb2g/Services.asmx?WSDL}</li>
* <li>{@link http://staging.timatic.aero/timaticwebservices/timatic3.WSDL} sessionID for processLogin has a header with required="false"</li>
* <li>{@link http://www.reservationfactory.com/wsdls/air_v21_0/Air.wsdl}</li>
* <li>{@link http://unit4.detuinmachinecompany.com/wsdl.xml} WebID for operations is required with wsdl:required="true"</li>
* <li>{@link http://www.martonhouse.net/Invensys/InvensysAPI.asmx?WSDL}</li>
* <li>{@link http://yz.emsecure.net/automation/individual.asmx?WSDL}</li>
* </ul>
* </li>
* <li>Similar struct name:
* <ul>
* <li>{@link http://voipnow2demo.4psa.com//soap2/schema/3.0.0/voipnowservice.wsdl} timeInterval/TimeInterval, recharge/Recharge</li>
* </ul>
* </li>
* <li>Undefined parameter/return types by the SoapClient but determined by the WsdlToPhpGenerator class
* <ul>
* <li>{@link http://portaplusapi.icc-switch.com/soap12}</li>
* </ul>
* </li>
* <li>Operations calls own obect parameter methods and inherited methods (php code and php doc must take account of the inheritance) :
* <ul>
* <li>{@link http://voipnow2demo.4psa.com//soap2/schema/3.0.0/voipnowservice.wsdl}, ex : Add, AddUser, AddServiceProvider</li>
* <li>{@link http://www.reservationfactory.com/wsdls/air_v21_0/Air.wsdl}, ex : service</li>
* </ul>
* </li>
* <li>Biggest Packages generated :
* <ul>
* <li>{@link https://raw.github.com/jkinred/psphere/master/psphere/wsdl/vimService.wsdl}</li>
* <li>{@link https://americommerce.com/store/ws/AmeriCommerceDb.asmx?wsdl}</li>
* <li>{@link http://www.ovh.com/soapi/soapi-dlw-1.54.wsdl}</li>
* <li>{@link https://webservices.netsuite.com/wsdl/v2012_2_0/netsuite.wsdl}</li>
* </ul>
* </li>
* <li>Web Service with multiple parameters of same type per operation, parameters are now named as the original parameter name
* <ul>
* <li>{@link http://demo.magentocommerce.com/api/v2_soap?wsdl=1}, ex: login operation</li>
* </ul>
* </li>
* <li>Web Service with all parameter only detected with unknown parameter type and return per operation. These types must be retrieved from the WSDLs
* <ul>
* <li>{@link http://196.29.140.10:9091/services/MyBoardPack.Soap.svc?singleWsdl}</li>
* </ul>
* </li>
* </ul>
* @package WsdlToPhpGenerator
* @date 19/12/2012
*/
class WsdlToPhpGenerator extends SoapClient
{
/**
* Index where global values are stored in order to unset them once when it's necessary and to clean GLOBALS
* @var string
*/
const WSDL_TO_PHP_GENERATOR_GLOBAL_KEY = '__WsdlToPhpGeneratorGlobalKey__';
/**
* Index where audit values are stored in the global var
* @var string
*/
const WSDL_TO_PHP_GENERATOR_AUDIT_KEY = '__WsdlToPhpGeneratorAuditKey__';
/**
* Sets categorization of classes based on the end of the name of the struct or the function
* The category set the tree folders
* @var int
*/
const OPT_CAT_END_NAME = 0;
/**
* Sets categorization of classes based on the start of the name of the struct or the function
* The category set the tree folders
* @var int
*/
const OPT_CAT_START_NAME = 1;
/**
* Sets uncategorization of classes
* All files are put in the same folder
* @var int
*/
const OPT_CAT_NONE_NAME = 2;
/**
* Sets typed categorization of classes
* Files are put in folder named as their ContextualPart value.
* In this cas, there is no subfolder.
* @var int
*/
const OPT_CAT_TYPE = 3;
/**
* Index to set categorization when calling the constructor
* @var string
*/
const OPT_CAT_KEY = 'option_category_key';
/**
* Sets subcategorization of classes based on the end of the name of the struct or the function
* The category set the tree folders
* @var int
*/
const OPT_SUB_CAT_END_NAME = 0;
/**
* Sets subcategorization of classes based on the start of the name of the struct or the function
* The category set the tree folders
* @var int
*/
const OPT_SUB_CAT_START_NAME = 1;
/**
* Sets uncategorization of classes
* All files are put in the same folder
* @var int
*/
const OPT_SUB_CAT_NONE_NAME = 2;
/**
* Index to set subcategorization when calling the constructor
* @var string
*/
const OPT_SUB_CAT_KEY = 'option_sub_category_key';
/**
* Sets gathering mode of mtehod per class based on the end of the name of the operation
* @var int
*/
const OPT_GATH_METH_END_NAME = 0;
/**
* Sets gathering mode of mtehod per class based on the start of the name of the operation
* @var int
*/
const OPT_GATH_METH_START_NAME = 1;
/**
* Index to set gathering methods when calling the constructor
* @var string
*/
const OPT_GATH_METH_KEY = 'option_gather_methods_key';
/**
* Index to set gathering methods when calling the constructor
* @var string
*/
const OPT_SEND_PARAM_AS_ARRAY_KEY = 'option_send_param_as_array_key';
/**
* Index to enable/disable autoload file generation
* @var string
*/
const OPT_GEN_AUTOLOAD_KEY = 'option_generate_autaload_file_key';
/**
* Index to enable/disable autoload file generation
* @var string
*/
const OPT_GEN_WSDL_CLASS_KEY = 'option_generate_wsdl_class_key';
/**
* Index to enable/disable encapsulation of response or not in the response object
* @var string
*/
const OPT_RESPONSE_AS_WSDL_OBJECT_KEY = 'option_response_as_wsdl_object_key';
/**
* Index to enable/disable encapsulation of request in array with 'parameters' as main index
* @var string
*/
const OPT_SEND_PARAMETERS_AS_ARRAY_KEY = 'option_send_parameters_as_array_key';
/**
* Index to set string that points bases classes from which some classes inherits
* @var string
*/
const OPT_INHERITS_FROM_IDENTIFIER_KEY = 'option_inherits_from_identifier_key';
/**
* Index to set the generation of contants names based on the enumeration name with an incremental value
* @var string
*/
const OPT_GENERIC_CONSTANTS_NAMES_KEY = 'option_generic_constants_names_key';
/**
* Index to enable/disable tutorial file generation
* @var string
*/
const OPT_GEN_TUTORIAL_KEY = 'option_generate_tutorial_file_key';
/**
* Index to set additional PHP doc block tags to every generated file and class
* In order to set additional PHP doc block tags, pass an associative array as for example:
* - date=>date('Y-m-d')
* - author=>'Mikaël DELSOL'
* - etc.
* so every generated file and class will contain these PHP doc block tags:
* @date 2013-05-23
* @author Mikaël DELSOL
* etc.
* By default, the "date" tag is added with the current date
* @var string
*/
const OPT_ADD_COMMENTS = 'option_add_comments_key';
/**
* Index to enable/disable debug mode.
* Debug only display each call to the audit method to follow the calls and treatments
* @var string
*/
const OPT_DEBUG = 'option_debug';
/**
* Structs array
* @var array
*/
private $structs;
/**
* Services arrays
* @var array
*/
private $services;
/**
* Name of the package to use
* @var string
*/
private static $packageName;
/**
* Wsdl lists
* @var array
*/
private $wsdls;
/**
* Option to categorize classes
* @var int
*/
private static $optionCategory;
/**
* Option to subcategorize classes
* @var int
*/
private static $optionSubCategory;
/**
* Option to define how to gather methods by classes
* @var int
*/
private static $optionGatherMethods;
/**
* Option to set that parameters to soap call must be contained by an array where indexex are the parameters name
* @var bool
*/
private static $optionSendArrayAsParameter;
/**
* Option to enabled/disable autoload file generation
* @var bool
*/
private static $optionGenerateAutoloadFile;
/**
* Option to enabled/disable wsdl class file generation
* @var bool
*/
private static $optionGenerateWsdlClassFile;
/**
* Option to enable/disable encapsulation of response or not in the response class
* @var bool
*/
private static $optionResponseAsWsdlObject;
/**
* Option to enable/disable encapsulation of request in array with 'parameters' as main index
* @var bool
*/
private static $optionSendParametersAsArray;
/**
* Option to set string that points bases classes from which some classes inherits
* @var string
*/
private static $optionInheritsClassIdentifier;
/**
* Option to set set the generation of contants names based on the enumeration name with an incremental value
* @var string
*/
private static $optionGenericConstantsNames;
/**
* Option to enabled/disable tutorial file generation
* @var bool
*/
private static $optionGenerateTutorialFile;
/**
* Option to set additional PHP doc block tags to every generated file and class
* @var array
*/
private static $optionAddComments;
/**
* Option to set debug
* @var bool
*/
private static $optionDebug;
/**
* Use intern global variable instead of using the PHP $GLOBALS variable
* @var array
*/
private static $globals;
/**
* Constructor
* @uses SoapClient::__construct()
* @uses WsdlToPhpGenerator::setStructs()
* @uses WsdlToPhpGenerator::setServices()
* @uses WsdlToPhpGenerator::setWsdls()
* @uses WsdlToPhpGenerator::addWsdl()
* @uses WsdlToPhpGenerator::setOptionDebug()
* @uses WsdlToPhpGenerator::setOptionCategory()
* @uses WsdlToPhpGenerator::setOptionGenerateAutoloadFile()
* @uses WsdlToPhpGenerator::setOptionGenerateTutorialFile()
* @uses WsdlToPhpGenerator::setOptionAddComments()
* @uses WsdlToPhpGenerator::setOptionSubCategory()
* @uses WsdlToPhpGenerator::setOptionGenerateWsdlClassFile()
* @uses WsdlToPhpGenerator::setOptionGatherMethods()
* @uses WsdlToPhpGenerator::setOptionSendArrayAsParameter()
* @uses WsdlToPhpGenerator::setOptionResponseAsWsdlObject()
* @uses WsdlToPhpGenerator::setOptionGenericConstantsNames()
* @uses WsdlToPhpGenerator::setOptionInheritsClassIdentifier()
* @uses WsdlToPhpGenerator::setOptionSendParametersAsArray()
* @uses WsdlToPhpGenerator::OPT_DEBUG
* @uses WsdlToPhpGenerator::OPT_CAT_KEY
* @uses WsdlToPhpGenerator::OPT_CAT_START_NAME
* @uses WsdlToPhpGenerator::OPT_GEN_AUTOLOAD_KEY
* @uses WsdlToPhpGenerator::OPT_GEN_TUTORIAL_KEY
* @uses WsdlToPhpGenerator::OPT_SUB_CAT_KEY
* @uses WsdlToPhpGenerator::OPT_ADD_COMMENTS
* @uses WsdlToPhpGenerator::OPT_SUB_CAT_START_NAME
* @uses WsdlToPhpGenerator::OPT_GEN_WSDL_CLASS_KEY
* @uses WsdlToPhpGenerator::OPT_GATH_METH_KEY
* @uses WsdlToPhpGenerator::OPT_GATH_METH_START_NAME
* @uses WsdlToPhpGenerator::OPT_SEND_PARAM_AS_ARRAY_KEY
* @uses WsdlToPhpGenerator::OPT_RESPONSE_AS_WSDL_OBJECT_KEY
* @uses WsdlToPhpGenerator::OPT_GENERIC_CONSTANTS_NAMES_KEY
* @uses WsdlToPhpGenerator::OPT_INHERITS_FROM_IDENTIFIER_KEY
* @uses WsdlToPhpGenerator::OPT_SEND_PARAMETERS_AS_ARRAY_KEY
* @param string $_pathToWsdl WSDL url or path
* @param string $_login login to get access to WSDL
* @param string $_password password to get access to WSDL
* @param array $_options associative array between WsdlToPhpGenerator options keys and values
* @param array $_wsdlOptions options to get access to WSDL
* @return WsdlToPhpGenerator
*/
public function __construct($_pathToWsdl,$_login = false,$_password = false,array $_options = array(),array $_wsdlOptions = array())
{
$pathToWsdl = trim($_pathToWsdl);
/**
* Options for WSDL
*/
$options = $_wsdlOptions;
$options['trace'] = true;
$options['exceptions'] = true;
$options['cache_wsdl'] = WSDL_CACHE_NONE;
$options['soap_version'] = SOAP_1_1;
if(!empty($_login) && !empty($_password))
{
$options['login'] = $_login;
$options['password'] = $_password;
}
$this->setStructs();
$this->setServices();
$this->setWsdls();
/**
* Construct
*/
try
{
parent::__construct($pathToWsdl,$options);
}
catch(SoapFault $fault)
{
//print_r($fault);
$options['soap_version'] = SOAP_1_2;
try
{
parent::__construct($pathToWsdl,$options);
}
catch(SoapFault $fault)
{
//print_r($fault);
}
}
$this->addWsdl($pathToWsdl);
/**
* Sets attributes
*/
self::setOptionDebug(array_key_exists(self::OPT_DEBUG,$_options)?$_options[self::OPT_DEBUG]:false);
self::setOptionCategory(array_key_exists(self::OPT_CAT_KEY,$_options)?$_options[self::OPT_CAT_KEY]:self::OPT_CAT_START_NAME);
self::setOptionGenerateAutoloadFile(array_key_exists(self::OPT_GEN_AUTOLOAD_KEY,$_options)?$_options[self::OPT_GEN_AUTOLOAD_KEY]:false);
self::setOptionGenerateTutorialFile(array_key_exists(self::OPT_GEN_TUTORIAL_KEY,$_options)?$_options[self::OPT_GEN_TUTORIAL_KEY]:false);
self::setOptionAddComments(array_key_exists(self::OPT_ADD_COMMENTS,$_options)?$_options[self::OPT_ADD_COMMENTS]:array(
'date'=>date('Y-m-d')));
self::setOptionSubCategory(array_key_exists(self::OPT_SUB_CAT_KEY,$_options)?$_options[self::OPT_SUB_CAT_KEY]:self::OPT_SUB_CAT_START_NAME);
self::setOptionGenerateWsdlClassFile(array_key_exists(self::OPT_GEN_WSDL_CLASS_KEY,$_options)?$_options[self::OPT_GEN_WSDL_CLASS_KEY]:false);
self::setOptionGatherMethods(array_key_exists(self::OPT_GATH_METH_KEY,$_options)?$_options[self::OPT_GATH_METH_KEY]:self::OPT_GATH_METH_START_NAME);
self::setOptionSendArrayAsParameter(array_key_exists(self::OPT_SEND_PARAM_AS_ARRAY_KEY,$_options)?$_options[self::OPT_SEND_PARAM_AS_ARRAY_KEY]:false);
self::setOptionResponseAsWsdlObject(array_key_exists(self::OPT_RESPONSE_AS_WSDL_OBJECT_KEY,$_options)?$_options[self::OPT_RESPONSE_AS_WSDL_OBJECT_KEY]:false);
self::setOptionGenericConstantsNames(array_key_exists(self::OPT_GENERIC_CONSTANTS_NAMES_KEY,$_options)?$_options[self::OPT_GENERIC_CONSTANTS_NAMES_KEY]:false);
self::setOptionInheritsClassIdentifier(array_key_exists(self::OPT_INHERITS_FROM_IDENTIFIER_KEY,$_options)?$_options[self::OPT_INHERITS_FROM_IDENTIFIER_KEY]:'');
self::setOptionSendParametersAsArray(array_key_exists(self::OPT_SEND_PARAMETERS_AS_ARRAY_KEY,$_options)?$_options[self::OPT_SEND_PARAMETERS_AS_ARRAY_KEY]:false);
}
/**
* Generates all classes based on options
* @uses WsdlToPhpGenerator::setPackageName()
* @uses WsdlToPhpGenerator::getWsdl()
* @uses WsdlToPhpGenerator::getStructs()
* @uses WsdlToPhpGenerator::initStructs()
* @uses WsdlToPhpGenerator::getServices()
* @uses WsdlToPhpGenerator::initServices()
* @uses WsdlToPhpGenerator::loadWsdls()
* @uses WsdlToPhpGenerator::getOptionGenerateWsdlClassFile()
* @uses WsdlToPhpGenerator::generateWsdlClassFile()
* @uses WsdlToPhpGenerator::setOptionGenerateWsdlClassFile()
* @uses WsdlToPhpGenerator::generateStructsClasses()
* @uses WsdlToPhpGenerator::generateServicesClasses()
* @uses WsdlToPhpGenerator::generateClassMap()
* @uses WsdlToPhpGenerator::getOptionGenerateAutoloadFile()
* @uses WsdlToPhpGenerator::generateAutoloadFile()
* @uses WsdlToPhpGenerator::getOptionGenerateTutorialFile()
* @uses WsdlToPhpGenerator::generateTutorialFile()
* @uses WsdlToPhpGenerator::initGlobals()
* @uses WsdlToPhpGenerator::auditInit()
* @uses WsdlToPhpGenerator::audit()
* @param string $_packageName the string used to prefix all generate classes
* @param string $_rootDirectory path where classes should be generated
* @param int $_rootDirectoryRights system rights to apply on folder
* @param bool $_createRootDirectory create root directory if not exist
* @return bool true|false depending on the well creation fot the root directory
*/
public function generateClasses($_packageName,$_rootDirectory,$_rootDirectoryRights = 0775,$_createRootDirectory = true)
{
self::initGlobals();
$wsdl = $this->getWsdl(0);
self::auditInit('generate_classes',$wsdl);
self::setPackageName($_packageName);
$rootDirectory = $_rootDirectory . (substr($_rootDirectory,-1) != '/'?'/':'');
/**
* Root directory
*/
if(!is_dir($rootDirectory) && !$_createRootDirectory)
return false;
elseif($_createRootDirectory)
@mkdir($rootDirectory,$_rootDirectoryRights);
/**
* Begin process
*/
if(is_dir($rootDirectory))
{
/**
* Initialize elements
*/
$init = false;
if(!count($this->getStructs()))
$this->initStructs();
else
$init = true;
if(!count($this->getServices()))
$this->initServices();
if(!$init && count($this->wsdls))
$this->loadWsdls($wsdl);
/**
* Initialize specific elements when all wsdls are loaded
*/
$this->wsdlsLoaded();
/**
* Generates Wsdl Class ?
*/
if(self::getOptionGenerateWsdlClassFile())
$wsdlClassFile = $this->generateWsdlClassFile($rootDirectory);
else
$wsdlClassFile = array();
if(!count($wsdlClassFile))
self::setOptionGenerateWsdlClassFile(false);
/**
* Generates classes files
*/
$structsClassesFiles = $this->generateStructsClasses($rootDirectory,$_rootDirectoryRights);
$servicesClassesFiles = $this->generateServicesClasses($rootDirectory,$_rootDirectoryRights);
$classMapFile = $this->generateClassMap($rootDirectory);
/**
* Generates autoload ?
*/
if(self::getOptionGenerateAutoloadFile())
self::generateAutoloadFile($rootDirectory,array_merge($wsdlClassFile,$structsClassesFiles,$servicesClassesFiles,$classMapFile));
/**
* Generates tutorial ?
*/
if(self::getOptionGenerateTutorialFile())
$this->generateTutorialFile($rootDirectory,$servicesClassesFiles);
return self::audit('generate_classes',$wsdl);
}
else
return !self::audit('generate_classes',$wsdl);
}
/**
* Initialize structs defined in WSDL :
* - Get structs defined
* - Parse each struct definition
* - Analyze each struct paramaters
* @uses SoapClient::__getTypes()
* @uses WsdlToPhpGenerator::addStruct()
* @uses WsdlToPhpGenerator::addVirtualStruct()
* @uses WsdlToPhpGenerator::auditInit()
* @uses WsdlToPhpGenerator::audit()
* @tutorial restriction aren't get with structs, see loadWsdls :
* <xsd:simpleType name="SearchOption">
* --<xsd:restriction base="xsd:string">
* ----<xsd:enumeration value="DisableLocationDetection"/>
* ----<xsd:enumeration value="EnableHighlighting"/>
* --</xsd:restriction>
* </xsd:simpleType>
* Example on how to send them : http://msdn.microsoft.com/en-us/library/dd250961
* @return bool true|false depending on the well types catching from the WSDL
*/
private function initStructs()
{
self::auditInit('init_structs');
$types = $this->__getTypes();
if(is_array($types) && count($types))
{
$structsDefined = array();
foreach($types as $type)
{
$typeSignature = md5($type);
/**
* Remove useless break line, tabs
*/
$type = str_replace("\r",'',$type);
$type = str_replace("\n",'',$type);
$type = str_replace("\t",'',$type);
/**
* Remove curly braces
*/
$type = str_replace("{",'',$type);
$type = str_replace("}",'',$type);
/**
* Remove brackets
*/
$type = str_replace("[",'',$type);
$type = str_replace("]",'',$type);
/**
* Adds space to parse it
*/
$type = str_replace(';',' ;',$type);
/**
* Remove duplicate spaces
*/
$type = preg_replace('/[\s]+/',' ',$type);
/**
* Explode definition based on format :
* struct {struct_name} {paramName} {paramValue} ;[{paramName} {paramValue} ;]+
*/
$typeDef = explode(' ',$type);
/**
* Gets struct definition start
*/
$struct = $typeDef[0];
if($struct != 'struct')
{
if(!empty($typeDef[1]))
$this->addVirtualStruct($typeDef[1]);
continue;
}
/**
* Catch struct name
*/
$structName = $typeDef[1];
/**
* Struct already known? If not, then parse it and add attributes to it. We don't parse twice the same struct.
* This test now lets pass identically named elements with different structure such as the two followings:
* - struct Create { Create request; }
* - struct Create { ArrayOfDetailItem Details; string UserID; string Password; string TestMode; etc. }
* This will generate a Struct class containing the merge of all the different structures
*/
if(in_array($typeSignature,$structsDefined))
continue;
/**
* Collect struct params
*/
$start = false;
$then = false;
$end = false;
$structParamName = '';
$structParamType = '';
$typeDefCount = count($typeDef);
if($typeDefCount > 3)
{
for($i = 2;$i < $typeDefCount;$i++)
{
$typeVal = $typeDef[$i];
if($typeVal != '{' && is_string($typeVal) && !empty($typeVal) && !$start)
{
$end = false;
$then = false;
$start = true;
}
if($typeVal === ';')
{
$end = true;
$then = false;
$start = false;
}
if($then)
{
$structParamName = $typeVal;
if(!empty($structParamType) && !empty($structParamName) && !empty($structName))
{
$this->addStruct($structName,$structParamName,$structParamType);
array_push($structsDefined,$typeSignature);
$structParamName = '';
$structParamType = '';
}
}
if($start && !$then)
{
/**
* Replace some weird definition to known valid type
*/
$typeVal = str_replace('<anyXML>','DOMDocument',$typeVal);
$structParamType = $typeVal;
$then = true;
}
}
}
else
$this->addStruct($structName,$structParamName,$structParamType);
}
return self::audit('init_structs');
}
else
return !self::audit('init_structs');
}
/**
* Generates structs classes based on structs collected
* @uses WsdlToPhpGenerator::getStructs()
* @uses WsdlToPhpGenerator::getDirectory()
* @uses WsdlToPhpGenerator::populateFile()
* @uses WsdlToPhpGenerator::auditInit()
* @uses WsdlToPhpGenerator::audit()
* @uses WsdlToPhpModel::getName()
* @uses WsdlToPhpModel::getModelByName()
* @uses WsdlToPhpModel::getInheritance()
* @uses WsdlToPhpModel::getCleanName()
* @uses WsdlToPhpModel::getPackagedName()
* @uses WsdlToPhpModel::getClassDeclaration()
* @uses WsdlToPhpStruct::getIsStruct()
* @param string $_rootDirectory the directory
* @param int $_rootDirectoryRights the directory permissions
*/
private function generateStructsClasses($_rootDirectory,$_rootDirectoryRights)
{
self::auditInit('generate_structs');
$structs = $this->getStructs();
$structsClassesFiles = array();
if(count($structs))
{
/**
* Ordering structs in order to generate mother class first and to put them on top in the autoload file
*/
$structsToGenerateDone = array();
foreach($structs as $struct)
{
if(!array_key_exists($struct->getName(),$structsToGenerateDone))
$structsToGenerateDone[$struct->getName()] = 0;
$model = WsdlToPhpModel::getModelByName($struct->getInheritance());
while($model && $model->getIsStruct())
{
if(!array_key_exists($model->getName(),$structsToGenerateDone))
$structsToGenerateDone[$model->getName()] = 1;
else
$structsToGenerateDone[$model->getName()]++;
$model = WsdlToPhpModel::getModelByName($model->getInheritance());
}
}
/**
* Order by priority desc
*/
arsort($structsToGenerateDone);
$structTmp = $structs;
$structs = array();
foreach(array_keys($structsToGenerateDone) as $structName)
$structs[$structName] = $structTmp[$structName];
unset($structTmp,$structsToGenerateDone);
foreach($structs as $structName=>$struct)
{
if(!$struct->getIsStruct())
continue;
$elementFolder = $this->getDirectory($_rootDirectory,$_rootDirectoryRights,$struct);
array_push($structsClassesFiles,$structClassFileName = $elementFolder . $struct->getPackagedName() . '.php');
/**
* Generates file
*/
self::populateFile($structClassFileName,$struct->getClassDeclaration());
}
}
self::audit('generate_structs');
return $structsClassesFiles;
}
/**
* Initialize functions :
* - Get structs defined
* - Parse each struct definition
* @uses SoapClient::__getFunctions()
* @uses WsdlToPhpGenerator::addService()
* @uses WsdlToPhpGenerator::auditInit()
* @uses WsdlToPhpGenerator::audit()
* @return bool true|false depending on the well functions catching from the WSDL
*/
private function initServices()
{
self::auditInit('init_services');
$functions = $this->__getFunctions();
if(is_array($functions) && count($functions))
{
foreach($functions as $function)
{
$infos = explode(' ',$function);
/**
* "Regular" SOAP Style
*/
if(count($infos) <= 3)
{
$returnType = $infos[0];
if(count($infos) < 3 && strpos($infos[1],'()') !== false && array_key_exists(1,$infos))
{
$methodName = trim(str_replace('()','',$infos[1]));
$parameterType = null;
}
else
list($methodName,$parameterType) = explode('(',$infos[1]);
if(!empty($returnType) && !empty($methodName))
$this->addService($methodName,$parameterType,$returnType);
}
/**
* RPC SOAP Style
*/
elseif(count($infos) > 3)
{
/**
* Some RPC WS defines the return type as a list of values
* So we define the return type as an array and reset the informations to use to extract method name and parameters
*/
if(stripos($infos[0],'list(') === 0)
{
$infos = explode(' ',preg_replace('/(list\(.*\)\s)/i','',$function));
array_unshift($infos,'array');
}
/**
* Returns type is not defined in some case
*/
$returnType = strpos($infos[0],'(') === false?$infos[0]:'';
if(empty($returnType) && strpos($infos[0],'(') !== false)
{
$start = 1;
list($methodName,$firstParameterType) = explode('(',$infos[0]);
}
elseif(strpos($infos[1],'(') !== false)
{
$start = 2;
list($methodName,$firstParameterType) = explode('(',$infos[1]);
}
if(!empty($methodName))
{
$methodParameters = array();
$infosCount = count($infos);
for($i = $start;$i < $infosCount;$i += 2)
{
$info = str_replace(array(
',',
'(',
')',
'$'),'',trim($infos[$i]));
if(!empty($info))
$methodParameters = array_merge($methodParameters,array(
$info=>$i == $start?$firstParameterType:$infos[$i - 1]));
}
$this->addService($methodName,$methodParameters,empty($returnType)?'unknown':$returnType);