-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWSDL.p
366 lines (317 loc) · 16.1 KB
/
WSDL.p
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
/*------------------------------------------------------------------------
File: WSDL.P
Description: Builds the WSDL for procedures defined in
temp-tables generated by procInfo.p.
Input Parameters: ttProcedure Procedures.
ttMethod Internal procedures and Functions
to include.
ttParam Procedure Parameters.
ttTable Temp-tables used by the procedures.
ttField Temp-tables Fields.
ichWSDLFile Path to the generated WSDL file.
ichNameSpace The name of the web service.
ichPortLocation The deployment address of the
webservice.
Output Parameters: ochResult Error message or "" if there
isn't any
Author: Lic. Edgar Medrano Pérez
edgarmedrano@gmail.com
Created: 2005.06.25
Company: Open 4GL webservices project
http://o4glws.sourceforge.net
Notes:
------------------------------------------------------------------------*/
{o4glws/procInfo.i}
FUNCTION GetWSDLDataType RETURNS CHARACTER(
INPUT ichProgressDataType AS CHARACTER
) FORWARD.
DEFINE INPUT PARAMETER TABLE FOR ttProcedure.
DEFINE INPUT PARAMETER TABLE FOR ttMethod.
DEFINE INPUT PARAMETER TABLE FOR ttParam.
DEFINE INPUT PARAMETER TABLE FOR ttTable.
DEFINE INPUT PARAMETER TABLE FOR ttField.
DEFINE INPUT PARAMETER ichWSDLFile AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER ichNameSpace AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER ichPortLocation AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER ochResult AS CHARACTER NO-UNDO.
DEFINE VARIABLE vhaAll AS HANDLE NO-UNDO.
DEFINE VARIABLE vhaComplexContent AS HANDLE NO-UNDO.
DEFINE VARIABLE vhaXMLNode AS HANDLE NO-UNDO.
DEFINE VARIABLE vhaXMLParentNode AS HANDLE NO-UNDO.
DEFINE VARIABLE vhaTemp AS HANDLE NO-UNDO.
DEFINE VARIABLE vhaTemp2 AS HANDLE NO-UNDO.
DEFINE VARIABLE vhaTemp3 AS HANDLE NO-UNDO.
DEFINE VARIABLE vhaTextNode AS HANDLE NO-UNDO.
DEFINE VARIABLE vhaWSDL AS HANDLE NO-UNDO.
DEFINE VARIABLE vhaWSDLRoot AS HANDLE NO-UNDO.
IF ichWSDLFile = ""
OR ichWSDLFile = ? THEN
DO:
ochResult = SUBSTITUTE("Unable to use WSDL File: [&1]", ichWSDLFile).
RETURN.
END.
IF ichNameSpace = ""
OR ichNameSpace = ? THEN
DO:
ochResult = ochResult
+ "~n"
+ SUBSTITUTE("Unable to use Namespace: [&1]", ichNameSpace).
RETURN.
END.
IF ichPortLocation = ""
OR ichPortLocation = ? THEN
DO:
ochResult = ochResult
+ "~n"
+ SUBSTITUTE("Unable to use Port Location: [&1]", ichPortLocation).
RETURN.
END.
CREATE X-NODEREF vhaAll.
CREATE X-NODEREF vhaComplexContent.
CREATE X-NODEREF vhaTemp.
CREATE X-NODEREF vhaTemp2.
CREATE X-NODEREF vhaTemp3.
CREATE X-DOCUMENT vhaWSDL.
CREATE X-NODEREF vhaXMLNode.
CREATE X-NODEREF vhaXMLParentNode.
CREATE X-NODEREF vhaWSDLRoot.
/** Root attributes **/
vhaWSDL:CREATE-NODE(vhaWSDLRoot, "definitions", "ELEMENT").
vhaWSDLRoot:SET-ATTRIBUTE("xmlns:http", "http://schemas.xmlsoap.org/wsdl/http/").
vhaWSDLRoot:SET-ATTRIBUTE("xmlns:soap", "http://schemas.xmlsoap.org/wsdl/soap/").
vhaWSDLRoot:SET-ATTRIBUTE("xmlns:s", "http://www.w3.org/2001/XMLSchema").
vhaWSDLRoot:SET-ATTRIBUTE("xmlns:s0", SUBSTITUTE("urn:&1", ichNameSpace)).
vhaWSDLRoot:SET-ATTRIBUTE("xmlns:soapenc", "http://schemas.xmlsoap.org/soap/encoding/").
vhaWSDLRoot:SET-ATTRIBUTE("xmlns:tm", "http://microsoft.com/wsdl/mime/textMatching/").
vhaWSDLRoot:SET-ATTRIBUTE("xmlns:mime", "http://schemas.xmlsoap.org/wsdl/mime/").
vhaWSDLRoot:SET-ATTRIBUTE("xmlns:wsdl", "http://schemas.xmlsoap.org/wsdl/").
vhaWSDLRoot:SET-ATTRIBUTE("targetNamespace", SUBSTITUTE("urn:&1", ichNameSpace)).
vhaWSDLRoot:SET-ATTRIBUTE("name", ichNameSpace).
vhaWSDLRoot:SET-ATTRIBUTE("xmlns", "http://schemas.xmlsoap.org/wsdl/").
vhaWSDL:APPEND-CHILD(vhaWSDLRoot).
/** Types **/
vhaWSDL:CREATE-NODE(vhaXMLParentNode, "types", "ELEMENT").
vhaWSDLRoot:APPEND-CHILD(vhaXMLParentNode).
/** S:Schema **/
vhaWSDL:CREATE-NODE(vhaXMLNode, "s:schema", "ELEMENT").
vhaXMLNode:SET-ATTRIBUTE("targetNamespace", SUBSTITUTE("urn:&1", ichNameSpace)).
vhaXMLNode:SET-ATTRIBUTE("xmlns", "http://www.w3.org/2001/XMLSchema").
vhaXMLParentNode:APPEND-CHILD(vhaXMLNode).
/** First Create any Complex Types used for temp-tables **/
FOR EACH ttProcedure
NO-LOCK:
FOR EACH ttTable
WHERE ttTable.iProcId = ttProcedure.iProcId
NO-LOCK:
vhaWSDL:CREATE-NODE(vhaTemp, "s:complexType", "ELEMENT").
vhaTemp:SET-ATTRIBUTE("name", ttProcedure.cName + "_" + ttTable.cName).
vhaXMLNode:APPEND-CHILD(vhaTemp).
vhaWSDL:CREATE-NODE(vhaAll, "s:all", "ELEMENT").
vhaTemp:APPEND-CHILD(vhaAll).
FOR EACH ttField
WHERE ttField.iProcId = ttTable.iProcId
AND ttField.cTableName = ttTable.cName
NO-LOCK
BY ttField.iSeq:
vhaWSDL:CREATE-NODE(vhaTemp2, "s:element", "ELEMENT").
vhaTemp2:SET-ATTRIBUTE("name", ttField.cName).
vhaTemp2:SET-ATTRIBUTE("type", GetWSDLDataType(INPUT ttField.cDataType)).
vhaAll:APPEND-CHILD(vhaTemp2).
END. /** for each ttfield **/
vhaWSDL:CREATE-NODE(vhaTemp, "s:complexType", "ELEMENT").
vhaTemp:SET-ATTRIBUTE("name", SUBSTITUTE("&1Array", ttProcedure.cName + "_" + ttTable.cName)).
vhaXMLNode:APPEND-CHILD(vhaTemp).
vhaWSDL:CREATE-NODE(vhaComplexContent, "s:complexContent", "ELEMENT").
vhaTemp:APPEND-CHILD(vhaComplexContent).
vhaWSDL:CREATE-NODE(vhaTemp2, "s:restriction", "ELEMENT").
vhaTemp2:SET-ATTRIBUTE("base", "soapenc:Array").
vhaComplexContent:APPEND-CHILD(vhaTemp2).
vhaWSDL:CREATE-NODE(vhaTemp3, "s:attribute", "ELEMENT").
vhaTemp3:SET-ATTRIBUTE("ref", "soapenc:arrayType").
vhaTemp3:SET-ATTRIBUTE("wsdl:arrayType", SUBSTITUTE("s0:&1[]", ttProcedure.cName + "_" + ttTable.cName)).
vhaTemp2:APPEND-CHILD(vhaTemp3).
END. /** for each tttable **/
END. /** for each ttProcedure **/
/** Messages **/
FOR EACH ttProcedure
NO-LOCK:
FOR EACH ttMethod
WHERE ttMethod.iProcId = ttProcedure.iProcId
NO-LOCK:
/** Request **/
/*IF CAN-FIND(FIRST ttParam
WHERE ttParam.iProcId = ttMethod.iProcId
AND (ttParam.cMethodName = ttMethod.cName
OR ttParam.cMethodName = "")
AND ttParam.cDirection <> "OUTPUT") THEN*/
DO:
vhaWSDL:CREATE-NODE(vhaXMLParentNode, "message", "ELEMENT").
vhaXMLParentNode:SET-ATTRIBUTE("name", ttProcedure.cName + (IF ttMethod.cName = "" THEN "" ELSE "_") + ttMethod.cName).
vhaWSDLRoot:APPEND-CHILD(vhaXMLParentNode).
FOR EACH ttParam
WHERE ttParam.iProcId = ttMethod.iProcId
AND (ttParam.cMethodName = ttMethod.cName
OR ttParam.cMethodName = "")
AND ttParam.cDirection <> "OUTPUT"
NO-LOCK
BY ttParam.cMethodName
BY ttParam.iSeq:
vhaWSDL:CREATE-NODE(vhaXMLNode, "part", "ELEMENT").
vhaXMLNode:SET-ATTRIBUTE("name", (IF ttParam.cMethodName = "" THEN ttProcedure.cName + "_" ELSE "") + ttParam.cName).
IF ttParam.cDataType <> "TABLE" THEN
vhaXMLNode:SET-ATTRIBUTE("type", SUBSTITUTE("s:&1", GetWSDLDataType(INPUT ttParam.cDataType))).
ELSE
vhaXMLNode:SET-ATTRIBUTE("type", SUBSTITUTE("s0:&1Array", ttProcedure.cName + "_" + ttParam.cName)).
vhaXMLParentNode:APPEND-CHILD(vhaXMLNode).
END. /** for each ttparam **/
END.
/** Response **/
/*IF CAN-FIND(FIRST ttParam
WHERE ttParam.iProcId = ttMethod.iProcId
AND (ttParam.cMethodName = ttMethod.cName
OR ttParam.cMethodName = "")
AND ttParam.cDirection <> "INPUT") THEN*/
DO:
vhaWSDL:CREATE-NODE(vhaXMLParentNode, "message", "ELEMENT").
vhaXMLParentNode:SET-ATTRIBUTE("name", SUBSTITUTE("&1Response", ttProcedure.cName + (IF ttMethod.cName = "" THEN "" ELSE "_") + ttMethod.cName)).
vhaWSDLRoot:APPEND-CHILD(vhaXMLParentNode).
FOR EACH ttParam
WHERE ttParam.iProcId = ttMethod.iProcId
AND (ttParam.cMethodName = ttMethod.cName
OR ttParam.cMethodName = "")
AND ttParam.cDirection <> "INPUT"
NO-LOCK
BY ttParam.cMethodName
BY ttParam.iSeq:
vhaWSDL:CREATE-NODE(vhaXMLNode, "part", "ELEMENT").
vhaXMLNode:SET-ATTRIBUTE("name", (IF ttParam.cMethodName = "" THEN ttProcedure.cName + "_" ELSE "") + ttParam.cName).
IF ttParam.cDataType <> "TABLE" THEN
vhaXMLNode:SET-ATTRIBUTE("type", SUBSTITUTE("s:&1", GetWSDLDataType(INPUT ttParam.cDataType))).
ELSE
vhaXMLNode:SET-ATTRIBUTE("type", SUBSTITUTE("s0:&1Array", ttProcedure.cName + "_" + ttParam.cName)).
vhaXMLParentNode:APPEND-CHILD(vhaXMLNode).
END. /** for each ttparam **/
END.
/*
vhaWSDL:CREATE-NODE(vhaXMLNode, "part", "ELEMENT").
vhaXMLNode:SET-ATTRIBUTE("name", "return").
vhaXMLNode:SET-ATTRIBUTE("type", SUBSTITUTE("s0:&1Result", ttProcedure.cName + (IF ttMethod.cName = "" THEN "" ELSE "_") + ttMethod.cName)).
vhaXMLParentNode:APPEND-CHILD(vhaXMLNode).
*/
END. /** for each ttmethod **/
END. /** for each ttProcedure **/
/** PortType **/
vhaWSDL:CREATE-NODE(vhaXMLNode, "portType", "ELEMENT").
vhaXMLNode:SET-ATTRIBUTE("name", SUBSTITUTE("&1Port", ichNameSpace)).
vhaWSDLRoot:APPEND-CHILD(vhaXMLNode).
/** Operations **/
FOR EACH ttProcedure
NO-LOCK:
FOR EACH ttMethod
WHERE ttMethod.iProcId = ttProcedure.iProcId
NO-LOCK:
vhaWSDL:CREATE-NODE(vhaXMLParentNode, "operation", "ELEMENT").
vhaXMLParentNode:SET-ATTRIBUTE("name", ttProcedure.cName + (IF ttMethod.cName = "" THEN "" ELSE "_") + ttMethod.cName).
vhaXMLNode:APPEND-CHILD(vhaXMLParentNode).
/** Input **/
vhaWSDL:CREATE-NODE(vhaTemp, "input", "ELEMENT").
vhaTemp:SET-ATTRIBUTE("message", SUBSTITUTE("s0:&1", ttProcedure.cName + (IF ttMethod.cName = "" THEN "" ELSE "_") + ttMethod.cName)).
vhaXMLParentNode:APPEND-CHILD(vhaTemp).
/** Output **/
vhaWSDL:CREATE-NODE(vhaTemp, "output", "ELEMENT").
vhaTemp:SET-ATTRIBUTE("message", SUBSTITUTE("s0:&1Response", ttProcedure.cName + (IF ttMethod.cName = "" THEN "" ELSE "_") + ttMethod.cName)).
vhaXMLParentNode:APPEND-CHILD(vhaTemp).
END. /** for each ttmethod **/
END. /** for each ttProcedure **/
/** Binding **/
vhaWSDL:CREATE-NODE(vhaXMLParentNode, "binding", "ELEMENT").
vhaXMLParentNode:SET-ATTRIBUTE("name", SUBSTITUTE("&1Binding", ichNameSpace)).
vhaXMLParentNode:SET-ATTRIBUTE("type", SUBSTITUTE("s0:&1Port", ichNameSpace)).
vhaWSDLRoot:APPEND-CHILD(vhaXMLParentNode).
/** Soap:Binding **/
vhaWSDL:CREATE-NODE(vhaXMLNode, "soap:binding", "ELEMENT").
vhaXMLNode:SET-ATTRIBUTE("transport", "http://schemas.xmlsoap.org/soap/http").
vhaXMLNode:SET-ATTRIBUTE("style", "rpc").
vhaXMLParentNode:APPEND-CHILD(vhaXMLNode).
/** Operation **/
FOR EACH ttProcedure
NO-LOCK:
FOR EACH ttMethod
WHERE ttMethod.iProcId = ttProcedure.iProcId
NO-LOCK:
vhaWSDL:CREATE-NODE(vhaXMLNode, "operation", "ELEMENT").
vhaXMLNode:SET-ATTRIBUTE("name", ttProcedure.cName + (IF ttMethod.cName = "" THEN "" ELSE "_") + ttMethod.cName).
vhaXMLParentNode:APPEND-CHILD(vhaXMLNode).
/** Soap:Operation **/
vhaWSDL:CREATE-NODE(vhaTemp, "soap:operation", "ELEMENT").
vhaTemp:SET-ATTRIBUTE("soapAction", SUBSTITUTE("urn:&1Action", ichNameSpace)).
vhaXMLNode:APPEND-CHILD(vhaTemp).
/** Input **/
vhaWSDL:CREATE-NODE(vhaTemp, "input", "ELEMENT").
vhaXMLNode:APPEND-CHILD(vhaTemp).
/** Soap:Body **/
vhaWSDL:CREATE-NODE(vhaTemp2, "soap:body", "ELEMENT").
vhaTemp2:SET-ATTRIBUTE("use", "encoded").
vhaTemp2:SET-ATTRIBUTE("namespace", SUBSTITUTE("urn:&1", ichNameSpace)).
vhaTemp2:SET-ATTRIBUTE("encodingStyle", "http://schemas.xmlsoap.org/soap/encoding/").
vhaTemp:APPEND-CHILD(vhaTemp2).
/** Output **/
vhaWSDL:CREATE-NODE(vhaTemp, "output", "ELEMENT").
vhaXMLNode:APPEND-CHILD(vhaTemp).
/** Soap:Body **/
vhaWSDL:CREATE-NODE(vhaTemp2, "soap:body", "ELEMENT").
vhaTemp2:SET-ATTRIBUTE("use", "encoded").
vhaTemp2:SET-ATTRIBUTE("namespace", SUBSTITUTE("urn:&1", ichNameSpace)).
vhaTemp2:SET-ATTRIBUTE("encodingStyle", "http://schemas.xmlsoap.org/soap/encoding/").
vhaTemp:APPEND-CHILD(vhaTemp2).
END. /** for each ttmethod **/
END. /** for each ttProcedure **/
/** Service **/
vhaWSDL:CREATE-NODE(vhaXMLParentNode, "service", "ELEMENT").
vhaXMLParentNode:SET-ATTRIBUTE("name", ichNameSpace).
vhaWSDLRoot:APPEND-CHILD(vhaXMLParentNode).
/** Port **/
vhaWSDL:CREATE-NODE(vhaXMLNode, "port", "ELEMENT").
vhaXMLNode:SET-ATTRIBUTE("name", SUBSTITUTE("&1Port", ichNameSpace)).
vhaXMLNode:SET-ATTRIBUTE("binding", SUBSTITUTE("s0:&1Binding", ichNameSpace)).
vhaXMLParentNode:APPEND-CHILD(vhaXMLNode).
/** Soap:Address **/
vhaWSDL:CREATE-NODE(vhaTemp, "soap:address", "ELEMENT").
vhaTemp:SET-ATTRIBUTE("location", ichPortLocation).
vhaXMLNode:APPEND-CHILD(vhaTemp).
vhaWSDL:SAVE("FILE", ichWSDLFile).
DELETE OBJECT vhaAll.
DELETE OBJECT vhaComplexContent.
DELETE OBJECT vhaTemp.
DELETE OBJECT vhaTemp2.
DELETE OBJECT vhaTemp3.
DELETE OBJECT vhaWSDL.
DELETE OBJECT vhaXMLNode.
DELETE OBJECT vhaXMLParentNode.
DELETE OBJECT vhaWSDLRoot.
RETURN.
FUNCTION GetWSDLDataType RETURNS CHARACTER(INPUT ichProgressDataType AS CHARACTER):
DEFINE VARIABLE vchWSDLDataType AS CHARACTER NO-UNDO.
CASE KEYWORD-ALL(ichProgressDataType):
WHEN "CHARACTER"
OR WHEN "COM-HANDLE"
OR WHEN "HANDLE"
OR WHEN "MEMPTR"
OR WHEN "RAW"
OR WHEN "ROWID"
OR WHEN "WIDGET-HANDLE" THEN
vchWSDLDataType = "string".
WHEN "DATE" THEN
vchWSDLDataType = "date".
WHEN "DECIMAL" THEN
vchWSDLDataType = "decimal".
WHEN "INTEGER"
OR WHEN "RECID" THEN
vchWSDLDataType = "int".
WHEN "LOGICAL" THEN
vchWSDLDataType = "boolean".
OTHERWISE
vchWSDLDataType = SUBSTITUTE("ERROR: Unknown Progress Data Type [&1]", ichProgressDataType).
END CASE. /** ichProgressDataType **/
RETURN vchWSDLDataType.
END FUNCTION. /** getwsdldatatype **/