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_SOAP_H
20 #define PHP_SOAP_H
21
22 #include "php.h"
23 #include "ext/standard/php_standard.h"
24 #if defined(HAVE_PHP_SESSION) && !defined(COMPILE_DL_SESSION)
25 #include "ext/session/php_session.h"
26 #endif
27 #include "zend_smart_str.h"
28 #include "php_ini.h"
29 #include "SAPI.h"
30 #include <libxml/parser.h>
31 #include <libxml/xpath.h>
32
33 #define PHP_SOAP_VERSION PHP_VERSION
34
35 #ifndef PHP_WIN32
36 # define TRUE 1
37 # define FALSE 0
38 # define stricmp strcasecmp
39 #endif
40
41 typedef struct _encodeType encodeType, *encodeTypePtr;
42 typedef struct _encode encode, *encodePtr;
43
44 typedef struct _sdl sdl, *sdlPtr;
45 typedef struct _sdlRestrictionInt sdlRestrictionInt, *sdlRestrictionIntPtr;
46 typedef struct _sdlRestrictionChar sdlRestrictionChar, *sdlRestrictionCharPtr;
47 typedef struct _sdlRestrictions sdlRestrictions, *sdlRestrictionsPtr;
48 typedef struct _sdlType sdlType, *sdlTypePtr;
49 typedef struct _sdlParam sdlParam, *sdlParamPtr;
50 typedef struct _sdlFunction sdlFunction, *sdlFunctionPtr;
51 typedef struct _sdlAttribute sdlAttribute, *sdlAttributePtr;
52 typedef struct _sdlBinding sdlBinding, *sdlBindingPtr;
53 typedef struct _sdlSoapBinding sdlSoapBinding, *sdlSoapBindingPtr;
54 typedef struct _sdlSoapBindingFunction sdlSoapBindingFunction, *sdlSoapBindingFunctionPtr;
55 typedef struct _sdlSoapBindingFunctionBody sdlSoapBindingFunctionBody, *sdlSoapBindingFunctionBodyPtr;
56
57 typedef struct _soapMapping soapMapping, *soapMappingPtr;
58 typedef struct _soapService soapService, *soapServicePtr;
59
60 #include "php_xml.h"
61 #include "php_encoding.h"
62 #include "php_sdl.h"
63 #include "php_schema.h"
64 #include "php_http.h"
65 #include "php_packet_soap.h"
66
67 struct _soapMapping {
68 zval to_xml;
69 zval to_zval;
70 };
71
72 struct _soapHeader;
73
74 struct _soapService {
75 sdlPtr sdl;
76
77 struct _soap_functions {
78 HashTable *ft;
79 int functions_all;
80 } soap_functions;
81
82 struct _soap_class {
83 zend_class_entry *ce;
84 zval *argv;
85 uint32_t argc;
86 int persistence;
87 } soap_class;
88
89 zval soap_object;
90
91 HashTable *typemap;
92 int version;
93 int type;
94 char *actor;
95 char *uri;
96 xmlCharEncodingHandlerPtr encoding;
97 HashTable *class_map;
98 int features;
99 int send_errors;
100 struct _soapHeader **soap_headers_ptr;
101
102 bool trace;
103 zend_string *last_response_body;
104 };
105
106 #define SOAP_CLASS 1
107 #define SOAP_FUNCTIONS 2
108 #define SOAP_OBJECT 3
109 #define SOAP_FUNCTIONS_ALL 999
110
111 #define SOAP_MAP_FUNCTION 1
112 #define SOAP_MAP_CLASS 2
113
114 #define SOAP_PERSISTENCE_SESSION 1
115 #define SOAP_PERSISTENCE_REQUEST 2
116
117 #define SOAP_1_1 1
118 #define SOAP_1_2 2
119
120 #define SOAP_ACTOR_NEXT 1
121 #define SOAP_ACTOR_NONE 2
122 #define SOAP_ACTOR_UNLIMATERECEIVER 3
123
124 #define SOAP_1_1_ACTOR_NEXT "http://schemas.xmlsoap.org/soap/actor/next"
125
126 #define SOAP_1_2_ACTOR_NEXT "http://www.w3.org/2003/05/soap-envelope/role/next"
127 #define SOAP_1_2_ACTOR_NONE "http://www.w3.org/2003/05/soap-envelope/role/none"
128 #define SOAP_1_2_ACTOR_UNLIMATERECEIVER "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"
129
130 #define SOAP_COMPRESSION_ACCEPT 0x20
131 #define SOAP_COMPRESSION_GZIP 0x00
132 #define SOAP_COMPRESSION_DEFLATE 0x10
133
134 #define SOAP_AUTHENTICATION_BASIC 0
135 #define SOAP_AUTHENTICATION_DIGEST 1
136
137 #define SOAP_SINGLE_ELEMENT_ARRAYS (1<<0)
138 #define SOAP_WAIT_ONE_WAY_CALLS (1<<1)
139 #define SOAP_USE_XSI_ARRAY_TYPE (1<<2)
140
141 #define WSDL_CACHE_NONE 0x0
142 #define WSDL_CACHE_DISK 0x1
143 #define WSDL_CACHE_MEMORY 0x2
144 #define WSDL_CACHE_BOTH 0x3
145
146 /* New SOAP SSL Method Constants */
147 #define SOAP_SSL_METHOD_TLS 0
148 #define SOAP_SSL_METHOD_SSLv2 1
149 #define SOAP_SSL_METHOD_SSLv3 2
150 #define SOAP_SSL_METHOD_SSLv23 3
151
152
153 ZEND_BEGIN_MODULE_GLOBALS(soap)
154 HashTable defEncNs; /* mapping of default namespaces to prefixes */
155 HashTable defEnc;
156 HashTable defEncIndex;
157 HashTable *typemap;
158 int cur_uniq_ns;
159 int soap_version;
160 sdlPtr sdl;
161 char* error_code;
162 zval error_object;
163 bool use_soap_error_handler;
164 char cache_mode;
165 char cache_enabled;
166 char* cache_dir;
167 zend_long cache_ttl;
168 zend_long cache_limit;
169 HashTable *mem_cache;
170 xmlCharEncodingHandlerPtr encoding;
171 HashTable *class_map;
172 int features;
173 HashTable wsdl_cache;
174 int cur_uniq_ref;
175 HashTable *ref_map;
176 ZEND_END_MODULE_GLOBALS(soap)
177
178 #ifdef ZTS
179 #include "TSRM.h"
180 #endif
181
182 extern zend_module_entry soap_module_entry;
183 #define soap_module_ptr &soap_module_entry
184 #define phpext_soap_ptr soap_module_ptr
185
186 ZEND_EXTERN_MODULE_GLOBALS(soap)
187 #define SOAP_GLOBAL(v) ZEND_MODULE_GLOBALS_ACCESSOR(soap, v)
188
189 #if defined(ZTS) && defined(COMPILE_DL_SOAP)
190 ZEND_TSRMLS_CACHE_EXTERN()
191 #endif
192
193 extern zend_class_entry* soap_class_entry;
194 extern zend_class_entry* soap_var_class_entry;
195 extern zend_class_entry* soap_url_class_entry;
196 extern zend_class_entry* soap_sdl_class_entry;
197
198 void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail);
199
200 #define soap_error0(severity, format) \
201 php_error(severity, "SOAP-ERROR: " format)
202
203 #define soap_error1(severity, format, param1) \
204 php_error(severity, "SOAP-ERROR: " format, param1)
205
206 #define soap_error2(severity, format, param1, param2) \
207 php_error(severity, "SOAP-ERROR: " format, param1, param2)
208
209 #define soap_error3(severity, format, param1, param2, param3) \
210 php_error(severity, "SOAP-ERROR: " format, param1, param2, param3)
211
php_soap_deref(zval * zv)212 static zend_always_inline zval *php_soap_deref(zval *zv) {
213 if (UNEXPECTED(Z_TYPE_P(zv) == IS_REFERENCE)) {
214 return Z_REFVAL_P(zv);
215 }
216 return zv;
217 }
218
219 #define Z_CLIENT_URI_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 0))
220 #define Z_CLIENT_STYLE_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 1))
221 #define Z_CLIENT_USE_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 2))
222 #define Z_CLIENT_LOCATION_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 3))
223 #define Z_CLIENT_TRACE_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 4))
224 #define Z_CLIENT_COMPRESSION_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 5))
225 #define Z_CLIENT_SDL_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 6))
226 #define Z_CLIENT_TYPEMAP_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 7))
227 #define Z_CLIENT_HTTPSOCKET_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 8))
228 #define Z_CLIENT_HTTPURL_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 9))
229 #define Z_CLIENT_LOGIN_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 10))
230 #define Z_CLIENT_PASSWORD_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 11))
231 #define Z_CLIENT_USE_DIGEST_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 12))
232 #define Z_CLIENT_DIGEST_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 13))
233 #define Z_CLIENT_PROXY_HOST_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 14))
234 #define Z_CLIENT_PROXY_PORT_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 15))
235 #define Z_CLIENT_PROXY_LOGIN_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 16))
236 #define Z_CLIENT_PROXY_PASSWORD_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 17))
237 #define Z_CLIENT_EXCEPTIONS_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 18))
238 #define Z_CLIENT_ENCODING_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 19))
239 #define Z_CLIENT_CLASSMAP_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 20))
240 #define Z_CLIENT_FEATURES_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 21))
241 #define Z_CLIENT_CONNECTION_TIMEOUT_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 22))
242 #define Z_CLIENT_STREAM_CONTEXT_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 23))
243 #define Z_CLIENT_USER_AGENT_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 24))
244 #define Z_CLIENT_KEEP_ALIVE_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 25))
245 #define Z_CLIENT_SSL_METHOD_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 26))
246 #define Z_CLIENT_SOAP_VERSION_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 27))
247 #define Z_CLIENT_USE_PROXY_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 28))
248 #define Z_CLIENT_COOKIES_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 29))
249 #define Z_CLIENT_DEFAULT_HEADERS_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 30))
250 #define Z_CLIENT_SOAP_FAULT_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 31))
251 #define Z_CLIENT_LAST_REQUEST_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 32))
252 #define Z_CLIENT_LAST_RESPONSE_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 33))
253 #define Z_CLIENT_LAST_REQUEST_HEADERS_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 34))
254 #define Z_CLIENT_LAST_RESPONSE_HEADERS_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 35))
255
256 typedef struct soap_url_object {
257 php_url *url;
258 zend_object std;
259 } soap_url_object;
260
soap_url_object_fetch(zend_object * obj)261 static inline soap_url_object *soap_url_object_fetch(zend_object *obj)
262 {
263 return (soap_url_object *) ((char *) obj - XtOffsetOf(soap_url_object, std));
264 }
265
266 #define Z_SOAP_URL_P(zv) soap_url_object_fetch(Z_OBJ_P(zv))
267
268 typedef struct soap_sdl_object {
269 sdl *sdl;
270 zend_object std;
271 } soap_sdl_object;
272
273 #endif
274