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