0
|
1 /*
|
|
2 wsdl.cpp
|
|
3
|
|
4 WSDL 1.1 and WSDL 2.0 binding schema implementation
|
|
5
|
|
6 --------------------------------------------------------------------------------
|
|
7 gSOAP XML Web services tools
|
|
8 Copyright (C) 2000-2012, Robert van Engelen, Genivia Inc. All Rights Reserved.
|
|
9 This software is released under one of the following licenses:
|
|
10 GPL or Genivia's license for commercial use.
|
|
11 --------------------------------------------------------------------------------
|
|
12 GPL license.
|
|
13
|
|
14 This program is free software; you can redistribute it and/or modify it under
|
|
15 the terms of the GNU General Public License as published by the Free Software
|
|
16 Foundation; either version 2 of the License, or (at your option) any later
|
|
17 version.
|
|
18
|
|
19 This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
20 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
21 PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
22
|
|
23 You should have received a copy of the GNU General Public License along with
|
|
24 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
25 Place, Suite 330, Boston, MA 02111-1307 USA
|
|
26
|
|
27 Author contact information:
|
|
28 engelen@genivia.com / engelen@acm.org
|
|
29 --------------------------------------------------------------------------------
|
|
30 A commercial use license is available from Genivia, Inc., contact@genivia.com
|
|
31 --------------------------------------------------------------------------------
|
|
32
|
|
33 */
|
|
34
|
|
35 #include "wsdlH.h"
|
|
36 #include "includes.h"
|
|
37
|
|
38 extern struct Namespace namespaces[];
|
|
39
|
|
40 const char *qname_token(const char *QName, const char *URI)
|
|
41 { if (QName && QName[0] == '"' && QName[1] == '"' && QName[2] == ':')
|
|
42 return QName + 3;
|
|
43 if (QName && URI && *QName == '"') // QNames are stored in the format "URI":name, unless the URI is in the nsmap
|
|
44 { size_t n = strlen(URI);
|
|
45 if (!strncmp(QName + 1, URI, n) && QName[n + 1] == '"')
|
|
46 return QName + n + 3;
|
|
47 }
|
|
48 return NULL;
|
|
49 }
|
|
50
|
|
51 int is_builtin_qname(const char *QName)
|
|
52 { if (iflag)
|
|
53 return 1;
|
|
54 if (QName)
|
|
55 { if (*QName == '#') // reserved QNames
|
|
56 return 0;
|
|
57 if (*QName != '"')
|
|
58 return 1; // if the QName does not start with a ", it must be in the nsmap
|
|
59 const char *s = strchr(QName + 1, '"');
|
|
60 if (s)
|
|
61 { size_t n = s - QName - 1;
|
|
62 for (SetOfString::const_iterator i = exturis.begin(); i != exturis.end(); ++i)
|
|
63 if (strlen(*i) == n && !strncmp(QName + 1, *i, n))
|
|
64 return 1; // QName is in exturis
|
|
65 }
|
|
66 }
|
|
67 return 0;
|
|
68 }
|
|
69
|
|
70 ////////////////////////////////////////////////////////////////////////////////
|
|
71 //
|
|
72 // wsdl
|
|
73 //
|
|
74 ////////////////////////////////////////////////////////////////////////////////
|
|
75
|
|
76 extern "C" {
|
|
77 int warn_ignore(struct soap*, const char*);
|
|
78 int show_ignore(struct soap*, const char*);
|
|
79 }
|
|
80
|
|
81 wsdl__definitions::wsdl__definitions()
|
|
82 { soap = soap_new1(SOAP_XML_TREE | SOAP_C_UTFSTRING);
|
|
83 #ifdef HTTPDA_H
|
|
84 soap_register_plugin(soap, http_da);
|
|
85 #endif
|
|
86 #ifdef WITH_OPENSSL
|
|
87 soap_ssl_client_context(soap, SOAP_SSL_NO_AUTHENTICATION, NULL, NULL, NULL, NULL, NULL);
|
|
88 #endif
|
|
89 soap_set_namespaces(soap, namespaces);
|
|
90 soap_default(soap);
|
|
91 if (vflag)
|
|
92 soap->fignore = show_ignore;
|
|
93 else
|
|
94 soap->fignore = warn_ignore;
|
|
95 soap->encodingStyle = NULL;
|
|
96 soap->proxy_host = proxy_host;
|
|
97 soap->proxy_port = proxy_port;
|
|
98 soap->proxy_userid = proxy_userid;
|
|
99 soap->proxy_passwd = proxy_passwd;
|
|
100 name = NULL;
|
|
101 targetNamespace = soap_strdup(soap, "");
|
|
102 documentation = NULL;
|
|
103 types = NULL;
|
|
104 updated = false;
|
|
105 location = NULL;
|
|
106 redirs = 0;
|
|
107 }
|
|
108
|
|
109 wsdl__definitions::wsdl__definitions(struct soap *copy, const char *cwd, const char *loc)
|
|
110 { soap = soap_copy(copy);
|
|
111 soap->socket = SOAP_INVALID_SOCKET;
|
|
112 soap->recvfd = 0;
|
|
113 soap->sendfd = 1;
|
|
114 strcpy(soap->host, copy->host);
|
|
115 soap_default(soap);
|
|
116 soap->fignore = warn_ignore;
|
|
117 soap->encodingStyle = NULL;
|
|
118 updated = false;
|
|
119 location = NULL;
|
|
120 redirs = 0;
|
|
121 read(cwd, loc);
|
|
122 }
|
|
123
|
|
124 wsdl__definitions::~wsdl__definitions()
|
|
125 { soap_destroy(soap);
|
|
126 soap_end(soap);
|
|
127 soap_done(soap);
|
|
128 free(soap);
|
|
129 }
|
|
130
|
|
131 int wsdl__definitions::get(struct soap *soap)
|
|
132 { return preprocess();
|
|
133 }
|
|
134
|
|
135 int wsdl__definitions::read(int num, char **loc)
|
|
136 { if (num <= 0)
|
|
137 return read((const char*)NULL, (const char*)NULL);
|
|
138 if (num == 1)
|
|
139 return read((const char*)NULL, loc[0]);
|
|
140 wsdl__import im;
|
|
141 im.namespace_ = NULL;
|
|
142 name = soap_strdup(soap, "WSDL");
|
|
143 targetNamespace = soap_strdup(soap, "");;
|
|
144 for (int i = 0; i < num; i++)
|
|
145 { im.location = loc[i];
|
|
146 import.push_back(im);
|
|
147 }
|
|
148 return preprocess();
|
|
149 }
|
|
150
|
|
151 int wsdl__definitions::read(const char *cwd, const char *loc)
|
|
152 { const char *cwd_temp;
|
|
153 if (!cwd)
|
|
154 cwd = cwd_path;
|
|
155 if (vflag)
|
|
156 fprintf(stderr, "\nOpening WSDL/XSD '%s' from '%s'\n", loc?loc:"", cwd?cwd:"");
|
|
157 if (loc)
|
|
158 { if (soap->recvfd > 2)
|
|
159 { soap_end_recv(soap);
|
|
160 close(soap->recvfd);
|
|
161 soap->recvfd = -1;
|
|
162 }
|
|
163 else if (soap_valid_socket(soap->socket))
|
|
164 { soap_end_recv(soap);
|
|
165 soap_closesock(soap);
|
|
166 }
|
|
167 #ifdef WITH_OPENSSL
|
|
168 if (!strncmp(loc, "http://", 7) || !strncmp(loc, "https://", 8))
|
|
169 #else
|
|
170 if (!strncmp(loc, "https://", 8))
|
|
171 { fprintf(stderr, "\nCannot connect to https site: no SSL support, please rebuild wsdl2h with SSL or download the files and rerun wsdl2h\n");
|
|
172 exit(1);
|
|
173 }
|
|
174 else if (!strncmp(loc, "http://", 7))
|
|
175 #endif
|
|
176 { fprintf(stderr, "\nConnecting to '%s' to retrieve WSDL/XSD...\n", loc);
|
|
177 location = soap_strdup(soap, loc);
|
|
178 if (soap_connect_command(soap, SOAP_GET, location, NULL))
|
|
179 { fprintf(stderr, "Connection failed\n");
|
|
180 soap_print_fault(soap, stderr);
|
|
181 exit(1);
|
|
182 }
|
|
183 fprintf(stderr, "Connected, receiving...\n");
|
|
184 }
|
|
185 else if (cwd && (!strncmp(cwd, "http://", 7) || !strncmp(cwd, "https://", 8)))
|
|
186 { char *s;
|
|
187 location = (char*)soap_malloc(soap, strlen(cwd) + strlen(loc) + 2);
|
|
188 strcpy(location, cwd);
|
|
189 s = strrchr(location, '/');
|
|
190 if (s)
|
|
191 *s = '\0';
|
|
192 strcat(location, "/");
|
|
193 strcat(location, loc);
|
|
194 fprintf(stderr, "\nConnecting to '%s' to retrieve relative path '%s' WSDL/XSD...\n", location, loc);
|
|
195 if (soap_connect_command(soap, SOAP_GET, location, NULL))
|
|
196 { fprintf(stderr, "Connection failed\n");
|
|
197 exit(1);
|
|
198 }
|
|
199 fprintf(stderr, "Connected, receiving...\n");
|
|
200 }
|
|
201 else
|
|
202 { soap->recvfd = open(loc, O_RDONLY, 0);
|
|
203 if (soap->recvfd < 0)
|
|
204 { if (cwd)
|
|
205 { char *s;
|
|
206 location = (char*)soap_malloc(soap, strlen(cwd) + strlen(loc) + 2);
|
|
207 strcpy(location, cwd);
|
|
208 s = strrchr(location, '/');
|
|
209 #ifdef WIN32
|
|
210 if (!s)
|
|
211 s = strrchr(location, '\\');
|
|
212 #endif
|
|
213 if (s)
|
|
214 *s = '\0';
|
|
215 strcat(location, "/");
|
|
216 strcat(location, loc);
|
|
217 if (!strncmp(location, "file://", 7))
|
|
218 location += 7;
|
|
219 soap->recvfd = open(location, O_RDONLY, 0);
|
|
220 }
|
|
221 if (soap->recvfd < 0 && import_path)
|
|
222 { location = (char*)soap_malloc(soap, strlen(import_path) + strlen(loc) + 2);
|
|
223 strcpy(location, import_path);
|
|
224 strcat(location, "/");
|
|
225 strcat(location, loc);
|
|
226 if (!strncmp(location, "file://", 7))
|
|
227 location += 7;
|
|
228 soap->recvfd = open(location, O_RDONLY, 0);
|
|
229 }
|
|
230 if (soap->recvfd < 0)
|
|
231 { fprintf(stderr, "\nCannot open '%s'\n", loc);
|
|
232 exit(1);
|
|
233 }
|
|
234 }
|
|
235 else
|
|
236 location = soap_strdup(soap, loc);
|
|
237 fprintf(stderr, "\nReading file '%s'...\n", location);
|
|
238 }
|
|
239 }
|
|
240 cwd_temp = cwd_path;
|
|
241 cwd_path = location;
|
|
242 if (!soap_begin_recv(soap))
|
|
243 this->soap_in(soap, "wsdl:", NULL);
|
|
244 if (soap->error)
|
|
245 { // handle sloppy WSDLs that import schemas at the top level rather than
|
|
246 // importing them in <types>
|
|
247 if (soap->error == SOAP_TAG_MISMATCH && soap->level == 0)
|
|
248 { soap_retry(soap);
|
|
249 xs__schema *schema = soap_new_xs__schema(soap, -1);
|
|
250 schema->soap_in(soap, "xs:schema", NULL);
|
|
251 if (soap->error)
|
|
252 { fprintf(stderr, "\nAn error occurred while parsing WSDL or XSD from '%s'\n", loc?loc:"");
|
|
253 soap_print_fault(soap, stderr);
|
|
254 if (soap->error < 200)
|
|
255 soap_print_fault_location(soap, stderr);
|
|
256 exit(1);
|
|
257 }
|
|
258 name = NULL;
|
|
259 targetNamespace = schema->targetNamespace;
|
|
260 if (vflag)
|
|
261 cerr << "Found schema '" << (targetNamespace?targetNamespace:"") << "' when expecting WSDL" << endl;
|
|
262 types = soap_new_wsdl__types(soap, -1);
|
|
263 types->documentation = NULL;
|
|
264 types->xs__schema_.push_back(schema);
|
|
265 types->preprocess(*this);
|
|
266 }
|
|
267 // check HTTP redirect (socket was closed)
|
|
268 else if ((soap->error >= 301 && soap->error <= 303) || soap->error == 307)
|
|
269 { int r = SOAP_ERR;
|
|
270 fprintf(stderr, "Redirected to '%s'...\n", soap->endpoint);
|
|
271 if (redirs++ < 10)
|
|
272 r = read(cwd, soap->endpoint);
|
|
273 else
|
|
274 fprintf(stderr, "\nMax redirects exceeded\n");
|
|
275 redirs--;
|
|
276 return r;
|
|
277 }
|
|
278 else if (soap->error == 401)
|
|
279 { int r = SOAP_ERR;
|
|
280 fprintf(stderr, "Authenticating to '%s' realm '%s'...\n", loc, soap->authrealm);
|
|
281 if (auth_userid && auth_passwd && redirs++ < 1)
|
|
282 {
|
|
283 #ifdef HTTPDA_H
|
|
284 struct http_da_info info;
|
|
285 http_da_save(soap, &info, soap->authrealm, auth_userid, auth_passwd);
|
|
286 #else
|
|
287 soap->userid = auth_userid;
|
|
288 soap->passwd = auth_passwd;
|
|
289 #endif
|
|
290 r = read(cwd, loc);
|
|
291 #ifdef HTTPDA_H
|
|
292 http_da_release(soap, &info);
|
|
293 #endif
|
|
294 redirs--;
|
|
295 }
|
|
296 else
|
|
297 fprintf(stderr, "Authentication failed, use option -r:uid:pwd and (re)build with OpenSSL to enable digest authentication\n");
|
|
298 return r;
|
|
299 }
|
|
300 else
|
|
301 { fprintf(stderr, "\nAn error occurred while parsing WSDL from '%s'\n", loc?loc:"");
|
|
302 soap_print_fault(soap, stderr);
|
|
303 if (soap->error < 200)
|
|
304 soap_print_fault_location(soap, stderr);
|
|
305 exit(1);
|
|
306 }
|
|
307 }
|
|
308 fprintf(stderr, "Done reading '%s'\n", loc?loc:"");
|
|
309 soap_end_recv(soap);
|
|
310 if (soap->recvfd > 2)
|
|
311 { close(soap->recvfd);
|
|
312 soap->recvfd = -1;
|
|
313 }
|
|
314 else
|
|
315 soap_closesock(soap);
|
|
316 cwd_path = cwd_temp;
|
|
317 return SOAP_OK;
|
|
318 }
|
|
319
|
|
320 int wsdl__definitions::preprocess()
|
|
321 { if (vflag)
|
|
322 cerr << "Preprocessing wsdl definitions '" << (location?location:"") << "' namespace '" << (targetNamespace?targetNamespace:"") << "'" << endl;
|
|
323 // process import
|
|
324 for (vector<wsdl__import>::iterator im1 = import.begin(); im1 != import.end(); ++im1)
|
|
325 (*im1).preprocess(*this);
|
|
326 // merge nested imported WSDLs into single import list
|
|
327 again:
|
|
328 for (vector<wsdl__import>::iterator im2 = import.begin(); im2 != import.end(); ++im2)
|
|
329 { if ((*im2).definitionsPtr())
|
|
330 { for (vector<wsdl__import>::iterator i = (*im2).definitionsPtr()->import.begin(); i != (*im2).definitionsPtr()->import.end(); ++i)
|
|
331 { if ((*i).definitionsPtr())
|
|
332 { bool found = false;
|
|
333 if (vflag)
|
|
334 cerr << "Import WSDL '" << ((*i).location?(*i).location:"") << endl;
|
|
335 for (vector<wsdl__import>::iterator j = import.begin(); j != import.end(); ++j)
|
|
336 { if ((*i).definitionsPtr() == (*j).definitionsPtr()
|
|
337 || ((*i).location && (*j).location && !strcmp((*i).location, (*j).location)))
|
|
338 { found = true;
|
|
339 break;
|
|
340 }
|
|
341 }
|
|
342 if (!found)
|
|
343 { if (vflag)
|
|
344 cerr << "Adding imported WSDL '" << ((*i).location?(*i).location:"") << "' to '" << (location?location:"") << "' ('" << (name?name:"") << "') namespace '" << (targetNamespace?targetNamespace:"") << "'" << endl;
|
|
345 import.push_back(*i);
|
|
346 goto again;
|
|
347 }
|
|
348 }
|
|
349 }
|
|
350 }
|
|
351 }
|
|
352 // merge <types>
|
|
353 for (vector<wsdl__import>::iterator im3 = import.begin(); im3 != import.end(); ++im3)
|
|
354 { if ((*im3).definitionsPtr() && (*im3).definitionsPtr()->types)
|
|
355 { if (!types)
|
|
356 { types = soap_new_wsdl__types(soap, -1);
|
|
357 types->soap_default(soap);
|
|
358 }
|
|
359 // merge <types>, check for duplicates, add namespaces for sloppy imports
|
|
360 for (vector<xs__schema*>::const_iterator i = (*im3).definitionsPtr()->types->xs__schema_.begin(); i != (*im3).definitionsPtr()->types->xs__schema_.end(); ++i)
|
|
361 { bool found = false;
|
|
362 vector<xs__schema*>::const_iterator j;
|
|
363 if (!(*i)->targetNamespace)
|
|
364 { (*i)->targetNamespace = targetNamespace;
|
|
365 if (!Wflag)
|
|
366 cerr << "Warning: schema without namespace, assigning namespace '" << (targetNamespace?targetNamespace:"") << "'" << endl;
|
|
367 }
|
|
368 for (j = types->xs__schema_.begin(); j != types->xs__schema_.end(); ++j)
|
|
369 { if ((*j)->targetNamespace && !strcmp((*i)->targetNamespace, (*j)->targetNamespace))
|
|
370 { found = true;
|
|
371 break;
|
|
372 }
|
|
373 }
|
|
374 // add new schema only if not already in <types>, otherwise merge schema components
|
|
375 if (found)
|
|
376 { if (vflag)
|
|
377 cerr << "Warning: duplicate schema with namespace '" << ((*i)->targetNamespace?(*i)->targetNamespace:"") << "' merged in WSDL '" << (name?name:"") << "' namespace '" << (targetNamespace?targetNamespace:"") << "'" << endl;
|
|
378 (*j)->insert(*(*i));
|
|
379 }
|
|
380 else
|
|
381 { if (vflag)
|
|
382 cerr << "Adding schema with namespace '" << ((*i)->targetNamespace?(*i)->targetNamespace:"") << "' to types in WSDL '" << (name?name:"") << "' namespace '" << (targetNamespace?targetNamespace:"") << "'" << endl;
|
|
383 types->xs__schema_.push_back(*i);
|
|
384 }
|
|
385 }
|
|
386 }
|
|
387 }
|
|
388 // process the types
|
|
389 if (types)
|
|
390 types->preprocess(*this);
|
|
391 return SOAP_OK;
|
|
392 }
|
|
393
|
|
394 int wsdl__definitions::traverse()
|
|
395 { if (updated)
|
|
396 return SOAP_OK;
|
|
397 if (vflag)
|
|
398 cerr << "Analyzing definitions '" << (name?name:"") << "' in wsdl namespace '" << (targetNamespace?targetNamespace:"") << "'" << endl;
|
|
399 updated = true;
|
|
400 if (!targetNamespace)
|
|
401 { if (vflag)
|
|
402 cerr << "Warning: wsdl '" << (name?name:"") << "' has no targetNamespace" << endl;
|
|
403 targetNamespace = soap_strdup(soap, "");
|
|
404 }
|
|
405 // process import first
|
|
406 for (vector<wsdl__import>::iterator im = import.begin(); im != import.end(); ++im)
|
|
407 (*im).traverse(*this);
|
|
408 // then process the types
|
|
409 if (types)
|
|
410 types->traverse(*this);
|
|
411 // process messages before portType
|
|
412 for (vector<wsdl__message>::iterator mg = message.begin(); mg != message.end(); ++mg)
|
|
413 (*mg).traverse(*this);
|
|
414 // process portType before binding
|
|
415 for (vector<wsdl__portType>::iterator pt = portType.begin(); pt != portType.end(); ++pt)
|
|
416 (*pt).traverse(*this);
|
|
417 // process interface before binding WSDL 2.0
|
|
418 for (vector<wsdl__portType>::iterator in = interface_.begin(); in != interface_.end(); ++in)
|
|
419 (*in).traverse(*this);
|
|
420 // process binding
|
|
421 for (vector<wsdl__binding>::iterator bg = binding.begin(); bg != binding.end(); ++bg)
|
|
422 (*bg).traverse(*this);
|
|
423 // process service
|
|
424 for (vector<wsdl__service>::iterator sv = service.begin(); sv != service.end(); ++sv)
|
|
425 (*sv).traverse(*this);
|
|
426 if (vflag)
|
|
427 cerr << "End of definitions '" << (name?name:"") << "' namespace '" << (targetNamespace?targetNamespace:"") << "'" << endl;
|
|
428 for (std::vector<wsp__Policy>::iterator p = wsp__Policy_.begin(); p != wsp__Policy_.end(); ++p)
|
|
429 (*p).traverse(*this);
|
|
430 return SOAP_OK;
|
|
431 }
|
|
432
|
|
433 const char *wsdl__definitions::sourceLocation()
|
|
434 { return location;
|
|
435 }
|
|
436
|
|
437 int wsdl__definitions::error()
|
|
438 { return soap->error;
|
|
439 }
|
|
440
|
|
441 void wsdl__definitions::print_fault()
|
|
442 { soap_print_fault(soap, stderr);
|
|
443 if (soap->error < 200)
|
|
444 soap_print_fault_location(soap, stderr);
|
|
445 }
|
|
446
|
|
447 void wsdl__definitions::builtinType(const char *type)
|
|
448 { builtinTypeSet.insert(type);
|
|
449 }
|
|
450
|
|
451 void wsdl__definitions::builtinTypes(const SetOfString& types)
|
|
452 { for (SetOfString::const_iterator tp = types.begin(); tp != types.end(); ++tp)
|
|
453 builtinTypeSet.insert(*tp);
|
|
454 }
|
|
455
|
|
456 void wsdl__definitions::builtinElement(const char *element)
|
|
457 { builtinElementSet.insert(element);
|
|
458 }
|
|
459
|
|
460 void wsdl__definitions::builtinElements(const SetOfString& elements)
|
|
461 { for (SetOfString::const_iterator el = elements.begin(); el != elements.end(); ++el)
|
|
462 builtinElementSet.insert(*el);
|
|
463 }
|
|
464
|
|
465 void wsdl__definitions::builtinAttribute(const char *attribute)
|
|
466 { builtinAttributeSet.insert(attribute);
|
|
467 }
|
|
468
|
|
469 void wsdl__definitions::builtinAttributes(const SetOfString& attributes)
|
|
470 { for (SetOfString::const_iterator at = attributes.begin(); at != attributes.end(); ++at)
|
|
471 builtinAttributeSet.insert(*at);
|
|
472 }
|
|
473
|
|
474 const SetOfString& wsdl__definitions::builtinTypes() const
|
|
475 { return builtinTypeSet;
|
|
476 }
|
|
477
|
|
478 const SetOfString& wsdl__definitions::builtinElements() const
|
|
479 { return builtinElementSet;
|
|
480 }
|
|
481
|
|
482 const SetOfString& wsdl__definitions::builtinAttributes() const
|
|
483 { return builtinAttributeSet;
|
|
484 }
|
|
485
|
|
486 int wsdl__service::traverse(wsdl__definitions& definitions)
|
|
487 { if (vflag)
|
|
488 cerr << "Analyzing service '" << (name?name:"") << "' in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
489 // process ports
|
|
490 for (vector<wsdl__port>::iterator pt = port.begin(); pt != port.end(); ++pt)
|
|
491 (*pt).traverse(definitions);
|
|
492 for (vector<wsdl__port>::iterator ep = endpoint.begin(); ep != endpoint.end(); ++ep)
|
|
493 (*ep).traverse(definitions);
|
|
494 for (vector<wsp__Policy>::iterator py = wsp__Policy_.begin(); py != wsp__Policy_.end(); ++py)
|
|
495 (*py).traverse(definitions);
|
|
496 for (vector<wsp__PolicyReference>::iterator pr = wsp__PolicyReference_.begin(); pr != wsp__PolicyReference_.end(); ++pr)
|
|
497 (*pr).traverse(definitions);
|
|
498 return SOAP_OK;
|
|
499 }
|
|
500
|
|
501 wsdl__port::wsdl__port()
|
|
502 { bindingRef = NULL;
|
|
503 }
|
|
504
|
|
505 int wsdl__port::traverse(wsdl__definitions& definitions)
|
|
506 { if (vflag)
|
|
507 cerr << " Analyzing service port/endpoint in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
508 // search binding name
|
|
509 const char *token = qname_token(binding, definitions.targetNamespace);
|
|
510 bindingRef = NULL;
|
|
511 if (token)
|
|
512 { for (vector<wsdl__binding>::iterator binding = definitions.binding.begin(); binding != definitions.binding.end(); ++binding)
|
|
513 { if ((*binding).name && !strcmp((*binding).name, token))
|
|
514 { bindingRef = &(*binding);
|
|
515 if (vflag)
|
|
516 cerr << " Found port/endpoint '" << (name?name:"") << "' binding '" << (token?token:"") << "'" << endl;
|
|
517 break;
|
|
518 }
|
|
519 }
|
|
520 }
|
|
521 if (!bindingRef)
|
|
522 { for (vector<wsdl__import>::iterator import = definitions.import.begin(); import != definitions.import.end(); ++import)
|
|
523 { wsdl__definitions *importdefinitions = (*import).definitionsPtr();
|
|
524 if (importdefinitions)
|
|
525 { token = qname_token(binding, importdefinitions->targetNamespace);
|
|
526 if (token)
|
|
527 { for (vector<wsdl__binding>::iterator binding = importdefinitions->binding.begin(); binding != importdefinitions->binding.end(); ++binding)
|
|
528 { if ((*binding).name && !strcmp((*binding).name, token))
|
|
529 { bindingRef = &(*binding);
|
|
530 if (vflag)
|
|
531 cerr << " Found port/endpoint '" << (name?name:"") << "' binding '" << (token?token:"") << "'" << endl;
|
|
532 break;
|
|
533 }
|
|
534 }
|
|
535 }
|
|
536 }
|
|
537 }
|
|
538 }
|
|
539 if (!bindingRef)
|
|
540 if (!Wflag)
|
|
541 cerr << "Warning: no port/endpoint '" << (name?name:"") << "' binding '" << (binding?binding:"") << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
542 if (wsp__Policy_)
|
|
543 wsp__Policy_->traverse(definitions);
|
|
544 if (wsp__PolicyReference_)
|
|
545 wsp__PolicyReference_->traverse(definitions);
|
|
546 return SOAP_OK;
|
|
547 }
|
|
548
|
|
549 void wsdl__port::bindingPtr(wsdl__binding *binding)
|
|
550 { bindingRef = binding;
|
|
551 if (!bindingRef && vflag)
|
|
552 cerr << "Warning: wsdl__port binding set to NULL" << endl;
|
|
553 }
|
|
554
|
|
555 wsdl__binding *wsdl__port::bindingPtr() const
|
|
556 { return bindingRef;
|
|
557 }
|
|
558
|
|
559 wsdl__binding::wsdl__binding()
|
|
560 { portTypeRef = NULL;
|
|
561 }
|
|
562
|
|
563 int wsdl__binding::traverse(wsdl__definitions& definitions)
|
|
564 { const char *token;
|
|
565 if (vflag)
|
|
566 cerr << " Analyzing binding '" << (name?name:"") << "' in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
567 portTypeRef = NULL;
|
|
568 if (interface_) // WSDL 2.0
|
|
569 token = qname_token(interface_, definitions.targetNamespace);
|
|
570 else
|
|
571 token = qname_token(type, definitions.targetNamespace);
|
|
572 if (token)
|
|
573 { for (vector<wsdl__portType>::iterator portType = definitions.portType.begin(); portType != definitions.portType.end(); ++portType)
|
|
574 { if ((*portType).name && !strcmp((*portType).name, token))
|
|
575 { portTypeRef = &(*portType);
|
|
576 if (vflag)
|
|
577 cerr << " Found binding '" << (name?name:"") << "' portType '" << (token?token:"") << "'" << endl;
|
|
578 break;
|
|
579 }
|
|
580 }
|
|
581 // WSDL 2.0
|
|
582 for (vector<wsdl__portType>::iterator i = definitions.interface_.begin(); i != definitions.interface_.end(); ++i)
|
|
583 { if ((*i).name && !strcmp((*i).name, token))
|
|
584 { portTypeRef = &(*i);
|
|
585 if (vflag)
|
|
586 cerr << " Found binding '" << (name?name:"") << "' interface '" << (token?token:"") << "'" << endl;
|
|
587 break;
|
|
588 }
|
|
589 }
|
|
590 }
|
|
591 if (!portTypeRef)
|
|
592 { for (vector<wsdl__import>::iterator import = definitions.import.begin(); import != definitions.import.end(); ++import)
|
|
593 { wsdl__definitions *importdefinitions = (*import).definitionsPtr();
|
|
594 if (importdefinitions)
|
|
595 { if (interface_) // WSDL 2.0
|
|
596 token = qname_token(interface_, importdefinitions->targetNamespace);
|
|
597 else
|
|
598 token = qname_token(type, importdefinitions->targetNamespace);
|
|
599 if (token)
|
|
600 { for (vector<wsdl__portType>::iterator portType = importdefinitions->portType.begin(); portType != importdefinitions->portType.end(); ++portType)
|
|
601 { if ((*portType).name && !strcmp((*portType).name, token))
|
|
602 { portTypeRef = &(*portType);
|
|
603 if (vflag)
|
|
604 cerr << " Found binding '" << (name?name:"") << "' portType '" << (token?token:"") << "'" << endl;
|
|
605 break;
|
|
606 }
|
|
607 }
|
|
608 // WSDL 2.0
|
|
609 for (vector<wsdl__portType>::iterator i = importdefinitions->interface_.begin(); i != importdefinitions->interface_.end(); ++i)
|
|
610 { if ((*i).name && !strcmp((*i).name, token))
|
|
611 { portTypeRef = &(*i);
|
|
612 if (vflag)
|
|
613 cerr << " Found binding '" << (name?name:"") << "' interface '" << (token?token:"") << "'" << endl;
|
|
614 break;
|
|
615 }
|
|
616 }
|
|
617 }
|
|
618 }
|
|
619 }
|
|
620 }
|
|
621 if (!portTypeRef)
|
|
622 { if (!Wflag)
|
|
623 { if (interface_)
|
|
624 cerr << "Warning: no binding '" << (name?name:"") << "' interface '" << (interface_?interface_:"") << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
625 else
|
|
626 cerr << "Warning: no binding '" << (name?name:"") << "' portType '" << (type?type:"") << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
627 }
|
|
628 }
|
|
629 // WSDL 2.0
|
|
630 for (vector<wsdl__ext_fault>::iterator f = fault.begin(); f != fault.end(); ++f)
|
|
631 (*f).traverse(definitions, portTypeRef);
|
|
632 for (vector<wsdl__ext_operation>::iterator i = operation.begin(); i != operation.end(); ++i)
|
|
633 (*i).traverse(definitions, portTypeRef);
|
|
634 for (vector<wsp__Policy>::iterator p = wsp__Policy_.begin(); p != wsp__Policy_.end(); ++p)
|
|
635 (*p).traverse(definitions);
|
|
636 for (vector<wsp__PolicyReference>::iterator r = wsp__PolicyReference_.begin(); r != wsp__PolicyReference_.end(); ++r)
|
|
637 (*r).traverse(definitions);
|
|
638 return SOAP_OK;
|
|
639 }
|
|
640
|
|
641 void wsdl__binding::portTypePtr(wsdl__portType *portType)
|
|
642 { portTypeRef = portType;
|
|
643 if (!portTypeRef && vflag)
|
|
644 cerr << "Warning: wsdl__binding portType set to NULL" << endl;
|
|
645 }
|
|
646
|
|
647 wsdl__portType *wsdl__binding::portTypePtr() const
|
|
648 { return portTypeRef;
|
|
649 }
|
|
650
|
|
651 wsdl__ext_operation::wsdl__ext_operation()
|
|
652 { operationRef = NULL;
|
|
653 }
|
|
654
|
|
655 int wsdl__ext_operation::traverse(wsdl__definitions& definitions, wsdl__portType *portTypeRef)
|
|
656 { if (vflag)
|
|
657 cerr << " Analyzing binding operation '" << (name?name:ref?ref:"") << "' in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
658 if (input)
|
|
659 input->traverse(definitions);
|
|
660 if (output)
|
|
661 output->traverse(definitions);
|
|
662 for (vector<wsdl__ext_fault>::iterator f = fault.begin(); f != fault.end(); ++f)
|
|
663 (*f).traverse(definitions, portTypeRef);
|
|
664 // WSDL 2.0
|
|
665 for (vector<wsdl__ext_fault>::iterator fi = infault.begin(); fi != infault.end(); ++fi)
|
|
666 (*fi).traverse(definitions, portTypeRef);
|
|
667 for (vector<wsdl__ext_fault>::iterator fo = outfault.begin(); fo != outfault.end(); ++fo)
|
|
668 (*fo).traverse(definitions, portTypeRef);
|
|
669 operationRef = NULL;
|
|
670 if (portTypeRef)
|
|
671 { // WSDL 2.0, assumption: ref refers to an operation in the interface for this binding
|
|
672 const char *token = NULL;
|
|
673 if (ref)
|
|
674 token = qname_token(ref, portTypeRef->definitionsPtr()->targetNamespace);
|
|
675 for (vector<wsdl__operation>::iterator i = portTypeRef->operation.begin(); i != portTypeRef->operation.end(); ++i)
|
|
676 { if (token)
|
|
677 { if ((*i).name && !strcmp((*i).name, token))
|
|
678 { operationRef = &(*i);
|
|
679 if (vflag)
|
|
680 cerr << " Found operation '" << token << "' in interface '" << portTypeRef->name << "'" << endl;
|
|
681 break;
|
|
682 }
|
|
683 }
|
|
684 else if (name && (*i).name && !strcmp((*i).name, name))
|
|
685 { if ((!input
|
|
686 || !input->name
|
|
687 || ((*i).__union1 == SOAP_UNION_wsdl__union_ioput_input && (*i).__ioput1.input->name && !strcmp((*i).__ioput1.input->name, input->name))
|
|
688 || ((*i).__union2 == SOAP_UNION_wsdl__union_ioput_input && (*i).__ioput2.input->name && !strcmp((*i).__ioput2.input->name, input->name))
|
|
689 )
|
|
690 && (!output
|
|
691 || !output->name
|
|
692 || ((*i).__union1 == SOAP_UNION_wsdl__union_ioput_output && (*i).__ioput1.output->name && !strcmp((*i).__ioput1.output->name, output->name))
|
|
693 || ((*i).__union2 == SOAP_UNION_wsdl__union_ioput_output && (*i).__ioput2.output->name && !strcmp((*i).__ioput2.output->name, output->name))
|
|
694 ))
|
|
695 { operationRef = &(*i);
|
|
696 if (vflag)
|
|
697 cerr << " Found operation '" << name << "' in portType '" << portTypeRef->name << "'" << endl;
|
|
698 break;
|
|
699 }
|
|
700 }
|
|
701 }
|
|
702 if (name && !operationRef)
|
|
703 { for (vector<wsdl__operation>::iterator j = portTypeRef->operation.begin(); j != portTypeRef->operation.end(); ++j)
|
|
704 { if ((*j).name && !strcmp((*j).name, name))
|
|
705 { if (input
|
|
706 && input->name
|
|
707 && (((*j).__union1 == SOAP_UNION_wsdl__union_ioput_input && (*j).__ioput1.input->name && !strcmp((*j).__ioput1.input->name, input->name))
|
|
708 || ((*j).__union2 == SOAP_UNION_wsdl__union_ioput_input && (*j).__ioput2.input->name && !strcmp((*j).__ioput2.input->name, input->name))
|
|
709 ))
|
|
710 cerr << "Warning: no matching portType operation input name '" << input->name << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
711 if (output
|
|
712 && output->name
|
|
713 && (((*j).__union1 == SOAP_UNION_wsdl__union_ioput_output && (*j).__ioput1.output->name && !strcmp((*j).__ioput1.output->name, output->name))
|
|
714 || ((*j).__union2 == SOAP_UNION_wsdl__union_ioput_output && (*j).__ioput2.output->name && !strcmp((*j).__ioput2.output->name, output->name))
|
|
715 ))
|
|
716 cerr << "Warning: no matching portType operation output name '" << output->name << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
717 operationRef = &(*j);
|
|
718 if (vflag)
|
|
719 cerr << " Found operation '" << name << "'" << endl;
|
|
720 break;
|
|
721 }
|
|
722 }
|
|
723 }
|
|
724 }
|
|
725 if (!operationRef)
|
|
726 { if (!Wflag)
|
|
727 { if (ref)
|
|
728 cerr << "Warning: no matching interface operation '" << (ref?ref:"") << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
729 else
|
|
730 cerr << "Warning: no matching portType operation '" << (name?name:"") << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
731 }
|
|
732 }
|
|
733 else
|
|
734 { for (vector<wsdl__ext_fault>::iterator i = fault.begin(); i != fault.end(); ++i)
|
|
735 { if ((*i).name)
|
|
736 { for (vector<wsdl__fault>::iterator j = operationRef->fault.begin(); j != operationRef->fault.end(); ++j)
|
|
737 { if ((*j).name && !strcmp((*j).name, (*i).name))
|
|
738 { (*i).faultPtr(&(*j));
|
|
739 if (vflag)
|
|
740 cerr << " Found fault '" << (*j).name << "' message" << endl;
|
|
741 break;
|
|
742 }
|
|
743 }
|
|
744 }
|
|
745 else if ((*i).soap__fault_ && (*i).soap__fault_->name) // try the soap:fault name, this is not elegant, but neither is WSDL 1.1
|
|
746 { for (vector<wsdl__fault>::iterator j = operationRef->fault.begin(); j != operationRef->fault.end(); ++j)
|
|
747 { if ((*j).name && !strcmp((*j).name, (*i).soap__fault_->name))
|
|
748 { (*i).faultPtr(&(*j));
|
|
749 if (vflag)
|
|
750 cerr << " Found fault '" << ((*j).name?(*j).name:"") << "' message" << endl;
|
|
751 break;
|
|
752 }
|
|
753 }
|
|
754 }
|
|
755 if (!(*i).faultPtr())
|
|
756 if (!Wflag)
|
|
757 cerr << "Warning: no soap:fault '" << ((*i).name?(*i).name:"") << "' message in wsdl definitions '" << (definitions.name?definitions.name:"") << "' operation '" << (name?name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
758 }
|
|
759 }
|
|
760 if (wsp__Policy_)
|
|
761 wsp__Policy_->traverse(definitions);
|
|
762 if (wsp__PolicyReference_)
|
|
763 wsp__PolicyReference_->traverse(definitions);
|
|
764 return SOAP_OK;
|
|
765 }
|
|
766
|
|
767 void wsdl__ext_operation::operationPtr(wsdl__operation *operation)
|
|
768 { operationRef = operation;
|
|
769 if (!operationRef && vflag)
|
|
770 cerr << "Warning: wsdl__ext_operation operation set to NULL" << endl;
|
|
771 }
|
|
772
|
|
773 wsdl__operation *wsdl__ext_operation::operationPtr() const
|
|
774 { return operationRef;
|
|
775 }
|
|
776
|
|
777 int wsdl__ext_ioput::traverse(wsdl__definitions& definitions)
|
|
778 { if (vflag)
|
|
779 cerr << " Analyzing binding operation input/output in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
780 for (vector<soap__header>::iterator hd = soap__header_.begin(); hd != soap__header_.end(); ++hd)
|
|
781 (*hd).traverse(definitions);
|
|
782 for (vector<wsoap__header>::iterator whd = wsoap__header_.begin(); whd != wsoap__header_.end(); ++whd)
|
|
783 (*whd).traverse(definitions);
|
|
784 if (mime__multipartRelated_)
|
|
785 mime__multipartRelated_->traverse(definitions);
|
|
786 if (wsp__Policy_)
|
|
787 wsp__Policy_->traverse(definitions);
|
|
788 if (wsp__PolicyReference_)
|
|
789 wsp__PolicyReference_->traverse(definitions);
|
|
790 return SOAP_OK;
|
|
791 }
|
|
792
|
|
793 wsdl__ext_fault::wsdl__ext_fault()
|
|
794 { faultRef = NULL;
|
|
795 }
|
|
796
|
|
797 int wsdl__ext_fault::traverse(wsdl__definitions& definitions, wsdl__portType *portTypeRef)
|
|
798 { if (vflag)
|
|
799 cerr << " Analyzing binding operation fault in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
800 if (ref && portTypeRef)
|
|
801 { // WSDL 2.0, assumption: ref refers to a fault in the interface for this binding
|
|
802 const char *token = qname_token(ref, portTypeRef->definitionsPtr()->targetNamespace);
|
|
803 if (token)
|
|
804 { for (vector<wsdl__fault>::iterator fault = portTypeRef->fault.begin(); fault != portTypeRef->fault.end(); ++fault)
|
|
805 { if ((*fault).name && !strcmp((*fault).name, token))
|
|
806 { faultRef = &(*fault);
|
|
807 if (vflag)
|
|
808 cerr << " Found fault '" << (*fault).name << endl;
|
|
809 break;
|
|
810 }
|
|
811 }
|
|
812 }
|
|
813 if (!faultRef)
|
|
814 if (!Wflag)
|
|
815 cerr << "Warning: no fault '" << (ref?ref:"") << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' interface '" << (portTypeRef->name?portTypeRef->name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
816 }
|
|
817 if (wsp__Policy_)
|
|
818 wsp__Policy_->traverse(definitions);
|
|
819 if (wsp__PolicyReference_)
|
|
820 wsp__PolicyReference_->traverse(definitions);
|
|
821 return SOAP_OK;
|
|
822 }
|
|
823
|
|
824 void wsdl__ext_fault::faultPtr(wsdl__fault *fault)
|
|
825 { faultRef = fault;
|
|
826 if (!faultRef && vflag)
|
|
827 cerr << "Warning: wsdl__ext_fault fault ref set to NULL" << endl;
|
|
828 }
|
|
829
|
|
830 wsdl__fault *wsdl__ext_fault::faultPtr() const
|
|
831 { return faultRef;
|
|
832 }
|
|
833
|
|
834 wsdl__portType::wsdl__portType()
|
|
835 { definitionsRef = NULL;
|
|
836 }
|
|
837
|
|
838 int wsdl__portType::traverse(wsdl__definitions& definitions)
|
|
839 { if (vflag)
|
|
840 cerr << " Analyzing portType/interface '" << (name?name:"") << "' in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
841 definitionsRef = &definitions;
|
|
842 // traverse faults before operations, WSDL 2.0
|
|
843 for (vector<wsdl__fault>::iterator f = fault.begin(); f != fault.end(); ++f)
|
|
844 (*f).traverse(definitions);
|
|
845 for (vector<wsdl__operation>::iterator i = operation.begin(); i != operation.end(); ++i)
|
|
846 (*i).traverse(definitions);
|
|
847 if (wsp__Policy_)
|
|
848 wsp__Policy_->traverse(definitions);
|
|
849 if (wsp__PolicyReference_)
|
|
850 wsp__PolicyReference_->traverse(definitions);
|
|
851 return SOAP_OK;
|
|
852 }
|
|
853
|
|
854 void wsdl__portType::definitionsPtr(wsdl__definitions *definitions)
|
|
855 { definitionsRef = definitions;
|
|
856 }
|
|
857
|
|
858 wsdl__definitions *wsdl__portType::definitionsPtr() const
|
|
859 { return definitionsRef;
|
|
860 }
|
|
861
|
|
862 int wsdl__operation::traverse(wsdl__definitions& definitions)
|
|
863 { if (vflag)
|
|
864 cerr << " Analyzing portType/interface operation '" << (name?name:"") << "' in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
865 if (__union1 == SOAP_UNION_wsdl__union_ioput_input)
|
|
866 if (__ioput1.input)
|
|
867 __ioput1.input->traverse(definitions);
|
|
868 if (__union1 == SOAP_UNION_wsdl__union_ioput_output)
|
|
869 if (__ioput1.output)
|
|
870 __ioput1.output->traverse(definitions);
|
|
871 if (__union2 == SOAP_UNION_wsdl__union_ioput_input)
|
|
872 if (__ioput2.input)
|
|
873 __ioput2.input->traverse(definitions);
|
|
874 if (__union2 == SOAP_UNION_wsdl__union_ioput_output)
|
|
875 if (__ioput2.output)
|
|
876 __ioput2.output->traverse(definitions);
|
|
877 for (vector<wsdl__fault>::iterator i = fault.begin(); i != fault.end(); ++i)
|
|
878 (*i).traverse(definitions);
|
|
879 // WSDL 2.0
|
|
880 for (vector<wsdl__fault>::iterator fi = infault.begin(); fi != infault.end(); ++fi)
|
|
881 (*fi).traverse(definitions);
|
|
882 for (vector<wsdl__fault>::iterator fo = outfault.begin(); fo != outfault.end(); ++fo)
|
|
883 (*fo).traverse(definitions);
|
|
884 if (wsp__Policy_)
|
|
885 wsp__Policy_->traverse(definitions);
|
|
886 if (wsp__PolicyReference_)
|
|
887 wsp__PolicyReference_->traverse(definitions);
|
|
888 return SOAP_OK;
|
|
889 }
|
|
890
|
|
891 wsdl__ioput::wsdl__ioput()
|
|
892 { messageRef = NULL;
|
|
893 elementRef = NULL;
|
|
894 }
|
|
895
|
|
896 int wsdl__ioput::traverse(wsdl__definitions& definitions)
|
|
897 { if (vflag)
|
|
898 cerr << " Analyzing portType/interface operation input/output in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
899 messageRef = NULL;
|
|
900 elementRef = NULL;
|
|
901 // WSDL 2.0
|
|
902 if (element)
|
|
903 { if (definitions.types)
|
|
904 { for (vector<xs__schema*>::iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)
|
|
905 { const char *token = qname_token(element, (*schema)->targetNamespace);
|
|
906 if (token)
|
|
907 { for (vector<xs__element>::iterator element = (*schema)->element.begin(); element != (*schema)->element.end(); ++element)
|
|
908 { if ((*element).name && !strcmp((*element).name, token))
|
|
909 { elementRef = &(*element);
|
|
910 if (vflag)
|
|
911 cerr << " Found input/output '" << (messageLabel?messageLabel:"") << "' element '" << (token?token:"") << "'" << endl;
|
|
912 break;
|
|
913 }
|
|
914 }
|
|
915 }
|
|
916 }
|
|
917 }
|
|
918 if (*element != '#' && !elementRef)
|
|
919 { if (is_builtin_qname(element))
|
|
920 definitions.builtinElement(element);
|
|
921 else
|
|
922 if (!Wflag)
|
|
923 cerr << "Warning: no input/output '" << (messageLabel?messageLabel:"") << "' element '" << element << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
924 }
|
|
925 }
|
|
926 else
|
|
927 { const char *token = qname_token(message, definitions.targetNamespace);
|
|
928 if (token)
|
|
929 { for (vector<wsdl__message>::iterator message = definitions.message.begin(); message != definitions.message.end(); ++message)
|
|
930 { if ((*message).name && !strcmp((*message).name, token))
|
|
931 { messageRef = &(*message);
|
|
932 if (vflag)
|
|
933 cerr << " Found input/output '" << (name?name:"") << "' message '" << (token?token:"") << "'" << endl;
|
|
934 break;
|
|
935 }
|
|
936 }
|
|
937 }
|
|
938 if (!messageRef)
|
|
939 { for (vector<wsdl__import>::iterator import = definitions.import.begin(); import != definitions.import.end(); ++import)
|
|
940 { wsdl__definitions *importdefinitions = (*import).definitionsPtr();
|
|
941 if (importdefinitions)
|
|
942 { token = qname_token(message, importdefinitions->targetNamespace);
|
|
943 if (token)
|
|
944 { for (vector<wsdl__message>::iterator message = importdefinitions->message.begin(); message != importdefinitions->message.end(); ++message)
|
|
945 { if ((*message).name && !strcmp((*message).name, token))
|
|
946 { messageRef = &(*message);
|
|
947 if (vflag)
|
|
948 cerr << " Found input/output '" << (name?name:"") << "' message '" << (token?token:"") << "'" << endl;
|
|
949 break;
|
|
950 }
|
|
951 }
|
|
952 }
|
|
953 }
|
|
954 }
|
|
955 }
|
|
956 if (!messageRef)
|
|
957 if (!Wflag)
|
|
958 cerr << "Warning: no input/output '" << (name?name:"") << "' message '" << (message?message:"") << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
959 }
|
|
960 if (wsp__Policy_)
|
|
961 wsp__Policy_->traverse(definitions);
|
|
962 if (wsp__PolicyReference_)
|
|
963 wsp__PolicyReference_->traverse(definitions);
|
|
964 return SOAP_OK;
|
|
965 }
|
|
966
|
|
967 void wsdl__ioput::messagePtr(wsdl__message *message)
|
|
968 { messageRef = message;
|
|
969 }
|
|
970
|
|
971 wsdl__message *wsdl__ioput::messagePtr() const
|
|
972 { return messageRef;
|
|
973 }
|
|
974
|
|
975 void wsdl__ioput::elementPtr(xs__element *element)
|
|
976 { elementRef = element;
|
|
977 }
|
|
978
|
|
979 xs__element *wsdl__ioput::elementPtr() const
|
|
980 { return elementRef;
|
|
981 }
|
|
982
|
|
983 wsdl__fault::wsdl__fault()
|
|
984 { messageRef = NULL;
|
|
985 elementRef = NULL;
|
|
986 }
|
|
987
|
|
988 int wsdl__fault::traverse(wsdl__definitions& definitions)
|
|
989 { if (vflag)
|
|
990 cerr << " Analyzing portType/interface operation faults in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
991 messageRef = NULL;
|
|
992 elementRef = NULL;
|
|
993 // WSDL 2.0
|
|
994 if (ref)
|
|
995 { const char *token = qname_token(ref, definitions.targetNamespace);
|
|
996 if (token)
|
|
997 { for (vector<wsdl__portType>::iterator i = definitions.interface_.begin(); i != definitions.interface_.end(); ++i)
|
|
998 { for (vector<wsdl__fault>::iterator fault = (*i).fault.begin(); fault != (*i).fault.end(); ++fault)
|
|
999 { if ((*fault).name && !strcmp((*fault).name, token))
|
|
1000 { elementRef = (*fault).elementPtr();
|
|
1001 if (vflag)
|
|
1002 cerr << " Found fault '" << (ref?ref:"") << "' element '" << (token?token:"") << "'" << endl;
|
|
1003 break;
|
|
1004 }
|
|
1005 }
|
|
1006 }
|
|
1007 }
|
|
1008 if (!elementRef)
|
|
1009 { for (vector<wsdl__import>::iterator import = definitions.import.begin(); import != definitions.import.end(); ++import)
|
|
1010 { wsdl__definitions *importdefinitions = (*import).definitionsPtr();
|
|
1011 if (importdefinitions)
|
|
1012 { token = qname_token(message, importdefinitions->targetNamespace);
|
|
1013 if (token)
|
|
1014 { for (vector<wsdl__portType>::iterator i = importdefinitions->interface_.begin(); i != importdefinitions->interface_.end(); ++i)
|
|
1015 { for (vector<wsdl__fault>::iterator fault = (*i).fault.begin(); fault != (*i).fault.end(); ++fault)
|
|
1016 { if ((*fault).name && !strcmp((*fault).name, token))
|
|
1017 { elementRef = (*fault).elementPtr();
|
|
1018 if (vflag)
|
|
1019 cerr << " Found fault '" << (ref?ref:"") << "' element '" << (token?token:"") << "'" << endl;
|
|
1020 break;
|
|
1021 }
|
|
1022 }
|
|
1023 }
|
|
1024 }
|
|
1025 }
|
|
1026 }
|
|
1027 }
|
|
1028 if (!elementRef)
|
|
1029 { if (is_builtin_qname(element))
|
|
1030 definitions.builtinElement(element);
|
|
1031 else
|
|
1032 if (!Wflag)
|
|
1033 cerr << "Warning: no fault '" << (messageLabel?messageLabel:"") << "' ref '" << ref << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
1034 }
|
|
1035 }
|
|
1036 else if (element)
|
|
1037 { if (definitions.types)
|
|
1038 { for (vector<xs__schema*>::iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)
|
|
1039 { const char *token = qname_token(element, (*schema)->targetNamespace);
|
|
1040 if (token)
|
|
1041 { for (vector<xs__element>::iterator element = (*schema)->element.begin(); element != (*schema)->element.end(); ++element)
|
|
1042 { if ((*element).name && !strcmp((*element).name, token))
|
|
1043 { elementRef = &(*element);
|
|
1044 if (vflag)
|
|
1045 cerr << " Found fault '" << (messageLabel?messageLabel:"") << "' element '" << (token?token:"") << "'" << endl;
|
|
1046 break;
|
|
1047 }
|
|
1048 }
|
|
1049 }
|
|
1050 }
|
|
1051 }
|
|
1052 if (!elementRef)
|
|
1053 { if (is_builtin_qname(element))
|
|
1054 definitions.builtinElement(element);
|
|
1055 else
|
|
1056 if (!Wflag)
|
|
1057 cerr << "Warning: no fault '" << (messageLabel?messageLabel:"") << "' element '" << element << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
1058 }
|
|
1059 }
|
|
1060 else
|
|
1061 { const char *token = qname_token(message, definitions.targetNamespace);
|
|
1062 if (token)
|
|
1063 { for (vector<wsdl__message>::iterator message = definitions.message.begin(); message != definitions.message.end(); ++message)
|
|
1064 { if ((*message).name && !strcmp((*message).name, token))
|
|
1065 { messageRef = &(*message);
|
|
1066 if (vflag)
|
|
1067 cerr << " Found operation fault '" << (name?name:"") << "' message '" << (token?token:"") << "'" << endl;
|
|
1068 break;
|
|
1069 }
|
|
1070 }
|
|
1071 }
|
|
1072 if (!messageRef)
|
|
1073 { for (vector<wsdl__import>::iterator import = definitions.import.begin(); import != definitions.import.end(); ++import)
|
|
1074 { wsdl__definitions *importdefinitions = (*import).definitionsPtr();
|
|
1075 if (importdefinitions)
|
|
1076 { token = qname_token(message, importdefinitions->targetNamespace);
|
|
1077 if (token)
|
|
1078 { for (vector<wsdl__message>::iterator message = importdefinitions->message.begin(); message != importdefinitions->message.end(); ++message)
|
|
1079 { if ((*message).name && !strcmp((*message).name, token))
|
|
1080 { messageRef = &(*message);
|
|
1081 if (vflag)
|
|
1082 cerr << " Found operation fault '" << (name?name:"") << "' message '" << (token?token:"") << "'" << endl;
|
|
1083 break;
|
|
1084 }
|
|
1085 }
|
|
1086 }
|
|
1087 }
|
|
1088 }
|
|
1089 }
|
|
1090 if (!messageRef)
|
|
1091 if (!Wflag)
|
|
1092 cerr << "Warning: no operation fault '" << (name?name:"") << "' message '" << (message?message:"") << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
1093 }
|
|
1094 if (wsp__Policy_)
|
|
1095 wsp__Policy_->traverse(definitions);
|
|
1096 if (wsp__PolicyReference_)
|
|
1097 wsp__PolicyReference_->traverse(definitions);
|
|
1098 return SOAP_OK;
|
|
1099 }
|
|
1100
|
|
1101 void wsdl__fault::messagePtr(wsdl__message *message)
|
|
1102 { messageRef = message;
|
|
1103 }
|
|
1104
|
|
1105 wsdl__message *wsdl__fault::messagePtr() const
|
|
1106 { return messageRef;
|
|
1107 }
|
|
1108
|
|
1109 void wsdl__fault::elementPtr(xs__element *element)
|
|
1110 { elementRef = element;
|
|
1111 }
|
|
1112
|
|
1113 xs__element *wsdl__fault::elementPtr() const
|
|
1114 { return elementRef;
|
|
1115 }
|
|
1116
|
|
1117 int wsdl__message::traverse(wsdl__definitions& definitions)
|
|
1118 { if (vflag)
|
|
1119 cerr << " Analyzing message '" << (name?name:"") << "' in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
1120 for (vector<wsdl__part>::iterator i = part.begin(); i != part.end(); ++i)
|
|
1121 (*i).traverse(definitions);
|
|
1122 for (vector<wsp__Policy>::iterator p = wsp__Policy_.begin(); p != wsp__Policy_.end(); ++p)
|
|
1123 (*p).traverse(definitions);
|
|
1124 for (vector<wsp__PolicyReference>::iterator r = wsp__PolicyReference_.begin(); r != wsp__PolicyReference_.end(); ++r)
|
|
1125 (*r).traverse(definitions);
|
|
1126 return SOAP_OK;
|
|
1127 }
|
|
1128
|
|
1129 wsdl__part::wsdl__part()
|
|
1130 { elementRef = NULL;
|
|
1131 simpleTypeRef = NULL;
|
|
1132 complexTypeRef = NULL;
|
|
1133 }
|
|
1134
|
|
1135 int wsdl__part::traverse(wsdl__definitions& definitions)
|
|
1136 { if (vflag)
|
|
1137 cerr << " Analyzing message parts in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
1138 elementRef = NULL;
|
|
1139 simpleTypeRef = NULL;
|
|
1140 complexTypeRef = NULL;
|
|
1141 if (definitions.types)
|
|
1142 { for (vector<xs__schema*>::iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)
|
|
1143 { const char *token = qname_token(element, (*schema)->targetNamespace);
|
|
1144 if (token)
|
|
1145 { for (vector<xs__element>::iterator element = (*schema)->element.begin(); element != (*schema)->element.end(); ++element)
|
|
1146 { if ((*element).name && !strcmp((*element).name, token))
|
|
1147 { elementRef = &(*element);
|
|
1148 if (vflag)
|
|
1149 cerr << " Found message part '" << (name?name:"") << "' element '" << (token?token:"") << "'" << endl;
|
|
1150 break;
|
|
1151 }
|
|
1152 }
|
|
1153 }
|
|
1154 token = qname_token(type, (*schema)->targetNamespace);
|
|
1155 if (token)
|
|
1156 { for (vector<xs__simpleType>::iterator simpleType = (*schema)->simpleType.begin(); simpleType != (*schema)->simpleType.end(); ++simpleType)
|
|
1157 { if ((*simpleType).name && !strcmp((*simpleType).name, token))
|
|
1158 { simpleTypeRef = &(*simpleType);
|
|
1159 if (vflag)
|
|
1160 cerr << " Found message part '" << (name?name:"") << "' simpleType '" << (token?token:"") << "'" << endl;
|
|
1161 break;
|
|
1162 }
|
|
1163 }
|
|
1164 }
|
|
1165 token = qname_token(type, (*schema)->targetNamespace);
|
|
1166 if (token)
|
|
1167 { for (vector<xs__complexType>::iterator complexType = (*schema)->complexType.begin(); complexType != (*schema)->complexType.end(); ++complexType)
|
|
1168 { if ((*complexType).name && !strcmp((*complexType).name, token))
|
|
1169 { complexTypeRef = &(*complexType);
|
|
1170 if (vflag)
|
|
1171 cerr << " Found message part '" << (name?name:"") << "' complexType '" << (token?token:"") << "'" << endl;
|
|
1172 break;
|
|
1173 }
|
|
1174 }
|
|
1175 }
|
|
1176 }
|
|
1177 }
|
|
1178 if (!elementRef && !simpleTypeRef && !complexTypeRef)
|
|
1179 { if (element)
|
|
1180 { if (is_builtin_qname(element))
|
|
1181 definitions.builtinElement(element);
|
|
1182 else
|
|
1183 if (!Wflag)
|
|
1184 cerr << "Warning: no message part '" << (name?name:"") << "' element '" << element << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
1185 }
|
|
1186 else if (type)
|
|
1187 { if (is_builtin_qname(type))
|
|
1188 definitions.builtinType(type);
|
|
1189 else
|
|
1190 if (!Wflag)
|
|
1191 cerr << "Warning: no message part '" << (name?name:"") << "' type '" << type << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
1192 }
|
|
1193 else
|
|
1194 if (!Wflag)
|
|
1195 cerr << "Warning: no message part '" << (name?name:"") << "' element or type in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
1196 }
|
|
1197 return SOAP_OK;
|
|
1198 }
|
|
1199
|
|
1200 void wsdl__part::elementPtr(xs__element *element)
|
|
1201 { elementRef = element;
|
|
1202 if (!elementRef && vflag)
|
|
1203 cerr << "Warning: wsdl__part element set to NULL" << endl;
|
|
1204 }
|
|
1205
|
|
1206 void wsdl__part::simpleTypePtr(xs__simpleType *simpleType)
|
|
1207 { simpleTypeRef = simpleType;
|
|
1208 if (!simpleTypeRef && vflag)
|
|
1209 cerr << "Warning: wsdl__part simpleType set to NULL" << endl;
|
|
1210 }
|
|
1211
|
|
1212 void wsdl__part::complexTypePtr(xs__complexType *complexType)
|
|
1213 { complexTypeRef = complexType;
|
|
1214 if (!complexTypeRef && vflag)
|
|
1215 cerr << "Warning: wsdl__part complexType set to NULL" << endl;
|
|
1216 }
|
|
1217
|
|
1218 xs__element *wsdl__part::elementPtr() const
|
|
1219 { return elementRef;
|
|
1220 }
|
|
1221
|
|
1222 xs__simpleType *wsdl__part::simpleTypePtr() const
|
|
1223 { return simpleTypeRef;
|
|
1224 }
|
|
1225
|
|
1226 xs__complexType *wsdl__part::complexTypePtr() const
|
|
1227 { return complexTypeRef;
|
|
1228 }
|
|
1229
|
|
1230 int wsdl__types::preprocess(wsdl__definitions& definitions)
|
|
1231 { if (vflag)
|
|
1232 cerr << "Preprocessing wsdl types" << endl;
|
|
1233 if (!empty()) // WSDL 2.0 <types>
|
|
1234 { targetNamespace = definitions.targetNamespace;
|
|
1235 xs__schema_.push_back(this);
|
|
1236 }
|
|
1237 // set the location of each schema in <types> to the WSDL's location
|
|
1238 for (vector<xs__schema*>::iterator schema0 = xs__schema_.begin(); schema0 != xs__schema_.end(); ++schema0)
|
|
1239 { if (!(*schema0)->sourceLocation())
|
|
1240 (*schema0)->sourceLocation(definitions.sourceLocation());
|
|
1241 }
|
|
1242 again:
|
|
1243 // link imported schemas, need to repeat when <types> is extended with new imported schema (from inside another schema, etc.)
|
|
1244 for (vector<xs__schema*>::iterator schema1 = xs__schema_.begin(); schema1 != xs__schema_.end(); ++schema1)
|
|
1245 { for (vector<xs__import>::iterator import = (*schema1)->import.begin(); import != (*schema1)->import.end(); ++import)
|
|
1246 { if ((*import).namespace_ && !(*import).schemaPtr() && strcmp((*import).namespace_, targetNamespace))
|
|
1247 { for (vector<xs__schema*>::const_iterator schema2 = xs__schema_.begin(); schema2 != xs__schema_.end(); ++schema2)
|
|
1248 { if (schema2 != schema1 && (*schema2)->targetNamespace && !strcmp((*import).namespace_, (*schema2)->targetNamespace))
|
|
1249 { (*import).schemaPtr(*schema2);
|
|
1250 break;
|
|
1251 }
|
|
1252 }
|
|
1253 }
|
|
1254 }
|
|
1255 }
|
|
1256 // if a schema is imported but not in <types> then get it
|
|
1257 for (vector<xs__schema*>::iterator schema2 = xs__schema_.begin(); schema2 != xs__schema_.end(); ++schema2)
|
|
1258 { for (vector<xs__import>::iterator import = (*schema2)->import.begin(); import != (*schema2)->import.end(); ++import)
|
|
1259 { bool found = false;
|
|
1260 if ((*import).schemaPtr())
|
|
1261 found = true;
|
|
1262 if (vflag)
|
|
1263 cerr << "Preprocessing schema '" << (*schema2)->targetNamespace << "' import '" << ((*import).namespace_?(*import).namespace_:"") << "'" << endl;
|
|
1264 if (!found && (*import).namespace_)
|
|
1265 { if ((*import).schemaPtr())
|
|
1266 found = true;
|
|
1267 else if (strcmp((*import).namespace_, targetNamespace))
|
|
1268 { for (vector<xs__schema*>::const_iterator schema3 = xs__schema_.begin(); schema3 != xs__schema_.end(); ++schema3)
|
|
1269 { if (schema3 != schema2 && (*schema3)->targetNamespace && !strcmp((*import).namespace_, (*schema3)->targetNamespace))
|
|
1270 { found = true;
|
|
1271 if (vflag)
|
|
1272 cerr << "Schema '" << (*schema2)->targetNamespace << "' already found and present" << endl;
|
|
1273 break;
|
|
1274 }
|
|
1275 }
|
|
1276 }
|
|
1277 if (!found)
|
|
1278 { for (SetOfString::const_iterator i = exturis.begin(); i != exturis.end(); ++i)
|
|
1279 { if (!soap_tag_cmp((*import).namespace_, *i))
|
|
1280 { found = true;
|
|
1281 break;
|
|
1282 }
|
|
1283 }
|
|
1284 }
|
|
1285 }
|
|
1286 if (!found && !iflag) // don't import any of the schemas in the .nsmap table (or when -i option is used)
|
|
1287 { xs__schema *importschema;
|
|
1288 importschema = (*import).schemaPtr();
|
|
1289 if (!importschema)
|
|
1290 { const char *s = (*import).schemaLocation;
|
|
1291 if (!s)
|
|
1292 s = (*import).namespace_;
|
|
1293 if (!s)
|
|
1294 continue;
|
|
1295 importschema = new xs__schema(definitions.soap, (*schema2)->sourceLocation(), s);
|
|
1296 if (!(*import).namespace_)
|
|
1297 { if ((*schema2)->targetNamespace)
|
|
1298 (*import).namespace_ = (*schema2)->targetNamespace;
|
|
1299 else if (importschema->targetNamespace)
|
|
1300 (*import).namespace_ = importschema->targetNamespace;
|
|
1301 else
|
|
1302 (*import).namespace_ = soap_strdup(definitions.soap, "");
|
|
1303 }
|
|
1304 if (!importschema->targetNamespace || !*importschema->targetNamespace)
|
|
1305 importschema->targetNamespace = (*import).namespace_;
|
|
1306 else if ((*import).namespace_ && strcmp(importschema->targetNamespace, (*import).namespace_))
|
|
1307 cerr << "Schema import namespace '" << ((*import).namespace_?(*import).namespace_:"") << "' does not correspond to imported namespace '" << importschema->targetNamespace << "'" << endl;
|
|
1308 }
|
|
1309 if (strcmp((*import).namespace_, targetNamespace))
|
|
1310 { for (vector<xs__schema*>::const_iterator schema3 = xs__schema_.begin(); schema3 != xs__schema_.end(); ++schema3)
|
|
1311 { if (schema3 != schema2 && (*schema3)->targetNamespace && !strcmp((*import).namespace_, (*schema3)->targetNamespace))
|
|
1312 { found = true;
|
|
1313 (*import).schemaPtr(*schema3);
|
|
1314 break;
|
|
1315 }
|
|
1316 }
|
|
1317 }
|
|
1318 if (!found)
|
|
1319 { (*import).schemaPtr(importschema);
|
|
1320 xs__schema_.push_back(importschema);
|
|
1321 if (vflag)
|
|
1322 cerr << "Adding schema '" << importschema->targetNamespace << "'" << endl;
|
|
1323 goto again;
|
|
1324 }
|
|
1325 }
|
|
1326 }
|
|
1327 }
|
|
1328 return SOAP_OK;
|
|
1329 }
|
|
1330
|
|
1331 int wsdl__types::traverse(wsdl__definitions& definitions)
|
|
1332 { if (vflag)
|
|
1333 cerr << " Analyzing types in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
1334 for (vector<xs__schema*>::iterator schema3 = xs__schema_.begin(); schema3 != xs__schema_.end(); ++schema3)
|
|
1335 { // artificially extend the <import> of each schema to include others so when we traverse schemas we can resolve references
|
|
1336 for (vector<xs__schema*>::iterator importschema = xs__schema_.begin(); importschema != xs__schema_.end(); ++importschema)
|
|
1337 { if (schema3 != importschema && (*importschema)->targetNamespace)
|
|
1338 { xs__import *import = soap_new_xs__import(definitions.soap, -1);
|
|
1339 import->namespace_ = (*importschema)->targetNamespace;
|
|
1340 import->schemaPtr(*importschema);
|
|
1341 (*schema3)->import.push_back(*import);
|
|
1342 }
|
|
1343 }
|
|
1344 // check and report
|
|
1345 for (vector<xs__import>::iterator import = (*schema3)->import.begin(); import != (*schema3)->import.end(); ++import)
|
|
1346 { if ((*import).namespace_)
|
|
1347 { bool found = false;
|
|
1348 for (vector<xs__schema*>::const_iterator importschema = xs__schema_.begin(); importschema != xs__schema_.end(); ++importschema)
|
|
1349 { if ((*importschema)->targetNamespace && !strcmp((*import).namespace_, (*importschema)->targetNamespace))
|
|
1350 { found = true;
|
|
1351 break;
|
|
1352 }
|
|
1353 }
|
|
1354 if (!found && vflag)
|
|
1355 cerr << "Schema import namespace '" << (*import).namespace_ << "' refers to an unknown Schema" << endl;
|
|
1356 }
|
|
1357 else if (!Wflag)
|
|
1358 cerr << "Warning: schema import '" << ((*import).schemaLocation ? (*import).schemaLocation : "") << "' has no namespace" << endl;
|
|
1359 }
|
|
1360 }
|
|
1361 // traverse the schemas
|
|
1362 for (vector<xs__schema*>::iterator schema4 = xs__schema_.begin(); schema4 != xs__schema_.end(); ++schema4)
|
|
1363 (*schema4)->traverse();
|
|
1364 // find all built-in types, elements, and attributes
|
|
1365 for (vector<xs__schema*>::iterator schema5 = xs__schema_.begin(); schema5 != xs__schema_.end(); ++schema5)
|
|
1366 { if (vflag)
|
|
1367 for (SetOfString::const_iterator i = (*schema5)->builtinTypes().begin(); i != (*schema5)->builtinTypes().end(); ++i)
|
|
1368 cerr << " Built-in schema type '" << (*i) << "'" << endl;
|
|
1369 definitions.builtinTypes((*schema5)->builtinTypes());
|
|
1370 definitions.builtinElements((*schema5)->builtinElements());
|
|
1371 definitions.builtinAttributes((*schema5)->builtinAttributes());
|
|
1372 }
|
|
1373 return SOAP_OK;
|
|
1374 }
|
|
1375
|
|
1376 int wsdl__import::preprocess(wsdl__definitions& definitions)
|
|
1377 { static map<const char*, wsdl__definitions*, ltstr> included;
|
|
1378 bool found = false;
|
|
1379 if (vflag)
|
|
1380 cerr << "Preprocess wsdl import '" << (location?location:"") << "'" << endl;
|
|
1381 definitionsRef = NULL;
|
|
1382 if (namespace_)
|
|
1383 { for (SetOfString::const_iterator i = exturis.begin(); i != exturis.end(); ++i)
|
|
1384 { if (!soap_tag_cmp(namespace_, *i))
|
|
1385 { found = true;
|
|
1386 break;
|
|
1387 }
|
|
1388 }
|
|
1389 }
|
|
1390 if (!found && location)
|
|
1391 { map<const char*, wsdl__definitions*, ltstr>::iterator i = included.find(location);
|
|
1392 if (i != included.end())
|
|
1393 { if (vflag)
|
|
1394 fprintf(stderr, "\nWSDL/XSD '%s' already imported\n", location);
|
|
1395 found = true;
|
|
1396 definitionsRef = (*i).second;
|
|
1397 }
|
|
1398 }
|
|
1399 if (!found && location)
|
|
1400 { // parse imported definitions
|
|
1401 const char *source = definitions.sourceLocation();
|
|
1402 if (vflag)
|
|
1403 cerr << "Importing '" << location << "' into '" << (source?source:"(source location not set)") << "'" << endl;
|
|
1404 included[location] = definitionsRef = new wsdl__definitions(definitions.soap, source, location);
|
|
1405 if (!definitionsRef)
|
|
1406 return SOAP_EOF;
|
|
1407 if (!namespace_)
|
|
1408 namespace_ = definitionsRef->targetNamespace;
|
|
1409 else if (!definitionsRef->targetNamespace || !*definitionsRef->targetNamespace)
|
|
1410 definitionsRef->targetNamespace = namespace_;
|
|
1411 else if (strcmp(namespace_, definitionsRef->targetNamespace))
|
|
1412 cerr << "Error: wsdl definitions/import '" << location << "' namespace '" << namespace_ << "' does not match imported targetNamespace '" << definitionsRef->targetNamespace << "'" << endl;
|
|
1413 }
|
|
1414 else if (!location)
|
|
1415 cerr << "Warning: wsdl definitions/import has no location attribute" << endl;
|
|
1416 return SOAP_OK;
|
|
1417 }
|
|
1418
|
|
1419 int wsdl__import::traverse(wsdl__definitions& definitions)
|
|
1420 { if (definitionsRef)
|
|
1421 { if (vflag)
|
|
1422 cerr << " Analyzing imported wsdl namespace '" << (namespace_?namespace_:"") << "' in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
|
|
1423 // process import first
|
|
1424 for (vector<wsdl__import>::iterator im = definitionsRef->import.begin(); im != definitionsRef->import.end(); ++im)
|
|
1425 (*im).traverse(definitions);
|
|
1426 // then process the types
|
|
1427 if (definitionsRef->types)
|
|
1428 definitionsRef->types->traverse(definitions);
|
|
1429 // process messages before portTypes
|
|
1430 for (vector<wsdl__message>::iterator mg = definitionsRef->message.begin(); mg != definitionsRef->message.end(); ++mg)
|
|
1431 (*mg).traverse(definitions);
|
|
1432 // process portTypes before bindings
|
|
1433 for (vector<wsdl__portType>::iterator pt = definitionsRef->portType.begin(); pt != definitionsRef->portType.end(); ++pt)
|
|
1434 (*pt).traverse(definitions);
|
|
1435 // process bindings
|
|
1436 for (vector<wsdl__binding>::iterator bg = definitionsRef->binding.begin(); bg != definitionsRef->binding.end(); ++bg)
|
|
1437 (*bg).traverse(definitions);
|
|
1438 // process services
|
|
1439 for (vector<wsdl__service>::iterator sv = definitionsRef->service.begin(); sv != definitionsRef->service.end(); ++sv)
|
|
1440 (*sv).traverse(definitions);
|
|
1441 if (vflag)
|
|
1442 cerr << " End of imported wsdl namespace '" << (namespace_?namespace_:"") << "'" << endl;
|
|
1443 }
|
|
1444 return SOAP_OK;
|
|
1445 }
|
|
1446
|
|
1447 void wsdl__import::definitionsPtr(wsdl__definitions *definitions)
|
|
1448 { definitionsRef = definitions;
|
|
1449 if (!definitionsRef && vflag)
|
|
1450 cerr << "Warning: wsdl__import definitions set to NULL" << endl;
|
|
1451 }
|
|
1452
|
|
1453 wsdl__definitions *wsdl__import::definitionsPtr() const
|
|
1454 { return definitionsRef;
|
|
1455 }
|
|
1456
|
|
1457 wsdl__import::wsdl__import()
|
|
1458 { definitionsRef = NULL;
|
|
1459 }
|
|
1460
|
|
1461 ////////////////////////////////////////////////////////////////////////////////
|
|
1462 //
|
|
1463 // streams
|
|
1464 //
|
|
1465 ////////////////////////////////////////////////////////////////////////////////
|
|
1466
|
|
1467 ostream &operator<<(ostream &o, const wsdl__definitions &e)
|
|
1468 { if (!e.soap)
|
|
1469 { struct soap soap;
|
|
1470 soap_init2(&soap, SOAP_IO_DEFAULT, SOAP_XML_TREE | SOAP_C_UTFSTRING);
|
|
1471 soap_set_namespaces(&soap, namespaces);
|
|
1472 e.soap_serialize(&soap);
|
|
1473 soap_begin_send(&soap);
|
|
1474 e.soap_out(&soap, "wsdl:definitions", 0, NULL);
|
|
1475 soap_end_send(&soap);
|
|
1476 soap_destroy(&soap);
|
|
1477 soap_end(&soap);
|
|
1478 soap_done(&soap);
|
|
1479 }
|
|
1480 else
|
|
1481 { ostream *os = e.soap->os;
|
|
1482 e.soap->os = &o;
|
|
1483 e.soap_serialize(e.soap);
|
|
1484 soap_begin_send(e.soap);
|
|
1485 e.soap_out(e.soap, "wsdl:definitions", 0, NULL);
|
|
1486 soap_end_send(e.soap);
|
|
1487 e.soap->os = os;
|
|
1488 }
|
|
1489 return o;
|
|
1490 }
|
|
1491
|
|
1492 istream &operator>>(istream &i, wsdl__definitions &e)
|
|
1493 { if (!e.soap)
|
|
1494 { e.soap = soap_new1(SOAP_XML_TREE | SOAP_C_UTFSTRING);
|
|
1495 soap_set_namespaces(e.soap, namespaces);
|
|
1496 }
|
|
1497 istream *is = e.soap->is;
|
|
1498 e.soap->is = &i;
|
|
1499 if (soap_begin_recv(e.soap)
|
|
1500 || !e.soap_in(e.soap, "wsdl:", NULL)
|
|
1501 || soap_end_recv(e.soap))
|
|
1502 { // handle error? Note: e.soap->error is set and app should check
|
|
1503 }
|
|
1504 e.soap->is = is;
|
|
1505 return i;
|
|
1506 }
|
|
1507
|
|
1508 ////////////////////////////////////////////////////////////////////////////////
|
|
1509 //
|
|
1510 // Miscellaneous
|
|
1511 //
|
|
1512 ////////////////////////////////////////////////////////////////////////////////
|
|
1513
|
|
1514 extern "C" {
|
|
1515
|
|
1516 int warn_ignore(struct soap *soap, const char *tag)
|
|
1517 { // We don't warn if the omitted element was an annotation or a documentation in an unexpected place
|
|
1518 if (soap->mustUnderstand)
|
|
1519 fprintf(stderr, "Error: element '%s' at level %d must be understood\n", tag, soap->level);
|
|
1520 if (!Wflag
|
|
1521 && soap_match_tag(soap, tag, "xs:annotation")
|
|
1522 && soap_match_tag(soap, tag, "xs:documentation")
|
|
1523 && soap_match_tag(soap, tag, "xs:appinfo"))
|
|
1524 fprintf(stderr, "Warning: unexpected element '%s' at level %d is skipped (safe to ignore)\n", tag, soap->level);
|
|
1525 if (soap->body && !soap_string_in(soap, 0, -1, -1))
|
|
1526 return soap->error;
|
|
1527 return SOAP_OK;
|
|
1528 }
|
|
1529
|
|
1530 int show_ignore(struct soap *soap, const char *tag)
|
|
1531 { warn_ignore(soap, tag);
|
|
1532 soap_print_fault_location(soap, stderr);
|
|
1533 return SOAP_OK;
|
|
1534 }
|
|
1535
|
|
1536 } // end extern "C"
|