Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Soap.h

Go to the documentation of this file.
00001 /* 
00002  * wsdlpull - A C++ parser  for WSDL  (Web services description language)
00003  * Copyright (C) 2005-2007 Vivek Krishna
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public
00016  * License along with this library; if not, write to the Free
00017  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  *
00019  *
00020  */
00021 
00022 
00023 #ifndef _SOAPEXTH
00024 #define _SOAPEXTH
00025 
00026 #include <iostream>
00027 #include <fstream>
00028 
00029 #include <wsdlparser/WsdlExtension.h>
00030 #include <wsdlparser/WsdlParser.h>
00031 #include <schemaparser/SchemaValidator.h>
00032 
00033 #if 0
00034 const std::string httpTransport = "http://schemas.xmlsoap.org/soap/http";
00035 const std::string httpBinding = "http://schemas.xmlsoap.org/wsdl/http/";
00036 const std::string soapEncUri = "http://schemas.xmlsoap.org/soap/encoding/";
00037 const std::string soapEnvUri = "http://schemas.xmlsoap.org/soap/envelope/";
00038 const std::string soapBindingUri ="http://schemas.xmlsoap.org/wsdl/soap/";
00039 #endif
00040 
00041 
00042 
00043 class Soap:public WsdlExtension
00044 {
00045  public:
00046   
00047   static const std::string httpTransport;
00048   static const std::string httpBinding ;
00049   static const std::string soapEncUri ;
00050   static const std::string soapEnvUri ;
00051   static const std::string soapBindingUri ;
00052 
00053   typedef enum
00054     {
00055       LITERAL,
00056       ENCODED
00057     } Encoding;
00058   
00059   typedef enum
00060     {
00061       RPC,
00062       DOC
00063     } Style;
00064 
00065   typedef enum
00066     {
00067       NONE,
00068       HTTP,
00069       SMTP
00070     } Transport;
00071 
00072   Soap();
00073   virtual ~Soap();
00074 
00075   Transport getTransportMethod()const;
00076   Style getStyle()const;
00077   /*
00078     Returns the namespace URI of the wsdl
00079     extensibility elements that it can handle.
00080   */
00081   std::string getNamespace()const ;
00082   void setNamespacePrefix(string pre);
00083   std::string getNamespacePrefix()const;
00084   bool isNamespaceHandler(const std::string & ns)const;
00085   std::string getExtensibilitySchema(void)const;
00086   std::string getEncodingSchema(void)const ;
00087   void setSchemaParser(SchemaParser * spe);
00088 
00089   // parent is the Wsdl parent element type under which the extensibility element has come
00090   int handleElement(int parent, XmlPullParser *);
00091   //attName is the extensibility attribute
00092   int handleAttribute(int parent, string attName, XmlPullParser *);
00093   //returns a valid extensibilty element
00094   int getElementName(int id)const;
00095   int getElemAttribute(int id, int att_num);
00096   int getElemAttributeValue(int id, int att_num);
00097   //returns a valid extensibility attribute
00098   int getAttributeName(int id)const;
00099 
00100   //this is the start of all ids that must be used for elems/attributes in this namespace
00101   void setStartId(int id);
00102   int getStartId()const;
00103 
00104   void setWsdlParser(WsdlParser * wp);
00105   bool wasUsed()const;
00106 
00107   void serialize(ostream & out);
00108   void getSoapOperationInfo(int elemId, std::string & soapAction, Soap::Style& style);
00109   void getSoapBodyInfo(int elemId, std::string & ns, Soap::Encoding &use);
00110   void getSoapHeaderInfo(int elemId, int &schemaId, int &typeId);
00111   bool  getServiceLocation(int elemId, std::string &location);
00112   
00113   //TODO add more methods like this
00114   bool isSoapBody(int id);
00115   bool isSoapHeader(int id);
00116 
00117   /*
00118     Enums used in soap
00119   */
00120 
00121  private:
00122   void error(string);
00123   int processBinding(TypeContainer * t);
00124   int processOp(int, TypeContainer * t);
00125   int processBody(int, TypeContainer * t);
00126   int processHeader(int, TypeContainer * t);
00127   int processFault(int, TypeContainer * t);
00128   int processAddress(int parent, TypeContainer * t);
00129   std::string sNamespace, sNsPrefix, sTitle;
00130   int startId;
00131   SchemaParser *mySchemaParser;
00132   SchemaValidator *mySchemaValidator;
00133   WsdlParser *wParser;
00134   
00135   typedef struct  
00136   {
00137     int typeId;
00138     int index;
00139   }IDTableIndex ;
00140 
00141   std::vector<IDTableIndex> idTable;
00142   int idCounter;
00143 
00144   typedef struct
00145   {
00146     int wsdlOpId;
00147     std::string soapAction;
00148     Style style;
00149   } SoapOperationBinding;
00150   std::vector<SoapOperationBinding> ops_;
00151 
00152   typedef struct
00153   {
00154     int messageId;
00155     Encoding use;
00156     int encodingStyle;
00157     std::string urn;
00158   } SoapMessageBinding;
00159   std::vector<SoapMessageBinding> body_;
00160   //  int nMsgs;
00161 
00162   typedef struct
00163   {
00164     int schema;
00165     int typeId;
00166   }SoapHeaderBinding;
00167   std::vector<SoapHeaderBinding> header_;
00168   //  int nHeader;
00169 
00170   Transport transport_;
00171   Style style_;
00172   std::vector<std::string> location_;
00173 };
00174 
00175 inline 
00176 int
00177 Soap::getElementName(int id)const
00178 {
00179     if (id < startId || id > (startId + idCounter - 1))
00180         return 0;
00181     return idTable[id - startId].typeId;
00182 }
00183 
00184 
00185 inline
00186 int
00187 Soap::getAttributeName(int id)const
00188 {
00189     if (id < startId || id > (startId + idCounter - 1))
00190         return 0;
00191     return idTable[id - startId].typeId;
00192 }
00193 
00194 inline
00195 std::string
00196 Soap::getNamespace()const 
00197 {
00198   return sNamespace;
00199 }
00200 
00201 inline
00202 void
00203 Soap::setNamespacePrefix(string pre)
00204 {
00205   sNsPrefix = pre;
00206 }
00207 
00208 inline
00209 std::string
00210 Soap::getNamespacePrefix()const
00211 {
00212   return sNsPrefix;
00213 }
00214 
00215 inline
00216 bool
00217 Soap::isNamespaceHandler(const std::string & ns)const
00218 {
00219   return (ns == sNamespace);
00220 }
00221 
00222 inline
00223 void
00224 Soap::setSchemaParser(SchemaParser * spe)
00225 {
00226   mySchemaParser = spe;
00227   mySchemaValidator = new SchemaValidator(mySchemaParser);
00228 }
00229 
00230 inline
00231 void
00232 Soap::setStartId(int id)
00233 {
00234   startId = id;
00235 }
00236 
00237 inline
00238 int
00239 Soap:: getStartId()const
00240 {
00241   return startId;
00242 }
00243 
00244 inline
00245 void
00246 Soap::setWsdlParser(WsdlParser * wp)
00247 {
00248   wParser = wp;
00249 }
00250 
00251 inline
00252 bool
00253 Soap::wasUsed()const
00254 {
00255   return (wParser != 0);
00256 }
00257 
00258 inline
00259 Soap::Transport
00260 Soap::getTransportMethod()const
00261 {
00262   return transport_;
00263 }
00264 
00265 inline
00266 Soap::Style
00267 Soap::getStyle()const
00268 {
00269   return style_;
00270 }
00271 
00272 #endif                                            /*  */

Generated on Sun Oct 16 10:11:52 2005 for wsdlpull by  doxygen 1.3.9.1