5
WSDL parser and converter to gSOAP header file format
7
--------------------------------------------------------------------------------
8
gSOAP XML Web services tools
9
Copyright (C) 2000-2007, Robert van Engelen, Genivia Inc. All Rights Reserved.
10
This software is released under one of the following two licenses:
11
GPL or Genivia's license for commercial use.
12
--------------------------------------------------------------------------------
15
This program is free software; you can redistribute it and/or modify it under
16
the terms of the GNU General Public License as published by the Free Software
17
Foundation; either version 2 of the License, or (at your option) any later
20
This program is distributed in the hope that it will be useful, but WITHOUT ANY
21
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
22
PARTICULAR PURPOSE. See the GNU General Public License for more details.
24
You should have received a copy of the GNU General Public License along with
25
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
26
Place, Suite 330, Boston, MA 02111-1307 USA
28
Author contact information:
29
engelen@genivia.com / engelen@acm.org
30
--------------------------------------------------------------------------------
31
A commercial use license is available from Genivia, Inc., contact@genivia.com
32
--------------------------------------------------------------------------------
35
soapcpp2 -ipwsdl wsdl.h
36
g++ -o wsdl2h wsdl2h.cpp types.cpp service.cpp wsdl.cpp schema.cpp wsdlC.cpp stdsoap2.cpp
39
Resolve relative versus absolute import paths for reading imported WSDL/schema (use URL local addresses)
40
Do not generate abstract complexTypes, but include defs in derived types
41
Handle simpleType derivation from base64
50
static void options(int argc, char **argv);
73
char *infile[MAXINFILES],
77
*mapfile = "typemap.dat",
82
int proxy_port = 8080;
84
FILE *stream = stdout;
88
extern struct Namespace namespaces[];
90
const char *service_prefix = NULL;
91
const char *schema_prefix = "ns";
93
char elementformat[] = " %-35s %-30s";
94
char pointerformat[] = " %-35s *%-30s";
95
char attributeformat[] = " @%-35s %-30s";
96
char vectorformat[] = " std::vector<%-23s> %-30s";
97
char pointervectorformat[] = " std::vector<%-22s> *%-30s";
98
char arrayformat[] = " %-35s *__ptr%-25s";
99
char sizeformat[] = " %-35s __size%-24s";
100
char offsetformat[] = "// %-35s __offset%-22s";
101
char choiceformat[] = " %-35s __union%-23s";
102
char schemaformat[] = "//gsoap %-5s schema %s:\t%s\n";
103
char serviceformat[] = "//gsoap %-4s service %s:\t%s %s\n";
104
char paraformat[] = " %-35s%s%s%s";
105
char anonformat[] = " %-35s%s_%s%s";
107
char copyrightnotice[] = "\n** The gSOAP WSDL parser for C and C++ "VERSION"\n** Copyright (C) 2000-2007 Robert van Engelen, Genivia Inc.\n** All Rights Reserved. This product is provided \"as is\", without any warranty.\n** The gSOAP WSDL parser is released under one of the following two licenses:\n** GPL or the commercial license by Genivia Inc. Use option -l for more info.\n\n";
109
char licensenotice[] = "\
110
--------------------------------------------------------------------------------\n\
111
gSOAP XML Web services tools\n\
112
Copyright (C) 2000-2007, Robert van Engelen, Genivia Inc. All Rights Reserved.\n\
114
This software is released under one of the following two licenses:\n\
115
GPL or Genivia's license for commercial use.\n\
119
This program is free software; you can redistribute it and/or modify it under\n\
120
the terms of the GNU General Public License as published by the Free Software\n\
121
Foundation; either version 2 of the License, or (at your option) any later\n\
124
This program is distributed in the hope that it will be useful, but WITHOUT ANY\n\
125
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\n\
126
PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\
128
You should have received a copy of the GNU General Public License along with\n\
129
this program; if not, write to the Free Software Foundation, Inc., 59 Temple\n\
130
Place, Suite 330, Boston, MA 02111-1307 USA\n\
132
Author contact information:\n\
133
engelen@genivia.com / engelen@acm.org\n\
134
--------------------------------------------------------------------------------\n\
135
A commercial use license is available from Genivia, Inc., contact@genivia.com\n\
136
--------------------------------------------------------------------------------\n";
138
int main(int argc, char **argv)
140
fprintf(stderr, copyrightnotice);
143
{ fprintf(stderr, licensenotice);
148
wsdl__definitions definitions;
149
definitions.read(infiles, infile);
150
if (definitions.error())
151
{ definitions.print_fault();
154
definitions.traverse();
155
def.compile(definitions);
158
fprintf(stderr, "\nTo complete the process, compile with:\nsoapcpp2 %s\n\n", outfile);
163
////////////////////////////////////////////////////////////////////////////////
167
////////////////////////////////////////////////////////////////////////////////
170
{ struct Namespace *p = namespaces;
173
{ if (p->in && *p->in)
174
exturis.insert(p->in);
176
exturis.insert(p->ns);
181
////////////////////////////////////////////////////////////////////////////////
183
// Parse command line options
185
////////////////////////////////////////////////////////////////////////////////
187
static void options(int argc, char **argv)
190
for (i = 1; i < argc; i++)
209
fprintf(stderr, "wsdl2h: Options -c and -q clash\n");
234
else if (i < argc && argv[++i])
235
import_path = argv[i];
237
fprintf(stderr, "wsdl2h: Option -I requires a path argument\n");
250
else if (i < argc && argv[++i])
251
schema_prefix = argv[i];
253
fprintf(stderr, "wsdl2h: Option -n requires a prefix name argument\n");
260
else if (i < argc && argv[++i])
261
service_prefix = argv[i];
263
fprintf(stderr, "wsdl2h: Option -N requires a prefix name argument\n");
270
else if (i < argc && argv[++i])
273
fprintf(stderr, "wsdl2h: Option -o requires an output file argument\n");
283
else if (i < argc && argv[++i])
284
cppnamespace = argv[i];
286
fprintf(stderr, "wsdl2h: Option -q requires a C++ namespace name argument\n");
288
fprintf(stderr, "wsdl2h: Options -c and -q clash\n");
295
else if (i < argc && argv[++i])
296
proxy_host = argv[i];
298
fprintf(stderr, "wsdl2h: Option -r requires a proxy host:port argument\n");
300
{ char *s = (char*)emalloc(strlen(proxy_host + 1));
301
strcpy(s, proxy_host);
303
s = strchr(proxy_host, ':');
305
{ proxy_port = soap_strtol(s + 1, NULL, 10);
318
else if (i < argc && argv[++i])
321
fprintf(stderr, "wsdl2h: Option -t requires a type map file argument\n");
343
fprintf(stderr, "Usage: wsdl2h [-a] [-c] [-d] [-e] [-f] [-g] [-h] [-I path] [-j] [-l] [-m] [-n name] [-N name] [-p] [-q name] [-r proxyhost:port] [-s] [-t typemapfile.dat] [-u] [-v] [-w] [-x] [-y] [-z] [-_] [-o outfile.h] infile.wsdl infile.xsd http://www... ...\n\n");
345
-a generate indexed struct names for local elements with anonymous types\n\
346
-c generate C source code\n\
347
-d use DOM to populate xs:any and xsd:anyType elements\n\
348
-e don't qualify enum names\n\
349
-f generate flat C++ class hierarchy\n\
350
-g generate global top-level element declarations\n\
351
-h display help info\n\
352
-Ipath use path to find files\n\
353
-j don't generate SOAP_ENV__Header and SOAP_ENV__Detail definitions\n\
354
-l include license information in output\n\
355
-m use xsd.h module to import primitive types\n\
356
-nname use name as the base namespace prefix instead of 'ns'\n\
357
-Nname use name as the base namespace prefix for service namespaces\n\
358
-ofile output to file\n\
359
-p create polymorphic types with C++ inheritance with base xsd__anyType\n\
360
-qname use name for the C++ namespace for all service declarations\n\
362
connect via proxy host and port\n\
363
-s don't generate STL code (no std::string and no std::vector)\n\
364
-tfile use type map file instead of the default file typemap.dat\n\
365
-u don't generate unions\n\
367
-w always wrap response parameters in a response struct (<=1.1.4 behavior)\n\
368
-x don't generate _XML any/anyAttribute extensibility elements\n\
369
-y generate typedef synonyms for structs and enums\n\
370
-z generate pointer-based arrays for backward compatibility < gSOAP 2.7.6e\n\
371
-_ don't generate _USCORE (replace with UNICODE _x005f)\n\
372
infile.wsdl infile.xsd http://www... list of input sources (if none: use stdin)\n\
376
fprintf(stderr, "wsdl2h: Unknown option %s\n", a);
382
{ infile[infiles++] = argv[i];
383
if (infiles >= MAXINFILES)
384
{ fprintf(stderr, "wsdl2h: too many files\n");
391
{ if (strncmp(infile[0], "http://", 7) && strncmp(infile[0], "https://", 8))
392
{ const char *s = strrchr(infile[0], '.');
393
if (s && (!strcmp(s, ".wsdl") || !strcmp(s, ".gwsdl") || !strcmp(s, ".xsd")))
394
{ outfile = estrdup(infile[0]);
395
outfile[s - infile[0] + 1] = 'h';
396
outfile[s - infile[0] + 2] = '\0';
399
{ outfile = (char*)emalloc(strlen(infile[0]) + 3);
400
strcpy(outfile, infile[0]);
401
strcat(outfile, ".h");
406
{ stream = fopen(outfile, "w");
408
{ fprintf(stderr, "Cannot write to %s\n", outfile);
412
fprintf(stream, "namespace %s {\n", cppnamespace);
413
fprintf(stderr, "Saving %s\n\n", outfile);
418
////////////////////////////////////////////////////////////////////////////////
422
////////////////////////////////////////////////////////////////////////////////
424
struct Namespace namespaces[] =
426
{"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/*/soap-envelope"},
427
{"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org/*/soap-encoding"},
428
{"xsi", "http://www.w3.org/2001/XMLSchema-instance"},
429
{"xsd", "-"}, // http://www.w3.org/2001/XMLSchema"}, // don't use this, it might conflict with xs
430
{"xml", "http://www.w3.org/XML/1998/namespace"},
431
{"xs", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema" },
432
{"http", "http://schemas.xmlsoap.org/wsdl/http/"},
433
{"soap", "http://schemas.xmlsoap.org/wsdl/soap/", "http://schemas.xmlsoap.org/wsdl/soap*/"},
434
{"mime", "http://schemas.xmlsoap.org/wsdl/mime/"},
435
{"dime", "http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/", "http://schemas.xmlsoap.org/ws/*/dime/wsdl/"},
436
{"wsdl", "http://schemas.xmlsoap.org/wsdl/"},
437
{"gwsdl", "http://www.gridforum.org/namespaces/2003/03/gridWSDLExtensions"},