annotate GEMBASSY-1.0.3/gsoap/wsdl/service.cpp @ 0:8300eb051bea draft

Initial upload
author ktnyt
date Fri, 26 Jun 2015 05:19:29 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2 service.cpp
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
4 Generate gSOAP service structures from WSDL.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
5
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
6 --------------------------------------------------------------------------------
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
7 gSOAP XML Web services tools
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
8 Copyright (C) 2000-2013, Robert van Engelen, Genivia Inc. All Rights Reserved.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
9 This part of the software is released under one of the following licenses:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
10 GPL or Genivia's license for commercial use.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
11 --------------------------------------------------------------------------------
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
12 GPL license.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
13
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
14 This program is free software; you can redistribute it and/or modify it under
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
15 the terms of the GNU General Public License as published by the Free Software
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
16 Foundation; either version 2 of the License, or (at your option) any later
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
17 version.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
18
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
19 This program is distributed in the hope that it will be useful, but WITHOUT ANY
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
20 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
21 PARTICULAR PURPOSE. See the GNU General Public License for more details.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
22
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
23 You should have received a copy of the GNU General Public License along with
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
24 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
25 Place, Suite 330, Boston, MA 02111-1307 USA
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
26
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
27 Author contact information:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
28 engelen@genivia.com / engelen@acm.org
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
29 --------------------------------------------------------------------------------
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
30 A commercial use license is available from Genivia, Inc., contact@genivia.com
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
31 --------------------------------------------------------------------------------
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
32
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
33 TODO: consider adding support for non-SOAP HTTP operations
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
34 add headerfault output definitions
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
35
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
36 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
37
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
38 #include "types.h"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
39 #include "service.h"
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
40
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
41 #include <algorithm>
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
42
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
43 #define URI_CHAR(c) (((c) > 32 && (c) != '"' && (c) != '<' && (c) != '>' && (c) != '\\' && (c) != '^' && (c) != '`' && (c) <= 'z') || (c) == '~')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
44
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
45 static const char *urienc(struct soap*, const char*);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
46 static bool imported(const char *tag);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
47 static void comment(const char *start, const char *middle, const char *end, const char *text);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
48 static void page(const char *page, const char *title, const char *text);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
49 static void section(const char *section, const char *title, const char *text);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
50 static void banner(const char*);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
51 static void banner(const char*, const char*);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
52 static void ident();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
53 static void gen_policy(Service&, const vector<const wsp__Policy*>&, const char*, Types&);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
54 static void gen_policy_enablers(const Service&);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
55
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
56 ////////////////////////////////////////////////////////////////////////////////
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
57 //
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
58 // Definitions methods
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
59 //
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
60 ////////////////////////////////////////////////////////////////////////////////
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
61
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
62 Definitions::Definitions()
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
63 { }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
64
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
65 void Definitions::collect(const wsdl__definitions &definitions)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
66 { // Collect information: analyze WSDL definitions and imported definitions
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
67 analyze(definitions);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
68 for (vector<wsdl__import>::const_iterator import = definitions.import.begin(); import != definitions.import.end(); ++import)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
69 if ((*import).definitionsPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
70 analyze(*(*import).definitionsPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
71 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
72
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
73 void Definitions::analyze(const wsdl__definitions &definitions)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
74 { // Analyze WSDL and build Service information
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
75 int binding_count = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
76 // Determine number of relevant SOAP service bindings (service prefix option only)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
77 for (vector<wsdl__binding>::const_iterator i = definitions.binding.begin(); i != definitions.binding.end(); ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
78 { for (vector<wsdl__ext_operation>::const_iterator j = (*i).operation.begin(); j != (*i).operation.end(); ++j)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
79 { if ((*j).operationPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
80 { binding_count++;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
81 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
82 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
83 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
84 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
85 if (binding_count == 0 && definitions.name && (!definitions.portType.empty() || !definitions.interface_.empty()))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
86 fprintf(stderr, "\nWarning: WSDL \"%s\" has no bindings to implement operations\n", definitions.name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
87 else if (binding_count > 1 && !service_prefix)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
88 { // This puts all operations under a single binding
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
89 fprintf(stderr, "\nWarning: %d service bindings found, but collected as one service (use option -Nname to produce a separate service for each binding)\n", binding_count);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
90 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
91 // Analyze and collect service data
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
92 for (vector<wsdl__binding>::const_iterator binding = definitions.binding.begin(); binding != definitions.binding.end(); ++binding)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
93 { // /definitions/binding/documentation
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
94 const char *binding_documentation = (*binding).documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
95 // /definitions/binding/soap:binding
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
96 soap__binding *soap__binding_ = (*binding).soap__binding_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
97 // /definitions/binding/soap:binding/@transport
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
98 const char *soap__binding_transport = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
99 int version = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
100 if (soap__binding_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
101 soap__binding_transport = soap__binding_->transport;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
102 else if ((*binding).wsoap__version && strlen((*binding).wsoap__version) > 2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
103 version = (*binding).wsoap__version[2]-'0'; // WSDL 2.0
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
104 else if (!(*binding).http__binding_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
105 version = 2; // assume WSDL 2.0
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
106 if (version == 2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
107 soap12 = true;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
108 // /definitions/binding/@soap:protocol
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
109 if ((*binding).wsoap__protocol)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
110 soap__binding_transport = (*binding).wsoap__protocol;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
111 // /definitions/binding/@name
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
112 const char *binding_name = "";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
113 if ((*binding).name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
114 binding_name = (*binding).name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
115 else if ((*binding).portTypePtr() && (*binding).portTypePtr()->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
116 { char *s = (char*)soap_malloc(definitions.soap, strlen((*binding).portTypePtr()->name) + 8);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
117 strcpy(s, (*binding).portTypePtr()->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
118 strcat(s, "Binding");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
119 binding_name = s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
120 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
121 // /definitions/binding/@type
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
122 const char *binding_type = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
123 if ((*binding).type_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
124 binding_type = (*binding).type_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
125 // TODO: need to find the Policy of portType, though never used...
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
126 // const wsp__Policy *portType_policy = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
127 // /definitions/binding/wsp:Policy and wsp:PolicyReference
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
128 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
129 const wsp__Policy *binding_policy = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
130 if ((*binding).wsp__Policy_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
131 binding_policy = (*binding).wsp__Policy_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
132 if ((*binding).wsp__PolicyReference_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
133 binding_policy = (*binding).wsp__PolicyReference_->policyPtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
134 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
135 // /definitions/binding/http:binding
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
136 http__binding *http__binding_ = (*binding).http__binding_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
137 const char *http__binding_verb = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
138 if (http__binding_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
139 http__binding_verb = http__binding_->verb; // HTTP POST and GET
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
140 else if ((*binding).whttp__methodDefault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
141 http__binding_verb = (*binding).whttp__methodDefault; // HTTP POST and GET
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
142 // /definitions/binding/soap:binding/@style
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
143 soap__styleChoice soap__binding_style = document;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
144 if (soap__binding_ && soap__binding_->style)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
145 soap__binding_style = *soap__binding_->style;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
146 // /definitions/binding/operation*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
147 for (vector<wsdl__ext_operation>::const_iterator operation = (*binding).operation.begin(); operation != (*binding).operation.end(); ++operation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
148 { // /definitions/portType/operation/ associated with /definitions/binding/operation
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
149 wsdl__operation *wsdl__operation_ = (*operation).operationPtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
150 // /definitions/binding/operation/soap:operation
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
151 soap__operation *soap__operation_ = (*operation).soap__operation_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
152 // /definitions/binding/operation/soap:operation/@style
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
153 soap__styleChoice soap__operation_style = soap__binding_style;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
154 if (soap__operation_ && soap__operation_->style)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
155 soap__operation_style = *soap__operation_->style;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
156 // /definitions/binding/@wsoap:mepDefault
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
157 const char *soap__operation_mep = (*binding).wsoap__mepDefault;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
158 // /definitions/binding/operation/@wsoap:mep
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
159 if ((*operation).wsoap__mep)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
160 soap__operation_mep = (*operation).wsoap__mep;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
161 // /definitions/binding/operation/@whttp:method
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
162 const char *http_method = http__binding_verb;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
163 if ((*operation).whttp__method)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
164 http_method = (*operation).whttp__method;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
165 // /definitions/binding/operation/@wsoap:action
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
166 const char *soap__operation_action = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
167 if ((*operation).wsoap__action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
168 soap__operation_action = (*operation).wsoap__action;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
169 // /definitions/binding/operation/http:operation
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
170 http__operation *http__operation_ = (*operation).http__operation_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
171 // /definitions/binding/wsp:Policy and wsp:PolicyReference
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
172 const wsp__Policy *ext_operation_policy = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
173 if ((*operation).wsp__Policy_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
174 ext_operation_policy = (*operation).wsp__Policy_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
175 if ((*operation).wsp__PolicyReference_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
176 ext_operation_policy = (*operation).wsp__PolicyReference_->policyPtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
177 // /definitions/binding/operation/http:operation/@location
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
178 const char *http__operation_location = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
179 if (http__operation_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
180 http__operation_location = http__operation_->location;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
181 else if ((*operation).whttp__location)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
182 http__operation_location = (*operation).whttp__location;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
183 // /definitions/binding/operation/input and output
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
184 wsdl__ext_ioput *ext_input, *ext_output;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
185 // /definitions/portType/operation
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
186 if (wsdl__operation_ && wsdl__operation_->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
187 { bool reversed = false;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
188 wsdl__ioput *input = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
189 wsdl__ioput *output = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
190 // normalize input/output order for solicit-response operations
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
191 if (wsdl__operation_->__union1 == SOAP_UNION_wsdl__union_ioput_input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
192 input = wsdl__operation_->__ioput1.input;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
193 else if (wsdl__operation_->__union1 == SOAP_UNION_wsdl__union_ioput_output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
194 { reversed = true;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
195 input = wsdl__operation_->__ioput1.output;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
196 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
197 if (wsdl__operation_->__union2 == SOAP_UNION_wsdl__union_ioput_input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
198 { reversed = true;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
199 output = wsdl__operation_->__ioput2.input;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
200 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
201 else if (wsdl__operation_->__union2 == SOAP_UNION_wsdl__union_ioput_output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
202 output = wsdl__operation_->__ioput2.output;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
203 else // one input only or one output only (or none)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
204 { reversed = false;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
205 input = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
206 output = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
207 if (wsdl__operation_->__union1 == SOAP_UNION_wsdl__union_ioput_input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
208 input = wsdl__operation_->__ioput1.input;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
209 else if (wsdl__operation_->__union1 == SOAP_UNION_wsdl__union_ioput_output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
210 output = wsdl__operation_->__ioput1.output;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
211 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
212 if (!reversed)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
213 { ext_input = (*operation).input;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
214 ext_output = (*operation).output;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
215 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
216 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
217 { ext_input = (*operation).output;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
218 ext_output = (*operation).input;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
219 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
220 if ((http_method && !strcmp(http_method, "GET"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
221 || (wsdl__operation_->pattern && !strstr(wsdl__operation_->pattern, "in")))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
222 input = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
223 if (wsdl__operation_->pattern && !strstr(wsdl__operation_->pattern, "out"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
224 output = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
225 if (wsdl__operation_->pattern) // WSDL 2.0
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
226 { soap__operation_style = document;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
227 if (wsdl__operation_->style && !strcmp(wsdl__operation_->style, "http://www.w3.org/ns/wsdl/rpc"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
228 soap__operation_style = rpc;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
229 else if ((*binding).portTypePtr() && (*binding).portTypePtr()->styleDefault && !strcmp( (*binding).portTypePtr()->styleDefault, "http://www.w3.org/ns/wsdl/rpc"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
230 soap__operation_style = rpc;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
231 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
232 // /definitions/binding/wsp:Policy and wsp:PolicyReference
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
233 const wsp__Policy *operation_policy = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
234 if (wsdl__operation_->wsp__Policy_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
235 operation_policy = wsdl__operation_->wsp__Policy_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
236 if (wsdl__operation_->wsp__PolicyReference_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
237 operation_policy = wsdl__operation_->wsp__PolicyReference_->policyPtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
238 if (!Rflag && (http__operation_ || http__operation_location))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
239 { // skip WSDL REST HTTP operations
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
240 if (!Wflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
241 fprintf(stderr, "\nWarning: ignoring REST operation '%s' in binding '%s' (use option -R to enable REST)\n", wsdl__operation_->name, binding_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
242 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
243 else if (input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
244 { soap__body *input_body = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
245 mime__mimeXml *input_mime = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
246 mime__content *input_mime_content = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
247 if (!reversed && ext_input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
248 { input_body = ext_input->soap__body_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
249 input_mime = ext_input->mime__mimeXml_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
250 input_mime_content = ext_input->mime__content_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
251 if (ext_input->mime__multipartRelated_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
252 { for (vector<mime__part>::const_iterator part = ext_input->mime__multipartRelated_->part.begin(); part != ext_input->mime__multipartRelated_->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
253 if ((*part).soap__body_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
254 { input_body = (*part).soap__body_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
255 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
256 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
257 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
258 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
259 else if (ext_output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
260 { input_body = ext_output->soap__body_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
261 input_mime = ext_output->mime__mimeXml_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
262 input_mime_content = ext_output->mime__content_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
263 if (ext_output->mime__multipartRelated_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
264 { for (vector<mime__part>::const_iterator part = ext_output->mime__multipartRelated_->part.begin(); part != ext_output->mime__multipartRelated_->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
265 if ((*part).soap__body_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
266 { input_body = (*part).soap__body_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
267 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
268 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
269 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
270 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
271 if (wsdl__operation_->style && !strcmp(wsdl__operation_->style, "http://www.w3.org/ns/wsdl/style/iri"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
272 { input_mime_content = soap_new_mime__content(definitions.soap);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
273 input_mime_content->soap_default(definitions.soap);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
274 input_mime_content->type = (char*)"application/x-www-form-urlencoded";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
275 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
276 // MUST have an input binding, otherwise can't generate a service operation
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
277 if (input_body || input_mime || input_mime_content || input->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
278 { char *URI;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
279 if (input_body && soap__operation_style == rpc)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
280 URI = input_body->namespace_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
281 else if (binding_count == 1 || !service_prefix)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
282 URI = definitions.targetNamespace;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
283 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
284 { // multiple service bidings are used, each needs a unique new URI
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
285 URI = (char*)soap_malloc(definitions.soap, strlen(definitions.targetNamespace) + strlen(binding_name) + 2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
286 strcpy(URI, definitions.targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
287 if (*URI && URI[strlen(URI)-1] != '/')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
288 strcat(URI, "/");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
289 strcat(URI, binding_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
290 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
291 if (URI)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
292 { const char *prefix = types.nsprefix(service_prefix, URI);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
293 const char *name = types.aname(NULL, NULL, binding_name); // name of service is binding name
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
294 Service *service = services[prefix];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
295 if (!service)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
296 { service = services[prefix] = new Service();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
297 service->prefix = prefix;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
298 service->URI = urienc(definitions.soap, URI);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
299 service->name = name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
300 service->transport = soap__binding_transport;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
301 if ((*binding).portTypePtr() && (*binding).portTypePtr()->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
302 service->type = types.aname(NULL, NULL, (*binding).portTypePtr()->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
303 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
304 service->type = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
305 // collect faults (TODO: this is not used anywhere)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
306 for (vector<wsdl__ext_fault>::const_iterator fault = (*binding).fault.begin(); fault != (*binding).fault.end(); ++fault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
307 { Message *f = analyze_fault(definitions, service, *fault);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
308 if (f)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
309 service->fault[f->name] = f;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
310 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
311 // collect policies for the bindings
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
312 for (vector<wsp__Policy>::const_iterator p = (*binding).wsp__Policy_.begin(); p != (*binding).wsp__Policy_.end(); ++p)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
313 service->policy.push_back(&(*p));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
314 for (vector<wsp__PolicyReference>::const_iterator r = (*binding).wsp__PolicyReference_.begin(); r != (*binding).wsp__PolicyReference_.end(); ++r)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
315 service->policy.push_back((*r).policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
316 // collect policies for the service endpoints
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
317 for (vector<wsdl__service>::const_iterator s = definitions.service.begin(); s != definitions.service.end(); ++s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
318 { for (vector<wsp__Policy>::const_iterator p = (*s).wsp__Policy_.begin(); p != (*s).wsp__Policy_.end(); ++p)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
319 service->policy.push_back(&(*p));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
320 for (vector<wsp__PolicyReference>::const_iterator r = (*s).wsp__PolicyReference_.begin(); r != (*s).wsp__PolicyReference_.end(); ++r)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
321 service->policy.push_back((*r).policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
322 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
323 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
324 for (vector<wsdl__service>::const_iterator s = definitions.service.begin(); s != definitions.service.end(); ++s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
325 { for (vector<wsdl__port>::const_iterator port = (*s).port.begin(); port != (*s).port.end(); ++port)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
326 { if ((*port).bindingPtr() == &(*binding))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
327 { if ((*port).soap__address_ && (*port).soap__address_->location)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
328 service->location.insert(urienc(definitions.soap, (*port).soap__address_->location));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
329 if ((*port).wsa__EndpointReference && (*port).wsa__EndpointReference->Address)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
330 service->location.insert(urienc(definitions.soap, (*port).wsa__EndpointReference->Address));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
331 if ((*port).http__address_ && (*port).http__address_->location)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
332 service->location.insert(urienc(definitions.soap, (*port).http__address_->location));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
333 // collect service documentation
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
334 if ((*s).documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
335 service->service_documentation[(*service).name] = (*s).documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
336 if ((*port).documentation && (*port).name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
337 service->port_documentation[(*port).name] = (*port).documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
338 if (binding_documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
339 service->binding_documentation[binding_name] = binding_documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
340 // collect policies for the service and endpoints
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
341 if ((*port).wsp__Policy_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
342 service->policy.push_back((*port).wsp__Policy_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
343 if ((*port).wsp__PolicyReference_ && (*port).wsp__PolicyReference_->policyPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
344 service->policy.push_back((*port).wsp__PolicyReference_->policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
345 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
346 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
347 for (vector<wsdl__port>::const_iterator endpoint = (*s).endpoint.begin(); endpoint != (*s).endpoint.end(); ++endpoint)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
348 { if ((*endpoint).bindingPtr() == &(*binding))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
349 { if ((*endpoint).address)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
350 service->location.insert(urienc(definitions.soap, (*endpoint).address));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
351 if ((*endpoint).wsa__EndpointReference && (*endpoint).wsa__EndpointReference->Address)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
352 service->location.insert(urienc(definitions.soap, (*endpoint).wsa__EndpointReference->Address));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
353 if ((*endpoint).http__address_ && (*endpoint).http__address_->location)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
354 service->location.insert(urienc(definitions.soap, (*endpoint).http__address_->location));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
355 // TODO: locations need auth
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
356 // service->auth_scheme = (*endpoint).whttp__authenticationScheme;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
357 // service->auth_realm = (*endpoint).whttp__authenticationRealm;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
358 // collect service documentation
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
359 if ((*s).documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
360 service->service_documentation[(*service).name] = (*s).documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
361 if ((*endpoint).documentation && (*endpoint).name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
362 service->port_documentation[(*endpoint).name] = (*endpoint).documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
363 if (binding_documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
364 service->binding_documentation[binding_name] = binding_documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
365 // collect policies for the service and endpoints
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
366 if ((*endpoint).wsp__Policy_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
367 service->policy.push_back((*endpoint).wsp__Policy_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
368 if ((*endpoint).wsp__PolicyReference_ && (*endpoint).wsp__PolicyReference_->policyPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
369 service->policy.push_back((*endpoint).wsp__PolicyReference_->policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
370 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
371 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
372 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
373 Operation *op = new Operation();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
374 op->name = types.aname(NULL, NULL, wsdl__operation_->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
375 op->prefix = prefix;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
376 op->URI = urienc(definitions.soap, URI);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
377 op->style = soap__operation_style;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
378 op->mep = soap__operation_mep;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
379 if (soap__binding_transport
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
380 && (!strcmp(soap__binding_transport+strlen(soap__binding_transport)-4, "http")
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
381 || !strcmp(soap__binding_transport+strlen(soap__binding_transport)-5, "HTTP/")))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
382 { if ((op->mep && strstr(op->mep, "soap-response"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
383 || (http_method && !strcmp(http_method, "GET")))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
384 op->protocol = "SOAP-GET";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
385 else if (version == 1)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
386 op->protocol = "SOAP1.1";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
387 else if (version == 2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
388 op->protocol = "SOAP1.2";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
389 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
390 op->protocol = "SOAP";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
391 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
392 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
393 { if (http_method)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
394 op->protocol = http_method;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
395 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
396 op->protocol = "HTTP";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
397 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
398 op->documentation = wsdl__operation_->documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
399 op->operation_documentation = (*operation).documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
400 op->parameterOrder = wsdl__operation_->parameterOrder;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
401 if (http__operation_location)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
402 op->action = http__operation_location; // TODO: for now, store HTTP location in action
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
403 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
404 { op->action = soap__operation_action;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
405 if ((*operation).soap__operation_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
406 { if ((*operation).soap__operation_->soapActionRequired)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
407 op->action = (*operation).soap__operation_->soapAction;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
408 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
409 else if (version != 2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
410 op->action = "";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
411 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
412 if (operation_policy)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
413 op->policy.push_back(operation_policy);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
414 if (ext_operation_policy)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
415 op->policy.push_back(ext_operation_policy);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
416 op->input = new Message();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
417 op->input->name = wsdl__operation_->name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
418 if (input_body && soap__operation_style == rpc && !input_body->namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
419 { op->input->URI = "";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
420 fprintf(stderr, "\nError: no soap:body namespace attribute\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
421 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
422 else if (input_body)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
423 op->input->URI = urienc(definitions.soap, input_body->namespace_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
424 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
425 op->input->URI = service->URI;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
426 op->input->style = soap__operation_style;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
427 if (input_body)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
428 { op->input->use = input_body->use;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
429 op->input->encodingStyle = input_body->encodingStyle;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
430 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
431 if (input->wsa__Action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
432 op->input->action = input->wsa__Action;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
433 else if (input->wsam__Action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
434 op->input->action = input->wsam__Action;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
435 else if (op->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
436 op->input->action = op->action;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
437 else if (definitions.targetNamespace && (*binding).portTypePtr() && (*binding).portTypePtr()->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
438 { const char *name = input->name ? input->name : op->name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
439 char *tmp = (char*)soap_malloc(definitions.soap, strlen(definitions.targetNamespace) + strlen((*binding).portTypePtr()->name) + strlen(name) + 3);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
440 sprintf(tmp, "%s/%s/%s", definitions.targetNamespace, (*binding).portTypePtr()->name, name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
441 op->input->action = tmp;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
442 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
443 op->input->message = input->messagePtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
444 op->input->element = input->elementPtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
445 op->input->part = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
446 op->input->mustUnderstand = false;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
447 op->input->multipartRelated = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
448 op->input->content = input_mime_content;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
449 op->input->body_parts = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
450 op->input->layout = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
451 op->input->ext_documentation = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
452 if (ext_input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
453 { op->input->multipartRelated = ext_input->mime__multipartRelated_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
454 if (ext_input->mime__multipartRelated_ && !ext_input->mime__multipartRelated_->part.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
455 op->input->header = ext_input->mime__multipartRelated_->part.front().soap__header_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
456 else if (!ext_input->soap__header_.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
457 op->input->header = ext_input->soap__header_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
458 else if (!ext_input->wsoap__header_.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
459 op->input->wheader = ext_input->wsoap__header_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
460 if (ext_input->mime__multipartRelated_ && !ext_input->mime__multipartRelated_->part.empty() && ext_input->mime__multipartRelated_->part.front().soap__body_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
461 op->input->body_parts = ext_input->mime__multipartRelated_->part.front().soap__body_->parts;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
462 else if (input_body)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
463 op->input->body_parts = input_body->parts;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
464 if (ext_input->dime__message_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
465 op->input->layout = ext_input->dime__message_->layout;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
466 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
467 op->input->layout = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
468 op->input->ext_documentation = ext_input->documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
469 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
470 op->input->documentation = input->documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
471 // collect input message policies
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
472 if (op->input->message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
473 { for (vector<wsp__Policy>::const_iterator p = op->input->message->wsp__Policy_.begin(); p != op->input->message->wsp__Policy_.end(); ++p)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
474 op->input->policy.push_back(&(*p));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
475 for (vector<wsp__PolicyReference>::const_iterator r = op->input->message->wsp__PolicyReference_.begin(); r != op->input->message->wsp__PolicyReference_.end(); ++r)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
476 op->input->policy.push_back((*r).policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
477 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
478 if (input->wsp__Policy_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
479 op->input->policy.push_back(input->wsp__Policy_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
480 if (input->wsp__PolicyReference_ && input->wsp__PolicyReference_->policyPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
481 op->input->policy.push_back(input->wsp__PolicyReference_->policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
482 if (ext_input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
483 { if (ext_input->wsp__Policy_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
484 op->input->policy.push_back(ext_input->wsp__Policy_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
485 if (ext_input->wsp__PolicyReference_ && ext_input->wsp__PolicyReference_->policyPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
486 op->input->policy.push_back(ext_input->wsp__PolicyReference_->policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
487 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
488 if (soap__operation_style == document)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
489 op->input_name = types.oname("__", op->URI, op->input->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
490 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
491 op->input_name = types.oname(NULL, op->input->URI, op->input->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
492 if (output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
493 { soap__body *output_body = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
494 mime__mimeXml *output_mime = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
495 mime__content *output_mime_content = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
496 if (ext_output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
497 { output_body = ext_output->soap__body_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
498 output_mime = ext_output->mime__mimeXml_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
499 output_mime_content = ext_output->mime__content_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
500 if (ext_output->mime__multipartRelated_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
501 { for (vector<mime__part>::const_iterator part = ext_output->mime__multipartRelated_->part.begin(); part != ext_output->mime__multipartRelated_->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
502 if ((*part).soap__body_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
503 { output_body = (*part).soap__body_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
504 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
505 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
506 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
507 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
508 if (ext_output && ext_output->mime__content_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
509 { op->output = new Message();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
510 op->output->name = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
511 op->output->URI = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
512 op->output->style = soap__operation_style;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
513 op->output->use = literal;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
514 op->output->encodingStyle = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
515 op->output->action = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
516 op->output->body_parts = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
517 op->output->part = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
518 op->output->mustUnderstand = false;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
519 op->output->multipartRelated = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
520 op->output->content = output_mime_content;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
521 op->output->message = output->messagePtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
522 op->output->element = output->elementPtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
523 op->output->layout = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
524 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
525 else if (output_body || output_mime || output_mime_content || output->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
526 { op->output = new Message();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
527 op->output->name = wsdl__operation_->name; // RPC uses operation/@name with suffix 'Response' as set below
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
528 op->output->style = soap__operation_style;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
529 if (output_body)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
530 { op->output->use = output_body->use;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
531 // the code below is a hack around the RPC encoded response message element tag mismatch with Axis:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
532 if (!output_body->namespace_ || output_body->use == encoded)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
533 op->output->URI = op->input->URI; // encoded seems (?) to require the request's namespace
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
534 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
535 op->output->URI = urienc(definitions.soap, output_body->namespace_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
536 op->output->encodingStyle = output_body->encodingStyle;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
537 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
538 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
539 op->output->URI = service->URI;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
540 if (output->wsa__Action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
541 op->output->action = output->wsa__Action;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
542 else if (output->wsam__Action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
543 op->output->action = output->wsam__Action;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
544 else if (http__operation_location)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
545 op->output->action = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
546 else if (op->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
547 { const char *name = op->action;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
548 char *tmp = (char*)soap_malloc(definitions.soap, strlen(name) + 9);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
549 strcpy(tmp, name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
550 strcat(tmp, "Response");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
551 op->output->action = tmp;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
552 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
553 else if (definitions.targetNamespace && (*binding).portTypePtr() && (*binding).portTypePtr()->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
554 { const char *name = output->name ? output->name : op->name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
555 char *tmp = (char*)soap_malloc(definitions.soap, strlen(definitions.targetNamespace) + strlen((*binding).portTypePtr()->name) + strlen(name) + 11);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
556 sprintf(tmp, "%s/%s/%s%s", definitions.targetNamespace, (*binding).portTypePtr()->name, name, output->name ? "" : "Response");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
557 op->output->action = tmp;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
558 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
559 op->output->message = output->messagePtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
560 op->output->element = output->elementPtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
561 op->output->part = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
562 op->output->content = output_mime_content;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
563 op->output->body_parts = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
564 op->output->layout = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
565 op->output->ext_documentation = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
566 op->output->mustUnderstand = false;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
567 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
568 if (ext_output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
569 { op->output->multipartRelated = ext_output->mime__multipartRelated_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
570 if (ext_output->mime__multipartRelated_ && !ext_output->mime__multipartRelated_->part.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
571 op->output->header = ext_output->mime__multipartRelated_->part.front().soap__header_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
572 else if (!ext_output->soap__header_.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
573 op->output->header = ext_output->soap__header_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
574 else if (!ext_output->wsoap__header_.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
575 op->output->wheader = ext_output->wsoap__header_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
576 if (ext_output->mime__multipartRelated_ && !ext_output->mime__multipartRelated_->part.empty() && ext_output->mime__multipartRelated_->part.front().soap__body_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
577 op->output->body_parts = ext_output->mime__multipartRelated_->part.front().soap__body_->parts;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
578 else if (output_body)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
579 op->output->body_parts = output_body->parts;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
580 if (ext_output->dime__message_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
581 op->output->layout = ext_output->dime__message_->layout;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
582 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
583 op->output->layout = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
584 op->output->ext_documentation = ext_output->documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
585 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
586 if (op->output->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
587 { char *s = (char*)soap_malloc(definitions.soap, strlen(op->output->name) + 9);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
588 strcpy(s, op->output->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
589 strcat(s, "Response");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
590 if (soap__operation_style == document)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
591 op->output_name = types.oname("__", op->URI, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
592 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
593 op->output_name = types.oname(NULL, op->output->URI, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
594 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
595 op->output->documentation = output->documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
596 // collect output message policies
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
597 if (op->output->message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
598 { for (vector<wsp__Policy>::const_iterator p = op->output->message->wsp__Policy_.begin(); p != op->output->message->wsp__Policy_.end(); ++p)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
599 op->output->policy.push_back(&(*p));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
600 for (vector<wsp__PolicyReference>::const_iterator r = op->output->message->wsp__PolicyReference_.begin(); r != op->output->message->wsp__PolicyReference_.end(); ++r)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
601 op->output->policy.push_back((*r).policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
602 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
603 if (output->wsp__Policy_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
604 op->output->policy.push_back(output->wsp__Policy_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
605 if (output->wsp__PolicyReference_ && output->wsp__PolicyReference_->policyPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
606 op->output->policy.push_back(output->wsp__PolicyReference_->policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
607 if (ext_output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
608 { if (ext_output->wsp__Policy_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
609 op->output->policy.push_back(ext_output->wsp__Policy_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
610 if (ext_output->wsp__PolicyReference_ && ext_output->wsp__PolicyReference_->policyPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
611 op->output->policy.push_back(ext_output->wsp__PolicyReference_->policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
612 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
613 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
614 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
615 { op->output_name = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
616 op->output = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
617 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
618 analyze_headers(definitions, service, ext_input, ext_output);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
619 analyze_faults(definitions, service, op, operation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
620 service->operation.push_back(op);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
621 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
622 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
623 { if (!Wflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
624 fprintf(stderr, "\nWarning: no SOAP RPC operation namespace, operations will be ignored\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
625 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
626 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
627 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
628 fprintf(stderr, "\nError: no wsdl:definitions/binding/operation/input\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
629 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
630 else if (output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
631 { // This part is similar to the previous clause, limited to one-way output operations
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
632 soap__body *output_body = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
633 mime__mimeXml *output_mime = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
634 mime__content *output_mime_content = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
635 if (!reversed && ext_output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
636 { output_body = ext_output->soap__body_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
637 output_mime = ext_output->mime__mimeXml_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
638 output_mime_content = ext_output->mime__content_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
639 if (ext_output->mime__multipartRelated_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
640 { for (vector<mime__part>::const_iterator part = ext_output->mime__multipartRelated_->part.begin(); part != ext_output->mime__multipartRelated_->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
641 if ((*part).soap__body_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
642 { output_body = (*part).soap__body_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
643 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
644 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
645 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
646 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
647 else if (ext_input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
648 { output_body = ext_input->soap__body_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
649 output_mime = ext_input->mime__mimeXml_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
650 output_mime_content = ext_input->mime__content_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
651 if (ext_input->mime__multipartRelated_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
652 { for (vector<mime__part>::const_iterator part = ext_input->mime__multipartRelated_->part.begin(); part != ext_input->mime__multipartRelated_->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
653 if ((*part).soap__body_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
654 { output_body = (*part).soap__body_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
655 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
656 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
657 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
658 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
659 if (wsdl__operation_->style && !strcmp(wsdl__operation_->style, "http://www.w3.org/ns/wsdl/style/iri"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
660 { output_mime_content = soap_new_mime__content(definitions.soap);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
661 output_mime_content->soap_default(definitions.soap);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
662 output_mime_content->type = (char*)"application/x-www-form-urlencoded";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
663 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
664 if (output_body || output_mime || output_mime_content || output->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
665 { char *URI;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
666 if (output_body && soap__operation_style == rpc)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
667 URI = output_body->namespace_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
668 else if (binding_count == 1 || !service_prefix)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
669 URI = definitions.targetNamespace;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
670 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
671 { // multiple service bidings are used, each needs a unique new URI
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
672 URI = (char*)soap_malloc(definitions.soap, strlen(definitions.targetNamespace) + strlen(binding_name) + 2);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
673 strcpy(URI, definitions.targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
674 if (*URI && URI[strlen(URI)-1] != '/')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
675 strcat(URI, "/");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
676 strcat(URI, binding_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
677 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
678 if (URI)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
679 { const char *prefix = types.nsprefix(service_prefix, URI);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
680 const char *name = types.aname(NULL, NULL, binding_name); // name of service is binding name
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
681 Service *service = services[prefix];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
682 if (!service)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
683 { service = services[prefix] = new Service();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
684 service->prefix = prefix;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
685 service->URI = urienc(definitions.soap, URI);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
686 service->name = name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
687 service->transport = soap__binding_transport;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
688 if ((*binding).portTypePtr() && (*binding).portTypePtr()->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
689 service->type = types.aname(NULL, NULL, (*binding).portTypePtr()->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
690 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
691 service->type = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
692 // collect faults (TODO: this is not used anywhere)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
693 for (vector<wsdl__ext_fault>::const_iterator fault = (*binding).fault.begin(); fault != (*binding).fault.end(); ++fault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
694 { Message *f = analyze_fault(definitions, service, *fault);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
695 if (f)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
696 service->fault[f->name] = f;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
697 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
698 // collect policies for the bindings
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
699 for (vector<wsp__Policy>::const_iterator p = (*binding).wsp__Policy_.begin(); p != (*binding).wsp__Policy_.end(); ++p)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
700 service->policy.push_back(&(*p));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
701 for (vector<wsp__PolicyReference>::const_iterator r = (*binding).wsp__PolicyReference_.begin(); r != (*binding).wsp__PolicyReference_.end(); ++r)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
702 service->policy.push_back((*r).policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
703 // collect policies for the service endpoints
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
704 for (vector<wsdl__service>::const_iterator s = definitions.service.begin(); s != definitions.service.end(); ++s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
705 { for (vector<wsp__Policy>::const_iterator p = (*s).wsp__Policy_.begin(); p != (*s).wsp__Policy_.end(); ++p)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
706 service->policy.push_back(&(*p));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
707 for (vector<wsp__PolicyReference>::const_iterator r = (*s).wsp__PolicyReference_.begin(); r != (*s).wsp__PolicyReference_.end(); ++r)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
708 service->policy.push_back((*r).policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
709 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
710 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
711 for (vector<wsdl__service>::const_iterator s = definitions.service.begin(); s != definitions.service.end(); ++s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
712 { for (vector<wsdl__port>::const_iterator port = (*s).port.begin(); port != (*s).port.end(); ++port)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
713 { if ((*port).bindingPtr() == &(*binding))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
714 { if ((*port).soap__address_ && (*port).soap__address_->location)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
715 service->location.insert(urienc(definitions.soap, (*port).soap__address_->location));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
716 else if ((*port).wsa__EndpointReference && (*port).wsa__EndpointReference->Address)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
717 service->location.insert(urienc(definitions.soap, (*port).wsa__EndpointReference->Address));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
718 // TODO: HTTP address for HTTP operations
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
719 // if ((*port).http__address_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
720 // http__address_location = http__address_->location;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
721 // collect service documentation
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
722 if ((*s).documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
723 service->service_documentation[(*service).name] = (*s).documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
724 if ((*port).documentation && (*port).name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
725 service->port_documentation[(*port).name] = (*port).documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
726 if (binding_documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
727 service->binding_documentation[binding_name] = binding_documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
728 // collect policies for the service and endpoints
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
729 if ((*port).wsp__Policy_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
730 service->policy.push_back((*port).wsp__Policy_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
731 if ((*port).wsp__PolicyReference_ && (*port).wsp__PolicyReference_->policyPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
732 service->policy.push_back((*port).wsp__PolicyReference_->policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
733 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
734 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
735 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
736 Operation *op = new Operation();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
737 op->input_name = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
738 op->input = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
739 op->name = types.aname(NULL, NULL, wsdl__operation_->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
740 op->prefix = prefix;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
741 op->URI = urienc(definitions.soap, URI);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
742 op->style = soap__operation_style;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
743 op->mep = soap__operation_mep;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
744 if (soap__binding_transport
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
745 && (!strcmp(soap__binding_transport+strlen(soap__binding_transport)-4, "http")
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
746 || !strcmp(soap__binding_transport+strlen(soap__binding_transport)-5, "HTTP/")))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
747 { if (op->mep && strstr(op->mep, "soap-response")
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
748 || (http_method && !strcmp(http_method, "GET")))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
749 op->protocol = "SOAP-GET";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
750 else if (version == 1)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
751 op->protocol = "SOAP1.1";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
752 else if (version == 2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
753 op->protocol = "SOAP1.2";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
754 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
755 op->protocol = "SOAP";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
756 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
757 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
758 { if (http_method)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
759 op->protocol = http_method;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
760 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
761 op->protocol = "HTTP";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
762 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
763 op->documentation = wsdl__operation_->documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
764 op->operation_documentation = (*operation).documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
765 op->parameterOrder = wsdl__operation_->parameterOrder;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
766 if (http__operation_location)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
767 op->action = http__operation_location; // TODO: for now, store HTTP location in action
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
768 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
769 { op->action = soap__operation_action;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
770 if ((*operation).soap__operation_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
771 { if ((*operation).soap__operation_->soapActionRequired)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
772 op->action = (*operation).soap__operation_->soapAction;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
773 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
774 else if (version != 2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
775 op->action = "";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
776 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
777 if (operation_policy)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
778 op->policy.push_back(operation_policy);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
779 if (ext_operation_policy)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
780 op->policy.push_back(ext_operation_policy);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
781 op->output = new Message(); // one-way output operation
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
782 op->output->name = wsdl__operation_->name; // RPC uses operation/@name
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
783 if (output_body && soap__operation_style == rpc && !output_body->namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
784 { op->output->URI = "";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
785 fprintf(stderr, "\nError: no soap:body namespace attribute\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
786 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
787 else if (output_body)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
788 op->output->URI = urienc(definitions.soap, output_body->namespace_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
789 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
790 op->output->URI = service->URI;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
791 op->output->style = soap__operation_style;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
792 if (output_body)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
793 { op->output->use = output_body->use;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
794 op->output->encodingStyle = output_body->encodingStyle;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
795 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
796 if (output->wsa__Action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
797 op->output->action = output->wsa__Action;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
798 else if (output->wsam__Action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
799 op->output->action = output->wsam__Action;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
800 else if (op->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
801 op->output->action = op->action;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
802 else if (definitions.targetNamespace && (*binding).portTypePtr() && (*binding).portTypePtr()->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
803 { const char *name = output->name ? output->name : op->name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
804 char *tmp = (char*)soap_malloc(definitions.soap, strlen(definitions.targetNamespace) + strlen((*binding).portTypePtr()->name) + strlen(name) + 3);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
805 sprintf(tmp, "%s/%s/%s", definitions.targetNamespace, (*binding).portTypePtr()->name, name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
806 op->output->action = tmp;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
807 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
808 op->output->message = output->messagePtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
809 op->output->element = output->elementPtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
810 op->output->part = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
811 op->output->mustUnderstand = false;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
812 op->output->multipartRelated = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
813 op->output->content = output_mime_content;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
814 op->output->body_parts = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
815 op->output->layout = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
816 op->output->ext_documentation = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
817 if (ext_output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
818 { op->output->multipartRelated = ext_output->mime__multipartRelated_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
819 if (ext_output->mime__multipartRelated_ && !ext_output->mime__multipartRelated_->part.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
820 op->output->header = ext_output->mime__multipartRelated_->part.front().soap__header_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
821 else if (!ext_output->soap__header_.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
822 op->output->header = ext_output->soap__header_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
823 else if (!ext_output->wsoap__header_.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
824 op->output->wheader = ext_output->wsoap__header_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
825 if (ext_output->mime__multipartRelated_ && !ext_output->mime__multipartRelated_->part.empty() && ext_output->mime__multipartRelated_->part.front().soap__body_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
826 op->output->body_parts = ext_output->mime__multipartRelated_->part.front().soap__body_->parts;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
827 else if (output_body)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
828 op->output->body_parts = output_body->parts;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
829 if (ext_output->dime__message_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
830 op->output->layout = ext_output->dime__message_->layout;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
831 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
832 op->output->layout = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
833 op->output->ext_documentation = ext_output->documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
834 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
835 op->output->documentation = output->documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
836 // collect output message policies
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
837 if (op->output->message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
838 { for (vector<wsp__Policy>::const_iterator p = op->output->message->wsp__Policy_.begin(); p != op->output->message->wsp__Policy_.end(); ++p)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
839 op->output->policy.push_back(&(*p));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
840 for (vector<wsp__PolicyReference>::const_iterator r = op->output->message->wsp__PolicyReference_.begin(); r != op->output->message->wsp__PolicyReference_.end(); ++r)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
841 op->output->policy.push_back((*r).policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
842 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
843 if (output->wsp__Policy_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
844 op->output->policy.push_back(output->wsp__Policy_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
845 if (output->wsp__PolicyReference_ && output->wsp__PolicyReference_->policyPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
846 op->output->policy.push_back(output->wsp__PolicyReference_->policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
847 if (ext_output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
848 { if (ext_output->wsp__Policy_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
849 op->output->policy.push_back(ext_output->wsp__Policy_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
850 if (ext_output->wsp__PolicyReference_ && ext_output->wsp__PolicyReference_->policyPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
851 op->output->policy.push_back(ext_output->wsp__PolicyReference_->policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
852 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
853 if (soap__operation_style == document)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
854 op->input_name = types.oname("__", op->URI, op->output->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
855 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
856 op->input_name = types.oname(NULL, op->output->URI, op->output->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
857 char *s = (char*)soap_malloc(definitions.soap, strlen(op->output->name) + 9);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
858 strcpy(s, op->output->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
859 strcat(s, "Response");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
860 if (soap__operation_style == document)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
861 op->output_name = types.oname("__", op->URI, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
862 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
863 op->output_name = types.oname(NULL, op->output->URI, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
864 analyze_headers(definitions, service, ext_input, ext_output);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
865 analyze_faults(definitions, service, op, operation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
866 service->operation.push_back(op);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
867 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
868 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
869 { if (!Wflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
870 fprintf(stderr, "\nWarning: no SOAP RPC operation namespace, operations will be ignored\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
871 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
872 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
873 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
874 fprintf(stderr, "\nError: no wsdl:definitions/binding/operation/output\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
875 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
876 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
877 fprintf(stderr, "\nError: no wsdl:definitions/portType/operation/input and output\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
878 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
879 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
880 fprintf(stderr, "\nError: no wsdl:definitions/portType/operation\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
881 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
882 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
883 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
884
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
885 void Definitions::analyze_headers(const wsdl__definitions &definitions, Service *service, wsdl__ext_ioput *ext_input, wsdl__ext_ioput *ext_output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
886 { // collect input headers and headerfaults
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
887 if (ext_input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
888 { const vector<soap__header> *soap__header_ = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
889 // check if soap header is in mime:multipartRelated
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
890 if (ext_input->mime__multipartRelated_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
891 { for (vector<mime__part>::const_iterator part = ext_input->mime__multipartRelated_->part.begin(); part != ext_input->mime__multipartRelated_->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
892 if (!(*part).soap__header_.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
893 { soap__header_ = &(*part).soap__header_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
894 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
895 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
896 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
897 if (!soap__header_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
898 soap__header_ = &ext_input->soap__header_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
899 for (vector<soap__header>::const_iterator header = soap__header_->begin(); header != soap__header_->end(); ++header)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
900 { Message *h = new Message();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
901 h->message = (*header).messagePtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
902 h->element = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
903 h->body_parts = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
904 h->part = (*header).partPtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
905 h->URI = urienc(definitions.soap, (*header).namespace_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
906 if (h->part && h->part->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
907 h->name = types.aname(NULL, NULL, h->part->element);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
908 else if (h->URI && h->part && h->part->name && h->part->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
909 h->name = types.aname(NULL, h->URI, h->part->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
910 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
911 { fprintf(stderr, "\nError in SOAP Header part definition: input part '%s' missing?\n", h->part && h->part->name ? h->part->name : "?");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
912 h->name = "";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
913 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
914 h->encodingStyle = (*header).encodingStyle;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
915 h->style = document; // irrelevant
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
916 h->use = (*header).use;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
917 h->mustUnderstand = true;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
918 h->multipartRelated = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
919 h->content = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
920 h->layout = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
921 h->ext_documentation = NULL; // TODO: add document content
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
922 h->documentation = NULL; // TODO: add document content
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
923 service->header[h->name] = h;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
924 for (vector<soap__headerfault>::const_iterator headerfault = (*header).headerfault.begin(); headerfault != (*header).headerfault.end(); ++headerfault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
925 { // TODO: headerfault processing. This is practically never used...
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
926 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
927 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
928 for (vector<wsoap__header>::const_iterator wheader = ext_input->wsoap__header_.begin(); wheader != ext_input->wsoap__header_.end(); ++wheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
929 { Message *h = new Message();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
930 h->message = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
931 h->element = (*wheader).elementPtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
932 h->body_parts = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
933 h->part = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
934 h->URI = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
935 h->mustUnderstand = (*wheader).mustUnderstand_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
936 h->name = types.aname(NULL, NULL, (*wheader).element);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
937 h->encodingStyle = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
938 h->style = document; // irrelevant
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
939 h->use = literal;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
940 h->multipartRelated = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
941 h->content = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
942 h->layout = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
943 h->ext_documentation = NULL; // TODO: add document content
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
944 h->documentation = NULL; // TODO: add document content
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
945 service->header[h->name] = h;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
946 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
947 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
948 // collect output headers and headerfaults
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
949 if (ext_output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
950 { const vector<soap__header> *soap__header_ = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
951 // check if soap header is in mime:multipartRelated
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
952 if (ext_output->mime__multipartRelated_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
953 { for (vector<mime__part>::const_iterator part = ext_output->mime__multipartRelated_->part.begin(); part != ext_output->mime__multipartRelated_->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
954 if (!(*part).soap__header_.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
955 { soap__header_ = &(*part).soap__header_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
956 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
957 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
958 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
959 if (!soap__header_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
960 soap__header_ = &ext_output->soap__header_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
961 for (vector<soap__header>::const_iterator header = soap__header_->begin(); header != soap__header_->end(); ++header)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
962 { Message *h = new Message();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
963 h->message = (*header).messagePtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
964 h->element = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
965 h->body_parts = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
966 h->part = (*header).partPtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
967 h->URI = urienc(definitions.soap, (*header).namespace_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
968 if (h->part && h->part->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
969 h->name = types.aname(NULL, NULL, h->part->element);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
970 else if (h->URI && h->part && h->part->name && h->part->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
971 h->name = types.aname(NULL, h->URI, h->part->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
972 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
973 { fprintf(stderr, "\nError in SOAP Header part definition: output part '%s' missing?\n", h->part && h->part->name ? h->part->name : "?");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
974 h->name = "";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
975 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
976 h->encodingStyle = (*header).encodingStyle;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
977 h->style = document; // irrelevant
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
978 h->use = (*header).use;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
979 h->mustUnderstand = false;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
980 h->multipartRelated = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
981 h->content = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
982 h->layout = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
983 h->ext_documentation = NULL; // TODO: add document content?
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
984 h->documentation = NULL; // TODO: add document content?
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
985 service->header[h->name] = h;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
986 for (vector<soap__headerfault>::const_iterator headerfault = (*header).headerfault.begin(); headerfault != (*header).headerfault.end(); ++headerfault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
987 { // TODO: headerfault processing. This is practically never used...
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
988 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
989 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
990 for (vector<wsoap__header>::const_iterator wheader = ext_output->wsoap__header_.begin(); wheader != ext_output->wsoap__header_.end(); ++wheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
991 { Message *h = new Message();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
992 h->message = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
993 h->element = (*wheader).elementPtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
994 h->body_parts = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
995 h->part = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
996 h->URI = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
997 h->mustUnderstand = (*wheader).mustUnderstand_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
998 h->name = types.aname(NULL, NULL, (*wheader).element);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
999 h->encodingStyle = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1000 h->style = document; // irrelevant
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1001 h->use = literal;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1002 h->multipartRelated = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1003 h->content = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1004 h->layout = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1005 h->ext_documentation = NULL; // TODO: add document content
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1006 h->documentation = NULL; // TODO: add document content
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1007 service->header[h->name] = h;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1008 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1009 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1010 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1011
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1012 void Definitions::analyze_faults(const wsdl__definitions &definitions, Service *service, Operation *op, vector<wsdl__ext_operation>::const_iterator& operation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1013 { for (vector<wsdl__ext_fault>::const_iterator fault = (*operation).fault.begin(); fault != (*operation).fault.end(); ++fault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1014 { Message *f = analyze_fault(definitions, service, *fault);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1015 if (f)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1016 { op->outfault.push_back(f);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1017 service->fault[f->name] = f;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1018 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1019 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1020 for (vector<wsdl__ext_fault>::const_iterator infault = (*operation).infault.begin(); infault != (*operation).infault.end(); ++infault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1021 { Message *f = analyze_fault(definitions, service, *infault);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1022 if (f)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1023 { op->infault.push_back(f);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1024 service->fault[f->name] = f;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1025 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1026 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1027 for (vector<wsdl__ext_fault>::const_iterator outfault = (*operation).outfault.begin(); outfault != (*operation).outfault.end(); ++outfault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1028 { Message *f = analyze_fault(definitions, service, *outfault);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1029 if (f)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1030 { op->outfault.push_back(f);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1031 service->fault[f->name] = f;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1032 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1033 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1034 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1035
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1036 Message *Definitions::analyze_fault(const wsdl__definitions &definitions, Service *service, const wsdl__ext_fault &ext_fault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1037 { Message *f = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1038 const wsdl__fault *fault = ext_fault.faultPtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1039 if (fault && (fault->messagePtr() || fault->elementPtr()))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1040 { f = new Message();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1041 f->message = fault->messagePtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1042 f->element = fault->elementPtr();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1043 f->body_parts = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1044 f->part = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1045 f->encodingStyle = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1046 if (ext_fault.soap__fault_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1047 f->encodingStyle = ext_fault.soap__fault_->encodingStyle;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1048 f->action = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1049 if (fault->wsa__Action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1050 f->action = fault->wsa__Action;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1051 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1052 f->action = fault->wsam__Action;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1053 if (ext_fault.soap__fault_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1054 f->URI = ext_fault.soap__fault_->namespace_;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1055 else if (f->element && f->element->schemaPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1056 f->URI = f->element->schemaPtr()->targetNamespace;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1057 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1058 f->URI = service->URI; // must have a unique URI
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1059 f->style = document; // irrelevant
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1060 f->use = literal;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1061 if (ext_fault.soap__fault_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1062 f->use = ext_fault.soap__fault_->use;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1063 if (ext_fault.wsoap__code)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1064 { char *s = (char*)soap_malloc(definitions.soap, 80 + strlen(ext_fault.wsoap__code) + (ext_fault.wsoap__subcodes ? strlen(ext_fault.wsoap__subcodes) : 0));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1065 sprintf(s, "\"%s\" with subcodes \"%s\"", ext_fault.wsoap__code, ext_fault.wsoap__subcodes ? ext_fault.wsoap__subcodes : "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1066 f->body_parts = s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1067 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1068 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1069 f->ext_documentation = ext_fault.documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1070 f->mustUnderstand = false;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1071 f->multipartRelated = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1072 f->content = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1073 f->layout = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1074 if (f->message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1075 { f->name = types.aname("_", f->URI, f->message->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1076 f->documentation = f->message->documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1077 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1078 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1079 { f->name = types.aname(NULL, f->URI, fault->element);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1080 f->documentation = fault->documentation;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1081 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1082 // collect fault message policies
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1083 if (fault->wsp__Policy_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1084 f->policy.push_back(fault->wsp__Policy_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1085 if (fault->wsp__PolicyReference_ && fault->wsp__PolicyReference_->policyPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1086 f->policy.push_back(fault->wsp__PolicyReference_->policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1087 if (ext_fault.wsp__Policy_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1088 f->policy.push_back(ext_fault.wsp__Policy_);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1089 if (ext_fault.wsp__PolicyReference_ && ext_fault.wsp__PolicyReference_->policyPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1090 f->policy.push_back(ext_fault.wsp__PolicyReference_->policyPtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1091 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1092 else if (ext_fault.soap__fault_ && ext_fault.soap__fault_->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1093 fprintf(stderr, "\nError: no wsdl:definitions/binding/operation/fault/soap:fault '%s'\n", ext_fault.soap__fault_->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1094 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1095 fprintf(stderr, "\nError: no wsdl:definitions/binding/operation/fault/soap:fault\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1096 return f;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1097 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1098
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1099 void Definitions::compile(const wsdl__definitions& definitions)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1100 { // compile the definitions and generate gSOAP header file
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1101 const char *defs;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1102 if (definitions.name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1103 defs = types.aname(NULL, NULL, definitions.name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1104 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1105 defs = "Service";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1106 ident();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1107 fprintf(stream, "/** @page page_notes Usage Notes\n\nNOTE:\n\n - Run soapcpp2 on %s to generate the SOAP/XML processing logic.\n Use soapcpp2 -I to specify paths for #import\n To build with STL, 'stlvector.h' is imported from 'import' dir in package.\n Use soapcpp2 -j to generate improved proxy and server classes.\n - Use wsdl2h -c and -s to generate pure C code or C++ code without STL.\n - Use 'typemap.dat' to control namespace bindings and type mappings.\n It is strongly recommended to customize the names of the namespace prefixes\n generated by wsdl2h. To do so, modify the prefix bindings in the Namespaces\n section below and add the modified lines to 'typemap.dat' to rerun wsdl2h.\n - Use Doxygen (www.doxygen.org) on this file to generate documentation.\n - Use wsdl2h -R to generate REST operations.\n - Use wsdl2h -nname to use name as the base namespace prefix instead of 'ns'.\n - Use wsdl2h -Nname for service prefix and produce multiple service bindings\n - Use wsdl2h -d to enable DOM support for xsd:anyType.\n - Use wsdl2h -g to auto-generate readers and writers for root elements.\n - Use wsdl2h -b to auto-generate bi-directional operations (duplex ops).\n - Struct/class members serialized as XML attributes are annotated with a '@'.\n - Struct/class members that have a special role are annotated with a '$'.\n\nWARNING:\n\n DO NOT INCLUDE THIS ANNOTATED FILE DIRECTLY IN YOUR PROJECT SOURCE CODE.\n USE THE FILES GENERATED BY soapcpp2 FOR YOUR PROJECT'S SOURCE CODE:\n THE soapStub.h FILE CONTAINS THIS CONTENT WITHOUT ANNOTATIONS.\n\n", outfile?outfile:"this file");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1108 fprintf(stream, "LICENSE:\n\n@verbatim\n%s@endverbatim\n\n*/\n\n", licensenotice);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1109 // gsoap compiler options: 'w' disables WSDL/schema output to avoid file collisions
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1110 if (cflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1111 fprintf(stream, "\n//gsoapopt cw\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1112 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1113 fprintf(stream, "\n//gsoapopt w\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1114 banner("Definitions", definitions.targetNamespace?definitions.targetNamespace:"targetNamespace");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1115 // copy documentation from WSDL definitions
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1116 if (definitions.documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1117 { fprintf(stream, "/* WSDL Documentation:\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1118 text(definitions.documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1119 fprintf(stream, "*/\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1120 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1121 if (definitions.version)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1122 { banner("Version", definitions.version);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1123 fprintf(stream, "#define SOAP_WSDL_VERSION \"%s\"\n", definitions.version);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1124 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1125 banner("Import");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1126 if (dflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1127 { fprintf(stream, "\n// dom.h declares the DOM xsd__anyType object (compiler and link with dom.cpp)\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1128 fprintf(stream, "#import \"dom.h\"\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1129 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1130 if (!cflag && !sflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1131 { fprintf(stream, "\n// STL vector containers (use option -s to remove STL dependency)\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1132 fprintf(stream, "#import \"stlvector.h\"\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1133 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1134 if (mflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1135 { fprintf(stream, "#import \"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1136 fprintf(stream, "xsd.h\"\t// import primitive XSD types.\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1137 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1138 for (SetOfString::const_iterator u = exturis.begin(); u != exturis.end(); ++u)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1139 { bool found = false;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1140 size_t n = strlen(*u);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1141 for (SetOfString::const_iterator i = definitions.builtinTypes().begin(); i != definitions.builtinTypes().end(); ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1142 { if (**i == '"' && !strncmp(*u, *i + 1, n) && (*i)[n+1] == '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1143 { found = true;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1144 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1145 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1146 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1147 if (!found)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1148 { for (SetOfString::const_iterator j = definitions.builtinElements().begin(); j != definitions.builtinElements().end(); ++j)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1149 { if (**j == '"' && !strncmp(*u, *j + 1, n) && (*j)[n+1] == '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1150 { found = true;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1151 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1152 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1153 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1154 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1155 if (!found)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1156 { for (SetOfString::const_iterator k = definitions.builtinAttributes().begin(); k != definitions.builtinAttributes().end(); ++k)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1157 { if (**k == '"' && !strncmp(*u, *k + 1, n) && (*k)[n+1] == '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1158 { found = true;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1159 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1160 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1161 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1162 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1163 if (found)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1164 { if (vflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1165 fprintf(stderr, "import %s\n", *u);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1166 fprintf(stream, "#import \"%s.h\"\t// %s = <%s>\n", types.nsprefix(NULL, *u), types.nsprefix(NULL, *u), *u);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1167 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1168 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1169 banner("Schema Namespaces");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1170 // Determine if bindings use SOAP 1.2
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1171 soap12 = false;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1172 for (Namespace *p = definitions.soap->local_namespaces; p && p->id; p++)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1173 { if (p->out && !strcmp(p->id, "soap") && !strcmp(p->out, "http://schemas.xmlsoap.org/wsdl/soap12/"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1174 { soap12 = true;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1175 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1176 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1177 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1178 if (definitions.types)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1179 { fprintf(stream, "\n/* NOTE:\n\nIt is strongly recommended to customize the names of the namespace prefixes\ngenerated by wsdl2h. To do so, modify the prefix bindings below and add the\nmodified lines to typemap.dat to rerun wsdl2h:\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1180 if (definitions.targetNamespace && *definitions.targetNamespace)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1181 fprintf(stream, "%s = \"%s\"\n", types.nsprefix(service_prefix, definitions.targetNamespace), definitions.targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1182 for (vector<xs__schema*>::const_iterator schema1 = definitions.types->xs__schema_.begin(); schema1 != definitions.types->xs__schema_.end(); ++schema1)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1183 if (!definitions.targetNamespace || strcmp((*schema1)->targetNamespace, definitions.targetNamespace))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1184 fprintf(stream, "%s = \"%s\"\n", types.nsprefix(NULL, (*schema1)->targetNamespace), (*schema1)->targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1185 fprintf(stream, "\n*/\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1186 for (vector<xs__schema*>::const_iterator schema2 = definitions.types->xs__schema_.begin(); schema2 != definitions.types->xs__schema_.end(); ++schema2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1187 { const char *t = types.nsprefix(NULL, (*schema2)->targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1188 fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1189 types.document((*schema2)->annotation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1190 fprintf(stream, "#define SOAP_NAMESPACE_OF_%s\t\"%s\"\n", types.aname(NULL, NULL, t), urienc(definitions.soap, (*schema2)->targetNamespace));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1191 fprintf(stream, schemaformat, t, "namespace", urienc(definitions.soap, (*schema2)->targetNamespace));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1192 if ((*schema2)->elementFormDefault == (*schema2)->attributeFormDefault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1193 fprintf(stream, schemaformat, types.nsprefix(NULL, (*schema2)->targetNamespace), "form", (*schema2)->elementFormDefault == qualified ? "qualified" : "unqualified");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1194 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1195 { fprintf(stream, schemaformat, types.nsprefix(NULL, (*schema2)->targetNamespace), "elementForm", (*schema2)->elementFormDefault == qualified ? "qualified" : "unqualified");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1196 fprintf(stream, schemaformat, types.nsprefix(NULL, (*schema2)->targetNamespace), "attributeForm", (*schema2)->attributeFormDefault == qualified ? "qualified" : "unqualified");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1197 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1198 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1199 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1200 // generate the prototypes first: these should allow use before def, e.g. class names then generate the defs
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1201 // check if xsd:anyType is used
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1202 if (!cflag && !pflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1203 { for (SetOfString::const_iterator i = definitions.builtinTypes().begin(); i != definitions.builtinTypes().end(); ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1204 { if (!cflag && !strcmp(*i, "xs:anyType"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1205 { pflag = 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1206 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1207 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1208 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1209 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1210 if (dflag && pflag && !Pflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1211 { if (!Wflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1212 fprintf(stderr, "\nWarning -d option: -p option disabled and xsd__anyType base class removed.\nUse run-time SOAP_DOM_NODE flag to deserialize class instances into DOM nodes.\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1213 fprintf(stream, "\n/*\nWarning -d option used: -p option disabled and xsd:anyType base class removed.\nUse run-time SOAP_DOM_NODE flag to deserialize class instances into DOM nodes.\nA DOM node is represented by the xsd__anyType object implemented in dom.cpp.\n*/\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1214 pflag = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1215 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1216 // define xsd:anyType first, if used
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1217 if (!cflag && pflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1218 { const char *s, *t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1219 t = types.cname(NULL, NULL, "xs:anyType");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1220 s = types.deftypemap[t];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1221 if (s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1222 { if (*s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1223 { if (!mflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1224 fprintf(stream, "%s\n", s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1225 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1226 s = types.usetypemap[t];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1227 if (s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1228 { if (mflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1229 fprintf(stream, "// xsd.h: should define type %s\n", s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1230 types.knames.insert(s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1231 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1232 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1233 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1234 { fprintf(stderr, "\nError: no xsd__anyType defined in type map\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1235 pflag = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1236 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1237 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1238 if (Pflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1239 pflag = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1240 // produce built-in primitive types, limited to the ones that are used only
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1241 banner("Built-in Schema Types and Top-Level Elements and Attributes");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1242 if (vflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1243 fprintf(stderr, "\nGenerating built-in types\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1244 for (SetOfString::const_iterator i = definitions.builtinTypes().begin(); i != definitions.builtinTypes().end(); ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1245 { const char *s, *t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1246 if (!cflag && !strcmp(*i, "xs:anyType"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1247 continue;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1248 t = types.cname(NULL, NULL, *i);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1249 s = types.deftypemap[t];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1250 if (s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1251 { if (*s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1252 { if (**i == '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1253 fprintf(stream, "\n/// Imported type %s from typemap %s.\n", *i, mapfile?mapfile:"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1254 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1255 fprintf(stream, "\n/// Built-in type \"%s\".\n", *i);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1256 if (mflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1257 fprintf(stream, "// (declaration of %s removed by option -m)\n", t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1258 else if (!iflag && !imported(*i))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1259 types.format(s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1260 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1261 s = types.usetypemap[t];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1262 if (s && *s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1263 { if (mflag && **i != '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1264 fprintf(stream, "\n// xsd.h: typemap override of type %s with %s\n", t, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1265 if (types.knames.find(s) == types.knames.end())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1266 types.knames.insert(s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1267 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1268 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1269 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1270 for (SetOfString::const_iterator i = definitions.builtinTypes().begin(); i != definitions.builtinTypes().end(); ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1271 { const char *s, *t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1272 if (!cflag && !strcmp(*i, "xs:anyType"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1273 continue;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1274 t = types.cname(NULL, NULL, *i);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1275 s = types.deftypemap[t];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1276 if (!s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1277 { if (!mflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1278 { if (**i == '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1279 fprintf(stream, "\n// Imported type %s defined by %s\n", *i, t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1280 else if (!iflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1281 { s = types.tname(NULL, NULL, "xsd:string");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1282 fprintf(stream, "\n/// Primitive built-in type \"%s\"\n", *i);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1283 fprintf(stream, "typedef %s %s;\n", s, t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1284 types.deftname(TYPEDEF, NULL, strchr(s, '*') != NULL, NULL, NULL, *i);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1285 const char *u = types.uri(*i);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1286 if (u && !types.uris[u])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1287 fprintf(stream, schemaformat, types.nsprefix(types.prefix(*i), u), "namespace", u);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1288 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1289 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1290 else if (**i == '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1291 fprintf(stream, "\n// Imported type %s defined by %s\n", *i, t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1292 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1293 fprintf(stream, "\n// xsd.h: should define type %s\n", t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1294 types.deftname(TYPEDEF, NULL, false, NULL, NULL, *i);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1295 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1296 if (pflag && !strncmp(*i, "xs:", 3)) // only xsi types are polymorph
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1297 { s = types.aname(NULL, NULL, *i);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1298 if (!mflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1299 { fprintf(stream, "\n/// Class wrapper for built-in type \"%s\" derived from xsd__anyType\n/// Use virtual method soap_type() == SOAP_TYPE_%s to check runtime type (see soapStub.h)\n", *i, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1300 fprintf(stream, "class %s : public xsd__anyType\n{ public:\n", s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1301 fprintf(stream, elementformat, types.tname(NULL, NULL, *i), "__item;");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1302 fprintf(stream, "\n};\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1303 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1304 types.knames.insert(s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1305 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1306 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1307 // produce built-in primitive elements, limited to the ones that are used only
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1308 if (vflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1309 fprintf(stderr, "\nGenerating built-in elements\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1310 for (SetOfString::const_iterator j = definitions.builtinElements().begin(); j != definitions.builtinElements().end(); ++j)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1311 { const char *s, *t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1312 t = types.cname("_", NULL, *j);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1313 s = types.deftypemap[t];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1314 if (s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1315 { if (*s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1316 { if (**j == '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1317 fprintf(stream, "\n/// Imported element %s from typemap %s.\n", *j, mapfile?mapfile:"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1318 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1319 fprintf(stream, "\n/// Built-in element \"%s\".\n", *j);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1320 if (mflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1321 fprintf(stream, "// (declaration of %s removed by option -m)\n", t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1322 else if (!iflag && !imported(*j))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1323 types.format(s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1324 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1325 s = types.usetypemap[t];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1326 if (s && *s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1327 { if (mflag && **j != '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1328 fprintf(stream, "\n// xsd.h: typemap override of element %s with %s\n", t, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1329 if (types.knames.find(s) == types.knames.end())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1330 types.knames.insert(s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1331 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1332 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1333 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1334 { if (!mflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1335 { if (**j == '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1336 fprintf(stream, "\n// Imported element %s declared as %s\n", *j, t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1337 else if (!iflag && !imported(*j))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1338 { s = types.tname(NULL, NULL, "xsd:any");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1339 fprintf(stream, "\n/// Built-in element \"%s\".\n", *j);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1340 fprintf(stream, "typedef %s %s;\n", s, t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1341 types.deftname(TYPEDEF, NULL, true, "_", NULL, *j); // already pointer
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1342 const char *u = types.uri(*j);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1343 if (u && !types.uris[u])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1344 fprintf(stream, schemaformat, types.nsprefix(types.prefix(*j), u), "namespace", u);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1345 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1346 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1347 else if (**j == '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1348 fprintf(stream, "\n// Imported element %s declared as %s\n", *j, t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1349 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1350 fprintf(stream, "\n// xsd.h: should define element %s\n", t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1351 types.deftname(TYPEDEF, NULL, false, "_", NULL, *j);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1352 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1353 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1354 // produce built-in primitive attributes, limited to the ones that are used only
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1355 if (vflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1356 fprintf(stderr, "\nGenerating built-in attributes\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1357 for (SetOfString::const_iterator k = definitions.builtinAttributes().begin(); k != definitions.builtinAttributes().end(); ++k)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1358 { const char *s, *t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1359 t = types.cname("_", NULL, *k);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1360 s = types.deftypemap[t];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1361 if (s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1362 { if (*s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1363 { if (**k == '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1364 fprintf(stream, "\n/// Imported attribute %s from typemap %s.\n", *k, mapfile?mapfile:"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1365 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1366 fprintf(stream, "\n/// Built-in attribute \"%s\".\n", *k);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1367 if (mflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1368 fprintf(stream, "// (declaration of %s removed by option -m)\n", t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1369 else if (!iflag && !imported(*k))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1370 types.format(s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1371 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1372 s = types.usetypemap[t];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1373 if (s && *s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1374 { if (mflag && **k != '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1375 fprintf(stream, "\n// xsd.h: typemap override of attribute %s with %s\n", t, s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1376 if (types.knames.find(s) == types.knames.end())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1377 types.knames.insert(s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1378 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1379 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1380 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1381 { s = types.tname(NULL, NULL, "xsd:string");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1382 if (!mflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1383 { if (**k == '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1384 fprintf(stream, "\n// Imported attribute %s declared as %s\n", *k, t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1385 else if (!iflag && !imported(*k))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1386 { fprintf(stream, "\n/// Built-in attribute \"%s\".\n", *k);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1387 fprintf(stream, "typedef %s %s;\n", s, t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1388 const char *u = types.uri(*k);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1389 if (u && !types.uris[u])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1390 fprintf(stream, schemaformat, types.nsprefix(types.prefix(*k), u), "namespace", u);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1391 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1392 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1393 else if (**k == '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1394 fprintf(stream, "// Imported attribute %s declared as %s\n", *k, t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1395 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1396 fprintf(stream, "// xsd.h: should define attribute %s\n", t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1397 types.deftname(TYPEDEF, NULL, strchr(s, '*') != NULL, "_", NULL, *k);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1398 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1399 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1400 // produce types
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1401 // define class/struct types first
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1402 if (!cflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1403 banner("Forward Declarations");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1404 if (definitions.types)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1405 { comment("Definitions", defs, "types", definitions.types->documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1406 fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1407 for (vector<xs__schema*>::const_iterator schema4 = definitions.types->xs__schema_.begin(); schema4 != definitions.types->xs__schema_.end(); ++schema4)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1408 { if (vflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1409 fprintf(stderr, "\nDefining types in %s\n", (*schema4)->targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1410 for (vector<xs__complexType>::const_iterator complexType = (*schema4)->complexType.begin(); complexType != (*schema4)->complexType.end(); ++complexType)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1411 types.define((*schema4)->targetNamespace, NULL, *complexType);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1412 if (vflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1413 fprintf(stderr, "\nDefining elements in %s\n", (*schema4)->targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1414 for (vector<xs__element>::const_iterator element = (*schema4)->element.begin(); element != (*schema4)->element.end(); ++element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1415 { if (!(*element).type && !(*element).abstract)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1416 { if ((*element).complexTypePtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1417 types.define((*schema4)->targetNamespace, (*element).name, *(*element).complexTypePtr());
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1418 else if (!(*element).simpleTypePtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1419 { fprintf(stream, "\n/// Top-level root element \"%s\":%s.\n", (*schema4)->targetNamespace, (*element).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1420 if (gflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1421 { const char *t = types.deftname(TYPEDEF, NULL, false, "_", (*schema4)->targetNamespace, (*element).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1422 if (t)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1423 fprintf(stream, "typedef _XML %s;\n", t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1424 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1425 fprintf(stream, "// Element definition intentionally left blank.\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1426 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1427 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1428 { const char *s = types.cname("_", (*schema4)->targetNamespace, (*element).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1429 types.ptrtypemap[s] = types.usetypemap[s] = "_XML";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1430 fprintf(stream, "/// Note: use wsdl2h option -g to auto-generate a top-level root element declaration and processing code.\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1431 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1432 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1433 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1434 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1435 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1436 // visit types with lowest base level first
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1437 int baseLevel = 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1438 bool found;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1439 do
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1440 { found = (baseLevel == 1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1441 for (vector<xs__schema*>::iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1442 { if (found)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1443 banner("Schema Types and Top-Level Elements and Attributes", (*schema)->targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1444 for (vector<xs__simpleType>::iterator simpleType = (*schema)->simpleType.begin(); simpleType != (*schema)->simpleType.end(); ++simpleType)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1445 { if ((*simpleType).baseLevel() == baseLevel)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1446 { found = true;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1447 types.gen((*schema)->targetNamespace, NULL, *simpleType, false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1448 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1449 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1450 for (vector<xs__element>::iterator element = (*schema)->element.begin(); element != (*schema)->element.end(); ++element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1451 { if (!(*element).type && (*element).simpleTypePtr() && (*element).simpleTypePtr()->baseLevel() == baseLevel)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1452 { found = true;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1453 if ((*element).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1454 fprintf(stream, "/// Top-level root element \"%s\":%s of simpleType %s.\n", (*schema)->targetNamespace, (*element).name, (*element).type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1455 types.document((*element).annotation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1456 types.gen((*schema)->targetNamespace, (*element).name, *(*element).simpleTypePtr(), false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1457 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1458 if (!(*element).type && (*element).complexTypePtr() && (*element).complexTypePtr()->baseLevel() == baseLevel)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1459 found = true;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1460 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1461 for (vector<xs__attribute>::const_iterator attribute = (*schema)->attribute.begin(); attribute != (*schema)->attribute.end(); ++attribute)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1462 { if (!(*attribute).type && (*attribute).simpleTypePtr() && (*attribute).simpleTypePtr()->baseLevel() == baseLevel)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1463 { found = true;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1464 if ((*attribute).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1465 fprintf(stream, "/// Top-level attribute \"%s\":%s of simpleType %s.\n", (*schema)->targetNamespace, (*attribute).name, (*attribute).type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1466 types.document((*attribute).annotation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1467 types.gen((*schema)->targetNamespace, (*attribute).name, *(*attribute).simpleTypePtr(), false); // URI = NULL won't generate type in schema (type without namespace qualifier)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1468 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1469 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1470 for (vector<xs__complexType>::iterator complexType = (*schema)->complexType.begin(); complexType != (*schema)->complexType.end(); ++complexType)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1471 { if ((*complexType).baseLevel() == baseLevel)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1472 found = true;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1473 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1474 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1475 ++baseLevel;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1476 } while (found);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1477 // generate complex type defs. Problem: what if a simpleType restriction/extension depends on a complexType simpleContent restriction/extension?
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1478 int maxLevel = baseLevel;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1479 for (baseLevel = 1; baseLevel < maxLevel; ++baseLevel)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1480 { for (vector<xs__schema*>::iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1481 { if (baseLevel == 1)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1482 banner("Schema Complex Types and Top-Level Elements", (*schema)->targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1483 for (vector<xs__complexType>::iterator complexType = (*schema)->complexType.begin(); complexType != (*schema)->complexType.end(); ++complexType)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1484 { if ((*complexType).baseLevel() == baseLevel)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1485 types.gen((*schema)->targetNamespace, NULL, *complexType, false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1486 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1487 for (vector<xs__element>::iterator element = (*schema)->element.begin(); element != (*schema)->element.end(); ++element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1488 { if (!(*element).type && (*element).complexTypePtr() && (*element).complexTypePtr()->baseLevel() == baseLevel)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1489 { fprintf(stream, "\n\n/// Top-level root element \"%s\":%s\n", (*schema)->targetNamespace, (*element).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1490 types.document((*element).annotation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1491 types.gen((*schema)->targetNamespace, (*element).name, *(*element).complexTypePtr(), false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1492 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1493 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1494 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1495 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1496 for (vector<xs__schema*>::iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1497 { for (vector<xs__simpleType>::iterator simpleType = (*schema)->simpleType.begin(); simpleType != (*schema)->simpleType.end(); ++simpleType)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1498 { if ((*simpleType).baseLevel() <= 0)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1499 { fprintf(stream, "\n\n/// Warning: '%s' is a simpleType with cyclic restriction/extension inheritance\n", (*simpleType).name?(*simpleType).name:"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1500 fprintf(stream, "typedef _XML %s;\n", types.deftname(TYPEDEF, NULL, false, NULL, (*schema)->targetNamespace, (*simpleType).name));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1501 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1502 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1503 for (vector<xs__complexType>::iterator complexType = (*schema)->complexType.begin(); complexType != (*schema)->complexType.end(); ++complexType)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1504 { if ((*complexType).baseLevel() <= 0)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1505 { fprintf(stream, "\n\n/// Warning: '%s' is a complexType with cyclic restriction/extension inheritance\n", (*complexType).name?(*complexType).name:"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1506 if (cflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1507 fprintf(stream, "typedef _XML %s;\n", types.cname(NULL, (*schema)->targetNamespace, (*complexType).name));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1508 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1509 fprintf(stream, "class %s { };\n", types.cname(NULL, (*schema)->targetNamespace, (*complexType).name));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1510 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1511 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1512 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1513 // option to consider: generate local complexTypes iteratively
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1514 /*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1515 for (MapOfStringToType::const_iterator local = types.locals.begin(); local != types.locals.end(); ++local)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1516 { types.gen(NULL, (*local).first, *(*local).second);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1517 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1518 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1519 for (vector<xs__schema*>::iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1520 { if (vflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1521 fprintf(stderr, "\nGenerating elements in %s\n", (*schema)->targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1522 banner("Additional Top-Level Elements", (*schema)->targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1523 for (vector<xs__element>::iterator element = (*schema)->element.begin(); element != (*schema)->element.end(); ++element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1524 { if ((*element).name && (*element).type && !(*element).abstract)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1525 { fprintf(stream, "\n/// Top-level root element \"%s\":%s of type %s.\n", (*schema)->targetNamespace, (*element).name, (*element).type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1526 types.document((*element).annotation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1527 if (!types.is_defined("_", (*schema)->targetNamespace, (*element).name))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1528 { if (gflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1529 { const char *s = types.tname(NULL, (*schema)->targetNamespace, (*element).type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1530 const char *t = types.deftname(TYPEDEF, NULL, false, "_", (*schema)->targetNamespace, (*element).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1531 if (strncmp(s, "char", 4) && strchr(s, '*')) // don't want pointer typedef, unless char*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1532 { size_t n = strlen(s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1533 char *r = (char*)malloc(n);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1534 strncpy(r, s, n - 1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1535 r[n - 1] = '\0';
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1536 fprintf(stream, "typedef %s %s;\n", r, t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1537 free(r);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1538 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1539 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1540 fprintf(stream, "typedef %s %s;\n", s, t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1541 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1542 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1543 fprintf(stream, "/// Note: use wsdl2h option -g to auto-generate a top-level root element declaration and processing code.\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1544 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1545 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1546 { const char *s = types.cname("_", (*schema)->targetNamespace, (*element).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1547 const char *t = types.deftypemap[s];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1548 if (t && *t)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1549 { fprintf(stream, "/// Imported element %s from typemap %s.\n", s, mapfile?mapfile:"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1550 types.format(t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1551 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1552 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1553 fprintf(stream, "// '%s' element definition intentionally left blank.\n", types.cname("_", (*schema)->targetNamespace, (*element).name));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1554 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1555 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1556 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1557 if (vflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1558 fprintf(stderr, "\nGenerating attributes in %s\n", (*schema)->targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1559 banner("Additional Top-Level Attributes", (*schema)->targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1560 for (vector<xs__attribute>::iterator attribute = (*schema)->attribute.begin(); attribute != (*schema)->attribute.end(); ++attribute)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1561 { if ((*attribute).name && (*attribute).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1562 { fprintf(stream, "\n/// Top-level attribute \"%s\":%s of simpleType %s.\n", (*schema)->targetNamespace, (*attribute).name, (*attribute).type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1563 types.document((*attribute).annotation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1564 if (!types.is_defined("_", (*schema)->targetNamespace, (*attribute).name))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1565 { if (gflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1566 { const char *s = types.tname(NULL, (*schema)->targetNamespace, (*attribute).type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1567 const char *t = types.deftname(TYPEDEF, NULL, false, "_", (*schema)->targetNamespace, (*attribute).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1568 if (strncmp(s, "char", 4) && strchr(s, '*')) // don't want pointer typedef, unless char*
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1569 { size_t n = strlen(s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1570 char *r = (char*)malloc(n);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1571 strncpy(r, s, n - 1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1572 r[n - 1] = '\0';
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1573 fprintf(stream, "typedef %s %s;\n", r, t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1574 free(r);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1575 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1576 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1577 fprintf(stream, "typedef %s %s;\n", s, t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1578 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1579 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1580 fprintf(stream, "/// Note: use wsdl2h option -g to auto-generate a top-level attribute declaration and processing code.\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1581 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1582 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1583 { const char *s = types.cname("_", (*schema)->targetNamespace, (*attribute).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1584 const char *t = types.deftypemap[s];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1585 if (t && *t)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1586 { fprintf(stream, "/// Imported attribute %s from typemap %s.\n", s, mapfile?mapfile:"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1587 types.format(t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1588 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1589 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1590 fprintf(stream, "// '%s' attribute definition intentionally left blank.\n", types.cname("_", (*schema)->targetNamespace, (*attribute).name));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1591 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1592 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1593 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1594 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1595 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1596 if (vflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1597 fprintf(stderr, "\nCollecting service bindings\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1598 collect(definitions);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1599 if (!services.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1600 { banner("Services");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1601 if (soap12)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1602 fprintf(stream, "// This service supports SOAP 1.2 namespaces:\n#import \"soap12.h\"\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1603 for (MapOfStringToService::const_iterator service1 = services.begin(); service1 != services.end(); ++service1)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1604 { Service *sv = (*service1).second;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1605 if (sv && sv->prefix)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1606 { fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1607 if (sv->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1608 fprintf(stream, serviceformat, sv->prefix, "name", sv->name, "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1609 if (sv->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1610 fprintf(stream, serviceformat, sv->prefix, "type", sv->type, "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1611 for (SetOfString::const_iterator port = sv->location.begin(); port != sv->location.end(); ++port)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1612 fprintf(stream, serviceformat, sv->prefix, "port", (*port), "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1613 if (sv->URI)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1614 fprintf(stream, serviceformat, sv->prefix, "namespace", sv->URI, "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1615 if (sv->transport)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1616 fprintf(stream, serviceformat, sv->prefix, "transport", sv->transport, "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1617 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1618 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1619 fprintf(stream, "\n/** @mainpage %s Definitions\n", definitions.name?definitions.name:"Service");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1620 if (definitions.version)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1621 { section(defs, "_version Definitions Version", NULL);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1622 text(definitions.version);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1623 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1624 if (definitions.documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1625 { section(defs, "_documentation Documentation", NULL);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1626 text(definitions.documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1627 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1628 if (definitions.types && definitions.types->documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1629 { section(defs, "_types Schema Type Information", NULL);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1630 text(definitions.types->documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1631 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1632 section(defs, "_bindings Service Bindings", NULL);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1633 for (MapOfStringToService::const_iterator service2 = services.begin(); service2 != services.end(); ++service2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1634 { Service *sv = (*service2).second;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1635 if (sv && sv->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1636 fprintf(stream, "\n - @ref %s\n", sv->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1637 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1638 section(defs, "_more More Information", NULL);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1639 fprintf(stream, "\n - @ref page_notes \"Usage Notes\"\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1640 fprintf(stream, "\n - @ref page_XMLDataBinding \"XML Data Binding\"\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1641 if (!jflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1642 fprintf(stream, "\n - @ref SOAP_ENV__Header \"SOAP Header Content\" (when applicable)\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1643 if (!jflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1644 fprintf(stream, "\n - @ref SOAP_ENV__Detail \"SOAP Fault Detail Content\" (when applicable)\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1645 fprintf(stream, "\n\n*/\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1646 for (MapOfStringToService::const_iterator service3 = services.begin(); service3 != services.end(); ++service3)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1647 { Service *sv = (*service3).second;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1648 if (sv && sv->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1649 { fprintf(stream, "\n/**\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1650 page(sv->name, " Binding", sv->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1651 for (MapOfStringToString::const_iterator service_doc = sv->service_documentation.begin(); service_doc != sv->service_documentation.end(); ++service_doc)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1652 { const char *name = types.aname(NULL, NULL, (*service_doc).first);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1653 section(name, "_service Service Documentation", (*service_doc).first);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1654 text((*service_doc).second);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1655 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1656 for (MapOfStringToString::const_iterator port_doc = sv->port_documentation.begin(); port_doc != sv->port_documentation.end(); ++port_doc)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1657 { const char *name = types.aname(NULL, NULL, (*port_doc).first);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1658 section(name, "_port Port Documentation", (*port_doc).first);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1659 text((*port_doc).second);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1660 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1661 for (MapOfStringToString::const_iterator binding_doc = sv->binding_documentation.begin(); binding_doc != sv->binding_documentation.end(); ++binding_doc)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1662 { const char *name = types.aname(NULL, NULL, (*binding_doc).first);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1663 section(name, "_binding Binding Documentation", (*binding_doc).first);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1664 text((*binding_doc).second);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1665 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1666 section(sv->name, "_operations Operations of Binding ", sv->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1667 for (vector<Operation*>::const_iterator op = sv->operation.begin(); op != sv->operation.end(); ++op)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1668 { if (*op && (*op)->input && (*op)->input_name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1669 fprintf(stream, "\n - @ref %s\n", (*op)->input_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1670 else if (*op && (*op)->output_name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1671 fprintf(stream, "\n - @ref %s\n", (*op)->output_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1672 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1673 section(sv->name, "_ports Endpoints of Binding ", sv->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1674 for (SetOfString::const_iterator port = sv->location.begin(); port != sv->location.end(); ++port)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1675 fprintf(stream, "\n - %s\n", *port);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1676 if (!sv->policy.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1677 { section(sv->name, "_policy Policy of Binding ", sv->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1678 fprintf(stream, "\nSee Section @ref %s_policy_enablers\n", sv->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1679 gen_policy(*sv, sv->policy, "service endpoint ports", types);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1680 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1681 if (!service_prefix)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1682 fprintf(stream, "\nNote: use wsdl2h option -Nname to change the service binding prefix name\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1683 fprintf(stream, "\n\n*/\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1684 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1685 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1686 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1687 generate();
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1688 if (definitions.types)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1689 { banner("XML Data Binding");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1690 fprintf(stream, "\n/**\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1691 page("page_XMLDataBinding", " XML Data Binding", NULL);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1692 fprintf(stream, "\nSOAP/XML services use data bindings contractually bound by WSDL and auto-\ngenerated by wsdl2h and soapcpp2 (see Service Bindings). Plain data bindings\nare adopted from XML schemas as part of the WSDL types section or when running\nwsdl2h on a set of schemas to produce non-SOAP-based XML data bindings.\n\nThe following readers and writers are C/C++ data type (de)serializers auto-\ngenerated by wsdl2h and soapcpp2. Run soapcpp2 on this file to generate the\n(de)serialization code, which is stored in soapC.c[pp]. Include \"soapH.h\" in\nyour code to import these data type and function declarations. Only use the\nsoapcpp2-generated files in your project build. Do not include the wsdl2h-\ngenerated .h file in your code.\n\nData can be read in XML and deserialized from:\n - a file descriptor, using soap->recvfd = fd\n - a socket, using soap->socket = ...\n - a C++ stream, using soap->is = ...\n - a buffer, using the soap->frecv() callback\n\nData can be serialized in XML and written to:\n - a file descriptor, using soap->sendfd = fd\n - a socket, using soap->socket = ...\n - a C++ stream, using soap->os = ...\n - a buffer, using the soap->fsend() callback\n\nThe following options are available for (de)serialization control:\n - soap->encodingStyle = NULL; to remove SOAP 1.1/1.2 encodingStyle\n - soap_mode(soap, SOAP_XML_TREE); XML without id-ref (no cycles!)\n - soap_mode(soap, SOAP_XML_GRAPH); XML with id-ref (including cycles)\n - soap_set_namespaces(soap, struct Namespace *nsmap); to set xmlns bindings\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1693 for (vector<xs__schema*>::const_iterator schema5 = definitions.types->xs__schema_.begin(); schema5 != definitions.types->xs__schema_.end(); ++schema5)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1694 { const char *prefix = types.nsprefix(NULL, (*schema5)->targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1695 fprintf(stream, "\n@section %s Top-level root elements of schema \"%s\"\n", prefix, (*schema5)->targetNamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1696 for (vector<xs__element>::const_iterator element = (*schema5)->element.begin(); element != (*schema5)->element.end(); ++element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1697 { fprintf(stream, "\n - <%s:%s> ", prefix, (*element).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1698 if (types.is_defined("_", (*schema5)->targetNamespace, (*element).name))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1699 { const char *cname = types.cname("_", (*schema5)->targetNamespace, (*element).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1700 const char *pname = types.pname(true, "_", (*schema5)->targetNamespace, (*element).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1701 fprintf(stream, "@ref %s\n", cname);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1702 fprintf(stream, " @code\n // Reader (returns SOAP_OK on success):\n soap_read_%s(struct soap*, %s);\n // Writer (returns SOAP_OK on success):\n soap_write_%s(struct soap*, %s);\n @endcode\n", cname, pname, cname, pname);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1703 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1704 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1705 fprintf(stream, "(use wsdl2h option -g to auto-generate)\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1706 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1707 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1708 fprintf(stream, "\n*/\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1709 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1710 if (cppnamespace)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1711 fprintf(stream, "\n} // namespace %s\n", cppnamespace);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1712 fprintf(stream, "\n/* End of %s */\n", outfile?outfile:"file");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1713 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1714
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1715 void Definitions::generate()
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1716 { MapOfStringToMessage headers;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1717 MapOfStringToMessage faults;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1718 const char *t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1719 for (MapOfStringToService::const_iterator service1 = services.begin(); service1 != services.end(); ++service1)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1720 { if ((*service1).second)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1721 { for (MapOfStringToMessage::const_iterator header = (*service1).second->header.begin(); header != (*service1).second->header.end(); ++header)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1722 headers[(*header).first] = (*header).second;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1723 for (MapOfStringToMessage::const_iterator fault = (*service1).second->fault.begin(); fault != (*service1).second->fault.end(); ++fault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1724 faults[(*fault).first] = (*fault).second;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1725 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1726 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1727 // Generate SOAP Header definition
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1728 t = types.deftypemap["SOAP_ENV__Header"];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1729 if (t && *t)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1730 { banner("Custom SOAP Header");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1731 types.format(t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1732 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1733 else if (!jflag && !headers.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1734 { banner("SOAP Header");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1735 fprintf(stream, "/**\n\nThe SOAP Header is part of the gSOAP context and its content is accessed\nthrough the soap.header variable. You may have to set the soap.actor variable\nto serialize SOAP Headers with SOAP-ENV:actor or SOAP-ENV:role attributes.\nUse option -j to remove entire SOAP Header definition.\nUse option -k to remove the mustUnderstand qualifiers.\n\n*/\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1736 fprintf(stream, "struct SOAP_ENV__Header\n{\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1737 for (MapOfStringToMessage::const_iterator header = headers.begin(); header != headers.end(); ++header)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1738 { if ((*header).second->URI && !types.uris[(*header).second->URI])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1739 fprintf(stream, schemaformat, types.nsprefix(NULL, (*header).second->URI), "namespace", (*header).second->URI);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1740 comment("Header", (*header).first, "WSDL", (*header).second->ext_documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1741 comment("Header", (*header).first, "SOAP", (*header).second->documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1742 if ((*header).second->mustUnderstand && !kflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1743 { fprintf(stream, elementformat, "mustUnderstand", "// must be understood by receiver");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1744 fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1745 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1746 if ((*header).second->part && (*header).second->part->elementPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1747 { fprintf(stream, "/// \"%s\" SOAP Header part element\n", (*header).second->part->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1748 if ((*header).second->part->elementPtr()->type && (*header).second->part->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1749 fprintf(stream, elementformat, types.pname(true, NULL, NULL, (*header).second->part->elementPtr()->type), types.aname(NULL, NULL, (*header).second->part->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1750 else if ((*header).second->part->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1751 fprintf(stream, elementformat, types.pname(true, "_", NULL, (*header).second->part->element), types.aname(NULL, NULL, (*header).second->part->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1752 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1753 fprintf(stream, elementformat, types.pname(true, "_", NULL, (*header).second->part->elementPtr()->name), (*header).first);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1754 fprintf(stream, ";\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1755 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1756 else if ((*header).second->part && (*header).second->part->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1757 { fprintf(stream, "/// \"%s\" SOAP Header part type\n", (*header).second->part->type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1758 fprintf(stream, elementformat, types.pname(true, NULL, NULL, (*header).second->part->type), types.aname(NULL, (*header).second->URI, (*header).second->part->name));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1759 fprintf(stream, ";\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1760 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1761 else if ((*header).second->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1762 { fprintf(stream, "/// \"%s\" SOAP Header element", (*header).second->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1763 (*header).second->generate(types, ";", false, true, false, true);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1764 fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1765 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1766 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1767 { if ((*header).second->part && (*header).second->part->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1768 fprintf(stream, elementformat, types.pname(true, "_", NULL, (*header).second->part->element), (*header).first);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1769 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1770 fprintf(stream, pointerformat, (*header).first, (*header).first);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1771 fprintf(stream, ";\t///< TODO: Please check element name and type (imported type)\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1772 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1773 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1774 types.modify("SOAP_ENV__Header");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1775 fprintf(stream, "\n};\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1776 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1777 // Generate Fault detail element definitions
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1778 for (MapOfStringToMessage::const_iterator fault = faults.begin(); fault != faults.end(); ++fault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1779 { if ((*fault).second->use == encoded)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1780 { banner("SOAP Fault Detail Message");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1781 fprintf(stream, "/// SOAP Fault detail message \"%s:%s\"\n", (*fault).second->URI, (*fault).second->message->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1782 comment("Fault", (*fault).first, "WSDL", (*fault).second->ext_documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1783 comment("Fault", (*fault).first, "SOAP", (*fault).second->documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1784 if (cflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1785 fprintf(stream, "struct %s\n{", (*fault).first);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1786 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1787 fprintf(stream, "class %s\n{ public:", (*fault).first);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1788 (*fault).second->generate(types, ";", false, true, false, true);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1789 if (!cflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1790 { fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1791 fprintf(stream, pointerformat, "struct soap", "soap");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1792 fprintf(stream, ";");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1793 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1794 fprintf(stream, "\n};\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1795 if (cflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1796 fprintf(stream, "typedef struct %s %s;\n", (*fault).first, (*fault).first);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1797 if ((*fault).second->URI && !types.uris[(*fault).second->URI])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1798 fprintf(stream, schemaformat, types.nsprefix(NULL, (*fault).second->URI), "namespace", (*fault).second->URI);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1799 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1800 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1801 t = types.deftypemap["SOAP_ENV__Detail"];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1802 if (t && *t)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1803 { banner("Custom SOAP Fault Detail");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1804 types.format(t);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1805 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1806 else if (!jflag && !faults.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1807 { SetOfString fault_elements;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1808 banner("SOAP Fault Detail");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1809 fprintf(stream, "/**\n\nThe SOAP Fault is part of the gSOAP context and its content is accessed\nthrough the soap.fault->detail variable (SOAP 1.1) or the\nsoap.fault->SOAP_ENV__Detail variable (SOAP 1.2).\nUse wsdl2h option -j to omit these declarations.\n\n*/\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1810 fprintf(stream, "struct SOAP_ENV__Detail\n{\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1811 if (dflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1812 { const char *t = types.tname(NULL, NULL, "xsd:anyAttribute");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1813 fprintf(stream, attributeformat, t, "__anyAttribute");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1814 fprintf(stream, ";\t///< Catch any attribute content in DOM.\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1815 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1816 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1817 fprintf(stream, "// xsd:anyAttribute omitted: to parse attribute content of the Detail element into DOM anyAttribute, use wsdl2h option -d.\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1818 types.modify("SOAP_ENV__Detail");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1819 /* See below */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1820 fprintf(stream, elementformat, "_XML", "__any");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1821 fprintf(stream, ";\t///< Catch any element content in XML string.\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1822 /* The DOM representation is not desired since faultdetail is NULL.
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1823 However, future options may reenable this feature (see keep code here).
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1824 const char *t = types.tname(NULL, NULL, "xsd:any");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1825 fprintf(stream, elementformat, t, "__any");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1826 if (dflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1827 fprintf(stream, ";\t///< Catch any element content in DOM.\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1828 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1829 fprintf(stream, ";\t///< Catch any element content in XML string.\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1830 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1831 for (MapOfStringToMessage::const_iterator fault = faults.begin(); fault != faults.end(); ++fault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1832 { if ((*fault).second->URI && !types.uris[(*fault).second->URI])
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1833 fprintf(stream, schemaformat, types.nsprefix(NULL, (*fault).second->URI), "namespace", (*fault).second->URI);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1834 comment("Fault", (*fault).first, "WSDL", (*fault).second->ext_documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1835 comment("Fault", (*fault).first, "SOAP", (*fault).second->documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1836 if ((*fault).second->message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1837 { if ((*fault).second->use == literal)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1838 { for (vector<wsdl__part>::const_iterator part = (*fault).second->message->part.begin(); part != (*fault).second->message->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1839 { if ((*part).elementPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1840 { if (fault_elements.find((*part).element) == fault_elements.end())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1841 { if ((*part).elementPtr()->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1842 fprintf(stream, elementformat, types.pname(true, NULL, NULL, (*part).elementPtr()->type), types.aname(NULL, (*fault).second->URI, (*part).element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1843 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1844 fprintf(stream, elementformat, types.pname(true, "_", NULL, (*part).element), types.aname(NULL, (*fault).second->URI, (*part).element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1845 fprintf(stream, ";\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1846 fault_elements.insert((*part).element);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1847 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1848 fprintf(stream, "///< SOAP Fault element \"%s\" part \"%s\"\n", (*part).element?(*part).element:"", (*part).name?(*part).name:"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1849 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1850 else if ((*part).name && (*part).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1851 { if (fault_elements.find((*part).name) == fault_elements.end())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1852 { fprintf(stream, elementformat, types.pname(true, NULL, NULL, (*part).type), types.aname("_", (*fault).second->URI, (*part).name));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1853 fprintf(stream, ";\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1854 fault_elements.insert((*part).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1855 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1856 fprintf(stream, "///< SOAP Fault type \"%s\" part \"%s\"\n", (*part).type, (*part).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1857 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1858 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1859 fprintf(stream, "// Unknown SOAP Fault element \"%s\" part \"%s\"\n", (*fault).second->message->name, (*part).name?(*part).name:"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1860 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1861 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1862 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1863 { fprintf(stream, elementformat, (*fault).first, types.aname(NULL, (*fault).second->URI, (*fault).second->message->name));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1864 fprintf(stream, ";\t///< SOAP Fault detail message \"%s\":%s\n", (*fault).second->URI, (*fault).second->message->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1865 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1866 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1867 else if ((*fault).second->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1868 { if (fault_elements.find((*fault).second->name) == fault_elements.end())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1869 { fprintf(stream, pointerformat, types.pname(true, "_", (*fault).second->URI, (*fault).second->element->name), (*fault).second->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1870 fprintf(stream, ";\t///< SOAP Fault detail message \"%s\":%s\n", (*fault).second->URI, (*fault).second->element->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1871 fault_elements.insert((*fault).second->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1872 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1873 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1874 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1875 fprintf(stream, elementformat, "int", "__type");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1876 fprintf(stream, ";\t///< set to SOAP_TYPE_X for a serializable type X\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1877 fprintf(stream, pointerformat, "void", "fault");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1878 fprintf(stream, ";\t///< points to serializable object X or NULL\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1879 fprintf(stream, "};\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1880 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1881 /* The SOAP Fault struct below is autogenerated by soapcpp2 (kept here for future mods)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1882 if (!mflag && !faults.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1883 { fprintf(stream, "struct SOAP_ENV__Code\n{\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1884 fprintf(stream, elementformat, "_QName", "SOAP_ENV__Value");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1885 fprintf(stream, ";\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1886 fprintf(stream, pointerformat, "char", "SOAP_ENV__Node");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1887 fprintf(stream, ";\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1888 fprintf(stream, pointerformat, "char", "SOAP_ENV__Role");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1889 fprintf(stream, ";\n};\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1890 fprintf(stream, "struct SOAP_ENV__Detail\n{\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1891 fprintf(stream, elementformat, "int", "__type");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1892 fprintf(stream, ";\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1893 fprintf(stream, pointerformat, "void", "fault");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1894 fprintf(stream, ";\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1895 fprintf(stream, elementformat, "_XML", "__any");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1896 fprintf(stream, ";\n};\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1897 fprintf(stream, "struct SOAP_ENV__Fault\n{\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1898 fprintf(stream, elementformat, "_QName", "faultcode");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1899 fprintf(stream, ";\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1900 fprintf(stream, pointerformat, "char", "faultstring");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1901 fprintf(stream, ";\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1902 fprintf(stream, pointerformat, "char", "faultactor");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1903 fprintf(stream, ";\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1904 fprintf(stream, pointerformat, "struct SOAP_ENV__Detail", "detail");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1905 fprintf(stream, ";\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1906 fprintf(stream, pointerformat, "struct SOAP_ENV__Code", "SOAP_ENV__Code");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1907 fprintf(stream, ";\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1908 fprintf(stream, pointerformat, "char", "SOAP_ENV__Reason");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1909 fprintf(stream, ";\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1910 fprintf(stream, pointerformat, "struct SOAP_ENV__Detail", "SOAP_ENV__Detail");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1911 fprintf(stream, ";\n};\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1912 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1913 */
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1914 for (MapOfStringToService::const_iterator service2 = services.begin(); service2 != services.end(); ++service2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1915 if ((*service2).second)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1916 (*service2).second->generate(types);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1917 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1918
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1919 ////////////////////////////////////////////////////////////////////////////////
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1920 //
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1921 // Service methods
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1922 //
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1923 ////////////////////////////////////////////////////////////////////////////////
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1924
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1925 Service::Service()
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1926 { prefix = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1927 URI = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1928 name = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1929 type = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1930 transport = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1931 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1932
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1933 void Service::generate(Types& types)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1934 { const char *method_name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1935 banner("Service Binding", name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1936 for (vector<Operation*>::const_iterator op2 = operation.begin(); op2 != operation.end(); ++op2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1937 { if (*op2 && ((*op2)->input || bflag))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1938 { bool flag = false, anonymous = ((*op2)->style != document && (*op2)->parameterOrder != NULL);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1939 if (!(*op2)->input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1940 method_name = (*op2)->output_name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1941 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1942 method_name = (*op2)->input_name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1943 banner("Service Operation", method_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1944 if ((*op2)->output && (*op2)->output_name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1945 { if ((*op2)->style == document)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1946 flag = ((*op2)->output->element || ((*op2)->output->message && (*op2)->output->message->part.size() == 1));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1947 else if (!wflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1948 flag = ((*op2)->output->element || ((*op2)->output->message && (*op2)->output->use == encoded && (*op2)->output->message->part.size() == 1 && !(*(*op2)->output->message->part.begin()).simpleTypePtr() && !(*(*op2)->output->message->part.begin()).complexTypePtr()));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1949 if (flag && (*op2)->input && (*op2)->output && (*op2)->input->message && (*(*op2)->output->message->part.begin()).element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1950 for (vector<wsdl__part>::const_iterator part = (*op2)->input->message->part.begin(); part != (*op2)->input->message->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1951 if ((*part).element && !strcmp((*part).element, (*(*op2)->output->message->part.begin()).element))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1952 flag = false;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1953 if (!flag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1954 { if (bflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1955 fprintf(stream, "/* soapcpp2 generates the following struct automatically for your use:\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1956 fprintf(stream, "/// Operation response struct \"%s\" of operation \"%s\"\n", (*op2)->output_name, method_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1957 fprintf(stream, "struct %s\n{", (*op2)->output_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1958 (*op2)->output->generate(types, ";", anonymous, false, false, false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1959 fprintf(stream, "\n};\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1960 if (bflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1961 fprintf(stream, "*/\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1962 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1963 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1964 fprintf(stream, "\n/// Operation \"%s\" of service binding \"%s\"\n\n/**\n\nOperation details:\n", method_name, name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1965 if ((*op2)->documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1966 text((*op2)->documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1967 if ((*op2)->operation_documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1968 text((*op2)->operation_documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1969 if ((*op2)->input && (*op2)->input->documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1970 { fprintf(stream, "Input request:\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1971 text((*op2)->input->documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1972 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1973 if ((*op2)->input && (*op2)->input->ext_documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1974 { fprintf(stream, "Input request:\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1975 text((*op2)->input->ext_documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1976 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1977 if ((*op2)->output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1978 { if ((*op2)->output->documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1979 { fprintf(stream, "Output response:\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1980 text((*op2)->output->documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1981 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1982 if ((*op2)->output->ext_documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1983 { fprintf(stream, "Output response:\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1984 text((*op2)->output->ext_documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1985 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1986 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1987 gen_policy(*this, (*op2)->policy, "operation", types);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1988 if ((*op2)->input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1989 { gen_policy(*this, (*op2)->input->policy, "request message", types);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1990 if ((*op2)->input->content)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1991 { fprintf(stream, "\n - Request message MIME content");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1992 if ((*op2)->input->content->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1993 { fprintf(stream, " type=\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1994 text((*op2)->input->content->type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1995 fprintf(stream, "\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1996 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1997 if ((*op2)->input->content->type && !strcmp((*op2)->input->content->type, "application/x-www-form-urlencoded"))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1998 fprintf(stream, "\n Use the httpform.c plugin to retrieve key-value pairs from the REST request\n message form data at the server side (client side is automated).\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
1999 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2000 fprintf(stream, "\n TODO: this form of MIME content is not automatically handled.\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2001 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2002 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2003 if ((*op2)->output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2004 { gen_policy(*this, (*op2)->output->policy, "response message", types);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2005 if ((*op2)->output->content)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2006 { fprintf(stream, "\n - Response message MIME content");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2007 if ((*op2)->output->content->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2008 { fprintf(stream, " type=\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2009 text((*op2)->output->content->type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2010 fprintf(stream, "\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2011 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2012 fprintf(stream, "\n TODO: this form of MIME content response is not automatically handled.\n Use one-way request and implement code to parse response.\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2013 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2014 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2015 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2016 fprintf(stream, "\n - One-way service request message\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2017 if ((*op2)->mep)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2018 fprintf(stream, "\n - SOAP MEP: \"%s\"\n", ((*op2)->mep));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2019 if ((*op2)->style == document)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2020 fprintf(stream, "\n - %s %s messaging\n", (*op2)->protocol, (*op2)->input && (*op2)->input->content && (*op2)->input->content->type ? (*op2)->input->content->type : "document/literal style");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2021 else if ((*op2)->input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2022 { if ((*op2)->input->use == literal)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2023 fprintf(stream, "\n - %s literal messaging\n", (*op2)->protocol);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2024 else if ((*op2)->input->encodingStyle)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2025 fprintf(stream, "\n - %s RPC encodingStyle=\"%s\"\n", (*op2)->input->encodingStyle, (*op2)->protocol);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2026 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2027 fprintf(stream, "\n - %s RPC encoded messaging\n", (*op2)->protocol);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2028 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2029 if ((*op2)->output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2030 { if (!(*op2)->input || (*op2)->input->use != (*op2)->output->use)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2031 { if ((*op2)->output->use == literal)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2032 fprintf(stream, "\n - %s literal response messages\n", (*op2)->protocol);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2033 else if ((*op2)->output->encodingStyle)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2034 fprintf(stream, "\n - %s RPC response encodingStyle=\"%s\"\n", (*op2)->protocol, (*op2)->output->encodingStyle);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2035 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2036 fprintf(stream, "\n - %s RPC encoded response messages\n", (*op2)->protocol);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2037 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2038 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2039 if ((*op2)->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2040 { if (*(*op2)->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2041 fprintf(stream, "\n - Action: \"%s\"\n", (*op2)->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2042 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2043 if ((*op2)->input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2044 { if ((*op2)->input->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2045 fprintf(stream, "\n - Addressing input action: \"%s\"\n", (*op2)->input->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2046 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2047 if ((*op2)->output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2048 { if ((*op2)->output->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2049 fprintf(stream, "\n - Addressing output action: \"%s\"\n", (*op2)->output->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2050 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2051 for (vector<Message*>::const_iterator infault = (*op2)->infault.begin(); infault != (*op2)->infault.end(); ++infault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2052 { if ((*infault)->message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2053 { if ((*infault)->use == literal)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2054 { for (vector<wsdl__part>::const_iterator part = (*infault)->message->part.begin(); part != (*infault)->message->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2055 { if ((*part).element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2056 fprintf(stream, "\n - SOAP Input Fault: %s (literal)\n", (*part).element);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2057 else if ((*part).name && (*part).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2058 fprintf(stream, "\n - SOAP Input Fault: %s (literal)\n", (*part).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2059 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2060 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2061 else if ((*infault)->message->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2062 fprintf(stream, "\n - SOAP Input Fault: %s\n", (*infault)->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2063 if ((*infault)->message->name && (*infault)->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2064 fprintf(stream, " - SOAP Input Fault addressing action: \"%s\"\n", (*infault)->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2065 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2066 else if ((*infault)->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2067 fprintf(stream, "\n - SOAP Input Fault: %s (literal)\n", (*infault)->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2068 if ((*infault)->body_parts)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2069 fprintf(stream, " SOAP Input Fault code: %s\n", (*infault)->body_parts);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2070 text((*infault)->documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2071 text((*infault)->ext_documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2072 gen_policy(*this, (*infault)->policy, "fault message", types);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2073 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2074 for (vector<Message*>::const_iterator outfault = (*op2)->outfault.begin(); outfault != (*op2)->outfault.end(); ++outfault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2075 { if ((*outfault)->message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2076 { if ((*outfault)->use == literal)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2077 { for (vector<wsdl__part>::const_iterator part = (*outfault)->message->part.begin(); part != (*outfault)->message->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2078 { if ((*part).element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2079 fprintf(stream, "\n - SOAP Output Fault: %s (literal)\n", (*part).element);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2080 else if ((*part).name && (*part).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2081 fprintf(stream, "\n - SOAP Output Fault: %s (literal)\n", (*part).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2082 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2083 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2084 else if ((*outfault)->message->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2085 fprintf(stream, "\n - SOAP Output Fault: %s\n", (*outfault)->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2086 if ((*outfault)->message->name && (*outfault)->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2087 fprintf(stream, " - SOAP Output Fault addressing action: \"%s\"\n", (*outfault)->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2088 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2089 else if ((*outfault)->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2090 fprintf(stream, "\n - SOAP Output Fault: %s (literal)\n", (*outfault)->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2091 if ((*outfault)->body_parts)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2092 fprintf(stream, " SOAP Output Fault code: %s\n", (*outfault)->body_parts);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2093 text((*outfault)->documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2094 text((*outfault)->ext_documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2095 gen_policy(*this, (*outfault)->policy, "fault message", types);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2096 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2097 if ((*op2)->input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2098 { if (!(*op2)->input->header.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2099 fprintf(stream, "\n - Request message has mandatory header part(s) (see @ref SOAP_ENV__Header):\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2100 for (vector<soap__header>::const_iterator inputheader = (*op2)->input->header.begin(); inputheader != (*op2)->input->header.end(); ++inputheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2101 { if ((*inputheader).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2102 { if ((*inputheader).use == encoded && (*inputheader).namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2103 fprintf(stream, " - %s\n", types.aname(NULL, (*inputheader).namespace_, (*inputheader).part));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2104 else if ((*inputheader).partPtr() && (*inputheader).partPtr()->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2105 fprintf(stream, " - %s\n", types.aname(NULL, NULL, (*inputheader).partPtr()->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2106 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2107 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2108 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2109 if ((*op2)->input && (*op2)->input->multipartRelated)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2110 { int k = 2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2111 fprintf(stream, "\n - Request message MIME multipart/related attachments:\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2112 for (vector<mime__part>::const_iterator part = (*op2)->input->multipartRelated->part.begin(); part != (*op2)->input->multipartRelated->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2113 { if ((*part).soap__body_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2114 { fprintf(stream, " -# MIME attachment with SOAP Body and mandatory header part(s):\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2115 for (vector<soap__header>::const_iterator header = (*part).soap__header_.begin(); header != (*part).soap__header_.end(); ++header)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2116 { if ((*header).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2117 { if ((*header).use == encoded && (*header).namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2118 fprintf(stream, " - %s\n", types.aname(NULL, (*header).namespace_, (*header).part));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2119 else if ((*header).partPtr() && (*header).partPtr()->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2120 fprintf(stream, " - %s\n", types.aname(NULL, NULL, (*header).partPtr()->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2121 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2122 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2123 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2124 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2125 { fprintf(stream, " -# MIME attachment %d:\n", k++);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2126 for (vector<mime__content>::const_iterator content = (*part).content.begin(); content != (*part).content.end(); ++content)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2127 { fprintf(stream, " -");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2128 if ((*content).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2129 { fprintf(stream, " part=\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2130 text((*content).part);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2131 fprintf(stream, "\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2132 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2133 if ((*content).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2134 { fprintf(stream, " type=\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2135 text((*content).type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2136 fprintf(stream, "\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2137 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2138 fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2139 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2140 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2141 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2142 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2143 if ((*op2)->input && (*op2)->input->layout)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2144 fprintf(stream, "\n - Request message has DIME attachments in compliance with %s\n", (*op2)->input->layout);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2145 if ((*op2)->output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2146 { if (!(*op2)->output->header.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2147 fprintf(stream, "\n - Response message has mandatory header part(s): (see @ref SOAP_ENV__Header)\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2148 for (vector<soap__header>::const_iterator outputheader = (*op2)->output->header.begin(); outputheader != (*op2)->output->header.end(); ++outputheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2149 { if ((*outputheader).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2150 { if ((*outputheader).use == encoded && (*outputheader).namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2151 fprintf(stream, " - %s\n", types.aname(NULL, (*outputheader).namespace_, (*outputheader).part));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2152 else if ((*outputheader).partPtr() && (*outputheader).partPtr()->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2153 fprintf(stream, " - %s\n", types.aname(NULL, NULL, (*outputheader).partPtr()->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2154 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2155 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2156 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2157 if ((*op2)->output && (*op2)->output_name && (*op2)->output->multipartRelated)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2158 { int k = 2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2159 fprintf(stream, "\n - Response message MIME multipart/related attachments\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2160 for (vector<mime__part>::const_iterator part = (*op2)->output->multipartRelated->part.begin(); part != (*op2)->output->multipartRelated->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2161 { if ((*part).soap__body_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2162 { fprintf(stream, " -# MIME attachment with SOAP Body and mandatory header part(s):\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2163 for (vector<soap__header>::const_iterator header = (*part).soap__header_.begin(); header != (*part).soap__header_.end(); ++header)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2164 { if ((*header).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2165 { if ((*header).use == encoded && (*header).namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2166 fprintf(stream, " - %s\n", types.aname(NULL, (*header).namespace_, (*header).part));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2167 else if ((*header).partPtr() && (*header).partPtr()->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2168 fprintf(stream, " - %s\n", types.aname(NULL, NULL, (*header).partPtr()->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2169 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2170 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2171 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2172 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2173 { fprintf(stream, " -# MIME attachment %d:\n", k++);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2174 for (vector<mime__content>::const_iterator content = (*part).content.begin(); content != (*part).content.end(); ++content)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2175 { fprintf(stream, " -");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2176 if ((*content).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2177 { fprintf(stream, " part=\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2178 text((*content).part);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2179 fprintf(stream, "\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2180 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2181 if ((*content).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2182 { fprintf(stream, " type=\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2183 text((*content).type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2184 fprintf(stream, "\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2185 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2186 fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2187 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2188 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2189 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2190 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2191 if ((*op2)->output && (*op2)->output_name && (*op2)->output->layout)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2192 fprintf(stream, "\n - Response message has DIME attachments in compliance with %s\n", (*op2)->output->layout);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2193 fprintf(stream, "\nC stub function (defined in soapClient.c[pp] generated by soapcpp2):\n@code\n int soap_%s_%s(\n struct soap *soap,\n NULL, // char *endpoint = NULL selects default endpoint for this operation\n NULL, // char *action = NULL selects default action for this operation\n // input parameters:", (*op2)->output?"call":"send", method_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2194 if ((*op2)->input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2195 (*op2)->input->generate(types, ",", false, false, false, false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2196 if ((*op2)->output && (*op2)->output_name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2197 { fprintf(stream, "\n // output parameters:");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2198 if (flag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2199 { if ((*op2)->style == rpc && (*op2)->output->message && (*(*op2)->output->message->part.begin()).name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2200 { fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2201 fprintf(stream, anonymous ? anonformat : paraformat, types.tname(NULL, NULL, (*(*op2)->output->message->part.begin()).type), cflag ? "*" : "&", types.aname(NULL, NULL, (*(*op2)->output->message->part.begin()).name), "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2202 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2203 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2204 (*op2)->output->generate(types, "", anonymous, false, true, false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2205 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2206 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2207 fprintf(stream, "\n struct %s%s", (*op2)->output_name, cflag ? "*" : "&");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2208 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2209 fprintf(stream, "\n );\n@endcode\n\nC server function (called from the service dispatcher defined in soapServer.c[pp]):\n@code\n int %s(\n struct soap *soap,\n // input parameters:", method_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2210 if ((*op2)->input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2211 (*op2)->input->generate(types, ",", false, false, false, false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2212 fprintf(stream, "\n // output parameters:");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2213 if ((*op2)->output && (*op2)->output_name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2214 { if (flag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2215 { if ((*op2)->style == rpc && (*op2)->output->message && (*(*op2)->output->message->part.begin()).name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2216 { fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2217 fprintf(stream, anonymous ? anonformat : paraformat, types.tname(NULL, NULL, (*(*op2)->output->message->part.begin()).type), cflag ? "*" : "&", types.aname(NULL, NULL, (*(*op2)->output->message->part.begin()).name), "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2218 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2219 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2220 (*op2)->output->generate(types, "", anonymous, false, true, false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2221 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2222 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2223 fprintf(stream, "\n struct %s%s", (*op2)->output_name, cflag ? "*" : "&");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2224 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2225 fprintf(stream, "\n );\n@endcode\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2226 if (!cflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2227 { fprintf(stream, "C++ proxy class (defined in soap%sProxy.h):\n", name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2228 fprintf(stream, "@code\n class %sProxy;\n@endcode\n", name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2229 fprintf(stream, "Important: use soapcpp2 option '-j' (or '-i') to generate greatly improved and easy-to-use proxy classes;\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2230 fprintf(stream, "C++ service class (defined in soap%sService.h):\n", name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2231 fprintf(stream, "@code\n class %sService;\n@endcode\n", name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2232 fprintf(stream, "Important: use soapcpp2 option '-j' (or '-i') to generate greatly improved and easy-to-use service classes;\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2233 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2234 fprintf(stream, "*/\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2235 (*op2)->generate(types, *this);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2236 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2237 else if (*op2 && (*op2)->output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2238 { if (!(*op2)->input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2239 method_name = (*op2)->output_name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2240 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2241 method_name = (*op2)->input_name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2242 banner("Service Operation", method_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2243 fprintf(stream, "\n/// Operation \"%s\" of service binding \"%s\"\n\n/**\n\nOperation details:\n", method_name, name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2244 if ((*op2)->documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2245 text((*op2)->documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2246 if ((*op2)->operation_documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2247 text((*op2)->operation_documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2248 if ((*op2)->output->documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2249 { fprintf(stream, "Output response:\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2250 text((*op2)->output->documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2251 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2252 if ((*op2)->output->ext_documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2253 { fprintf(stream, "Output response:\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2254 text((*op2)->output->ext_documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2255 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2256 gen_policy(*this, (*op2)->policy, "operation", types);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2257 gen_policy(*this, (*op2)->output->policy, "response message", types);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2258 fprintf(stream, "\n - One-way service response message\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2259 if ((*op2)->mep)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2260 fprintf(stream, "\n - SOAP MEP: \"%s\"\n", ((*op2)->mep));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2261 if ((*op2)->style == document)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2262 fprintf(stream, "\n - %s document/literal style messaging\n", (*op2)->protocol);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2263 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2264 { if ((*op2)->output->use == literal)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2265 fprintf(stream, "\n - %s RPC literal messaging\n", (*op2)->protocol);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2266 else if ((*op2)->output->encodingStyle)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2267 fprintf(stream, "\n - %s RPC encodingStyle=\"%s\"\n", (*op2)->output->encodingStyle, (*op2)->protocol);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2268 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2269 fprintf(stream, "\n - %s RPC encoded messaging\n", (*op2)->protocol);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2270 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2271 if ((*op2)->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2272 { if (*(*op2)->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2273 fprintf(stream, "\n - Action: \"%s\"\n", (*op2)->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2274 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2275 if ((*op2)->output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2276 { if ((*op2)->output->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2277 fprintf(stream, "\n - Addressing output action: \"%s\"\n", (*op2)->output->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2278 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2279 for (vector<Message*>::const_iterator outfault = (*op2)->outfault.begin(); outfault != (*op2)->outfault.end(); ++outfault)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2280 { if ((*outfault)->message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2281 { if ((*outfault)->use == literal)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2282 { for (vector<wsdl__part>::const_iterator part = (*outfault)->message->part.begin(); part != (*outfault)->message->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2283 { if ((*part).element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2284 fprintf(stream, "\n - SOAP Output Fault: %s (literal)\n", (*part).element);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2285 else if ((*part).name && (*part).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2286 fprintf(stream, "\n - SOAP Output Fault: %s (literal)\n", (*part).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2287 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2288 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2289 else if ((*outfault)->message->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2290 fprintf(stream, "\n - SOAP Output Fault: %s\n", (*outfault)->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2291 if ((*outfault)->message->name && (*outfault)->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2292 fprintf(stream, " - SOAP Output Fault addressing action: \"%s\"\n", (*outfault)->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2293 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2294 else if ((*outfault)->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2295 fprintf(stream, "\n - SOAP Output Fault: %s (literal)\n", (*outfault)->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2296 gen_policy(*this, (*outfault)->policy, "fault message", types);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2297 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2298 if (!(*op2)->output->header.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2299 fprintf(stream, "\n - Response message has mandatory header part(s) (see @ref SOAP_ENV__Header):\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2300 for (vector<soap__header>::const_iterator outputheader = (*op2)->output->header.begin(); outputheader != (*op2)->output->header.end(); ++outputheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2301 { if ((*outputheader).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2302 { if ((*outputheader).use == encoded && (*outputheader).namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2303 fprintf(stream, " - %s\n", types.aname(NULL, (*outputheader).namespace_, (*outputheader).part));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2304 else if ((*outputheader).partPtr() && (*outputheader).partPtr()->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2305 fprintf(stream, " - %s\n", types.aname(NULL, NULL, (*outputheader).partPtr()->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2306 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2307 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2308 if ((*op2)->output->multipartRelated)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2309 { int k = 2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2310 fprintf(stream, "\n - Response message MIME multipart/related attachments:\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2311 for (vector<mime__part>::const_iterator part = (*op2)->output->multipartRelated->part.begin(); part != (*op2)->output->multipartRelated->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2312 { if ((*part).soap__body_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2313 { fprintf(stream, " -# MIME attachment with SOAP Body and mandatory header part(s):\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2314 for (vector<soap__header>::const_iterator header = (*part).soap__header_.begin(); header != (*part).soap__header_.end(); ++header)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2315 { if ((*header).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2316 { if ((*header).use == encoded && (*header).namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2317 fprintf(stream, " - %s\n", types.aname(NULL, (*header).namespace_, (*header).part));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2318 else if ((*header).partPtr() && (*header).partPtr()->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2319 fprintf(stream, " - %s\n", types.aname(NULL, NULL, (*header).partPtr()->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2320 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2321 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2322 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2323 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2324 { fprintf(stream, " -# MIME attachment %d:\n", k++);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2325 for (vector<mime__content>::const_iterator content = (*part).content.begin(); content != (*part).content.end(); ++content)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2326 { fprintf(stream, " -");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2327 if ((*content).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2328 { fprintf(stream, " part=\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2329 text((*content).part);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2330 fprintf(stream, "\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2331 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2332 if ((*content).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2333 { fprintf(stream, " type=\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2334 text((*content).type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2335 fprintf(stream, "\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2336 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2337 fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2338 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2339 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2340 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2341 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2342 if ((*op2)->output->layout)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2343 fprintf(stream, "\n - Response message has DIME attachments in compliance with %s\n", (*op2)->output->layout);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2344 fprintf(stream, "\nC stub function (defined in soapClient.c[pp] generated by soapcpp2):\n@code\n int soap_call_%s(\n struct soap *soap,\n NULL, // char *endpoint = NULL selects default endpoint for this operation\n NULL, // char *action = NULL selects default action for this operation\n // parameters:", method_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2345 (*op2)->output->generate(types, ",", false, false, false, false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2346 fprintf(stream, "\n );\n@endcode\n\nC server function (called from the service dispatcher defined in soapServer.c[pp]):\n@code\n int %s(\n struct soap *soap,\n // parameters:", method_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2347 (*op2)->output->generate(types, ",", false, false, false, false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2348 fprintf(stream, "\n );\n@endcode\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2349 if (!cflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2350 { fprintf(stream, "C++ proxy class (defined in soap%sProxy.h):\n", name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2351 fprintf(stream, "@code\n class %sProxy;\n@endcode\n", name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2352 fprintf(stream, "Important: use soapcpp2 option '-j' (or '-i') to generate greatly improved and easy-to-use proxy classes;\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2353 fprintf(stream, "C++ service class (defined in soap%sService.h):\n", name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2354 fprintf(stream, "@code\n class %sService;\n@endcode\n", name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2355 fprintf(stream, "Important: use soapcpp2 option '-j' (or '-i') to generate greatly improved and easy-to-use service classes;\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2356 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2357 fprintf(stream, "*/\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2358 (*op2)->generate(types, *this);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2359 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2360 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2361 gen_policy_enablers(*this);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2362 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2363
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2364 void Service::add_import(const char *s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2365 { if (find_if(imports.begin(), imports.end(), eqstr(s)) == imports.end())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2366 imports.push_back(s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2367 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2368
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2369 void Service::del_import(const char *s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2370 { VectorOfString::iterator i = find_if(imports.begin(), imports.end(), eqstr(s));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2371 if (i != imports.end())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2372 imports.erase(i);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2373 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2374
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2375 ////////////////////////////////////////////////////////////////////////////////
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2376 //
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2377 // Operation methods
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2378 //
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2379 ////////////////////////////////////////////////////////////////////////////////
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2380
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2381 void Operation::generate(Types &types, Service &service)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2382 { bool flag = false, anonymous = ((style != document) && parameterOrder != NULL);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2383 const char *method_name = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2384 if (output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2385 { if (style == document)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2386 flag = (output->element || (output->message && output->message->part.size() == 1));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2387 else if (!wflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2388 flag = (output->element || (output->message && output->use == encoded && output->message->part.size() == 1 && !(*output->message->part.begin()).simpleTypePtr() && !(*output->message->part.begin()).complexTypePtr()));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2389 if (flag && input && input->message && (*output->message->part.begin()).element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2390 for (vector<wsdl__part>::const_iterator part = input->message->part.begin(); part != input->message->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2391 if ((*part).element && !strcmp((*part).element, (*output->message->part.begin()).element))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2392 flag = false;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2393 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2394 if (output && output_name && bflag) // (output && (!input || bflag))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2395 { if (input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2396 { method_name = strstr(output_name + 1, "__");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2397 if (method_name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2398 method_name += 2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2399 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2400 method_name = output_name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2401 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2402 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2403 { method_name = strstr(input_name + 1, "__");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2404 if (method_name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2405 method_name += 2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2406 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2407 method_name = input_name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2408 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2409 if (protocol)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2410 fprintf(stream, serviceformat, prefix, "method-protocol", method_name, protocol);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2411 if (output->content && output->content->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2412 fprintf(stream, serviceformat, prefix, "method-mime-type", method_name, output->content->type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2413 else if (style == document)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2414 fprintf(stream, serviceformat, prefix, "method-style", method_name, "document");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2415 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2416 fprintf(stream, serviceformat, prefix, "method-style", method_name, "rpc");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2417 if (output->use == literal)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2418 fprintf(stream, serviceformat, prefix, "method-encoding", method_name, "literal");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2419 else if (output->encodingStyle)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2420 fprintf(stream, serviceformat, prefix, "method-encoding", method_name, output->encodingStyle);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2421 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2422 fprintf(stream, serviceformat, prefix, "method-encoding", method_name, "encoded");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2423 if (output && output->action && *output->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2424 fprintf(stream, serviceformat, prefix, "method-action", method_name, output->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2425 else if (action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2426 { if (*action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2427 fprintf(stream, serviceformat, prefix, "method-action", method_name, action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2428 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2429 fprintf(stream, serviceformat, prefix, "method-action", method_name, "\"\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2430 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2431 for (vector<Message*>::const_iterator message = outfault.begin(); message != outfault.end(); ++message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2432 { if ((*message)->message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2433 { if ((*message)->use == literal)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2434 { for (vector<wsdl__part>::const_iterator part = (*message)->message->part.begin(); part != (*message)->message->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2435 { if ((*part).element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2436 fprintf(stream, serviceformat, prefix, "method-fault", method_name, types.aname(NULL, NULL, (*part).element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2437 else if ((*part).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2438 fprintf(stream, serviceformat, prefix, "method-fault", method_name, types.aname(NULL, (*message)->URI, (*part).name));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2439 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2440 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2441 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2442 { if ((*message)->message->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2443 fprintf(stream, serviceformat, prefix, "method-fault", method_name, (*message)->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2444 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2445 if ((*message)->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2446 fprintf(stream, serviceformat, prefix, "method-fault-action", method_name, (*message)->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2447 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2448 else if ((*message)->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2449 fprintf(stream, serviceformat, prefix, "method-fault", method_name, (*message)->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2450 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2451 if (output->multipartRelated)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2452 { for (vector<mime__part>::const_iterator outputmime = output->multipartRelated->part.begin(); outputmime != output->multipartRelated->part.end(); ++outputmime)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2453 { for (vector<soap__header>::const_iterator outputheader = (*outputmime).soap__header_.begin(); outputheader != (*outputmime).soap__header_.end(); ++outputheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2454 { if ((*outputheader).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2455 { if ((*outputheader).use == encoded && (*outputheader).namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2456 fprintf(stream, serviceformat, prefix, "method-header-part", method_name, types.aname(NULL, (*outputheader).namespace_, (*outputheader).part));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2457 else if ((*outputheader).partPtr() && (*outputheader).partPtr()->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2458 fprintf(stream, serviceformat, prefix, "method-header-part", method_name, types.aname(NULL, NULL, (*outputheader).partPtr()->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2459 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2460 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2461 for (vector<mime__content>::const_iterator content = (*outputmime).content.begin(); content != (*outputmime).content.end(); ++content)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2462 if ((*content).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2463 fprintf(stream, serviceformat, prefix, "method-mime-type", method_name, (*content).type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2464 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2465 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2466 // TODO: add headerfault directives
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2467 for (vector<soap__header>::const_iterator outputheader = output->header.begin(); outputheader != output->header.end(); ++outputheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2468 { if ((*outputheader).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2469 { if ((*outputheader).use == encoded && (*outputheader).namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2470 fprintf(stream, serviceformat, prefix, "method-header-part", method_name, types.aname(NULL, (*outputheader).namespace_, (*outputheader).part));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2471 else if ((*outputheader).partPtr() && (*outputheader).partPtr()->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2472 fprintf(stream, serviceformat, prefix, "method-header-part", method_name, types.aname(NULL, NULL, (*outputheader).partPtr()->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2473 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2474 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2475 for (vector<wsoap__header>::const_iterator outputwheader = output->wheader.begin(); outputwheader != output->wheader.end(); ++outputwheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2476 { if ((*outputwheader).element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2477 fprintf(stream, serviceformat, prefix, "method-header-part", method_name, types.aname(NULL, NULL, (*outputwheader).element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2478 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2479 if (input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2480 { fprintf(stream, "/// Operation response \"%s\" of operation \"%s\"\n", output_name, input_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2481 fprintf(stream, "int %s(", output_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2482 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2483 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2484 fprintf(stream, "int %s(", input_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2485 output->generate(types, ",", anonymous, true, false, false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2486 fprintf(stream, "\n void\t///< One-way message: no output parameter\n);\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2487 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2488 if (!input && output && output_name) // (!input && output && bflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2489 { method_name = strstr(output_name + 1, "__");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2490 if (method_name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2491 method_name += 2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2492 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2493 method_name = output_name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2494 if (protocol)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2495 fprintf(stream, serviceformat, prefix, "method-protocol", method_name, protocol);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2496 if (output->content && output->content->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2497 fprintf(stream, serviceformat, prefix, "method-mime-type", method_name, output->content->type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2498 else if (style == document)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2499 fprintf(stream, serviceformat, prefix, "method-style", method_name, "document");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2500 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2501 fprintf(stream, serviceformat, prefix, "method-style", method_name, "rpc");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2502 if (output->use == literal)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2503 fprintf(stream, serviceformat, prefix, "method-encoding", method_name, "literal");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2504 else if (output->encodingStyle)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2505 fprintf(stream, serviceformat, prefix, "method-encoding", method_name, output->encodingStyle);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2506 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2507 fprintf(stream, serviceformat, prefix, "method-encoding", method_name, "encoded");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2508 if (output && output->action && *output->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2509 fprintf(stream, serviceformat, prefix, "method-action", method_name, output->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2510 else if (action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2511 { if (*action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2512 fprintf(stream, serviceformat, prefix, "method-action", method_name, action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2513 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2514 fprintf(stream, serviceformat, prefix, "method-action", method_name, "\"\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2515 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2516 for (vector<Message*>::const_iterator message = outfault.begin(); message != outfault.end(); ++message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2517 { if ((*message)->message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2518 { if ((*message)->use == literal)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2519 { for (vector<wsdl__part>::const_iterator part = (*message)->message->part.begin(); part != (*message)->message->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2520 { if ((*part).element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2521 fprintf(stream, serviceformat, prefix, "method-fault", method_name, types.aname(NULL, NULL, (*part).element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2522 else if ((*part).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2523 fprintf(stream, serviceformat, prefix, "method-fault", method_name, types.aname(NULL, (*message)->URI, (*part).name));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2524 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2525 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2526 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2527 { if ((*message)->message->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2528 fprintf(stream, serviceformat, prefix, "method-fault", method_name, (*message)->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2529 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2530 if ((*message)->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2531 fprintf(stream, serviceformat, prefix, "method-fault-action", method_name, (*message)->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2532 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2533 else if ((*message)->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2534 fprintf(stream, serviceformat, prefix, "method-fault", method_name, (*message)->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2535 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2536 if (output->multipartRelated)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2537 { for (vector<mime__part>::const_iterator outputmime = output->multipartRelated->part.begin(); outputmime != output->multipartRelated->part.end(); ++outputmime)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2538 { for (vector<soap__header>::const_iterator outputheader = (*outputmime).soap__header_.begin(); outputheader != (*outputmime).soap__header_.end(); ++outputheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2539 { if ((*outputheader).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2540 { if ((*outputheader).use == encoded && (*outputheader).namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2541 fprintf(stream, serviceformat, prefix, "method-header-part", method_name, types.aname(NULL, (*outputheader).namespace_, (*outputheader).part));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2542 else if ((*outputheader).partPtr() && (*outputheader).partPtr()->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2543 fprintf(stream, serviceformat, prefix, "method-header-part", method_name, types.aname(NULL, NULL, (*outputheader).partPtr()->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2544 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2545 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2546 for (vector<mime__content>::const_iterator content = (*outputmime).content.begin(); content != (*outputmime).content.end(); ++content)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2547 if ((*content).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2548 fprintf(stream, serviceformat, prefix, "method-mime-type", method_name, (*content).type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2549 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2550 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2551 // TODO: add headerfault directives
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2552 for (vector<soap__header>::const_iterator outputheader = output->header.begin(); outputheader != output->header.end(); ++outputheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2553 { if ((*outputheader).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2554 { if ((*outputheader).use == encoded && (*outputheader).namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2555 fprintf(stream, serviceformat, prefix, "method-header-part", method_name, types.aname(NULL, (*outputheader).namespace_, (*outputheader).part));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2556 else if ((*outputheader).partPtr() && (*outputheader).partPtr()->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2557 fprintf(stream, serviceformat, prefix, "method-header-part", method_name, types.aname(NULL, NULL, (*outputheader).partPtr()->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2558 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2559 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2560 for (vector<wsoap__header>::const_iterator outputwheader = output->wheader.begin(); outputwheader != output->wheader.end(); ++outputwheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2561 { if ((*outputwheader).element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2562 fprintf(stream, serviceformat, prefix, "method-header-part", method_name, types.aname(NULL, NULL, (*outputwheader).element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2563 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2564 fprintf(stream, "int %s(", output_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2565 if (flag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2566 { if (style == rpc && output->message && (*output->message->part.begin()).name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2567 { fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2568 fprintf(stream, anonymous ? anonformat : paraformat, types.tname(NULL, NULL, (*output->message->part.begin()).type), cflag ? "*" : "&", types.aname(NULL, NULL, (*output->message->part.begin()).name), "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2569 fprintf(stream, "\t///< Output parameter");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2570 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2571 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2572 output->generate(types, "", anonymous, true, true, false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2573 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2574 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2575 { fprintf(stream, "\n struct %-28s%s", output_name, cflag ? "*" : "&");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2576 fprintf(stream, "\t///< Output response struct parameter");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2577 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2578 fprintf(stream, "\n);\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2579 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2580 if (input && input_name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2581 { method_name = strstr(input_name + 1, "__");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2582 if (method_name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2583 method_name += 2;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2584 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2585 method_name = input_name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2586 if (protocol)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2587 fprintf(stream, serviceformat, prefix, "method-protocol", method_name, protocol);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2588 if (input->content && input->content->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2589 fprintf(stream, serviceformat, prefix, "method-mime-type", method_name, input->content->type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2590 else if (style == document)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2591 fprintf(stream, serviceformat, prefix, "method-style", method_name, "document");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2592 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2593 fprintf(stream, serviceformat, prefix, "method-style", method_name, "rpc");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2594 if (output && output->content && output->content->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2595 fprintf(stream, serviceformat, prefix, "method-output-mime-type", method_name, output->content->type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2596 if (!input || input->use == literal)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2597 fprintf(stream, serviceformat, prefix, "method-encoding", method_name, "literal");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2598 else if (input->encodingStyle)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2599 fprintf(stream, serviceformat, prefix, "method-encoding", method_name, input->encodingStyle);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2600 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2601 fprintf(stream, serviceformat, prefix, "method-encoding", method_name, "encoded");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2602 if (output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2603 { if (!input || input->use != output->use)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2604 { if (output->use == literal)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2605 fprintf(stream, serviceformat, prefix, "method-response-encoding", method_name, "literal");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2606 else if (output->encodingStyle)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2607 fprintf(stream, serviceformat, prefix, "method-response-encoding", method_name, output->encodingStyle);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2608 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2609 fprintf(stream, serviceformat, prefix, "method-response-encoding", method_name, "encoded");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2610 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2611 if (style == rpc && (!input || (input->URI && output->URI && strcmp(input->URI, output->URI))))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2612 fprintf(stream, schemaformat, types.nsprefix(NULL, output->URI), "namespace", output->URI);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2613 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2614 if (input && input->action && *input->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2615 fprintf(stream, serviceformat, prefix, "method-input-action", method_name, input->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2616 else if (action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2617 { if (*action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2618 fprintf(stream, serviceformat, prefix, "method-action", method_name, action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2619 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2620 fprintf(stream, serviceformat, prefix, "method-action", method_name, "\"\"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2621 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2622 if (output && output->action && *output->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2623 fprintf(stream, serviceformat, prefix, "method-output-action", method_name, output->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2624 for (vector<Message*>::const_iterator message = outfault.begin(); message != outfault.end(); ++message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2625 { if ((*message)->message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2626 { if ((*message)->use == literal)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2627 { for (vector<wsdl__part>::const_iterator part = (*message)->message->part.begin(); part != (*message)->message->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2628 { if ((*part).element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2629 fprintf(stream, serviceformat, prefix, "method-fault", method_name, types.aname(NULL, NULL, (*part).element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2630 else if ((*part).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2631 fprintf(stream, serviceformat, prefix, "method-fault", method_name, types.aname(NULL, (*message)->URI, (*part).name));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2632 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2633 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2634 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2635 { if ((*message)->message->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2636 fprintf(stream, serviceformat, prefix, "method-fault", method_name, (*message)->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2637 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2638 if ((*message)->action)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2639 fprintf(stream, serviceformat, prefix, "method-fault-action", method_name, (*message)->action);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2640 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2641 else if ((*message)->name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2642 fprintf(stream, serviceformat, prefix, "method-fault", method_name, (*message)->name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2643 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2644 if (input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2645 { if (input->multipartRelated)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2646 { for (vector<mime__part>::const_iterator inputmime = input->multipartRelated->part.begin(); inputmime != input->multipartRelated->part.end(); ++inputmime)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2647 { for (vector<soap__header>::const_iterator inputheader = (*inputmime).soap__header_.begin(); inputheader != (*inputmime).soap__header_.end(); ++inputheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2648 { if ((*inputheader).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2649 { if ((*inputheader).use == encoded && (*inputheader).namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2650 fprintf(stream, serviceformat, prefix, "method-input-header-part", method_name, types.aname(NULL, (*inputheader).namespace_, (*inputheader).part));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2651 else if ((*inputheader).partPtr() && (*inputheader).partPtr()->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2652 fprintf(stream, serviceformat, prefix, "method-input-header-part", method_name, types.aname(NULL, NULL, (*inputheader).partPtr()->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2653 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2654 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2655 for (vector<mime__content>::const_iterator content = (*inputmime).content.begin(); content != (*inputmime).content.end(); ++content)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2656 if ((*content).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2657 fprintf(stream, serviceformat, prefix, "method-input-mime-type", method_name, (*content).type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2658 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2659 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2660 // TODO: add headerfault directives
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2661 for (vector<soap__header>::const_iterator inputheader = input->header.begin(); inputheader != input->header.end(); ++inputheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2662 { if ((*inputheader).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2663 { if ((*inputheader).use == encoded && (*inputheader).namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2664 fprintf(stream, serviceformat, prefix, "method-input-header-part", method_name, types.aname(NULL, (*inputheader).namespace_, (*inputheader).part));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2665 else if ((*inputheader).partPtr() && (*inputheader).partPtr()->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2666 fprintf(stream, serviceformat, prefix, "method-input-header-part", method_name, types.aname(NULL, NULL, (*inputheader).partPtr()->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2667 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2668 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2669 for (vector<wsoap__header>::const_iterator inputwheader = input->wheader.begin(); inputwheader != input->wheader.end(); ++inputwheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2670 { if ((*inputwheader).element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2671 fprintf(stream, serviceformat, prefix, "method-input-header-part", method_name, types.aname(NULL, NULL, (*inputwheader).element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2672 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2673 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2674 if (output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2675 { if (output->multipartRelated)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2676 { for (vector<mime__part>::const_iterator outputmime = output->multipartRelated->part.begin(); outputmime != output->multipartRelated->part.end(); ++outputmime)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2677 { for (vector<soap__header>::const_iterator outputheader = (*outputmime).soap__header_.begin(); outputheader != (*outputmime).soap__header_.end(); ++outputheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2678 { if ((*outputheader).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2679 { if ((*outputheader).use == encoded && (*outputheader).namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2680 fprintf(stream, serviceformat, prefix, "method-output-header-part", method_name, types.aname(NULL, (*outputheader).namespace_, (*outputheader).part));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2681 else if ((*outputheader).partPtr() && (*outputheader).partPtr()->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2682 fprintf(stream, serviceformat, prefix, "method-output-header-part", method_name, types.aname(NULL, NULL, (*outputheader).partPtr()->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2683 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2684 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2685 for (vector<mime__content>::const_iterator content = (*outputmime).content.begin(); content != (*outputmime).content.end(); ++content)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2686 if ((*content).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2687 fprintf(stream, serviceformat, prefix, "method-output-mime-type", method_name, (*content).type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2688 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2689 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2690 for (vector<soap__header>::const_iterator outputheader = output->header.begin(); outputheader != output->header.end(); ++outputheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2691 { if ((*outputheader).part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2692 { if ((*outputheader).use == encoded && (*outputheader).namespace_)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2693 fprintf(stream, serviceformat, prefix, "method-output-header-part", method_name, types.aname(NULL, (*outputheader).namespace_, (*outputheader).part));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2694 else if ((*outputheader).partPtr() && (*outputheader).partPtr()->element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2695 fprintf(stream, serviceformat, prefix, "method-output-header-part", method_name, types.aname(NULL, NULL, (*outputheader).partPtr()->element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2696 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2697 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2698 for (vector<wsoap__header>::const_iterator outputwheader = output->wheader.begin(); outputwheader != output->wheader.end(); ++outputwheader)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2699 { if ((*outputwheader).element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2700 fprintf(stream, serviceformat, prefix, "method-output-header-part", method_name, types.aname(NULL, NULL, (*outputwheader).element));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2701 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2702 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2703 if (input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2704 fprintf(stream, "int %s(", input_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2705 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2706 fprintf(stream, "int %s(", output_name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2707 if (input)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2708 input->generate(types, ",", anonymous, true, false, false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2709 if (output)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2710 { if (flag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2711 { if (style == rpc && output->message && (*output->message->part.begin()).name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2712 { fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2713 fprintf(stream, anonymous ? anonformat : paraformat, types.tname(NULL, NULL, (*output->message->part.begin()).type), cflag ? "*" : "&", types.aname(NULL, NULL, (*output->message->part.begin()).name), "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2714 fprintf(stream, "\t///< Output parameter");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2715 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2716 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2717 output->generate(types, "", anonymous, true, true, false);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2718 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2719 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2720 { fprintf(stream, "\n struct %-28s%s", output_name, cflag ? "*" : "&");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2721 fprintf(stream, "\t///< Output response struct parameter");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2722 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2723 fprintf(stream, "\n);\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2724 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2725 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2726 fprintf(stream, "\n void\t///< One-way message: no output parameter\n);\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2727 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2728 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2729
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2730 ////////////////////////////////////////////////////////////////////////////////
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2731 //
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2732 // Message methods
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2733 //
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2734 ////////////////////////////////////////////////////////////////////////////////
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2735
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2736 void Message::generate(Types &types, const char *sep, bool anonymous, bool remark, bool response, bool optional)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2737 { if (message)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2738 { for (vector<wsdl__part>::const_iterator part = message->part.begin(); part != message->part.end(); ++part)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2739 { if (!(*part).name)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2740 fprintf(stderr, "\nError: no part name in message '%s'\n", message->name?message->name:"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2741 else if (!body_parts || soap_tagsearch(body_parts, (*part).name))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2742 { if (remark && (*part).documentation)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2743 comment("", (*part).name, "parameter", (*part).documentation);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2744 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2745 fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2746 if ((*part).element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2747 { if ((*part).elementPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2748 { const char *name, *type, *nameURI = NULL, *typeURI = NULL, *prefix = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2749 if (style == rpc && use == encoded)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2750 name = (*part).name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2751 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2752 { name = (*part).elementPtr()->name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2753 if (style == document && (*part).elementPtr()->schemaPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2754 nameURI = (*part).elementPtr()->schemaPtr()->targetNamespace;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2755 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2756 if ((*part).elementPtr()->type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2757 type = (*part).elementPtr()->type;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2758 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2759 { type = (*part).elementPtr()->name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2760 prefix = "_";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2761 if ((*part).elementPtr()->schemaPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2762 typeURI = (*part).elementPtr()->schemaPtr()->targetNamespace;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2763 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2764 if ((*part).elementPtr()->xmime__expectedContentTypes)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2765 fprintf(stream, " /// MTOM attachment with content types %s\n", (*part).elementPtr()->xmime__expectedContentTypes);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2766 if (response)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2767 { const char *t = types.tname(prefix, typeURI, type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2768 bool flag = (strchr(t, '*') && strcmp(t, "char*") && strcmp(t, "char *"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2769 fprintf(stream, anonymous ? anonformat : paraformat, t, flag ? " " : cflag ? "*" : "&", types.aname(NULL, nameURI, name), sep);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2770 if (remark)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2771 fprintf(stream, "\t///< Output parameter");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2772 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2773 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2774 { fprintf(stream, anonymous ? anonformat : paraformat, types.pname(optional, prefix, typeURI, type), " ", types.aname(NULL, nameURI, name), sep);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2775 if (remark && *sep == ',')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2776 fprintf(stream, "\t///< Input parameter");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2777 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2778 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2779 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2780 { fprintf(stream, anonymous ? anonformat : paraformat, types.pname(optional, NULL, NULL, (*part).element), " ", types.aname(NULL, NULL, (*part).element), sep);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2781 if (remark)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2782 fprintf(stream, "\t///< TODO: Check element type (imported type)");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2783 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2784 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2785 else if ((*part).type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2786 { if (response)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2787 { const char *t = types.tname(NULL, NULL, (*part).type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2788 bool flag = (strchr(t, '*') && strcmp(t, "char*") && strcmp(t, "char *"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2789 fprintf(stream, anonymous ? anonformat : paraformat, t, flag ? " " : cflag ? "*" : "&", types.aname(NULL, NULL, (*part).name), sep);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2790 if (remark)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2791 fprintf(stream, "\t///< Output parameter");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2792 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2793 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2794 { fprintf(stream, anonymous ? anonformat : paraformat, types.pname(optional, NULL, NULL, (*part).type), " ", types.aname(NULL, NULL, (*part).name), sep);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2795 if (remark && *sep == ',')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2796 fprintf(stream, "\t///< Input parameter");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2797 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2798 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2799 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2800 fprintf(stderr, "\nError: no wsdl:definitions/message/part/@type in part '%s'\n", (*part).name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2801 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2802 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2803 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2804 else if (element) // WSDL 2.0
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2805 { const char *prefix = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2806 const char *URI = NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2807 const char *name = element->name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2808 const char *type = element->type;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2809 if (!type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2810 { type = name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2811 prefix = "_";
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2812 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2813 if (element->schemaPtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2814 URI = element->schemaPtr()->targetNamespace;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2815 if (response)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2816 { const char *t = types.tname(prefix, URI, type);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2817 bool flag = (strchr(t, '*') && strcmp(t, "char*") && strcmp(t, "char *"));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2818 fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2819 fprintf(stream, paraformat, t, flag ? " " : cflag ? "*" : "&", anonymous ? "" : types.aname(NULL, URI, name), sep);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2820 if (remark)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2821 fprintf(stream, "\t///< Output parameter");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2822 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2823 else if (style == document || element->simpleTypePtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2824 { // WSDL 2.0 document style
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2825 fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2826 fprintf(stream, anonymous ? anonformat : paraformat, types.pname(optional, prefix, URI, type), " ", types.aname(NULL, URI, name), sep);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2827 if (remark && *sep == ',')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2828 fprintf(stream, "\t///< Input parameter");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2829 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2830 else if (element->complexTypePtr())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2831 { // WSDL 2.0 RPC style
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2832 xs__seqchoice *seq = element->complexTypePtr()->sequence;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2833 for (vector<xs__contents>::const_iterator i = seq->__contents.begin(); i != seq->__contents.end(); ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2834 { if ((*i).__union == SOAP_UNION_xs__union_content_element)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2835 { name = (*i).__content.element->name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2836 type = (*i).__content.element->type;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2837 if (!type)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2838 type = name;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2839 fprintf(stream, "\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2840 fprintf(stream, anonymous ? anonformat : paraformat, types.pname(optional, prefix, URI, type), " ", types.aname(NULL, NULL, name), sep);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2841 if (remark && *sep == ',')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2842 fprintf(stream, "\t///< Input parameter");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2843 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2844 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2845 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2846 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2847 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2848
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2849 ////////////////////////////////////////////////////////////////////////////////
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2850 //
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2851 // Miscellaneous
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2852 //
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2853 ////////////////////////////////////////////////////////////////////////////////
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2854
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2855 static const char *urienc(struct soap *soap, const char *uri)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2856 { const char *r, *s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2857 char *t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2858 size_t n = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2859 if (!uri)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2860 return NULL;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2861 for (s = uri; *s; s++)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2862 if (!URI_CHAR(*s))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2863 n++;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2864 if (!n)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2865 return uri;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2866 n = strlen(uri) + 2*n;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2867 r = t = (char*)soap_malloc(soap, n + 1);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2868 for (s = uri; *s; s++)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2869 { if (URI_CHAR(*s))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2870 *t++ = *s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2871 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2872 { sprintf(t, "%%%.2x", *s);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2873 t += 3;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2874 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2875 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2876 *t = '\0';
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2877 return r;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2878 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2879
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2880 static bool imported(const char *tag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2881 { if (!tag || *tag != '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2882 return false;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2883 for (SetOfString::const_iterator u = exturis.begin(); u != exturis.end(); ++u)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2884 { size_t n = strlen(*u);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2885 if (!strncmp(*u, tag + 1, n) && tag[n+1] == '"')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2886 return true;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2887 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2888 return false;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2889 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2890
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2891 static void comment(const char *start, const char *middle, const char *end, const char *text)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2892 { if (text)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2893 { if (strchr(text, '\r') || strchr(text, '\n'))
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2894 fprintf(stream, "\n/** %s %s %s documentation:\n%s\n*/\n\n", start, middle, end, text);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2895 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2896 fprintf(stream, "\n/// %s %s %s: %s\n", start, middle, end, text);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2897 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2898 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2899
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2900 static void page(const char *page, const char *title, const char *text)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2901 { if (text)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2902 fprintf(stream, "\n@page %s%s \"%s\"\n", page, title, text);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2903 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2904 fprintf(stream, "\n@page %s%s\n", page, title);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2905 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2906
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2907 static void section(const char *section, const char *title, const char *text)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2908 { if (text)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2909 fprintf(stream, "\n@section %s%s \"%s\"\n", section, title, text);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2910 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2911 fprintf(stream, "\n@section %s%s\n", section, title);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2912 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2913
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2914 static void banner(const char *text)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2915 { int i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2916 if (!text)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2917 return;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2918 fprintf(stream, "\n/");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2919 for (i = 0; i < 78; i++)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2920 fputc('*', stream);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2921 fprintf(stream, "\\\n *%76s*\n * %-75s*\n *%76s*\n\\", "", text, "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2922 for (i = 0; i < 78; i++)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2923 fputc('*', stream);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2924 fprintf(stream, "/\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2925 if (vflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2926 fprintf(stderr, "\n----<< %s >>----\n\n", text);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2927 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2928
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2929 static void banner(const char *text1, const char *text2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2930 { int i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2931 if (!text1)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2932 return;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2933 fprintf(stream, "\n/");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2934 for (i = 0; i < 78; i++)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2935 fputc('*', stream);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2936 if (text2)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2937 fprintf(stream, "\\\n *%76s*\n * %-75s*\n * %-73s*\n *%76s*\n\\", "", text1, text2, "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2938 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2939 fprintf(stream, "\\\n *%76s*\n * %-75s*\n *%76s*\n\\", "", text1, "");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2940 for (i = 0; i < 78; i++)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2941 fputc('*', stream);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2942 fprintf(stream, "/\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2943 if (vflag)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2944 fprintf(stderr, "\n----<< %s: %s >>----\n\n", text1, text2?text2:"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2945 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2946
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2947 static void ident()
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2948 { time_t t = time(NULL), *p = &t;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2949 char tmp[256];
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2950 int i;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2951 strftime(tmp, 256, "%Y-%m-%d %H:%M:%S GMT", gmtime(p));
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2952 fprintf(stream, "/* %s\n Generated by wsdl2h " WSDL2H_VERSION " from ", outfile?outfile:"");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2953 if (infiles)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2954 { for (i = 0; i < infiles; i++)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2955 fprintf(stream, "%s ", infile[i]);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2956 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2957 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2958 fprintf(stream, "(stdin) ");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2959 fprintf(stream, "and %s\n %s\n\n DO NOT INCLUDE THIS FILE DIRECTLY INTO YOUR PROJECT BUILDS\n USE THE soapcpp2-GENERATED SOURCE CODE FILES FOR YOUR PROJECT BUILDS\n\n gSOAP XML Web services tools.\n Copyright (C) 2000-2013 Robert van Engelen, Genivia Inc. All Rights Reserved.\n Part of this software is released under one of the following licenses:\n GPL or Genivia's license for commercial use.\n*/\n\n", mapfile, tmp);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2960 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2961
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2962 void text(const char *text)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2963 { const char *s;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2964 if (!text)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2965 return;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2966 size_t k = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2967 for (s = text; *s; s++, k++)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2968 { switch (*s)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2969 { case '\n':
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2970 if (k)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2971 { fputc('\n', stream);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2972 k = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2973 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2974 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2975 case '\t':
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2976 k = 8 * ((k + 8) / 8) - 1;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2977 fputc('\t', stream);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2978 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2979 case '/':
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2980 fputc(*s, stream);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2981 if (s[1] == '*')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2982 fputc(' ', stream);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2983 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2984 case '*':
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2985 fputc(*s, stream);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2986 if (s[1] == '/')
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2987 fputc(' ', stream);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2988 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2989 case ' ':
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2990 if (k >= 79)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2991 { fputc('\n', stream);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2992 k = 0;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2993 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2994 else
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2995 fputc(' ', stream);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2996 break;
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2997 default:
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2998 if (*s >= 32)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
2999 fputc(*s, stream);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3000 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3001 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3002 if (k)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3003 fputc('\n', stream);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3004 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3005
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3006 ////////////////////////////////////////////////////////////////////////////////
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3007 //
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3008 // WS-Policy
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3009 //
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3010 ////////////////////////////////////////////////////////////////////////////////
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3011
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3012 static void gen_policy(Service& service, const vector<const wsp__Policy*>& policy, const char *text, Types& types)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3013 { if (!policy.empty())
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3014 { fprintf(stream, "\n - WS-Policy applicable to the %s:\n", text);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3015 for (vector<const wsp__Policy*>::const_iterator p = policy.begin(); p != policy.end(); ++p)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3016 if (*p)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3017 (*p)->generate(service, types, 0);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3018 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3019 }
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3020
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3021 static void gen_policy_enablers(const Service& service)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3022 { fprintf(stream, "\n/**\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3023 page(service.name, " Binding", service.name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3024 section(service.name, "_policy_enablers Policy Enablers of Binding ", service.name);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3025 fprintf(stream, "\nBased on policies, this service imports");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3026 for (VectorOfString::const_iterator i = service.imports.begin(); i != service.imports.end(); ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3027 fprintf(stream, " %s", *i);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3028 fprintf(stream, "\n\n - WS-Policy reminders and enablers:\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3029 fprintf(stream, " - WS-Addressing 1.0 (2005/08, accepts 2004/08):\n\t@code\n\t#import \"wsa5.h\" // to be added to this header file for the soapcpp2 build step\n\t@endcode\n\t@code\n\t#include \"plugin/wsaapi.h\"\n\tsoap_register_plugin(soap, soap_wsa); // register the wsa plugin in your code\n\t// See the user guide gsoap/doc/wsa/html/index.html\n\t@endcode\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3030 fprintf(stream, " - WS-Addressing (2004/08):\n\t@code\n\t#import \"wsa.h\" // to be added to this header file for the soapcpp2 build step\n\t@endcode\n\t@code\n\t#include \"plugin/wsaapi.h\"\n\tsoap_register_plugin(soap, soap_wsa); // register the wsa plugin in your code\n\t// See the user guide gsoap/doc/wsa/html/index.html\n\t@endcode\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3031 fprintf(stream, " - WS-ReliableMessaging 1.0:\n\t@code\n\t#import \"wsrm5.h\" // to be added to this header file for the soapcpp2 build step\n\t@endcode\n\t@code\n\t#include \"plugin/wsrmapi.h\"\n\tsoap_register_plugin(soap, soap_wsa); // register the wsa plugin in your code\n\tsoap_register_plugin(soap, soap_wsrm); // register the wsrm plugin in your code\n\t// See the user guide gsoap/doc/wsrm/html/index.html\n\t@endcode\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3032 fprintf(stream, " - WS-ReliableMessaging 1.1:\n\t@code\n\t#import \"wsrm.h\" // to be added to this header file for the soapcpp2 build step\n\t@endcode\n\t@code\n\t#include \"plugin/wsrmapi.h\"\n\tsoap_register_plugin(soap, soap_wsa); // register the wsa plugin in your code\n\tsoap_register_plugin(soap, soap_wsrm); // register the wsrm plugin in your code\n\t// See the user guide gsoap/doc/wsrm/html/index.html\n\t@endcode\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3033 fprintf(stream, " - WS-Security (SOAP Message Security) 1.0 (accepts 1.1):\n\t@code\n\t#import \"wsse.h\" // to be added to this header file for the soapcpp2 build step\n\t@endcode\n\t@code\n\t#include \"plugin/wsseapi.h\"\n\tsoap_register_plugin(soap, soap_wsse); // register the wsse plugin in your code\n\t// See the user guide gsoap/doc/wsse/html/index.html\n\t@endcode\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3034 fprintf(stream, " - WS-Security (SOAP Message Security) 1.1 (accepts 1.0):\n\t@code\n\t#import \"wsse11.h\" // to be added to this header file for the soapcpp2 build step\n\t@endcode\n\t@code\n\t#include \"plugin/wsseapi.h\"\n\tsoap_register_plugin(soap, soap_wsse); // register the wsse plugin in your code\n\t// See the user guide gsoap/doc/wsse/html/index.html\n\t@endcode\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3035 fprintf(stream, " - HTTP Digest Authentication:\n\t@code\n\t#include \"plugin/httpda.h\"\n\tsoap_register_plugin(soap, soap_http_da); // register the HTTP DA plugin in your code\n\t// See the user guide gsoap/doc/httpda/html/index.html\n\t@endcode\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3036 fprintf(stream, "*/\n\n");
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3037 for (VectorOfString::const_iterator i = service.imports.begin(); i != service.imports.end(); ++i)
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3038 fprintf(stream, "#import \"%s\"\n", *i);
8300eb051bea Initial upload
ktnyt
parents:
diff changeset
3039 }