xref: /php-src/ext/soap/php_soap.h (revision 50484b59)
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 "php_globals.h"
24 #include "ext/standard/info.h"
25 #include "ext/standard/php_standard.h"
26 #if defined(HAVE_PHP_SESSION) && !defined(COMPILE_DL_SESSION)
27 #include "ext/session/php_session.h"
28 #endif
29 #include "zend_smart_str.h"
30 #include "php_ini.h"
31 #include "SAPI.h"
32 #include <libxml/parser.h>
33 #include <libxml/xpath.h>
34 
35 #define PHP_SOAP_VERSION PHP_VERSION
36 
37 #ifndef PHP_WIN32
38 # define TRUE 1
39 # define FALSE 0
40 # define stricmp strcasecmp
41 #endif
42 
43 extern int le_url;
44 
45 typedef struct _encodeType encodeType, *encodeTypePtr;
46 typedef struct _encode encode, *encodePtr;
47 
48 typedef struct _sdl sdl, *sdlPtr;
49 typedef struct _sdlRestrictionInt sdlRestrictionInt, *sdlRestrictionIntPtr;
50 typedef struct _sdlRestrictionChar sdlRestrictionChar, *sdlRestrictionCharPtr;
51 typedef struct _sdlRestrictions sdlRestrictions, *sdlRestrictionsPtr;
52 typedef struct _sdlType sdlType, *sdlTypePtr;
53 typedef struct _sdlParam sdlParam, *sdlParamPtr;
54 typedef struct _sdlFunction sdlFunction, *sdlFunctionPtr;
55 typedef struct _sdlAttribute sdlAttribute, *sdlAttributePtr;
56 typedef struct _sdlBinding sdlBinding, *sdlBindingPtr;
57 typedef struct _sdlSoapBinding sdlSoapBinding, *sdlSoapBindingPtr;
58 typedef struct _sdlSoapBindingFunction sdlSoapBindingFunction, *sdlSoapBindingFunctionPtr;
59 typedef struct _sdlSoapBindingFunctionBody sdlSoapBindingFunctionBody, *sdlSoapBindingFunctionBodyPtr;
60 
61 typedef struct _soapMapping soapMapping, *soapMappingPtr;
62 typedef struct _soapService soapService, *soapServicePtr;
63 
64 #include "php_xml.h"
65 #include "php_encoding.h"
66 #include "php_sdl.h"
67 #include "php_schema.h"
68 #include "php_http.h"
69 #include "php_packet_soap.h"
70 
71 struct _soapMapping {
72 	zval to_xml;
73 	zval to_zval;
74 };
75 
76 struct _soapHeader;
77 
78 struct _soapService {
79 	sdlPtr sdl;
80 
81 	struct _soap_functions {
82 		HashTable *ft;
83 		int functions_all;
84 	} soap_functions;
85 
86 	struct _soap_class {
87 		zend_class_entry *ce;
88 		zval *argv;
89 		int argc;
90 		int persistence;
91 	} soap_class;
92 
93 	zval soap_object;
94 
95 	HashTable *typemap;
96 	int        version;
97 	int        type;
98 	char      *actor;
99 	char      *uri;
100 	xmlCharEncodingHandlerPtr encoding;
101 	HashTable *class_map;
102 	int        features;
103 	struct _soapHeader **soap_headers_ptr;
104 	int send_errors;
105 };
106 
107 #define SOAP_CLASS 1
108 #define SOAP_FUNCTIONS 2
109 #define SOAP_OBJECT 3
110 #define SOAP_FUNCTIONS_ALL 999
111 
112 #define SOAP_MAP_FUNCTION 1
113 #define SOAP_MAP_CLASS 2
114 
115 #define SOAP_PERSISTENCE_SESSION 1
116 #define SOAP_PERSISTENCE_REQUEST 2
117 
118 #define SOAP_1_1 1
119 #define SOAP_1_2 2
120 
121 #define SOAP_ACTOR_NEXT             1
122 #define SOAP_ACTOR_NONE             2
123 #define SOAP_ACTOR_UNLIMATERECEIVER 3
124 
125 #define SOAP_1_1_ACTOR_NEXT             "http://schemas.xmlsoap.org/soap/actor/next"
126 
127 #define SOAP_1_2_ACTOR_NEXT             "http://www.w3.org/2003/05/soap-envelope/role/next"
128 #define SOAP_1_2_ACTOR_NONE             "http://www.w3.org/2003/05/soap-envelope/role/none"
129 #define SOAP_1_2_ACTOR_UNLIMATERECEIVER "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"
130 
131 #define SOAP_COMPRESSION_ACCEPT  0x20
132 #define SOAP_COMPRESSION_GZIP    0x00
133 #define SOAP_COMPRESSION_DEFLATE 0x10
134 
135 #define SOAP_AUTHENTICATION_BASIC   0
136 #define SOAP_AUTHENTICATION_DIGEST  1
137 
138 #define SOAP_SINGLE_ELEMENT_ARRAYS  (1<<0)
139 #define SOAP_WAIT_ONE_WAY_CALLS     (1<<1)
140 #define SOAP_USE_XSI_ARRAY_TYPE     (1<<2)
141 
142 #define WSDL_CACHE_NONE     0x0
143 #define WSDL_CACHE_DISK     0x1
144 #define WSDL_CACHE_MEMORY   0x2
145 #define WSDL_CACHE_BOTH     0x3
146 
147 /* New SOAP SSL Method Constants */
148 #define SOAP_SSL_METHOD_TLS     0
149 #define SOAP_SSL_METHOD_SSLv2   1
150 #define SOAP_SSL_METHOD_SSLv3   2
151 #define SOAP_SSL_METHOD_SSLv23  3
152 
153 
154 ZEND_BEGIN_MODULE_GLOBALS(soap)
155 	HashTable  defEncNs;     /* mapping of default namespaces to prefixes */
156 	HashTable  defEnc;
157 	HashTable  defEncIndex;
158 	HashTable *typemap;
159 	int        cur_uniq_ns;
160 	int        soap_version;
161 	sdlPtr     sdl;
162 	bool  use_soap_error_handler;
163 	char*      error_code;
164 	zval       error_object;
165 	char       cache;
166 	char       cache_mode;
167 	char       cache_enabled;
168 	char*      cache_dir;
169 	zend_long       cache_ttl;
170 	zend_long       cache_limit;
171 	HashTable *mem_cache;
172 	xmlCharEncodingHandlerPtr encoding;
173 	HashTable *class_map;
174 	int        features;
175 	HashTable  wsdl_cache;
176 	int        cur_uniq_ref;
177 	HashTable *ref_map;
178 ZEND_END_MODULE_GLOBALS(soap)
179 
180 #ifdef ZTS
181 #include "TSRM.h"
182 #endif
183 
184 extern zend_module_entry soap_module_entry;
185 #define soap_module_ptr &soap_module_entry
186 #define phpext_soap_ptr soap_module_ptr
187 
188 ZEND_EXTERN_MODULE_GLOBALS(soap)
189 #define SOAP_GLOBAL(v) ZEND_MODULE_GLOBALS_ACCESSOR(soap, v)
190 
191 #if defined(ZTS) && defined(COMPILE_DL_SOAP)
192 ZEND_TSRMLS_CACHE_EXTERN()
193 #endif
194 
195 extern zend_class_entry* soap_class_entry;
196 extern zend_class_entry* soap_var_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 #endif
257