Qore SoapHandler Module Reference  0.3.1
SoapHandler.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
4 /* SoapHandler.qm Copyright (C) 2012 - 2022 Qore Technologies, s.r.o.
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23 */
24 
25 // make sure we have the required qore version
26 
27 // requires XML functionality
28 
29 // requires the WSDL module
30 
31 // need mime definitions
32 
33 // need definitions from the HttpServerUtil
34 
35 // need Util functions
36 
37 // do not use $ for vars
38 
39 // require type declarations everywhere
40 
41 // do not ignore errors in call arguments
42 
43 
114 namespace SoapHandler {
116 class SoapHandler : public AbstractHttpRequestHandler {
117 
118 public:
120  const Version = "0.2.6";
121 
123 protected:
124  // method mappings: method name -> method hash
125  hash<auto> methods;
126 
127  // reverse mappings for methods: unique_id -> method -> True
128  hash<string, hash<string, bool>> rmethods;
129 
130  // URI path -> method name -> method mappings
131  hash<string, hash> uri_methods;
132 
133  // reverse URI path method mappings: unique_id -> URI path -> method name -> true
134  hash<string, hash<string, hash<string, bool>>> ruri_methods;
135 
136  // service name -> WebService objects
137  hash<string, WebService> wsh;
138 
139  // reverse mapping to remove wsh mappings; unique_id -> path -> True
140  hash<string, hash<string, bool>> rwsh;
141 
142  // operation name -> WebService object
143  hash<string, WebService> owsh;
144 
145  // reverse operation mappings; unique_id -> op name -> true
146  hash<string, hash<string, bool>> rowsh;
147 
148  // lookup URI path -> WebService object
149  hash<string, WebService> wsph;
150 
151  // reverse URI path lookups: unique_id -> URI path -> true
152  hash<string, hash<string, bool>> rwsph;
153 
154  // URI path -> SOAP Action -> method mappings
155  hash<string, hash<string, hash>> uri_sam;
156 
157  // reverse URI path -> SOAP Action mappings: unique_id -> URI path -> SOAPAction -> true
158  hash<string, hash<string, hash<string, bool>>> ruri_sam;
159 
160  // soapaction map: action -> binding -> operation
161  hash<string, hash> sam;
162 
163  // reverse mapping: unique_id -> soapaction -> True
164  hash<string, hash<string, bool>> rsam;
165 
166  int loglevel;
167 
168  // if True then verbose exception info will be logged
169  bool debug;
170 
171  // a closure/call reference to get the log message and/or process arguments in incoming requests
172  *code getLogMessage;
173 
174  // for atomicity when adding / removing methods
175  RWLock rwl();
176 
177  // path TreeMap for each HTTP method
178  hash<string, TreeMap> mapMethodPathToOperation;
179 
180  // soapaction -> method -> binding
181 
182 public:
184 
186 
190  constructor(AbstractAuthenticator auth, *code n_getLogMessage, bool dbg = False) ;
191 
192 
194 
206  addMethod(WebService ws, WSOperation op, auto func, *string help, *int logopt, auto cmark, *string path, auto err_func, *string altpath, *string binding, *string unique_id);
207 
208 
210  setDebug(bool dbg = True);
211 
212 
214  bool getDebug();
215 
216 
218 
220  removeService(string unique_id);
221 
222 
224  // don't reimplement this method; fix/enhance it in the module
225 protected:
226  final addMethodInternal(WebService ws, hash<auto> method);
227 public:
228 
229 
230 protected:
231  *hash<auto> help(hash<auto> cx);
232 public:
233 
234 
235  // don't reimplement this method; fix/enhance it in the module
236 protected:
237  final log(hash<auto> cx, string str);
238 public:
239 
240 
257 protected:
258  nothing msglog(hash<auto> cx, hash<auto> msg);
259 public:
260 
261 
262  // don't reimplement this method; fix/enhance it in the module
263 protected:
264  hash<auto> makeSoapFaultResponse(hash<auto> cx, string errLog, bool soap12, string err, string desc, *bool fmt);
265 public:
266 
267 
268  // don't reimplement this method; fix/enhance it in the module
269 protected:
270  final *hash<auto> callOperation(hash<auto> cx, auto args, hash<auto> method, bool reqsoap12);
271 public:
272 
273 
274 protected:
275  *hash<auto> matchMethod(TreeMap tm, string path, reference unmatched);
276 public:
277 
278 
279  // method called by HttpServer
280  // don't reimplement this method; fix/enhance it in the module
281  final hash<auto> handleRequest(hash<auto> cx, hash<auto> hdr, *data body);
282 
283 
284 protected:
285  *WebService tryMatch(string path);
286 public:
287 
289  };
290 };
removeService(string unique_id)
call to remove the given service
addMethod(WebService ws, WSOperation op, auto func, *string help, *int logopt, auto cmark, *string path, auto err_func, *string altpath, *string binding, *string unique_id)
adds a method to the handler dynamically
bool getDebug()
returns the current status of the debug flag
constructor(AbstractAuthenticator auth, *code n_getLogMessage, bool dbg=False)
creates the handler with the given method list
setDebug(bool dbg=True)
turns on or off debugging; when debugging is enabled more verbose error messages are reported
main SoapHandler namespace
Definition: SoapHandler.qm.dox.h:114