xref: /php-src/ext/soap/php_soap.h (revision fd2d8696)
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 	zval       class_map;
98 	int        features;
99 	int        send_errors;
100 	struct _soapHeader **soap_headers_ptr;
101 };
102 
103 #define SOAP_CLASS 1
104 #define SOAP_FUNCTIONS 2
105 #define SOAP_OBJECT 3
106 #define SOAP_FUNCTIONS_ALL 999
107 
108 #define SOAP_MAP_FUNCTION 1
109 #define SOAP_MAP_CLASS 2
110 
111 #define SOAP_PERSISTENCE_SESSION 1
112 #define SOAP_PERSISTENCE_REQUEST 2
113 
114 #define SOAP_1_1 1
115 #define SOAP_1_2 2
116 
117 #define SOAP_ACTOR_NEXT             1
118 #define SOAP_ACTOR_NONE             2
119 #define SOAP_ACTOR_UNLIMATERECEIVER 3
120 
121 #define SOAP_1_1_ACTOR_NEXT             "http://schemas.xmlsoap.org/soap/actor/next"
122 
123 #define SOAP_1_2_ACTOR_NEXT             "http://www.w3.org/2003/05/soap-envelope/role/next"
124 #define SOAP_1_2_ACTOR_NONE             "http://www.w3.org/2003/05/soap-envelope/role/none"
125 #define SOAP_1_2_ACTOR_UNLIMATERECEIVER "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"
126 
127 #define SOAP_COMPRESSION_ACCEPT  0x20
128 #define SOAP_COMPRESSION_GZIP    0x00
129 #define SOAP_COMPRESSION_DEFLATE 0x10
130 
131 #define SOAP_AUTHENTICATION_BASIC   0
132 #define SOAP_AUTHENTICATION_DIGEST  1
133 
134 #define SOAP_SINGLE_ELEMENT_ARRAYS  (1<<0)
135 #define SOAP_WAIT_ONE_WAY_CALLS     (1<<1)
136 #define SOAP_USE_XSI_ARRAY_TYPE     (1<<2)
137 
138 #define WSDL_CACHE_NONE     0x0
139 #define WSDL_CACHE_DISK     0x1
140 #define WSDL_CACHE_MEMORY   0x2
141 #define WSDL_CACHE_BOTH     0x3
142 
143 /* New SOAP SSL Method Constants */
144 #define SOAP_SSL_METHOD_TLS     0
145 #define SOAP_SSL_METHOD_SSLv2   1
146 #define SOAP_SSL_METHOD_SSLv3   2
147 #define SOAP_SSL_METHOD_SSLv23  3
148 
149 
150 ZEND_BEGIN_MODULE_GLOBALS(soap)
151 	HashTable  defEncNs;     /* mapping of default namespaces to prefixes */
152 	HashTable  defEnc;
153 	HashTable  defEncIndex;
154 	HashTable *typemap;
155 	int        cur_uniq_ns;
156 	int        soap_version;
157 	sdlPtr     sdl;
158 	char*      error_code;
159 	zval       error_object;
160 	bool       use_soap_error_handler;
161 	char       cache;
162 	char       cache_mode;
163 	char       cache_enabled;
164 	char*      cache_dir;
165 	zend_long       cache_ttl;
166 	zend_long       cache_limit;
167 	HashTable *mem_cache;
168 	xmlCharEncodingHandlerPtr encoding;
169 	HashTable *class_map;
170 	int        features;
171 	HashTable  wsdl_cache;
172 	int        cur_uniq_ref;
173 	HashTable *ref_map;
174 ZEND_END_MODULE_GLOBALS(soap)
175 
176 #ifdef ZTS
177 #include "TSRM.h"
178 #endif
179 
180 extern zend_module_entry soap_module_entry;
181 #define soap_module_ptr &soap_module_entry
182 #define phpext_soap_ptr soap_module_ptr
183 
184 ZEND_EXTERN_MODULE_GLOBALS(soap)
185 #define SOAP_GLOBAL(v) ZEND_MODULE_GLOBALS_ACCESSOR(soap, v)
186 
187 #if defined(ZTS) && defined(COMPILE_DL_SOAP)
188 ZEND_TSRMLS_CACHE_EXTERN()
189 #endif
190 
191 extern zend_class_entry* soap_class_entry;
192 extern zend_class_entry* soap_var_class_entry;
193 extern zend_class_entry* soap_url_class_entry;
194 extern zend_class_entry* soap_sdl_class_entry;
195 
196 void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail);
197 
198 #define soap_error0(severity, format) \
199 	php_error(severity, "SOAP-ERROR: " format)
200 
201 #define soap_error1(severity, format, param1) \
202 	php_error(severity, "SOAP-ERROR: " format, param1)
203 
204 #define soap_error2(severity, format, param1, param2) \
205 	php_error(severity, "SOAP-ERROR: " format, param1, param2)
206 
207 #define soap_error3(severity, format, param1, param2, param3) \
208 	php_error(severity, "SOAP-ERROR: " format, param1, param2, param3)
209 
php_soap_deref(zval * zv)210 static zend_always_inline zval *php_soap_deref(zval *zv) {
211 	if (UNEXPECTED(Z_TYPE_P(zv) == IS_REFERENCE)) {
212 		return Z_REFVAL_P(zv);
213 	}
214 	return zv;
215 }
216 
217 #define Z_CLIENT_URI_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 0))
218 #define Z_CLIENT_STYLE_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 1))
219 #define Z_CLIENT_USE_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 2))
220 #define Z_CLIENT_LOCATION_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 3))
221 #define Z_CLIENT_TRACE_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 4))
222 #define Z_CLIENT_COMPRESSION_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 5))
223 #define Z_CLIENT_SDL_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 6))
224 #define Z_CLIENT_TYPEMAP_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 7))
225 #define Z_CLIENT_HTTPSOCKET_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 8))
226 #define Z_CLIENT_HTTPURL_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 9))
227 #define Z_CLIENT_LOGIN_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 10))
228 #define Z_CLIENT_PASSWORD_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 11))
229 #define Z_CLIENT_USE_DIGEST_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 12))
230 #define Z_CLIENT_DIGEST_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 13))
231 #define Z_CLIENT_PROXY_HOST_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 14))
232 #define Z_CLIENT_PROXY_PORT_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 15))
233 #define Z_CLIENT_PROXY_LOGIN_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 16))
234 #define Z_CLIENT_PROXY_PASSWORD_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 17))
235 #define Z_CLIENT_EXCEPTIONS_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 18))
236 #define Z_CLIENT_ENCODING_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 19))
237 #define Z_CLIENT_CLASSMAP_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 20))
238 #define Z_CLIENT_FEATURES_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 21))
239 #define Z_CLIENT_CONNECTION_TIMEOUT_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 22))
240 #define Z_CLIENT_STREAM_CONTEXT_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 23))
241 #define Z_CLIENT_USER_AGENT_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 24))
242 #define Z_CLIENT_KEEP_ALIVE_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 25))
243 #define Z_CLIENT_SSL_METHOD_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 26))
244 #define Z_CLIENT_SOAP_VERSION_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 27))
245 #define Z_CLIENT_USE_PROXY_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 28))
246 #define Z_CLIENT_COOKIES_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 29))
247 #define Z_CLIENT_DEFAULT_HEADERS_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 30))
248 #define Z_CLIENT_SOAP_FAULT_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 31))
249 #define Z_CLIENT_LAST_REQUEST_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 32))
250 #define Z_CLIENT_LAST_RESPONSE_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 33))
251 #define Z_CLIENT_LAST_REQUEST_HEADERS_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 34))
252 #define Z_CLIENT_LAST_RESPONSE_HEADERS_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 35))
253 
254 typedef struct soap_url_object {
255 	php_url *url;
256 	zend_object std;
257 } soap_url_object;
258 
soap_url_object_fetch(zend_object * obj)259 static inline soap_url_object *soap_url_object_fetch(zend_object *obj)
260 {
261 	return (soap_url_object *) ((char *) obj - XtOffsetOf(soap_url_object, std));
262 }
263 
264 #define Z_SOAP_URL_P(zv) soap_url_object_fetch(Z_OBJ_P(zv))
265 
266 typedef struct soap_sdl_object {
267 	sdl *sdl;
268 	zend_object std;
269 } soap_sdl_object;
270 
271 #endif
272