wsdlpull svntrunk
Loading...
Searching...
No Matches
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
33
34namespace 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 {
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
192inline
193int
195{
196 if (id < startId || id > (startId + idCounter - 1))
197 return 0;
198 return idTable[id - startId].typeId;
199}
200
201
202inline
203int
205{
206 if (id < startId || id > (startId + idCounter - 1))
207 return 0;
208 return idTable[id - startId].typeId;
209}
210
211inline
212std::string
214{
215 return sNamespace;
216}
217
218inline
219void
221{
222 sNsPrefix = pre;
223}
224
225inline
226std::string
228{
229 return sNsPrefix;
230}
231
232inline
233bool
234Soap::isNamespaceHandler(const std::string & ns)const
235{
236 return (ns == sNamespace);
237}
238
239inline
240void
242{
243 mySchemaParser = spe;
244 mySchemaValidator = new SchemaValidator(mySchemaParser);
245}
246
247inline
248void
250{
251 startId = id;
252}
253
254inline
255int
257{
258 return startId;
259}
260
261inline
262void
264{
265 wParser_ = wp;
266}
267
268inline
269bool
271{
272 return (wParser_ != 0);
273}
274
275inline
278{
279 return transport_;
280}
281
282inline
285{
286 return style_;
287}
288
289inline
292{
293 return wParser_;
294}
295
296}
297#endif /* */
void setSchemaParser(SchemaParser *spe)
Definition Soap.h:241
bool wasUsed() const
Definition Soap.h:270
static const std::string soapEncUri12
Definition Soap.h:46
static const std::string soapBindingUri11
Definition Soap.h:48
bool isNamespaceHandler(const std::string &ns) const
Definition Soap.h:234
static const std::string soapEncUri11
Definition Soap.h:44
int getElemAttribute(int id, int att_num)
Transport getTransportMethod() const
Definition Soap.h:277
int getStartId() const
Definition Soap.h:256
std::string getNamespace() const
Definition Soap.h:213
void setNamespacePrefix(std::string pre)
Definition Soap.h:220
int getElementName(int id) const
Definition Soap.h:194
std::string getNamespacePrefix() const
Definition Soap.h:227
void setStartId(int id)
Definition Soap.h:249
void serialize(std::ostream &out)
static const std::string httpTransport
Definition Soap.h:42
void setWsdlParser(WsdlParser *wp)
Definition Soap.h:263
Style getStyle() const
Definition Soap.h:284
int getAttributeName(int id) const
Definition Soap.h:204
static const std::string soapBindingUri12
Definition Soap.h:49
static const std::string httpBinding
Definition Soap.h:43
WsdlParser * wsdlParser() const
Definition Soap.h:291
int getElemAttributeValue(int id, int att_num)
SoapVersion getSoapVersion() const
Definition Soap.h:124
static const std::string soapEnvUri12
Definition Soap.h:47
static const std::string soapEnvUri11
Definition Soap.h:45
#define WSDLPULL_EXPORT