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