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 class Soap:public WsdlExtension
00034 {
00035  public:
00036   
00037   static const std::string httpTransport;
00038   static const std::string httpBinding ;
00039   static const std::string soapEncUri ;
00040   static const std::string soapEnvUri ;
00041   static const std::string soapBindingUri ;
00042 
00043   typedef enum
00044     {
00045       LITERAL,
00046       ENCODED
00047     } Encoding;
00048   
00049   typedef enum
00050     {
00051       RPC,
00052       DOC
00053     } Style;
00054 
00055   typedef enum
00056     {
00057       NONE,
00058       HTTP,
00059       SMTP
00060     } Transport;
00061 
00062   Soap();
00063   virtual ~Soap();
00064 
00065   Transport getTransportMethod()const;
00066   Style getStyle()const;
00067   /*
00068     Returns the namespace URI of the wsdl
00069     extensibility elements that it can handle.
00070   */
00071   std::string getNamespace()const ;
00072   void setNamespacePrefix(string pre);
00073   std::string getNamespacePrefix()const;
00074   bool isNamespaceHandler(const std::string & ns)const;
00075   std::string getExtensibilitySchema(void)const;
00076   std::string getEncodingSchema(void)const ;
00077   void setSchemaParser(SchemaParser * spe);
00078 
00079   // parent is the Wsdl parent element type under which the extensibility element has come
00080   int handleElement(int parent, XmlPullParser *);
00081   //attName is the extensibility attribute
00082   int handleAttribute(int parent, string attName, XmlPullParser *);
00083   //returns a valid extensibilty element
00084   int getElementName(int id)const;
00085   int getElemAttribute(int id, int att_num);
00086   int getElemAttributeValue(int id, int att_num);
00087   //returns a valid extensibility attribute
00088   int getAttributeName(int id)const;
00089 
00090   //this is the start of all ids that must be used for elems/attributes in this namespace
00091   void setStartId(int id);
00092   int getStartId()const;
00093 
00094   void setWsdlParser(WsdlParser * wp);
00095   bool wasUsed()const;
00096 
00097   void serialize(ostream & out);
00098   void getSoapOperationInfo(int elemId, std::string & soapAction, Soap::Style& style);
00099   void getSoapBodyInfo(int elemId, std::string & ns, Soap::Encoding &use);
00100   void getSoapHeaderInfo(int elemId, int &schemaId, int &typeId);
00101   bool  getServiceLocation(int elemId, std::string &location);
00102   
00103   //TODO add more methods like this
00104   bool isSoapBody(int id);
00105   bool isSoapHeader(int id);
00106 
00107   /*
00108     Enums used in soap
00109   */
00110 
00111  private:
00112   void error(string);
00113   int processBinding(TypeContainer * t);
00114   int processOp(int, TypeContainer * t);
00115   int processBody(int, TypeContainer * t);
00116   int processHeader(int, TypeContainer * t);
00117   int processFault(int, TypeContainer * t);
00118   int processAddress(int parent, TypeContainer * t);
00119   std::string sNamespace, sNsPrefix, sTitle;
00120   int startId;
00121   SchemaParser *mySchemaParser;
00122   SchemaValidator *mySchemaValidator;
00123   WsdlParser *wParser;
00124   
00125   typedef struct  
00126   {
00127     int typeId;
00128     int index;
00129   }IDTableIndex ;
00130 
00131   std::vector<IDTableIndex> idTable;
00132   int idCounter;
00133 
00134   typedef struct
00135   {
00136     int wsdlOpId;
00137     std::string soapAction;
00138     Style style;
00139   } SoapOperationBinding;
00140   std::vector<SoapOperationBinding> ops_;
00141 
00142   typedef struct
00143   {
00144     int messageId;
00145     Encoding use;
00146     int encodingStyle;
00147     std::string urn;
00148   } SoapMessageBinding;
00149   std::vector<SoapMessageBinding> body_;
00150   //  int nMsgs;
00151 
00152   typedef struct
00153   {
00154     int schema;
00155     int typeId;
00156   }SoapHeaderBinding;
00157   std::vector<SoapHeaderBinding> header_;
00158   //  int nHeader;
00159 
00160   Transport transport_;
00161   Style style_;
00162   std::vector<std::string> location_;
00163 };
00164 
00165 inline 
00166 int
00167 Soap::getElementName(int id)const
00168 {
00169     if (id < startId || id > (startId + idCounter - 1))
00170         return 0;
00171     return idTable[id - startId].typeId;
00172 }
00173 
00174 
00175 inline
00176 int
00177 Soap::getAttributeName(int id)const
00178 {
00179     if (id < startId || id > (startId + idCounter - 1))
00180         return 0;
00181     return idTable[id - startId].typeId;
00182 }
00183 
00184 inline
00185 std::string
00186 Soap::getNamespace()const 
00187 {
00188   return sNamespace;
00189 }
00190 
00191 inline
00192 void
00193 Soap::setNamespacePrefix(string pre)
00194 {
00195   sNsPrefix = pre;
00196 }
00197 
00198 inline
00199 std::string
00200 Soap::getNamespacePrefix()const
00201 {
00202   return sNsPrefix;
00203 }
00204 
00205 inline
00206 bool
00207 Soap::isNamespaceHandler(const std::string & ns)const
00208 {
00209   return (ns == sNamespace);
00210 }
00211 
00212 inline
00213 void
00214 Soap::setSchemaParser(SchemaParser * spe)
00215 {
00216   mySchemaParser = spe;
00217   mySchemaValidator = new SchemaValidator(mySchemaParser);
00218 }
00219 
00220 inline
00221 void
00222 Soap::setStartId(int id)
00223 {
00224   startId = id;
00225 }
00226 
00227 inline
00228 int
00229 Soap:: getStartId()const
00230 {
00231   return startId;
00232 }
00233 
00234 inline
00235 void
00236 Soap::setWsdlParser(WsdlParser * wp)
00237 {
00238   wParser = wp;
00239 }
00240 
00241 inline
00242 bool
00243 Soap::wasUsed()const
00244 {
00245   return (wParser != 0);
00246 }
00247 
00248 inline
00249 Soap::Transport
00250 Soap::getTransportMethod()const
00251 {
00252   return transport_;
00253 }
00254 
00255 inline
00256 Soap::Style
00257 Soap::getStyle()const
00258 {
00259   return style_;
00260 }
00261 
00262 #endif                                            /*  */

Generated on Sat Oct 29 13:08:56 2005 for wsdlpull by  doxygen 1.3.9.1