-
Notifications
You must be signed in to change notification settings - Fork 2
/
idl2wsdl.rex
1131 lines (1052 loc) · 38.2 KB
/
idl2wsdl.rex
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
/*REXX 2.0.0
Copyright (c) 2009-2020, Andrew J. Armstrong
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*REXX*****************************************************************
** **
** NAME - IDL2WSDL **
** **
** FUNCTION - Converts an EntireX Interface Definition Language (IDL)**
** file into a Web Services Description Language (WSDL) **
** file. It may be useful for sites that want to **
** re-implement an EntireX application as a Web Service. **
** It takes the tedium of converting the relatively easy **
** to understand IDL file format into the hideously **
** complex WSDL file format. **
** **
** **
** USAGE - You can run this Rexx on an IBM mainframe, or on a PC **
** by using Regina Rexx from: **
** **
** http://regina-rexx.sourceforge.net **
** **
** **
** SYNTAX IDL2WSDL infile [url [ns [ (options [)] ]]]' **
** **
** Where, **
** infile = Name of your EntireX Interface Definition **
** Language (IDL) file. For example: **
** example.idl **
** url = URL of the service. For example: **
** http://10.1.2.3:8080/cics/cwba/soapima **
** ns = Namespace of the service. For example: **
** http://myservice.example.org **
** options = RPC - Remote Procedure Call (style) **
** DOCUMENT - XML document (style) **
** ENCODED - Parameters defined inline (use) **
** LITERAL - Parameters defined by schema (use)**
** WRAPPED - Special case of DOCUMENT LITERAL **
** XML - Create XML file (for debugging) **
** **
** Valid style and use combinations are: **
** WRAPPED <-- This is the default **
** DOCUMENT LITERAL **
** RPC LITERAL **
** RPC ENCODED **
** **
** NOTES - 1. This Rexx uses the Rexx XML parser in CBT FILE 647 **
** from www.cbttape.org. **
** You will have to either append the PARSEXML and **
** PRETTY source files manually to this file, or run **
** this file through the REXX rexx pre-processor. **
** **
** To use the pre-processor on TSO, run: **
** **
** tso rexxpp your.rexx.lib(idl2wsdl) **
** **
** To use the pre-processor on Windows, run: **
** **
** rexx rexxpp idl2wsdl.rexx idl2wsdl.new **
** **
** ...and then rename the .new file to .rexx **
** **
** AUTHOR - Andrew J. Armstrong <[email protected]> **
** **
** HISTORY - Date By Reason (most recent at the top please) **
** -------- --- ----------------------------------------- **
** 20090822 AJA Changed from GPL to BSD license. **
** 20060525 AJA Update documentation. **
** 20060216 AJA User must supply URL & namespace. **
** 20051106 AJA Support RPC/DOC + ENC/LIT/WRAPPED. **
** 20051102 AJA Intial version. **
** **
**********************************************************************/
parse arg sFileIn sURL sNamespace' ('sOptions')'
numeric digits 16
parse value sourceline(1) with . sVersion
say 'IDL000I EntireX IDL to WSDL File Converter' sVersion
if sFileIn = ''
then do
say 'Syntax:'
say ' IDL2WSDL infile url ns (options'
say
say 'Where:'
say ' infile = EntireX IDL input file. For example:'
say ' example.idl'
say ' url = URL of the service. For example:'
say ' http://10.1.2.3:8080/cics/cwba/soapima'
say ' ns = Namespace of the service. For example:'
say ' http://myservice.example.org'
say ' options = RPC - Remote Procedure Call (style)'
say ' DOCUMENT - XML document (style)'
say ' ENCODED - Parameters defined inline (use)'
say ' LITERAL - Parameters defined by schema (use)'
say ' WRAPPED - Special case of DOCUMENT LITERAL'
say ' XML - Create XML file (for debugging)'
say
say ' Valid option combinations are:'
say ' WRAPPED'
say ' DOCUMENT LITERAL'
say ' RPC LITERAL'
say ' RPC ENCODED'
exit
end
say 'IDL001I Reading EntireX IDL file in' sFileIn
sOptions = 'NOBLANKS' translate(sOptions)
call initParser sOptions /* DO THIS FIRST! Sets g. vars to '' */
call setDocType /* we don't need a doctype declaration */
g.0FILEIDL = sFileIn
g.0URL = prompt(sURL,,
'Enter URL of this service',,
'http://10.1.2.3:8080/cics/cwba/soapima/')
g.0NAMESPACE = prompt(sNamespace,,
'Enter XML namespace of this service',,
'http://myservice.example.org')
parse source g.0ENV .
if g.0ENV = 'TSO'
then do
address ISPEXEC
'CONTROL ERRORS RETURN'
g.0LINES = 0
end
call setOptions sOptions
call Prolog
/* Read the IDL file into an in-memory XML document */
idl = scanEntireXIdlFile()
sFileName = getFilenameWithoutExtension(sFileIn)
libraries = getChildNodes(idl)
do i = 1 to words(libraries)
library = word(libraries,i)
sLibrary = getAttribute(library,'name')
call createWSDL sFileName'.'sLibrary,library
end
call Epilog
exit
prompt: procedure expose g.
parse arg sReply,sPrompt,sDefault
if sReply = ''
then do
say 'IDL000R' sPrompt '['sDefault']:'
parse pull sReply
if sReply = '' then sReply = sDefault
end
return sReply
/*
<wsdl:definitions targetNamespace="yournamespace"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="yournamespace"
xmlns:intf="yournamespace"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
.
.
</wsdl:definitions>
*/
createWSDL: procedure expose g.
parse arg sFile,node
if g.0OPTION.XML
then call prettyPrinter sFile'.xml',,node
/* Build the high-level WSDL file structure... */
g.0DEFS = createElement('wsdl:definitions')
g.0TYPES = createElement('wsdl:types')
g.0PORTTYPE = createElement('wsdl:portType')
g.0BINDING = createElement('wsdl:binding')
g.0SERVICE = createElement('wsdl:service')
/* The porttype, binding and service elements are more-or-less the
same for all combinations of style and use, so build them now... */
call defineDefinitions node
call defineTypes node
call definePortType node
call defineBinding node
call defineService node
call appendChild g.0TYPES,g.0DEFS
/* Now add message elements depending on style and use... */
select
when g.0OPTION.WRAPPED then,
call createDocWrapped node
when g.0OPTION.DOCUMENT & g.0OPTION.LITERAL then,
call createDocLiteral node
when g.0OPTION.RPC & g.0OPTION.LITERAL then,
call createRpcLiteral node
when g.0OPTION.RPC & g.0OPTION.ENCODED then,
call createRpcEncoded node
otherwise,
call createDocWrapped node
end
call appendChild g.0PORTTYPE,g.0DEFS
call appendChild g.0BINDING,g.0DEFS
call appendChild g.0SERVICE,g.0DEFS
/* Serialise the WSDL document to a file... */
call prettyPrinter sFile'.wsdl',,g.0DEFS
return
defineDefinitions: procedure expose g.
parse arg node
call setAttributes g.0DEFS,,
'targetNamespace',g.0NAMESPACE,,
'xmlns:impl',g.0NAMESPACE,,
'xmlns:intf',g.0NAMESPACE,,
'xmlns:wsdl','http://schemas.xmlsoap.org/wsdl/',,
'xmlns:wsdlsoap','http://schemas.xmlsoap.org/wsdl/soap/',,
'xmlns:xsd','http://www.w3.org/2001/XMLSchema'
if g.0OPTION.ENCODED
then call setAttribute g.0DEFS,,
'xmlns:soapenc','http://schemas.xmlsoap.org/soap/encoding/'
call appendChild createComment('Created by EntireX IDL-to-WSDL',
'converter V1.0 on' date() time() userid()),g.0DEFS
if g.0OPTION.WRAPPED
then call appendChild createComment('Style='getStyle() '(wrapped)',
'Use='getUse()),g.0DEFS
else call appendChild createComment('Style='getStyle(),
'Use='getUse()),g.0DEFS
return
/*
<wsdl:types>
<schema targetNamespace="yournamespace"
xmlns="http://www.w3.org/2001/XMLSchema">
<import
namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="SecurityContext">
<sequence>
<element name="reason" nillable="true"
type="soapenc:string"/>
<element name="reasonCode" nillable="true"
type="soapenc:int"/>
<element name="returnCode" nillable="true"
type="soapenc:int"/>
<element name="success" nillable="true"
type="soapenc:boolean"/>
<element name="userid" nillable="true"
type="soapenc:string"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
*/
defineTypes: procedure expose g.
parse arg node
g.0SCHEMA = createElement('schema')
call appendChild g.0SCHEMA,g.0TYPES
if g.0OPTION.DOCUMENT | g.0OPTION.WRAPPED
then call setAttribute g.0SCHEMA,'elementFormDefault','qualified'
call setAttributes g.0SCHEMA,,
'targetNamespace',g.0NAMESPACE,,
'xmlns','http://www.w3.org/2001/XMLSchema'
if g.0OPTION.ENCODED
then do
import = createElement('import')
call appendChild import,g.0SCHEMA
call setAttribute import,,
'namespace','http://schemas.xmlsoap.org/soap/encoding/'
end
structuresnode = getChildrenByName(node,'structures')
structures = getChildren(structuresnode)
do i = 1 to words(structures)
struct = word(structures,i)
call appendComplexType struct,g.0SCHEMA
end
return
/*
<wsdl:operation name="verify">
<wsdl:input message="impl:verifyRequest"
name="verifyRequest"/>
<wsdl:output message="impl:verifyResponse"
name="verifyResponse"/>
</wsdl:operation>
*/
definePortType: procedure expose g.
parse arg node
sService = getAttribute(node,'name')
call setAttribute g.0PORTTYPE,'name',sService
programs = getChildrenByName(node,'programs')
if programs <> ''
then do
programs = getChildren(programs)
do i = 1 to words(programs)
program = word(programs,i)
sOperation = getAttribute(program,'name')
operation = createElement('wsdl:operation')
call appendChild operation,g.0PORTTYPE
call setAttribute operation,'name',sOperation
input = createElement('wsdl:input')
call appendChild input,operation
call setAttributes input,,
'message','impl:'sOperation'Request',,
'name',sOperation'Request'
output = createElement('wsdl:output')
call appendChild output,operation
call setAttributes output,,
'message','impl:'sOperation'Response',,
'name',sOperation'Response'
end
end
return
/*
<wsdl:binding name="SecuritySoapBinding"
type="impl:Security">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="verify">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="verifyRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="yournamespace"
use="encoded"/>
</wsdl:input>
<wsdl:output name="verifyResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="yournamespace"
use="encoded"/>
</wsdl:output>
</wsdl:operation>
.
.
</wsdl:binding>
*/
defineBinding: procedure expose g.
parse arg node
sService = getAttribute(node,'name')
call setAttributes g.0BINDING,,
'name',sService'SoapBinding',,
'type','impl:'sService
soapbinding = createElement('wsdlsoap:binding')
call appendChild soapbinding,g.0BINDING
call setAttributes soapbinding,,
'style',getStyle(),,
'transport','http://schemas.xmlsoap.org/soap/http'
programs = getChildrenByName(node,'programs')
if programs <> ''
then do
programs = getChildren(programs)
do i = 1 to words(programs)
program = word(programs,i)
sOperation = getAttribute(program,'name')
operation = createElement('wsdl:operation')
call setAttribute operation,'name',sOperation
call appendChild operation,g.0BINDING
soapoperation = createElement('wsdlsoap:operation')
call appendChild soapoperation,operation
call setAttribute soapoperation,'soapAction',''
input = createElement('wsdl:input')
call appendChild input,operation
call setAttribute input,'name',sOperation'Request'
body = createElement('wsdlsoap:body')
call appendChild body,input
if g.0OPTION.ENCODED
then call setAttribute body,,
'encodingStyle','http://schemas.xmlsoap.org/soap/encoding/'
call setAttributes body,,
'namespace',g.0NAMESPACE,,
'use',getUse()
output = createElement('wsdl:output')
call appendChild output,operation
call setAttribute output,'name',sOperation'Response'
body = createElement('wsdlsoap:body')
call appendChild body,output
if g.0OPTION.ENCODED
then call setAttribute body,,
'encodingStyle','http://schemas.xmlsoap.org/soap/encoding/'
if g.0OPTION.RPC
then call setAttribute body,'namespace',g.0NAMESPACE
call setAttribute body,'use',getUse()
end
end
return
getStyle: procedure expose g.
if g.0OPTION.RPC
then sStyle = 'rpc'
else sStyle = 'document'
return sStyle
getUse: procedure expose g.
if g.0OPTION.ENCODED
then sUse = 'encoded'
else sUse = 'literal'
return sUse
/*
<wsdl:service name="SecurityService">
<wsdl:port binding="impl:SecuritySoapBinding"
name="Security">
<wsdlsoap:address
location="http://10.9.2.31:5080/axis/services/Security"/>
</wsdl:port>
</wsdl:service>
*/
defineService: procedure expose g.
parse arg node
sService = getAttribute(node,'name')
call setAttribute g.0SERVICE,'name',sService'Service'
port = createElement('wsdl:port')
call appendChild port,g.0SERVICE
call setAttributes port,,
'binding','impl:'sService'SoapBinding',,
'name',sService
addr = createElement('wsdlsoap:address')
call appendChild addr,port
call setAttribute addr,,
'location',g.0URL || sService
return
/*
style=document, use=literal [WS-I compliant, with restrictions]
Elements of the SOAP body are the names of XML Schema elements that
describe each parameter (there is no wrapper operation and no multi-ref)
<soap:body>
<arg1Element>5</arg1Element>
<arg2Element>5.0</arg2Element>
</soap:body>
*/
createDocLiteral: procedure expose g.
parse arg node
say 'IDL003I Generating WSDL style=DOCUMENT use=LITERAL'
/*
<wsdl:message name="changePasswordRequest">
<wsdl:part name="userid" element="xsd:string"/>
<wsdl:part name="password" element="xsd:string"/>
<wsdl:part name="newPassword" element="xsd:string"/>
</wsdl:message>
<wsdl:message name="changePasswordResponse">
<wsdl:part name="changePasswordReturn"
element="impl:SecurityContext"/>
</wsdl:message>
.
.
*/
programs = getChildrenByName(node,'programs')
if programs <> ''
then do
programs = getChildren(programs)
do i = 1 to words(programs)
program = word(programs,i)
sOperation = getAttribute(program,'name')
request = createElement('wsdl:message')
call appendChild request,g.0DEFS
call setAttribute request,'name',sOperation'Request'
response = createElement('wsdl:message')
call appendChild response,g.0DEFS
call setAttribute response,'name',sOperation'Response'
parms = getChildren(program)
do j = 1 to words(parms)
parm = word(parms,j)
sType = getAttribute(parm,'type')
if sType <> '' /* if it is not a group */
then do
sName = getAttribute(parm,'name')
sDir = getAttribute(parm,'direction')
if wordpos('In',sDir) > 0
then call appendPartSchema sName,sType,request
if wordpos('Out',sDir) > 0
then call appendPartSchema sOperation'Return',sType,response
end
end
end
end
return
/*
<wsdl:part name="userid1" element="impl:userid1"/>
|
.----------------------'
|
V
<element name="userid1" type="xsd:string"/>
or
<element name="userid1" type="impl:schemaReference"/>
*/
appendPartSchema: procedure expose g.
parse arg sName,sEntireXType,node
sElementName = sName
if g.0USED.sElementName = 1 /* If this name is already used */
then do
do i = 1 by 1 until g.0USED.sNameX = ''
sNameX = sElementName || i
end
sElementName = sNameX
end
g.0USED.sElementName = 1
element = createElement('element')
call appendChild element,g.0SCHEMA
call setAttributes element,,
'name',sElementName,,
'type',getSchemaEncoding(sEntireXType)
part = createElement('wsdl:part')
call appendChild part,node
call setAttributes part,,
'name',sName,,
'element','impl:'sElementName
return
/*
style=wrapped
Special case of DOCLIT where there is only one parameter and it has the
same qname as the operation. In such cases, there is no actual type with
the name. The elements are treated as parameters to the operation
<soap:body>
<one-arg-same-name-as-operation>
<arg1Element>5</arg1Element>
<arg2Element>5.0</arg2Element>
</one-arg-same-name-as-operation>
</soap:body>
*/
createDocWrapped: procedure expose g.
parse arg node
say 'IDL003I Generating WSDL style=DOCUMENT (WRAPPED) use=LITERAL'
/*
<wsdl:message name="verifyRequest">
<wsdl:part element="impl:verify" name="parameters"/>
</wsdl:message>
<wsdl:message name="verifyResponse">
<wsdl:part element="impl:verifyResponse" name="parameters"/>
</wsdl:message>
.
.
*/
programs = getChildrenByName(node,'programs')
if programs <> ''
then do
programs = getChildren(programs)
do i = 1 to words(programs)
program = word(programs,i)
sOperation = getAttribute(program,'name')
sRequestElement = sOperation
sResponseElement = sOperation'Response'
call appendMessage sOperation'Request',sRequestElement
call appendMessage sOperation'Response',sResponseElement
request = getSequence(sRequestElement)
response = getSequence(sResponseElement)
parms = getChildren(program)
do j = 1 to words(parms)
parm = word(parms,j)
sType = getAttribute(parm,'type')
if sType <> '' /* if it is not a group */
then do
sName = getAttribute(parm,'name')
sDir = getAttribute(parm,'direction')
if wordpos('In',sDir) > 0
then call appendWrapped sName,sType,request
if wordpos('Out',sDir) > 0
then call appendWrapped sOperation'Return',sType,response
end
end
end
end
return
appendMessage: procedure expose g.
parse arg sMessageName,sElementName
message = createElement('wsdl:message')
call appendChild message,g.0DEFS
call setAttribute message,'name',sMessageName
part = createElement('wsdl:part')
call appendChild part,message
call setAttributes part,,
'name','parameters',,
'element','impl:'sElementName
return
/*
<element name="verify">
<complexType>
<sequence>
<element name="userid" type="xsd:string"/>
<element name="password" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="verifyResponse">
<complexType>
<sequence>
<element name="verifyReturn"
type="impl:SecurityContext"/>
</sequence>
</complexType>
</element>
*/
getSequence: procedure expose g.
parse arg sName
element = createElement('element')
call appendChild element,g.0SCHEMA
call setAttribute element,'name',sName
complexType = createElement('complexType')
call appendChild complexType,element
sequence = createElement('sequence')
call appendChild sequence,complexType
return sequence
/*
<element name="userid" type="xsd:string"/>
or
<element name="verifyReturn" type="impl:schemaReference"/>
*/
appendWrapped: procedure expose g.
parse arg sName,sEntireXType,sequence
element = createElement('element')
call appendChild element,sequence
call setAttributes element,,
'name',sName,,
'type',getSchemaEncoding(sEntireXType)
return
/*
style=document, use=encoded [NOT WS-I compliant]
There is no enclosing operation name element, but the parmeters are
encoded using SOAP encoding. This mode is not (well?) supported by
Apache Axis.
*/
createDocEncoded: procedure expose g.
parse arg node
say 'IDL099W WSDL style=DOCUMENT use=ENCODED not supported'
return
/*
style=rpc, use=literal
First element of the SOAP body is the operation.
The operation contains elements describing the parameters,
which are not serialized as encoded (and no multi-ref)
<soap:body>
<operation>
<arg1>5</arg1>
<arg2>5.0</arg2>
</operation>
</soap:body>
*/
createRpcLiteral: procedure expose g.
parse arg node
say 'IDL003I Generating WSDL style=RPC use=LITERAL'
/*
<wsdl:message name="changePasswordRequest">
<wsdl:part name="userid" type="xsd:string"/>
<wsdl:part name="password" type="xsd:string"/>
<wsdl:part name="newPassword" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="changePasswordResponse">
<wsdl:part name="changePasswordReturn"
type="impl:SecurityContext"/>
</wsdl:message>
.
.
*/
programs = getChildrenByName(node,'programs')
if programs <> ''
then do
programs = getChildren(programs)
do i = 1 to words(programs)
program = word(programs,i)
sOperation = getAttribute(program,'name')
request = createElement('wsdl:message')
call appendChild request,g.0DEFS
call setAttribute request,'name',sOperation'Request'
response = createElement('wsdl:message')
call appendChild response,g.0DEFS
call setAttribute response,'name',sOperation'Response'
parms = getChildren(program)
do j = 1 to words(parms)
parm = word(parms,j)
sType = getAttribute(parm,'type')
if sType <> '' /* if it is not a group */
then do
sName = getAttribute(parm,'name')
sDir = getAttribute(parm,'direction')
if wordpos('In',sDir) > 0
then call appendPartType sName,sType,request
if wordpos('Out',sDir) > 0
then call appendPartType sOperation'Return',sType,response
end
end
end
end
return
/*
style=rpc, use=encoded [NOT WS-I compliant]
First element of the SOAP body is the operation.
The operation contains elements describing the parameters,
which are serialized as encoded (possibly multi-ref)
<soap:body>
<operation>
<arg1 xsi:type="xsd:int">5</arg1>
<arg2 xsi:type="xsd:float">5.0</arg2>
</operation>
</soap:body>
*/
createRpcEncoded: procedure expose g.
parse arg node
say 'IDL003I Generating WSDL style=RPC use=ENCODED'
/*
<wsdl:message name="changePasswordRequest">
<wsdl:part name="userid" type="soapenc:string"/>
<wsdl:part name="password" type="soapenc:string"/>
<wsdl:part name="newPassword" type="soapenc:string"/>
</wsdl:message>
<wsdl:message name="changePasswordResponse">
<wsdl:part name="changePasswordReturn"
type="impl:SecurityContext"/>
</wsdl:message>
.
.
*/
programs = getChildrenByName(node,'programs')
if programs <> ''
then do
programs = getChildren(programs)
do i = 1 to words(programs)
program = word(programs,i)
sOperation = getAttribute(program,'name')
request = createElement('wsdl:message')
call appendChild request,g.0DEFS
call setAttribute request,'name',sOperation'Request'
response = createElement('wsdl:message')
call appendChild response,g.0DEFS
call setAttribute response,'name',sOperation'Response'
parms = getChildren(program)
do j = 1 to words(parms)
parm = word(parms,j)
sType = getAttribute(parm,'type')
if sType <> '' /* if it is not a group */
then do
sName = getAttribute(parm,'name')
sDir = getAttribute(parm,'direction')
if wordpos('In',sDir) > 0
then call appendPartType sName,sType,request
if wordpos('Out',sDir) > 0
then call appendPartType sOperation'Return',sType,response
end
end
end
end
return
/*
<wsdl:part name="userid" type="soapenc:string"/>
or
<wsdl:part name="operationReturn" type="impl:schemaReference"/>
*/
appendPartType: procedure expose g.
parse arg sName,sEntireXType,node
part = createElement('wsdl:part')
call appendChild part,node
call setAttributes part,,
'name',sName,,
'type',getEncoding(sEntireXType)
return
/*
<complexType name="SecurityContext">
<sequence>
<element name="reason" nillable="true"
type="soapenc:string"/>
<element name="reasonCode" nillable="true"
type="soapenc:int"/>
<element name="returnCode" nillable="true"
type="soapenc:int"/>
<element name="success" nillable="true"
type="soapenc:boolean"/>
<element name="userid" nillable="true"
type="soapenc:string"/>
</sequence>
</complexType>
*/
appendComplexType: procedure expose g.
parse arg struct,schema
sStructureName = getAttribute(struct,'name')
complexType = createElement('complexType')
call appendChild complexType,schema
call setAttribute complexType,'name',sStructureName
sequence = createElement('sequence')
call appendChild sequence,complexType
parms = getChildNodes(struct)
do i = 1 to words(parms)
parm = word(parms,i)
nLevel = getAttribute(parm,'level')
sName = getAttribute(parm,'name')
sType = getAttribute(parm,'type')
sDirection = getAttribute(parm,'direction')
select
when sType = '' then do
/* ignore an EntireX grouping level */
end
when left(sType,1) = "'" then do
parse var sType "'"sRef"'"
end
otherwise do
call appendElement sName,sType,sequence
end
end
end
return
/*
<sequence>
<element name="reason" nillable="true"
type="soapenc:string"/>
<element name="reasonCode" nillable="true"
type="soapenc:int"/>
<element name="returnCode" nillable="true"
type="soapenc:int"/>
<element name="success" nillable="true"
type="soapenc:boolean"/>
<element name="userid" nillable="true"
type="soapenc:string"/>
</sequence>
*/
appendElement: procedure expose g.
parse arg sName,sEntireXType,sequence
element = createElement('element')
call appendChild element,sequence
call setAttributes element,,
'name',sName,,
'nillable','true',,
'type',getEncoding(sEntireXType)
return
getEncoding: procedure expose g.
parse arg sEntireXType
if g.0OPTION.ENCODED
then sEncoding = getSoapEncoding(sEntireXType)
else sEncoding = getSchemaEncoding(sEntireXType)
return sEncoding
/* Map an EntireX data type to a SOAP encoded type */
getSoapEncoding: procedure expose g.
parse arg sEntireXType . 1 sType1 +1 1 sType2 +2
select
when sType1 = 'A' then do /* alphanumeric */
if sType2 = 'AV' /* variable length */
then sEncoding = 'soapenc:string'
else sEncoding = 'soapenc:string'
end
when sType1 = 'B' then do /* binary */
if sType2 = 'BV' /* variable length */
then sEncoding = 'soapenc:int'
else sEncoding = 'soapenc:int'
end
when sType1 = 'D' then do /* date */
sEncoding = 'soapenc:date'
end
when sType1 = 'F' then do /* floating point */
sEncoding = 'soapenc:float'
end
when sType1 = 'I' then do /* integer */
sEncoding = 'soapenc:int'
end
when sType1 = 'L' then do /* logical */
sEncoding = 'soapenc:boolean'
end
when sType1 = 'N' then do /* numeric */
if sType2 = 'NU' /* unsigned */
then sEncoding = 'soapenc:decimal'
else sEncoding = 'soapenc:decimal'
end
when sType1 = 'P' then do /* packed decimal */
if sType2 = 'PU' /* unsigned */
then sEncoding = 'soapenc:decimal'
else sEncoding = 'soapenc:decimal'
end
when sType1 = 'T' then do /* time */
sEncoding = 'soapenc:time'
end
when sType1 = "'" then do /* reference to a struct */
parse var sEntireXType "'"sReference"'"
sEncoding = 'impl:'sReference
end
otherwise do
sEncoding = 'soapenc:anyType'
end
end
return sEncoding
/* Map an EntireX data type to an XML schema data type */
getSchemaEncoding: procedure expose g.
parse arg sEntireXType . 1 sType1 +1 1 sType2 +2
select
when sType1 = 'A' then do /* alphanumeric */
if sType2 = 'AV' /* variable length */
then sEncoding = 'xsd:string'
else sEncoding = 'xsd:string'
end
when sType1 = 'B' then do /* binary */
if sType2 = 'BV' /* variable length */
then sEncoding = 'xsd:int'
else sEncoding = 'xsd:int'
end
when sType1 = 'D' then do /* date */
sEncoding = 'xsd:date'
end
when sType1 = 'F' then do /* floating point */
sEncoding = 'xsd:float'
end
when sType1 = 'I' then do /* integer */
sEncoding = 'xsd:int'
end
when sType1 = 'L' then do /* logical */
sEncoding = 'xsd:boolean'
end
when sType1 = 'N' then do /* numeric */
if sType2 = 'NU' /* unsigned */
then sEncoding = 'xsd:decimal'
else sEncoding = 'xsd:decimal'
end
when sType1 = 'P' then do /* packed decimal */
if sType2 = 'PU' /* unsigned */
then sEncoding = 'xsd:decimal'
else sEncoding = 'xsd:decimal'
end
when sType1 = 'T' then do /* time */
sEncoding = 'xsd:time'
end
when sType1 = "'" then do /* reference to a struct */
parse var sEntireXType "'"sReference"'"
sEncoding = 'impl:'sReference
end
otherwise do
sEncoding = 'xsd:anyType'
end
end
return sEncoding
getFilenameWithoutExtension: procedure expose g.
parse arg sFile
parse value reverse(sFile) with '.'sRest
return reverse(sRest)
scanEntireXIdlFile: procedure expose g.
idl = createElement('idl')