-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathsoap.h
184 lines (147 loc) · 5.58 KB
/
soap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2014 Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 1997-2010 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#ifndef PHP_SOAP_H
#define PHP_SOAP_H
#include "hphp/runtime/ext/extension.h"
#include <map>
#include <memory>
#include <vector>
#include "hphp/runtime/ext/soap/sdl.h"
#include "hphp/runtime/base/request-local.h"
#include "hphp/runtime/base/exceptions.h"
#include "hphp/runtime/base/http-client.h"
#include "hphp/util/lock.h"
#include "hphp/runtime/base/request-event-handler.h"
///////////////////////////////////////////////////////////////////////////////
// defines
#define SOAP_CLASS 1
#define SOAP_FUNCTIONS 2
#define SOAP_OBJECT 3
#define SOAP_FUNCTIONS_ALL 999
#define SOAP_MAP_FUNCTION 1
#define SOAP_MAP_CLASS 2
#define SOAP_PERSISTENCE_SESSION 1
#define SOAP_PERSISTENCE_REQUEST 2
#define SOAP_1_1 1
#define SOAP_1_2 2
#define SOAP_ACTOR_NEXT 1
#define SOAP_ACTOR_NONE 2
#define SOAP_ACTOR_UNLIMATERECEIVER 3
#define SOAP_1_1_ACTOR_NEXT \
"http://schemas.xmlsoap.org/soap/actor/next"
#define SOAP_1_2_ACTOR_NEXT \
"http://www.w3.org/2003/05/soap-envelope/role/next"
#define SOAP_1_2_ACTOR_NONE \
"http://www.w3.org/2003/05/soap-envelope/role/none"
#define SOAP_1_2_ACTOR_UNLIMATERECEIVER \
"http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"
#define SOAP_COMPRESSION_ACCEPT 0x20
#define SOAP_COMPRESSION_GZIP 0x00
#define SOAP_COMPRESSION_DEFLATE 0x10
#define SOAP_AUTHENTICATION_BASIC 0
#define SOAP_AUTHENTICATION_DIGEST 1
#define SOAP_SINGLE_ELEMENT_ARRAYS (1<<0)
#define SOAP_WAIT_ONE_WAY_CALLS (1<<1)
#define SOAP_USE_XSI_ARRAY_TYPE (1<<2)
#define WSDL_CACHE_NONE 0x0
#define WSDL_CACHE_DISK 0x1
#define WSDL_CACHE_MEMORY 0x2
#define WSDL_CACHE_BOTH 0x3
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
class SoapData final : public RequestEventHandler {
// SDL cache
struct sdlCacheBucket {
sdlPtr sdl;
time_t time;
};
typedef hphp_string_hash_map<std::shared_ptr<sdlCacheBucket>,sdlCacheBucket>
sdlCache;
public:
SoapData();
sdl *get_sdl(const char *uri, long cache_wsdl, HttpClient *http = NULL);
encodeMap *register_typemap(encodeMapPtr typemap);
void register_encoding(xmlCharEncodingHandlerPtr encoding);
void requestInit() override { reset(); }
void requestShutdown() override { reset(); }
private:
sdlPtr get_sdl_impl(const char *uri, long cache_wsdl, HttpClient *http);
void reset();
public:
// globals that live across requests
encodeMap m_defEnc; // name => encode
std::map<int, encodePtr> m_defEncIndex; // type => encode
std::map<std::string, std::string> m_defEncNs; // namespaces => prefixes
// request scope globals to avoid passing them between functions
int m_soap_version;
sdl *m_sdl;
xmlCharEncodingHandlerPtr m_encoding;
Array m_classmap; // typename => class name
encodeMap *m_typemap; // typename => encode
int m_features;
// error handling
bool m_use_soap_error_handler;
const char *m_error_code;
Object m_error_object;
// misc
int m_cur_uniq_ns;
int m_cur_uniq_ref;
Array m_ref_map; // reference handling
int64_t m_cache;
private:
int64_t m_cache_ttl;
sdlCache m_mem_cache; // URL => sdl
hphp_hash_set<sdlPtr> m_sdls;
hphp_hash_set<encodeMapPtr> m_typemaps;
hphp_hash_set<xmlCharEncodingHandlerPtr> m_encodings;
};
#define USE_SOAP_GLOBAL SoapData *__sg__ = s_soap_data.get();
#define SOAP_GLOBAL(name) __sg__->m_##name
DECLARE_EXTERN_REQUEST_LOCAL(SoapData, s_soap_data);
///////////////////////////////////////////////////////////////////////////////
// types used by SoapServer
struct soapFunctions {
Array ft;
Array ftOriginal;
bool functions_all;
};
struct soapClass {
String name;
Array argv;
int persistance;
};
class soapHeader : public ResourceData {
public:
DECLARE_RESOURCE_ALLOCATION_NO_SWEEP(soapHeader);
CLASSNAME_IS("soapHeader")
// overriding ResourceData
virtual const String& o_getClassNameHook() const { return classnameof(); }
sdlFunction *function;
String function_name;
bool mustUnderstand;
Array parameters;
Variant retval;
sdlSoapBindingFunctionHeader *hdr;
};
///////////////////////////////////////////////////////////////////////////////
class SoapException : public ExtendedException {
public:
SoapException(const char *fmt, ...) ATTRIBUTE_PRINTF(2,3);
};
///////////////////////////////////////////////////////////////////////////////
}
#endif