xref: /PHP-8.1/ext/soap/php_sdl.h (revision 01b3fc03)
1 /*
2   +----------------------------------------------------------------------+
3   | Copyright (c) The PHP Group                                          |
4   +----------------------------------------------------------------------+
5   | This source file is subject to version 3.01 of the PHP license,      |
6   | that is bundled with this package in the file LICENSE, and is        |
7   | available through the world-wide-web at the following url:           |
8   | https://www.php.net/license/3_01.txt                                 |
9   | If you did not receive a copy of the PHP license and are unable to   |
10   | obtain it through the world-wide-web, please send a note to          |
11   | license@php.net so we can mail you a copy immediately.               |
12   +----------------------------------------------------------------------+
13   | Authors: Brad Lafountain <rodif_bl@yahoo.com>                        |
14   |          Shane Caraveo <shane@caraveo.com>                           |
15   |          Dmitry Stogov <dmitry@php.net>                              |
16   +----------------------------------------------------------------------+
17 */
18 
19 #ifndef PHP_SDL_H
20 #define PHP_SDL_H
21 
22 #define XSD_WHITESPACE_COLLAPSE 1
23 #define XSD_WHITESPACE_PRESERVE 1
24 #define XSD_WHITESPACE_REPLACE  1
25 
26 typedef enum _sdlBindingType {
27 	BINDING_SOAP = 1,
28 	BINDING_HTTP = 2
29 } sdlBindingType;
30 
31 typedef enum _sdlEncodingStyle {
32 	SOAP_RPC      = 1,
33 	SOAP_DOCUMENT = 2
34 } sdlEncodingStyle;
35 
36 typedef enum _sdlRpcEncodingStyle {
37 	SOAP_ENCODING_DEFAULT = 0,
38 	SOAP_ENCODING_1_1     = 1,
39 	SOAP_ENCODING_1_2     = 2
40 } sdlRpcEncodingStyle;
41 
42 typedef enum _sdlEncodingUse {
43 	SOAP_ENCODED = 1,
44 	SOAP_LITERAL = 2
45 } sdlEncodingUse;
46 
47 typedef enum _sdlTransport {
48 	SOAP_TRANSPORT_HTTP = 1
49 } sdlTransport;
50 
51 struct _sdl {
52 	HashTable  functions;        /* array of sdlFunction */
53 	HashTable *types;            /* array of sdlTypesPtr */
54 	HashTable *elements;         /* array of sdlTypesPtr */
55 	HashTable *encoders;         /* array of encodePtr */
56 	HashTable *bindings;         /* array of sdlBindings (key'd by name) */
57 	HashTable *requests;         /* array of sdlFunction (references) */
58 	HashTable *groups;           /* array of sdlTypesPtr */
59 	char      *target_ns;
60 	char      *source;
61 	bool  is_persistent;
62 };
63 
64 typedef struct sdlCtx {
65 	sdlPtr     sdl;
66 
67 	HashTable  docs;             /* array of xmlDocPtr */
68 
69 	HashTable  messages;         /* array of xmlNodePtr */
70 	HashTable  bindings;         /* array of xmlNodePtr */
71 	HashTable  portTypes;        /* array of xmlNodePtr */
72 	HashTable  services;         /* array of xmlNodePtr */
73 
74 	HashTable *attributes;       /* array of sdlAttributePtr */
75 	HashTable *attributeGroups;  /* array of sdlTypesPtr */
76 	php_stream_context *context;
77 	zval               old_header;
78 } sdlCtx;
79 
80 struct _sdlBinding {
81 	char           *name;
82 	char           *location;
83 	sdlBindingType  bindingType;
84 	void           *bindingAttributes; /* sdlSoapBindingPtr */
85 };
86 
87 /* Soap Binding Specific stuff */
88 struct _sdlSoapBinding {
89 	sdlEncodingStyle  style;
90 	sdlTransport      transport; /* not implemented yet */
91 };
92 
93 typedef struct _sdlSoapBindingFunctionHeader {
94 	char                *name;
95 	char                *ns;
96 	sdlEncodingUse       use;
97 	sdlTypePtr           element;
98 	encodePtr            encode;
99 	sdlRpcEncodingStyle  encodingStyle; /* not implemented yet */
100 	HashTable           *headerfaults;  /* array of sdlSoapBindingFunctionHeaderPtr */
101 } sdlSoapBindingFunctionHeader, *sdlSoapBindingFunctionHeaderPtr;
102 
103 typedef struct _sdlSoapBindingFunctionFault {
104 	char                *ns;
105 	sdlEncodingUse       use;
106 	sdlRpcEncodingStyle  encodingStyle; /* not implemented yet */
107 } sdlSoapBindingFunctionFault, *sdlSoapBindingFunctionFaultPtr;
108 
109 struct _sdlSoapBindingFunctionBody {
110 	char                *ns;
111 	sdlEncodingUse       use;
112 	sdlRpcEncodingStyle  encodingStyle;  /* not implemented yet */
113 	HashTable           *headers;        /* array of sdlSoapBindingFunctionHeaderPtr */
114 };
115 
116 struct _sdlSoapBindingFunction {
117 	char                       *soapAction;
118 	sdlEncodingStyle            style;
119 
120 	sdlSoapBindingFunctionBody  input;
121 	sdlSoapBindingFunctionBody  output;
122 };
123 
124 struct _sdlRestrictionInt {
125 	int   value;
126 	char  fixed;
127 };
128 
129 struct _sdlRestrictionChar {
130 	char *value;
131 	char  fixed;
132 };
133 
134 struct _sdlRestrictions {
135 	HashTable *enumeration;              /* array of sdlRestrictionCharPtr */
136 	sdlRestrictionIntPtr minExclusive;
137 	sdlRestrictionIntPtr minInclusive;
138 	sdlRestrictionIntPtr maxExclusive;
139 	sdlRestrictionIntPtr maxInclusive;
140 	sdlRestrictionIntPtr totalDigits;
141 	sdlRestrictionIntPtr fractionDigits;
142 	sdlRestrictionIntPtr length;
143 	sdlRestrictionIntPtr minLength;
144 	sdlRestrictionIntPtr maxLength;
145 	sdlRestrictionCharPtr whiteSpace;
146 	sdlRestrictionCharPtr pattern;
147 };
148 
149 typedef enum _sdlContentKind {
150 	XSD_CONTENT_ELEMENT,
151 	XSD_CONTENT_SEQUENCE,
152 	XSD_CONTENT_ALL,
153 	XSD_CONTENT_CHOICE,
154 	XSD_CONTENT_GROUP_REF,
155 	XSD_CONTENT_GROUP,
156 	XSD_CONTENT_ANY
157 } sdlContentKind;
158 
159 
160 typedef struct _sdlContentModel sdlContentModel, *sdlContentModelPtr;
161 
162 struct _sdlContentModel {
163 	sdlContentKind kind;
164 	int min_occurs;
165 	int max_occurs;
166 	union {
167 		sdlTypePtr          element;      /* pointer to element */
168 		sdlTypePtr          group;        /* pointer to group */
169 		HashTable          *content;      /* array of sdlContentModel for sequnce,all,choice*/
170 		char               *group_ref;    /* reference to group */
171 	} u;
172 };
173 
174 typedef enum _sdlTypeKind {
175 	XSD_TYPEKIND_SIMPLE,
176 	XSD_TYPEKIND_LIST,
177 	XSD_TYPEKIND_UNION,
178 	XSD_TYPEKIND_COMPLEX,
179 	XSD_TYPEKIND_RESTRICTION,
180 	XSD_TYPEKIND_EXTENSION
181 } sdlTypeKind;
182 
183 typedef enum _sdlUse {
184 	XSD_USE_DEFAULT,
185 	XSD_USE_OPTIONAL,
186 	XSD_USE_PROHIBITED,
187 	XSD_USE_REQUIRED
188 } sdlUse;
189 
190 typedef enum _sdlForm {
191 	XSD_FORM_DEFAULT,
192 	XSD_FORM_QUALIFIED,
193 	XSD_FORM_UNQUALIFIED
194 } sdlForm;
195 
196 struct _sdlType {
197 	sdlTypeKind         kind;
198 	char               *name;
199 	char               *namens;
200 	char                nillable;
201 	HashTable          *elements;             /* array of sdlTypePtr */
202 	HashTable          *attributes;           /* array of sdlAttributePtr */
203 	sdlRestrictionsPtr  restrictions;
204 	encodePtr           encode;
205 	sdlContentModelPtr  model;
206 	char               *def;
207 	char               *fixed;
208 	char               *ref;
209 	sdlForm             form;
210 };
211 
212 struct _sdlParam {
213 	int        order;
214 	sdlTypePtr element;
215 	encodePtr  encode;
216 	char      *paramName;
217 };
218 
219 typedef struct _sdlFault {
220 	char      *name;
221 	HashTable *details;            /* array of sdlParamPtr */
222 	void      *bindingAttributes;  /* sdlSoapBindingFunctionFaultPtr */
223 } sdlFault, *sdlFaultPtr;
224 
225 struct _sdlFunction {
226 	char               *functionName;
227 	char               *requestName;
228 	char               *responseName;
229 	HashTable          *requestParameters;  /* array of sdlParamPtr */
230 	HashTable          *responseParameters; /* array of sdlParamPtr (this should only be one) */
231 	struct _sdlBinding *binding;
232 	void               *bindingAttributes;  /* sdlSoapBindingFunctionPtr */
233 	HashTable          *faults;             /* array of sdlFaultPtr */
234 };
235 
236 typedef struct _sdlExtraAttribute {
237 	char *ns;
238 	char *val;
239 } sdlExtraAttribute, *sdlExtraAttributePtr;
240 
241 struct _sdlAttribute {
242 	char      *name;
243 	char      *namens;
244 	char      *ref;
245 	char      *def;
246 	char      *fixed;
247 	sdlForm    form;
248 	sdlUse     use;
249 	HashTable *extraAttributes;			/* array of sdlExtraAttribute */
250 	encodePtr  encode;
251 };
252 
253 
254 sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl);
255 
256 encodePtr get_encoder_from_prefix(sdlPtr sdl, xmlNodePtr data, const xmlChar *type);
257 encodePtr get_encoder(sdlPtr sdl, const char *ns, const char *type);
258 encodePtr get_encoder_ex(sdlPtr sdl, const char *nscat, int len);
259 
260 sdlBindingPtr get_binding_from_type(sdlPtr sdl, sdlBindingType type);
261 sdlBindingPtr get_binding_from_name(sdlPtr sdl, char *name, char *ns);
262 
263 void delete_sdl(void *handle);
264 void delete_sdl_impl(void *handle);
265 
266 void sdl_set_uri_credentials(sdlCtx *ctx, char *uri);
267 void sdl_restore_uri_credentials(sdlCtx *ctx);
268 
269 #endif
270