wsdlpull  1.23
Soap.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  */
21 
22 
23 #ifndef _SOAPEXTH
24 #define _SOAPEXTH
25 
26 #include <iostream>
27 #include <fstream>
28 
30 #include "wsdlparser/WsdlParser.h"
33 
34 namespace WsdlPull {
35 
36 
37 
39 {
40  public:
41 
42  static const std::string httpTransport;
43  static const std::string httpBinding ;
44  static const std::string soapEncUri11 ;
45  static const std::string soapEnvUri11 ;
46  static const std::string soapEncUri12 ;
47  static const std::string soapEnvUri12 ;
48  static const std::string soapBindingUri11;
49  static const std::string soapBindingUri12 ;
50 
51  typedef enum {
53  SOAP12
54  } SoapVersion;
55 
56  typedef enum
57  {
59  ENCODED
60  } Encoding;
61 
62  typedef enum
63  {
64  RPC,
65  DOC
66  } Style;
67 
68  typedef enum
69  {
72  SMTP
73  } Transport;
74 
75  Soap(const std::string & schemaPath = "", SoapVersion a_soapVersion = SOAP11);
76  virtual ~Soap();
77 
81  void setSchemaPath(const std::string & schemaPath);
82 
83  Transport getTransportMethod()const;
84  Style getStyle()const;
85  /*
86  Returns the namespace URI of the wsdl
87  extensibility elements that it can handle.
88  */
89  std::string getNamespace()const ;
90  void setNamespacePrefix(std::string pre);
91  std::string getNamespacePrefix()const;
92  bool isNamespaceHandler(const std::string & ns)const;
93  std::string getExtensibilitySchema(void)const;
94  std::string getEncodingSchema(void)const ;
95  std::string getEncodingUri(void) const;
96  std::string getEnvelopeUri(void) const;
97  void setSchemaParser(SchemaParser * spe);
98 
99  // parent is the Wsdl parent element type under which the extensibility element has come
100  int handleElement(int parent, XmlPullParser *);
101  //attName is the extensibility attribute
102  int handleAttribute(int parent, std::string attName, XmlPullParser *);
103  //returns a valid extensibilty element
104  int getElementName(int id)const;
105  int getElemAttribute(int id, int att_num);
106  int getElemAttributeValue(int id, int att_num);
107  //returns a valid extensibility attribute
108  int getAttributeName(int id)const;
109 
110  //this is the start of all ids that must be used for elems/attributes in this namespace
111  void setStartId(int id);
112  int getStartId()const;
113 
114  void setWsdlParser(WsdlParser * wp);
115  WsdlParser * wsdlParser()const;
116  bool wasUsed()const;
117 
118  void serialize(std::ostream & out);
119  void getSoapOperationInfo(int elemId, std::string & soapAction, Soap::Style& style);
120  void getSoapBodyInfo(int elemId, std::string &ns, Soap::Encoding &use, std::string &encodingStyle);
121  void getSoapHeaderInfo(int elemId, std::string &ns, int &partId, const Message* & m);
122  bool getServiceLocation(int elemId, std::string &location);
123 
124  SoapVersion getSoapVersion() const { return soapVersion_; }
125 
126  //TODO add more methods like this
127  bool isSoapBody(int id);
128  bool isSoapHeader(int id);
129 
130  /*
131  Enums used in soap
132  */
133 
134  private:
135  void error(std::string);
136  int processBinding(TypeContainer * t);
137  int processOp(int, TypeContainer * t);
138  int processBody(int, TypeContainer * t);
139  int processHeader(int, TypeContainer * t);
140  int processFault(int, TypeContainer * t);
141  int processAddress(int parent, TypeContainer * t);
142  std::string sNamespace, sNsPrefix, sTitle;
143  int startId;
144  SchemaParser *mySchemaParser;
145  SchemaValidator *mySchemaValidator;
146  WsdlParser *wParser_;
147 
148  typedef struct
149  {
150  int typeId;
151  int index;
152  }IDTableIndex ;
153 
154  std::vector<IDTableIndex> idTable;
155  int idCounter;
156 
157  typedef struct
158  {
159  int wsdlOpId;
160  std::string soapAction;
161  Style style;
162  } SoapOperationBinding;
163  std::vector<SoapOperationBinding> ops_;
164 
165  typedef struct
166  {
167  int messageId;
168  Encoding use;
169  std::string encodingStyle;
170  std::string urn;
171  } SoapMessageBinding;
172  std::vector<SoapMessageBinding> body_;
173  // int nMsgs;
174 
175  typedef struct
176  {
177  std::string urn;
178  int partId_;
179  const Message* message_;
180  }SoapHeaderBinding;
181  std::vector<SoapHeaderBinding> header_;
182  // int nHeader;
183 
184  Transport transport_;
185  Style style_;
186  std::vector<std::string> location_;
187  std::string schemaPath_;
188 
189  SoapVersion soapVersion_; //The SOAP version to use
190 };
191 
192 inline
193 int
195 {
196  if (id < startId || id > (startId + idCounter - 1))
197  return 0;
198  return idTable[id - startId].typeId;
199 }
200 
201 
202 inline
203 int
205 {
206  if (id < startId || id > (startId + idCounter - 1))
207  return 0;
208  return idTable[id - startId].typeId;
209 }
210 
211 inline
212 std::string
214 {
215  return sNamespace;
216 }
217 
218 inline
219 void
220 Soap::setNamespacePrefix(std::string pre)
221 {
222  sNsPrefix = pre;
223 }
224 
225 inline
226 std::string
228 {
229  return sNsPrefix;
230 }
231 
232 inline
233 bool
234 Soap::isNamespaceHandler(const std::string & ns)const
235 {
236  return (ns == sNamespace);
237 }
238 
239 inline
240 void
242 {
243  mySchemaParser = spe;
244  mySchemaValidator = new SchemaValidator(mySchemaParser);
245 }
246 
247 inline
248 void
250 {
251  startId = id;
252 }
253 
254 inline
255 int
257 {
258  return startId;
259 }
260 
261 inline
262 void
264 {
265  wParser_ = wp;
266 }
267 
268 inline
269 bool
271 {
272  return (wParser_ != 0);
273 }
274 
275 inline
278 {
279  return transport_;
280 }
281 
282 inline
285 {
286  return style_;
287 }
288 
289 inline
290 WsdlParser *
292 {
293  return wParser_;
294 }
295 
296 }
297 #endif /* */
Style getStyle() const
Definition: Soap.h:284
static const std::string soapBindingUri12
Definition: Soap.h:49
SoapVersion getSoapVersion() const
Definition: Soap.h:124
WsdlParser * wsdlParser() const
Definition: Soap.h:291
bool isNamespaceHandler(const std::string &ns) const
Definition: Soap.h:234
static const std::string soapBindingUri11
Definition: Soap.h:48
static const std::string soapEnvUri11
Definition: Soap.h:45
void setNamespacePrefix(std::string pre)
Definition: Soap.h:220
static const std::string soapEncUri12
Definition: Soap.h:46
int getElementName(int id) const
Definition: Soap.h:194
void setWsdlParser(WsdlParser *wp)
Definition: Soap.h:263
int getStartId() const
Definition: Soap.h:256
bool wasUsed() const
Definition: Soap.h:270
static const std::string httpBinding
Definition: Soap.h:43
static const std::string soapEnvUri12
Definition: Soap.h:47
void setSchemaParser(SchemaParser *spe)
Definition: Soap.h:241
#define WSDLPULL_EXPORT
std::string getNamespacePrefix() const
Definition: Soap.h:227
void setStartId(int id)
Definition: Soap.h:249
static const std::string httpTransport
Definition: Soap.h:42
std::string getNamespace() const
Definition: Soap.h:213
static const std::string soapEncUri11
Definition: Soap.h:44
int getAttributeName(int id) const
Definition: Soap.h:204
Transport getTransportMethod() const
Definition: Soap.h:277