wsdlpull
1.23
Toggle main menu visibility
Loading...
Searching...
No Matches
src
wsdlparser
WsdlParser.h
Go to the documentation of this file.
1
/*
2
* Wsdlpull - A C++ parser for WSDL (Web services description language)
3
* Copyright (C) 2005-2007 Vivek Krishna
4
*
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
9
*
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Library General Public License for more details.
14
*
15
* You should have received a copy of the GNU Library General Public
16
* License along with this library; if not, write to the Free
17
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
*
19
*/
20
#ifndef _WSDLPARSERH
21
#define _WSDLPARSERH
22
23
#include "
xmlpull/wsdlpull_export.h
"
24
#include "
xmlpull/XmlPullParser.h
"
25
#include "
xmlpull/XmlPullParserException.h
"
26
#include "
schemaparser/SchemaParser.h
"
27
28
#include "
wsdlparser/PortType.h
"
29
#include "
wsdlparser/Message.h
"
30
#include "
wsdlparser/Operation.h
"
31
#include "
wsdlparser/Binding.h
"
32
#include "
wsdlparser/Service.h
"
33
#include "
wsdlparser/WsdlExtension.h
"
34
35
36
37
namespace
WsdlPull
{
38
39
const
std::string
wsdlUri
=
"http://schemas.xmlsoap.org/wsdl/"
;
40
41
class
Soap
;
42
//Wsdl pull parser
43
class
WSDLPULL_EXPORT
WsdlParser
44
{
45
public
:
48
55
WsdlParser
(std::istream & in = std::cin, std::ostream & out = std::cout,
56
const
std::string & schemaPath =
""
);
57
WsdlParser
(
const
std::string& Uri,std::ostream & out = std::cout,
58
const
std::string & schemaPath =
""
);
59
~WsdlParser
();
61
66
void
setSchemaPath
(
const
std::string & schemaPath);
67
70
76
int
getNextElement
();
77
83
int
getEventType
();
84
86
89
//NOTE:The caller must *NOT* free the pointers returned by the getter apis
90
//This is true for all apis except whenever the api returns a pointer to
91
//a list of elements which is not one of the root wsdl elements ,
92
//such as getOperations(port type) which is the only exception
97
std::string
getNamespace
(
void
);
98
103
std::string
getName
();
104
110
const
std::string*
getDocumentation
();
111
118
const
Binding
*
getBinding
();
119
126
const
Binding
*
getBinding
(
const
Qname
& q);
127
133
bool
getBindings
(
Binding::cBindingIterator
& begin,
134
Binding::cBindingIterator
& end)
const
;
135
142
const
Service
*
getService
();
143
150
typedef
std::list<Service*>::iterator
ServiceIterator
;
151
const
Service
*
getService
(
const
Qname
& q);
152
void
getServices
(
ServiceIterator
&from,
ServiceIterator
&to);
153
160
const
PortType
*
getPortType
();
161
168
const
PortType
*
getPortType
(
const
Qname
& q);
169
175
bool
getPortTypes
(
PortType::cPortTypeIterator
& begin,
176
PortType::cPortTypeIterator
& end)
const
;
177
185
bool
getOperations
(
const
Qname
& portType,
186
Operation::cOpIterator
& begin,
187
Operation::cOpIterator
& end);
188
196
const
Operation
*
getOperation
(
const
Qname
& portType,
197
const
Qname
& q);
198
205
const
Message
*
getMessage
();
206
213
const
Message
*
getMessage
(
const
Qname
& q);
214
220
std::list < const Message *>&
getMessages
();
221
229
230
void
getSchemaParsers
(std::vector<SchemaParser* >::iterator & from,
231
std::vector<SchemaParser* >::iterator & to) ;
232
238
int
getNumSchemas
()
const
;
239
246
const
SchemaParser
*
getSchemaParser
(std::string targetNamespace)
const
;
247
248
252
bool
status
()
const
;
253
std::string
wsdlPath
()
const
;
254
std::ostream &
logger
();
255
std::string &
getWsdlFileName
() {
256
return
wsdlFileName;
257
}
258
259
static
bool
useLocalSchema_
;
//if false fetch the schemas from the web
261
262
265
271
void
addExtensibilityHandler
(
WsdlExtension
* ext);
278
WsdlExtension
*
getExtensibilityHandler
(
const
std::string & ns);
279
//return the extensibility handler for the given id.
280
//WsdlParser only stores ids for the extensibility elements.
281
WsdlExtension
*
getExtensibilityHandler
(
int
extId);
283
284
287
291
bool
setFeature
(
int
feature_id);
293
294
298
enum
299
{
300
NONE
,
301
START
,
302
DEFINITION
,
303
DOCUMENTATION
,
304
ANNOTATION
,
305
IMPORT
,
306
SCHEMA
,
307
TYPES
,
308
MESSAGE
,
309
PART
,
310
PORT_TYPE
,
311
OPERATION
,
312
INPUT
,
313
OUTPUT
,
314
FAULT
,
315
BINDING
,
316
EXTENSIBILITY
,
317
SERVICE
,
318
PORT
,
319
END
320
};
321
322
#ifdef LOGGING
323
//for debugging
324
void
print(std::ostream & out);
325
#endif
326
327
//{@ Deprecated
334
const
SchemaParser
*getSchemaParser(
int
schemaId)
const
;
336
337
338
private
:
339
/*
340
* private methods for parsing
341
*/
342
int
peek(
bool
lookahead =
true
);
343
int
next();
344
void
error(std::string s,
int
level=0);
345
std::string getNamespace(std::string prefix);
346
Element
* getElement(
const
Qname
&);
347
int
getTypeId(
const
Qname
&);
348
int
getSchema(
const
Qname
& name,
bool
type =
true
);
349
std::string* parseDoc();
350
void
parseDefinitions();
351
void
parseMessage();
352
void
parseAnnotation();
353
void
parseImport();
354
PortType
*parsePortType();
355
Operation
*parseOperation(
PortType
* p);
356
void
processMessageExtensibility(
Operation
* op,
357
WsdlPull::MessageType
mtype);
358
void
parseTypes();
359
void
parseBinding();
360
void
parseService();
361
int
handleExtensibilityAttributes(std::string prefix, std::string name);
362
int
handleExtensibilityElement(
int
);
363
void
putMessage(
Message
* m);
364
void
putPortType(
PortType
* pt);
365
void
putBinding(
Binding
* bn);
366
void
initialize(
bool
);
367
bool
errorOccured_;
368
XmlPullParser
* openSchemaFile(
const
std::string& path);
369
const
Message
*pgetMessage(
const
Qname
& q);
370
std::string name_, tnsPrefix_, tnsUri_;
371
std::vector<SchemaParser*> schemaParser_;
372
373
typedef
struct
374
{
375
WsdlExtension
*we;
376
SchemaParser
*spe;
377
} ExtensionInfo;
378
std::list < const Message *> messages_;
379
std::vector<ExtensionInfo> wsdlExtensions_;
380
std::list < PortType *>porttypes_;
381
std::list < Binding *>bindings_;
382
std::list < Service*> services_;
383
384
class
Imports
385
{
386
public
:
387
Imports(std::string,std::string);
388
std::string ns, loc;
389
};
390
std::vector<Imports> imports_;
391
std::list < std::string *> docs_list_;
392
std::ostream & ostr;
393
std::istream & istr;
394
int
state_;
395
int
element_;
//the last Wsdl element parsed
396
std::string* Doc_;
397
XmlPullParser * xParser_;
398
std::ifstream xmlStream;
399
std::string wsdlFileName;
400
Soap * soap_,*soap2_;
401
const
int
MAX_EXT_XML;
402
std::string schemaPath_;
// Path to schemas, used by parser during parsing.
403
std::string uri_;
//The uri to use to resolve imports.1 level up the location of the wsdl file
404
};
405
406
407
inline
408
WsdlParser::Imports::Imports(std::string nameSpace,std::string location)
409
:ns(nameSpace),
410
loc(location)
411
{
412
}
413
414
415
inline
416
std::string
417
WsdlParser::getNamespace
(std::string prefix)
418
{
419
return
xParser_->getNamespace(prefix);
420
}
421
422
423
//public APIs
424
inline
425
int
426
WsdlParser::getNextElement
()
427
{
428
next();
429
return
element_;
430
}
431
432
inline
433
const
std::string*
434
WsdlParser::getDocumentation
()
435
{
436
return
(
const
std::string*) Doc_;
437
}
438
439
inline
440
std::string
441
WsdlParser::getNamespace
(
void
)
442
{
443
return
tnsUri_;
444
}
445
446
inline
447
std::string
448
WsdlParser::getName
()
449
{
450
return
name_;
451
}
452
453
454
455
inline
456
int
457
WsdlParser::getEventType
()
458
{
459
return
element_;
460
}
461
462
463
inline
464
std::list < const Message *>&
465
WsdlParser::getMessages
()
466
{
467
return
messages_;
468
}
469
470
//This is deprecated
471
//the ids 0 and 1 are return the schema parsers used to internally parse the soap schema.
472
//Ideally you should use getSchemaParser(std::string).If you want to iterate over all the schema parsers
473
//use getSchemaParsers
474
inline
475
const
SchemaParser
*
476
WsdlParser::getSchemaParser
(
int
schemaId)
const
477
{
478
return
(
const
SchemaParser
*) schemaParser_[schemaId];
479
}
480
481
inline
482
std::string
483
WsdlParser::wsdlPath
()
const
484
{
485
return
wsdlFileName ;
486
}
487
inline
488
bool
489
WsdlParser::status
()
const
490
{
491
return
!errorOccured_;
492
}
493
494
inline
495
std::ostream&
496
WsdlParser::logger
()
497
{
498
return
ostr;
499
}
500
}
501
/* */
502
#endif
/* */
Binding.h
Message.h
Operation.h
PortType.h
SchemaParser.h
Service.h
WsdlExtension.h
XmlPullParserException.h
XmlPullParser.h
Qname
Definition
Qname.h:31
Schema::Element
Definition
Element.h:31
Schema::SchemaParser
Definition
SchemaParser.h:43
WsdlPull::Binding
Definition
Binding.h:33
WsdlPull::Binding::cBindingIterator
std::list< Binding * >::const_iterator cBindingIterator
Definition
Binding.h:40
WsdlPull::Message
Definition
Message.h:64
WsdlPull::Operation
Definition
Operation.h:54
WsdlPull::Operation::cOpIterator
std::vector< Operation * >::const_iterator cOpIterator
Definition
Operation.h:57
WsdlPull::PortType
Definition
PortType.h:31
WsdlPull::PortType::cPortTypeIterator
std::list< PortType * >::const_iterator cPortTypeIterator
Definition
PortType.h:34
WsdlPull::Service
Definition
Service.h:31
WsdlPull::Soap
Definition
Soap.h:39
WsdlPull::WsdlExtension
Definition
WsdlExtension.h:42
WsdlPull::WsdlParser::getMessages
std::list< const Message * > & getMessages()
Definition
WsdlParser.h:465
WsdlPull::WsdlParser::getPortType
const PortType * getPortType()
Definition
WsdlParser.cpp:269
WsdlPull::WsdlParser::getService
const Service * getService()
Definition
WsdlParser.cpp:225
WsdlPull::WsdlParser::getExtensibilityHandler
WsdlExtension * getExtensibilityHandler(const std::string &ns)
Definition
WsdlParser.cpp:1261
WsdlPull::WsdlParser::getNumSchemas
int getNumSchemas() const
Definition
WsdlParser.cpp:1601
WsdlPull::WsdlParser::wsdlPath
std::string wsdlPath() const
Definition
WsdlParser.h:483
WsdlPull::WsdlParser::getEventType
int getEventType()
Definition
WsdlParser.h:457
WsdlPull::WsdlParser::useLocalSchema_
static bool useLocalSchema_
Definition
WsdlParser.h:259
WsdlPull::WsdlParser::getSchemaParsers
void getSchemaParsers(std::vector< SchemaParser * >::iterator &from, std::vector< SchemaParser * >::iterator &to)
Definition
WsdlParser.cpp:1534
WsdlPull::WsdlParser::setFeature
bool setFeature(int feature_id)
WsdlPull::WsdlParser::getWsdlFileName
std::string & getWsdlFileName()
Definition
WsdlParser.h:255
WsdlPull::WsdlParser::addExtensibilityHandler
void addExtensibilityHandler(WsdlExtension *ext)
Definition
WsdlParser.cpp:196
WsdlPull::WsdlParser::status
bool status() const
Definition
WsdlParser.h:489
WsdlPull::WsdlParser::getName
std::string getName()
Definition
WsdlParser.h:448
WsdlPull::WsdlParser::ServiceIterator
std::list< Service * >::iterator ServiceIterator
Definition
WsdlParser.h:150
WsdlPull::WsdlParser::PORT
@ PORT
Definition
WsdlParser.h:318
WsdlPull::WsdlParser::SCHEMA
@ SCHEMA
Definition
WsdlParser.h:306
WsdlPull::WsdlParser::FAULT
@ FAULT
Definition
WsdlParser.h:314
WsdlPull::WsdlParser::END
@ END
Definition
WsdlParser.h:319
WsdlPull::WsdlParser::DOCUMENTATION
@ DOCUMENTATION
Definition
WsdlParser.h:303
WsdlPull::WsdlParser::MESSAGE
@ MESSAGE
Definition
WsdlParser.h:308
WsdlPull::WsdlParser::BINDING
@ BINDING
Definition
WsdlParser.h:315
WsdlPull::WsdlParser::IMPORT
@ IMPORT
Definition
WsdlParser.h:305
WsdlPull::WsdlParser::SERVICE
@ SERVICE
Definition
WsdlParser.h:317
WsdlPull::WsdlParser::INPUT
@ INPUT
Definition
WsdlParser.h:312
WsdlPull::WsdlParser::PART
@ PART
Definition
WsdlParser.h:309
WsdlPull::WsdlParser::PORT_TYPE
@ PORT_TYPE
Definition
WsdlParser.h:310
WsdlPull::WsdlParser::DEFINITION
@ DEFINITION
Definition
WsdlParser.h:302
WsdlPull::WsdlParser::OPERATION
@ OPERATION
Definition
WsdlParser.h:311
WsdlPull::WsdlParser::TYPES
@ TYPES
Definition
WsdlParser.h:307
WsdlPull::WsdlParser::NONE
@ NONE
Definition
WsdlParser.h:300
WsdlPull::WsdlParser::OUTPUT
@ OUTPUT
Definition
WsdlParser.h:313
WsdlPull::WsdlParser::ANNOTATION
@ ANNOTATION
Definition
WsdlParser.h:304
WsdlPull::WsdlParser::START
@ START
Definition
WsdlParser.h:301
WsdlPull::WsdlParser::EXTENSIBILITY
@ EXTENSIBILITY
Definition
WsdlParser.h:316
WsdlPull::WsdlParser::getNextElement
int getNextElement()
Definition
WsdlParser.h:426
WsdlPull::WsdlParser::getDocumentation
const std::string * getDocumentation()
Definition
WsdlParser.h:434
WsdlPull::WsdlParser::logger
std::ostream & logger()
Definition
WsdlParser.h:496
WsdlPull::WsdlParser::getNamespace
std::string getNamespace(void)
Definition
WsdlParser.h:441
WsdlPull::WsdlParser::getSchemaParser
const SchemaParser * getSchemaParser(std::string targetNamespace) const
Definition
WsdlParser.cpp:385
WsdlPull::WsdlParser::getServices
void getServices(ServiceIterator &from, ServiceIterator &to)
Definition
WsdlParser.cpp:259
WsdlPull::WsdlParser::getBindings
bool getBindings(Binding::cBindingIterator &begin, Binding::cBindingIterator &end) const
Definition
WsdlParser.cpp:1573
WsdlPull::WsdlParser::getBinding
const Binding * getBinding()
Definition
WsdlParser.cpp:182
WsdlPull::WsdlParser::WsdlParser
WsdlParser(std::istream &in=std::cin, std::ostream &out=std::cout, const std::string &schemaPath="")
Definition
WsdlParser.cpp:37
WsdlPull::WsdlParser::getPortTypes
bool getPortTypes(PortType::cPortTypeIterator &begin, PortType::cPortTypeIterator &end) const
Definition
WsdlParser.cpp:1587
WsdlPull::WsdlParser::getMessage
const Message * getMessage()
Definition
WsdlParser.cpp:337
WsdlPull::WsdlParser::getOperations
bool getOperations(const Qname &portType, Operation::cOpIterator &begin, Operation::cOpIterator &end)
Definition
WsdlParser.cpp:303
WsdlPull::WsdlParser::getOperation
const Operation * getOperation(const Qname &portType, const Qname &q)
Definition
WsdlParser.cpp:318
WsdlPull::WsdlParser::setSchemaPath
void setSchemaPath(const std::string &schemaPath)
Definition
WsdlParser.cpp:1608
XmlPullParser
Definition
XmlPullParser.h:47
WsdlPull
Definition
Binding.h:27
WsdlPull::MessageType
MessageType
Definition
Operation.h:42
WsdlPull::wsdlUri
const std::string wsdlUri
Definition
WsdlParser.h:39
wsdlpull_export.h
WSDLPULL_EXPORT
#define WSDLPULL_EXPORT
Definition
wsdlpull_export.h:30
Generated by
1.17.0