2 +----------------------------------------------------------------------+
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 +----------------------------------------------------------------------+
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 ///////////////////////////////////////////////////////////////////////////////
32 #define SOAP_FUNCTIONS 2
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
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
75 ///////////////////////////////////////////////////////////////////////////////
77 class SoapData
: public RequestEventHandler
{
80 DECLARE_BOOST_TYPES(sdlCacheBucket
);
81 struct sdlCacheBucket
{
85 typedef StringTosdlCacheBucketPtrMap sdlCache
;
92 sdlCache m_mem_cache
; // URL => sdl
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
);
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
108 // request scope globals to avoid passing them between functions
111 xmlCharEncodingHandlerPtr m_encoding
;
112 Array m_classmap
; // typename => class name
113 encodeMap
*m_typemap
; // typename => encode
117 bool m_use_soap_error_handler
;
118 const char *m_error_code
;
119 Object m_error_object
;
124 Array m_ref_map
; // reference handling
127 virtual void requestInit() { reset();}
128 virtual void requestShutdown() { reset();}
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
);
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
{
158 class soapHeader
: public ResourceData
{
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
;
171 sdlSoapBindingFunctionHeader
*hdr
;
174 ///////////////////////////////////////////////////////////////////////////////
176 class SoapException
: public ExtendedException
{
178 SoapException(const char *fmt
, ...);
181 ///////////////////////////////////////////////////////////////////////////////