00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _WSDLPARSERH
00021 #define _WSDLPARSERH
00022
00023 #include "xmlpull/wsdlpull_export.h"
00024 #include "xmlpull/XmlPullParser.h"
00025 #include "xmlpull/XmlPullParserException.h"
00026 #include "schemaparser/SchemaParser.h"
00027
00028 #include "wsdlparser/PortType.h"
00029 #include "wsdlparser/Message.h"
00030 #include "wsdlparser/Operation.h"
00031 #include "wsdlparser/Binding.h"
00032 #include "wsdlparser/Service.h"
00033 #include "wsdlparser/WsdlExtension.h"
00034
00035
00036 namespace WsdlPull{
00037
00038 const std::string wsdlUri="http://schemas.xmlsoap.org/wsdl/";
00039
00040
00041 class Soap;
00042
00043 class WSDLPULL_EXPORT WsdlParser
00044 {
00045 public:
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 WsdlParser(std::istream & in = std::cin, std::ostream & out = std::cout,
00056 const std::string & schemaPath = "");
00057 WsdlParser(const std::string& Uri,std::ostream & out = std::cout,
00058 const std::string & schemaPath = "");
00059 ~WsdlParser();
00060
00061
00062
00063
00064
00065
00066 void setSchemaPath(const std::string & schemaPath);
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 int getNextElement();
00077
00078
00079
00080
00081
00082
00083 int getEventType();
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 std::string getNamespace(void);
00098
00099
00100
00101
00102
00103 std::string getName();
00104
00105
00106
00107
00108
00109
00110 const std::string* getDocumentation();
00111
00112
00113
00114
00115
00116
00117
00118 const Binding *getBinding();
00119
00120
00121
00122
00123
00124
00125
00126 const Binding *getBinding(const Qname & q);
00127
00128
00129
00130
00131
00132
00133 bool getBindings(Binding::cBindingIterator & begin,
00134 Binding::cBindingIterator & end)const;
00135
00136
00137
00138
00139
00140
00141
00142 const Service *getService();
00143
00144
00145
00146
00147
00148
00149
00150 typedef std::list<Service*>::iterator ServiceIterator;
00151 const Service *getService(const Qname & q);
00152 void getServices(ServiceIterator &from, ServiceIterator &to);
00153
00154
00155
00156
00157
00158
00159
00160 const PortType *getPortType();
00161
00162
00163
00164
00165
00166
00167
00168 const PortType *getPortType(const Qname & q);
00169
00170
00171
00172
00173
00174
00175 bool getPortTypes(PortType::cPortTypeIterator& begin,
00176 PortType::cPortTypeIterator& end)const;
00177
00178
00179
00180
00181
00182
00183
00184
00185 bool getOperations(const Qname & portType,
00186 Operation::cOpIterator& begin,
00187 Operation::cOpIterator& end);
00188
00189
00190
00191
00192
00193
00194
00195
00196 const Operation *getOperation(const Qname & portType,
00197 const Qname & q);
00198
00199
00200
00201
00202
00203
00204
00205 const Message *getMessage();
00206
00207
00208
00209
00210
00211
00212
00213 const Message *getMessage(const Qname & q);
00214
00215
00216
00217
00218
00219
00220 std::list < const Message *>& getMessages();
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230 void getSchemaParsers(std::vector<SchemaParser* >::iterator & from,
00231 std::vector<SchemaParser* >::iterator & to) ;
00232
00233
00234
00235
00236
00237
00238 int getNumSchemas() const;
00239
00240
00241
00242
00243
00244
00245
00246 const SchemaParser *getSchemaParser(std::string targetNamespace) const;
00247
00248
00249
00250
00251
00252 bool status()const;
00253 std::string wsdlPath()const;
00254 std::ostream & logger();
00255 std::string &getWsdlFileName()
00256 {
00257 return wsdlFileName;
00258 }
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270 void addExtensibilityHandler(WsdlExtension * ext);
00271
00272
00273
00274
00275
00276
00277 WsdlExtension * getExtensibilityHandler(const std::string & ns);
00278
00279
00280 WsdlExtension * getExtensibilityHandler(int extId);
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290 bool setFeature (int feature_id);
00291
00292
00293
00294
00295
00296
00297 enum
00298 {
00299 NONE ,
00300 START,
00301 DEFINITION,
00302 DOCUMENTATION,
00303 ANNOTATION,
00304 IMPORT,
00305 SCHEMA,
00306 TYPES,
00307 MESSAGE,
00308 PART,
00309 PORT_TYPE,
00310 OPERATION,
00311 INPUT,
00312 OUTPUT,
00313 FAULT,
00314 BINDING,
00315 EXTENSIBILITY,
00316 SERVICE,
00317 PORT,
00318 END
00319 };
00320
00321 #ifdef LOGGING
00322
00323 void print(std::ostream & out);
00324 #endif
00325
00326
00327
00328
00329
00330
00331
00332
00333 const SchemaParser *getSchemaParser(int schemaId) const;
00334
00335
00336 private:
00337
00338
00339
00340 int peek(bool lookahead = true);
00341 int next();
00342 void error(std::string s,int level=0);
00343 std::string getNamespace(std::string prefix);
00344 Element * getElement(const Qname &);
00345 int getTypeId(const Qname &);
00346 int getSchema(const Qname & name,bool type = true);
00347 std::string* parseDoc();
00348 void parseDefinitions();
00349 void parseMessage();
00350 void parseAnnotation();
00351 void parseImport();
00352 PortType *parsePortType();
00353 Operation *parseOperation(PortType* p);
00354 void parseTypes();
00355 void parseBinding();
00356 void parseService();
00357 int handleExtensibilityAttributes(std::string prefix, std::string name);
00358 int handleExtensibilityElement(int);
00359 void putMessage(Message * m);
00360 void putPortType(PortType * pt);
00361 void putBinding(Binding * bn);
00362 void initialize(bool);
00363 bool errorOccured_;
00364 XmlPullParser* openSchemaFile(const std::string& path);
00365 const Message *pgetMessage(const Qname& q);
00366 std::string name_, tnsPrefix_, tnsUri_;
00367 std::vector<SchemaParser*> schemaParser_;
00368
00369 typedef struct
00370 {
00371 WsdlExtension *we;
00372 SchemaParser *spe;
00373 } ExtensionInfo;
00374 std::list < const Message *> messages_;
00375 std::vector<ExtensionInfo> wsdlExtensions_;
00376 std::list < PortType *>porttypes_;
00377 std::list < Binding *>bindings_;
00378 std::list < Service*> services_;
00379
00380 class Imports
00381 {
00382 public:
00383 Imports(std::string,std::string);
00384 std::string ns, loc;
00385 };
00386 std::vector<Imports> imports_;
00387 std::list < std::string *> docs_list_;
00388 std::ostream & ostr;
00389 std::istream & istr;
00390 int state_;
00391 int element_;
00392 std::string* Doc_;
00393 XmlPullParser * xParser_;
00394 std::ifstream xmlStream;
00395 std::string wsdlFileName;
00396 Soap * soap_;
00397 const int MAX_EXT_XML;
00398 std::string schemaPath_;
00399 std::string uri_;
00400 };
00401
00402
00403 inline
00404 WsdlParser::Imports::Imports(std::string nameSpace,std::string location)
00405 :ns(nameSpace),
00406 loc(location)
00407 {
00408 }
00409
00410
00411 inline
00412 std::string
00413 WsdlParser::getNamespace(std::string prefix)
00414 {
00415 return xParser_->getNamespace(prefix);
00416 }
00417
00418
00419
00420 inline
00421 int
00422 WsdlParser::getNextElement()
00423 {
00424 next();
00425 return element_;
00426 }
00427
00428 inline
00429 const std::string*
00430 WsdlParser::getDocumentation()
00431 {
00432 return (const std::string*) Doc_;
00433 }
00434
00435 inline
00436 std::string
00437 WsdlParser::getNamespace(void)
00438 {
00439 return tnsUri_;
00440 }
00441
00442 inline
00443 std::string
00444 WsdlParser::getName()
00445 {
00446 return name_;
00447 }
00448
00449
00450
00451 inline
00452 int
00453 WsdlParser::getEventType()
00454 {
00455 return element_;
00456 }
00457
00458
00459 inline
00460 std::list < const Message *>&
00461 WsdlParser::getMessages()
00462 {
00463 return messages_;
00464 }
00465
00466
00467
00468
00469
00470 inline
00471 const SchemaParser *
00472 WsdlParser::getSchemaParser(int schemaId) const
00473 {
00474 return (const SchemaParser *) schemaParser_[schemaId];
00475 }
00476
00477 inline
00478 std::string
00479 WsdlParser::wsdlPath()const
00480 {
00481 return wsdlFileName ;
00482 }
00483 inline
00484 bool
00485 WsdlParser::status()const
00486 {
00487 return !errorOccured_;
00488 }
00489
00490 inline
00491 std::ostream&
00492 WsdlParser::logger()
00493 {
00494 return ostr;
00495 }
00496 }
00497
00498 #endif