comparison GEMBASSY-1.0.3/gsoap/wsdl/soap.cpp @ 0:8300eb051bea draft

Initial upload
author ktnyt
date Fri, 26 Jun 2015 05:19:29 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8300eb051bea
1 /*
2 soap.cpp
3
4 WSDL/SOAP binding schema
5
6 --------------------------------------------------------------------------------
7 gSOAP XML Web services tools
8 Copyright (C) 2001-2008, Robert van Engelen, Genivia Inc. All Rights Reserved.
9 This software is released under one of the following licenses:
10 GPL or Genivia's license for commercial use.
11 --------------------------------------------------------------------------------
12 GPL license.
13
14 This program is free software; you can redistribute it and/or modify it under
15 the terms of the GNU General Public License as published by the Free Software
16 Foundation; either version 2 of the License, or (at your option) any later
17 version.
18
19 This program is distributed in the hope that it will be useful, but WITHOUT ANY
20 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 PARTICULAR PURPOSE. See the GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
25 Place, Suite 330, Boston, MA 02111-1307 USA
26
27 Author contact information:
28 engelen@genivia.com / engelen@acm.org
29 --------------------------------------------------------------------------------
30 A commercial use license is available from Genivia, Inc., contact@genivia.com
31 --------------------------------------------------------------------------------
32
33 */
34
35 #include "wsdlH.h" // cannot include "schemaH.h"
36 #include "includes.h"
37
38 extern const char *qname_token(const char*, const char*);
39 extern int is_builtin_qname(const char*);
40
41 ////////////////////////////////////////////////////////////////////////////////
42 //
43 // soap:header
44 //
45 ////////////////////////////////////////////////////////////////////////////////
46
47 int soap__header::traverse(wsdl__definitions& definitions)
48 { if (vflag)
49 cerr << " Analyzing soap header in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
50 messageRef = NULL;
51 partRef = NULL;
52 const char *token = qname_token(message, definitions.targetNamespace);
53 if (token)
54 { for (vector<wsdl__message>::iterator message = definitions.message.begin(); message != definitions.message.end(); ++message)
55 { if ((*message).name && !strcmp((*message).name, token))
56 { messageRef = &(*message);
57 if (vflag)
58 cerr << " Found soap header part '" << (part?part:"") << "' message '" << (token?token:"") << "'" << endl;
59 break;
60 }
61 }
62 }
63 if (!messageRef)
64 { for (vector<wsdl__import>::iterator import = definitions.import.begin(); import != definitions.import.end(); ++import)
65 { wsdl__definitions *importdefinitions = (*import).definitionsPtr();
66 if (importdefinitions)
67 { token = qname_token(message, importdefinitions->targetNamespace);
68 if (token)
69 { for (vector<wsdl__message>::iterator message = importdefinitions->message.begin(); message != importdefinitions->message.end(); ++message)
70 { if ((*message).name && !strcmp((*message).name, token))
71 { messageRef = &(*message);
72 if (vflag)
73 cerr << " Found soap header part '" << (part?part:"") << "' message '" << (token?token:"") << "'" << endl;
74 break;
75 }
76 }
77 }
78 }
79 }
80 }
81 if (messageRef)
82 { if (part)
83 { for (vector<wsdl__part>::iterator pt = messageRef->part.begin(); pt != messageRef->part.end(); ++pt)
84 if ((*pt).name && !strcmp((*pt).name, part))
85 { partRef = &(*pt);
86 break;
87 }
88 }
89 if (!partRef)
90 cerr << "Warning: soap header has no matching part in message '" << (message?message:"") << "' in wsdl definitions '" << definitions.name << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
91 }
92 else
93 cerr << "Warning: could not find soap header part '" << (part?part:"") << "' message '" << (message?message:"") << "' in wsdl definitions '" << definitions.name << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
94 for (vector<soap__headerfault>::iterator i = headerfault.begin(); i != headerfault.end(); ++i)
95 (*i).traverse(definitions);
96 return SOAP_OK;
97 }
98
99 void soap__header::messagePtr(wsdl__message *message)
100 { messageRef = message;
101 }
102
103 wsdl__message *soap__header::messagePtr() const
104 { return messageRef;
105 }
106
107 void soap__header::partPtr(wsdl__part *part)
108 { partRef = part;
109 }
110
111 wsdl__part *soap__header::partPtr() const
112 { return partRef;
113 }
114
115 ////////////////////////////////////////////////////////////////////////////////
116 //
117 // soap:headerfault
118 //
119 ////////////////////////////////////////////////////////////////////////////////
120
121 int soap__headerfault::traverse(wsdl__definitions& definitions)
122 { if (vflag)
123 cerr << " Analyzing soap headerfault in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
124 messageRef = NULL;
125 partRef = NULL;
126 const char *token = qname_token(message, definitions.targetNamespace);
127 if (token)
128 { for (vector<wsdl__message>::iterator message = definitions.message.begin(); message != definitions.message.end(); ++message)
129 { if ((*message).name && !strcmp((*message).name, token))
130 { messageRef = &(*message);
131 if (vflag)
132 cerr << " Found soap headerfault part '" << (part?part:"") << "' message '" << (token?token:"") << "'" << endl;
133 break;
134 }
135 }
136 }
137 else
138 { for (vector<wsdl__import>::iterator import = definitions.import.begin(); import != definitions.import.end(); ++import)
139 { wsdl__definitions *importdefinitions = (*import).definitionsPtr();
140 if (importdefinitions)
141 { token = qname_token(message, importdefinitions->targetNamespace);
142 if (token)
143 { for (vector<wsdl__message>::iterator message = importdefinitions->message.begin(); message != importdefinitions->message.end(); ++message)
144 { if ((*message).name && !strcmp((*message).name, token))
145 { messageRef = &(*message);
146 if (vflag)
147 cerr << " Found soap headerfault part '" << (part?part:"") << "' message '" << (token?token:"") << "'" << endl;
148 break;
149 }
150 }
151 }
152 }
153 }
154 }
155 if (messageRef)
156 { if (part)
157 { for (vector<wsdl__part>::iterator pt = messageRef->part.begin(); pt != messageRef->part.end(); ++pt)
158 if ((*pt).name && !strcmp((*pt).name, part))
159 { partRef = &(*pt);
160 break;
161 }
162 }
163 if (!partRef)
164 cerr << "Warning: soap headerfault has no matching part in message '" << (message?message:"") << "' in wsdl definitions '" << definitions.name << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
165 }
166 else
167 cerr << "Warning: could not find soap headerfault part '" << (part?part:"") << "' message '" << (message?message:"") << "' in wSDL definitions '" << definitions.name << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
168 return SOAP_OK;
169 }
170
171 void soap__headerfault::messagePtr(wsdl__message *message)
172 { messageRef = message;
173 }
174
175 wsdl__message *soap__headerfault::messagePtr() const
176 { return messageRef;
177 }
178
179 void soap__headerfault::partPtr(wsdl__part *part)
180 { partRef = part;
181 }
182
183 wsdl__part *soap__headerfault::partPtr() const
184 { return partRef;
185 }
186
187 ////////////////////////////////////////////////////////////////////////////////
188 //
189 // wsoap:header
190 //
191 ////////////////////////////////////////////////////////////////////////////////
192
193 int wsoap__header::traverse(wsdl__definitions& definitions)
194 { if (vflag)
195 cerr << " Analyzing soap header in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
196 elementRef = NULL;
197 // WSDL 2.0
198 if (element)
199 { if (definitions.types)
200 { for (vector<xs__schema*>::iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)
201 { const char *token = qname_token(element, (*schema)->targetNamespace);
202 if (token)
203 { for (vector<xs__element>::iterator element = (*schema)->element.begin(); element != (*schema)->element.end(); ++element)
204 { if ((*element).name && !strcmp((*element).name, token))
205 { elementRef = &(*element);
206 if (vflag)
207 cerr << " Found soap header element '" << (token?token:"") << "'" << endl;
208 break;
209 }
210 }
211 }
212 }
213 }
214 if (!elementRef)
215 { if (is_builtin_qname(element))
216 definitions.builtinElement(element);
217 else
218 if (!Wflag)
219 cerr << "Warning: no soap header element '" << element << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
220 }
221 }
222 return SOAP_OK;
223 }
224
225 void wsoap__header::elementPtr(xs__element *element)
226 { elementRef = element;
227 }
228
229 xs__element *wsoap__header::elementPtr() const
230 { return elementRef;
231 }