Diff for /embedaddon/php/ext/soap/soap.c between versions 1.1 and 1.1.1.5

version 1.1, 2012/02/21 23:48:01 version 1.1.1.5, 2014/06/15 20:03:55
Line 2 Line 2
   +----------------------------------------------------------------------+    +----------------------------------------------------------------------+
   | PHP Version 5                                                        |    | PHP Version 5                                                        |
   +----------------------------------------------------------------------+    +----------------------------------------------------------------------+
  | Copyright (c) 1997-2012 The PHP Group                                |  | Copyright (c) 1997-2014 The PHP Group                                |
   +----------------------------------------------------------------------+    +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |    | 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        |    | that is bundled with this package in the file LICENSE, and is        |
Line 26 Line 26
 #if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)  #if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
 #include "ext/session/php_session.h"  #include "ext/session/php_session.h"
 #endif  #endif
#ifdef ZEND_ENGINE_2#include "zend_exceptions.h"
#  include "zend_exceptions.h" 
#endif 
   
   
 static int le_sdl = 0;  static int le_sdl = 0;
 int le_url = 0;  int le_url = 0;
 static int le_service = 0;  static int le_service = 0;
Line 69  static void delete_service(void *service); Line 68  static void delete_service(void *service);
 static void delete_url(void *handle);  static void delete_url(void *handle);
 static void delete_hashtable(void *hashtable);  static void delete_hashtable(void *hashtable);
   
 #ifndef ZEND_ENGINE_2  
 static void soap_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference);  
 #endif  
   
 static void soap_error_handler(int error_num, const char *error_filename, const uint error_lineno, const char *format, va_list args);  static void soap_error_handler(int error_num, const char *error_filename, const uint error_lineno, const char *format, va_list args);
   
 #define SOAP_SERVER_BEGIN_CODE() \  #define SOAP_SERVER_BEGIN_CODE() \
Line 90  static void soap_error_handler(int error_num, const ch Line 85  static void soap_error_handler(int error_num, const ch
         SOAP_GLOBAL(error_object) = _old_error_object;\          SOAP_GLOBAL(error_object) = _old_error_object;\
         SOAP_GLOBAL(soap_version) = _old_soap_version;          SOAP_GLOBAL(soap_version) = _old_soap_version;
   
 #ifdef ZEND_ENGINE_2  
 #define SOAP_CLIENT_BEGIN_CODE() \  #define SOAP_CLIENT_BEGIN_CODE() \
         zend_bool _old_handler = SOAP_GLOBAL(use_soap_error_handler);\          zend_bool _old_handler = SOAP_GLOBAL(use_soap_error_handler);\
         char* _old_error_code = SOAP_GLOBAL(error_code);\          char* _old_error_code = SOAP_GLOBAL(error_code);\
Line 134  static void soap_error_handler(int error_num, const ch Line 128  static void soap_error_handler(int error_num, const ch
         if (_bailout) {\          if (_bailout) {\
                 zend_bailout();\                  zend_bailout();\
         }          }
 #else  
 #define SOAP_CLIENT_BEGIN_CODE() \  
         zend_bool _old_handler = SOAP_GLOBAL(use_soap_error_handler);\  
         char* _old_error_code = SOAP_GLOBAL(error_code);\  
         zval* _old_error_object = SOAP_GLOBAL(error_object);\  
         int _old_soap_version = SOAP_GLOBAL(soap_version);\  
         SOAP_GLOBAL(use_soap_error_handler) = 1;\  
         SOAP_GLOBAL(error_code) = "Client";\  
         SOAP_GLOBAL(error_object) = this_ptr;  
   
 #define SOAP_CLIENT_END_CODE() \  
         SOAP_GLOBAL(use_soap_error_handler) = _old_handler;\  
         SOAP_GLOBAL(error_code) = _old_error_code;\  
         SOAP_GLOBAL(error_object) = _old_error_object;\  
         SOAP_GLOBAL(soap_version) = _old_soap_version;  
 #endif  
   
 #define FETCH_THIS_SDL(ss) \  #define FETCH_THIS_SDL(ss) \
         { \          { \
                 zval **__tmp; \                  zval **__tmp; \
Line 215  PHP_MINIT_FUNCTION(soap); Line 193  PHP_MINIT_FUNCTION(soap);
 PHP_MSHUTDOWN_FUNCTION(soap);  PHP_MSHUTDOWN_FUNCTION(soap);
 PHP_MINFO_FUNCTION(soap);  PHP_MINFO_FUNCTION(soap);
   
 #ifndef ZEND_ENGINE_2  
 # ifndef PHP_METHOD  
 #  define PHP_METHOD(classname, name)   ZEND_NAMED_FUNCTION(ZEND_FN(classname##_##name))  
 #  define PHP_ME(classname, name, arg_info, flags)      ZEND_NAMED_FE(name, ZEND_FN(classname##_##name), arg_info)  
 # endif  
   
 static char *zend_str_tolower_copy(char *dest, const char *source, unsigned int length)  
 {  
         register unsigned char *str = (unsigned char*)source;  
         register unsigned char *result = (unsigned char*)dest;  
         register unsigned char *end = str + length;  
   
         while (str < end) {  
                 *result++ = tolower((int)*str++);  
         }  
         *result = *end;  
   
         return dest;  
 }  
 #endif  
   
 /*  /*
   Registry Functions    Registry Functions
   TODO: this!    TODO: this!
Line 276  PHP_METHOD(SoapVar, SoapVar); Line 233  PHP_METHOD(SoapVar, SoapVar);
   
 /* SoapFault Functions */  /* SoapFault Functions */
 PHP_METHOD(SoapFault, SoapFault);  PHP_METHOD(SoapFault, SoapFault);
 #ifdef ZEND_ENGINE_2  
 PHP_METHOD(SoapFault, __toString);  PHP_METHOD(SoapFault, __toString);
 #endif  
   
 /* SoapParam Functions */  /* SoapParam Functions */
 PHP_METHOD(SoapParam, SoapParam);  PHP_METHOD(SoapParam, SoapParam);
Line 289  PHP_METHOD(SoapHeader, SoapHeader); Line 244  PHP_METHOD(SoapHeader, SoapHeader);
 #define SOAP_CTOR(class_name, func_name, arginfo, flags) PHP_ME(class_name, func_name, arginfo, flags)  #define SOAP_CTOR(class_name, func_name, arginfo, flags) PHP_ME(class_name, func_name, arginfo, flags)
   
 /* {{{ arginfo */  /* {{{ arginfo */
 #ifdef ZEND_ENGINE_2  
 ZEND_BEGIN_ARG_INFO(arginfo_soap__void, 0)  ZEND_BEGIN_ARG_INFO(arginfo_soap__void, 0)
 ZEND_END_ARG_INFO()  ZEND_END_ARG_INFO()
   
Line 429  ZEND_END_ARG_INFO() Line 383  ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_INFO_EX(arginfo_soap_is_soap_fault, 0, 0, 1)  ZEND_BEGIN_ARG_INFO_EX(arginfo_soap_is_soap_fault, 0, 0, 1)
         ZEND_ARG_INFO(0, object)          ZEND_ARG_INFO(0, object)
 ZEND_END_ARG_INFO()  ZEND_END_ARG_INFO()
 #else  
 unsigned char arginfo_soapclient___call[] = { 2, BYREF_NONE, BYREF_NONE };  
 unsigned char arginfo_soapclient___soapcall[] = { 5, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_FORCE };  
 # define arginfo_soapclient_soapclient                                  NULL  
 # define arginfo_soapclient___getlastrequest                    NULL  
 # define arginfo_soapclient___getlastresponse                   NULL  
 # define arginfo_soapclient___getlastrequestheaders     NULL  
 # define arginfo_soapclient___getlastresponseheaders    NULL  
 # define arginfo_soapclient___getfunctions                              NULL  
 # define arginfo_soapclient___gettypes                                  NULL  
 # define arginfo_soapclient___dorequest                                 NULL  
 # define arginfo_soapclient___setcookie                                 NULL  
 # define arginfo_soapclient___setlocation                               NULL  
 # define arginfo_soapclient___setsoapheaders                    NULL  
   
 # define arginfo_soapserver_soapserver                                  NULL  
 # define arginfo_soapserver_setpersistence                              NULL  
 # define arginfo_soapserver_setclass                                    NULL  
 # define arginfo_soapserver_setobject                                   NULL  
 # define arginfo_soapserver_addfunction                                 NULL  
 # define arginfo_soapserver_getfunctions                                NULL  
 # defina arginfo_soapserver_handle                                              NULL  
 # define arginfo_soapserver_fault                                               NULL  
 # define arginfo_soapserver_addsoapheader                               NULL  
   
 # define arginfo_soapvar_soapvar                                                NULL  
   
 # define arginfo_soapfault_soapfault                                    NULL  
   
 # define arginfo_soapheader_soapheader                                  NULL  
   
 # define arginfo_soapparam_soapparam                                    NULL  
   
 # define arginfo_soap_use_soap_error_handler                    NULL  
   
 # define arginfo_soap_is_soap_fault                                             NULL  
 #endif  
 /* }}} */  /* }}} */
   
 static const zend_function_entry soap_functions[] = {  static const zend_function_entry soap_functions[] = {
Line 476  static const zend_function_entry soap_functions[] = { Line 393  static const zend_function_entry soap_functions[] = {
   
 static const zend_function_entry soap_fault_functions[] = {  static const zend_function_entry soap_fault_functions[] = {
         SOAP_CTOR(SoapFault, SoapFault, arginfo_soapfault_soapfault, 0)          SOAP_CTOR(SoapFault, SoapFault, arginfo_soapfault_soapfault, 0)
 #ifdef ZEND_ENGINE_2  
         PHP_ME(SoapFault, __toString, arginfo_soap__void, 0)          PHP_ME(SoapFault, __toString, arginfo_soap__void, 0)
 #endif  
         PHP_FE_END          PHP_FE_END
 };  };
   
Line 548  zend_module_entry soap_module_entry = { Line 463  zend_module_entry soap_module_entry = {
 ZEND_GET_MODULE(soap)  ZEND_GET_MODULE(soap)
 #endif  #endif
   
 #ifndef ZEND_ENGINE_2  
 # define OnUpdateLong OnUpdateInt  
 #endif  
   
 ZEND_INI_MH(OnUpdateCacheEnabled)  
 {  
         if (OnUpdateBool(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC) == FAILURE) {  
                 return FAILURE;  
         }  
         if (SOAP_GLOBAL(cache_enabled)) {  
                 SOAP_GLOBAL(cache) = SOAP_GLOBAL(cache_mode);  
         } else {  
                 SOAP_GLOBAL(cache) = 0;  
         }  
         return SUCCESS;  
 }  
   
 ZEND_INI_MH(OnUpdateCacheMode)  ZEND_INI_MH(OnUpdateCacheMode)
 {  {
         char *p;          char *p;
Line 578  ZEND_INI_MH(OnUpdateCacheMode) Line 476  ZEND_INI_MH(OnUpdateCacheMode)
   
         *p = (char)atoi(new_value);          *p = (char)atoi(new_value);
   
        if (SOAP_GLOBAL(cache_enabled)) {        return SUCCESS;
                SOAP_GLOBAL(cache) = SOAP_GLOBAL(cache_mode);}
        } else {
                SOAP_GLOBAL(cache) = 0;static PHP_INI_MH(OnUpdateCacheDir)
 {
         /* Only do the open_basedir check at runtime */
         if (stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) {
                 char *p;
 
                 if (memchr(new_value, '\0', new_value_length) != NULL) {
                         return FAILURE;
                 }
 
                 /* we do not use zend_memrchr() since path can contain ; itself */
                 if ((p = strchr(new_value, ';'))) {
                         char *p2;
                         p++;
                         if ((p2 = strchr(p, ';'))) {
                                 p = p2 + 1;
                         }
                 } else {
                         p = new_value;
                 }
 
                 if (PG(open_basedir) && *p && php_check_open_basedir(p TSRMLS_CC)) {
                         return FAILURE;
                 }
         }          }
   
           OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
         return SUCCESS;          return SUCCESS;
 }  }
   
 PHP_INI_BEGIN()  PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("soap.wsdl_cache_enabled",     "1", PHP_INI_ALL, OnUpdateCacheEnabled,STD_PHP_INI_ENTRY("soap.wsdl_cache_enabled",     "1", PHP_INI_ALL, OnUpdateBool,
                   cache_enabled, zend_soap_globals, soap_globals)                    cache_enabled, zend_soap_globals, soap_globals)
STD_PHP_INI_ENTRY("soap.wsdl_cache_dir",         "/tmp", PHP_INI_ALL, OnUpdateString,STD_PHP_INI_ENTRY("soap.wsdl_cache_dir",         "/tmp", PHP_INI_ALL, OnUpdateCacheDir,
                   cache_dir, zend_soap_globals, soap_globals)                    cache_dir, zend_soap_globals, soap_globals)
 STD_PHP_INI_ENTRY("soap.wsdl_cache_ttl",         "86400", PHP_INI_ALL, OnUpdateLong,  STD_PHP_INI_ENTRY("soap.wsdl_cache_ttl",         "86400", PHP_INI_ALL, OnUpdateLong,
                   cache_ttl, zend_soap_globals, soap_globals)                    cache_ttl, zend_soap_globals, soap_globals)
Line 694  PHP_MINIT_FUNCTION(soap) Line 617  PHP_MINIT_FUNCTION(soap)
         ZEND_INIT_MODULE_GLOBALS(soap, php_soap_init_globals, NULL);          ZEND_INIT_MODULE_GLOBALS(soap, php_soap_init_globals, NULL);
         REGISTER_INI_ENTRIES();          REGISTER_INI_ENTRIES();
   
 #ifndef ZEND_ENGINE_2  
         /* Enable php stream/wrapper support for libxml */  
         xmlRegisterDefaultInputCallbacks();  
         xmlRegisterInputCallbacks(php_stream_xmlIO_match_wrapper, php_stream_xmlIO_open_wrapper,  
                         php_stream_xmlIO_read, php_stream_xmlIO_close);  
 #endif  
   
         /* Register SoapClient class */          /* Register SoapClient class */
         /* BIG NOTE : THIS EMITS AN COMPILATION WARNING UNDER ZE2 - handle_function_call deprecated.          /* BIG NOTE : THIS EMITS AN COMPILATION WARNING UNDER ZE2 - handle_function_call deprecated.
                 soap_call_function_handler should be of type struct _zend_function, not (*handle_function_call).                  soap_call_function_handler should be of type struct _zend_function, not (*handle_function_call).
         */          */
 #ifdef ZEND_ENGINE_2  
         {          {
                 zend_internal_function fe;                  zend_internal_function fe;
   
Line 717  PHP_MINIT_FUNCTION(soap) Line 632  PHP_MINIT_FUNCTION(soap)
                 fe.prototype = NULL;                  fe.prototype = NULL;
                 fe.num_args = 2;                  fe.num_args = 2;
                 fe.arg_info = NULL;                  fe.arg_info = NULL;
                 fe.pass_rest_by_reference = 0;  
   
                 INIT_OVERLOADED_CLASS_ENTRY(ce, PHP_SOAP_CLIENT_CLASSNAME, soap_client_functions,                  INIT_OVERLOADED_CLASS_ENTRY(ce, PHP_SOAP_CLIENT_CLASSNAME, soap_client_functions,
                         (zend_function *)&fe, NULL, NULL);                          (zend_function *)&fe, NULL, NULL);
                 soap_class_entry = zend_register_internal_class(&ce TSRMLS_CC);                  soap_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
         }          }
 #else  
         INIT_OVERLOADED_CLASS_ENTRY(ce, PHP_SOAP_CLIENT_CLASSNAME, soap_client_functions, soap_call_function_handler, NULL, NULL);  
         soap_class_entry = zend_register_internal_class(&ce TSRMLS_CC);  
 #endif  
   
         /* Register SoapVar class */          /* Register SoapVar class */
         INIT_CLASS_ENTRY(ce, PHP_SOAP_VAR_CLASSNAME, soap_var_functions);          INIT_CLASS_ENTRY(ce, PHP_SOAP_VAR_CLASSNAME, soap_var_functions);
         soap_var_class_entry = zend_register_internal_class(&ce TSRMLS_CC);          soap_var_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
Line 738  PHP_MINIT_FUNCTION(soap) Line 647  PHP_MINIT_FUNCTION(soap)
   
         /* Register SoapFault class */          /* Register SoapFault class */
         INIT_CLASS_ENTRY(ce, PHP_SOAP_FAULT_CLASSNAME, soap_fault_functions);          INIT_CLASS_ENTRY(ce, PHP_SOAP_FAULT_CLASSNAME, soap_fault_functions);
 #ifdef ZEND_ENGINE_2  
         soap_fault_class_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);          soap_fault_class_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);
 #else  
         soap_fault_class_entry = zend_register_internal_class(&ce TSRMLS_CC);  
 #endif  
   
         /* Register SoapParam class */          /* Register SoapParam class */
         INIT_CLASS_ENTRY(ce, PHP_SOAP_PARAM_CLASSNAME, soap_param_functions);          INIT_CLASS_ENTRY(ce, PHP_SOAP_PARAM_CLASSNAME, soap_param_functions);
Line 880  PHP_METHOD(SoapParam, SoapParam) Line 785  PHP_METHOD(SoapParam, SoapParam)
                 return;                  return;
         }          }
   
 #ifndef ZEND_ENGINE_2  
         zval_add_ref(&data);  
 #endif  
         add_property_stringl(this_ptr, "param_name", name, name_length, 1);          add_property_stringl(this_ptr, "param_name", name, name_length, 1);
         add_property_zval(this_ptr, "param_data", data);          add_property_zval(this_ptr, "param_data", data);
 }  }
Line 913  PHP_METHOD(SoapHeader, SoapHeader) Line 815  PHP_METHOD(SoapHeader, SoapHeader)
         add_property_stringl(this_ptr, "namespace", ns, ns_len, 1);          add_property_stringl(this_ptr, "namespace", ns, ns_len, 1);
         add_property_stringl(this_ptr, "name", name, name_len, 1);          add_property_stringl(this_ptr, "name", name, name_len, 1);
         if (data) {          if (data) {
 #ifndef ZEND_ENGINE_2  
                 zval_add_ref(&data);  
 #endif  
                 add_property_zval(this_ptr, "data", data);                  add_property_zval(this_ptr, "data", data);
         }          }
         add_property_bool(this_ptr, "mustUnderstand", must_understand);          add_property_bool(this_ptr, "mustUnderstand", must_understand);
Line 987  PHP_METHOD(SoapFault, SoapFault) Line 886  PHP_METHOD(SoapFault, SoapFault)
 /* }}} */  /* }}} */
   
   
 #ifdef ZEND_ENGINE_2  
 /* {{{ proto object SoapFault::SoapFault ( string faultcode, string faultstring [, string faultactor [, mixed detail [, string faultname [, mixed headerfault]]]])  /* {{{ proto object SoapFault::SoapFault ( string faultcode, string faultstring [, string faultactor [, mixed detail [, string faultname [, mixed headerfault]]]])
    SoapFault constructor */     SoapFault constructor */
 PHP_METHOD(SoapFault, __toString)  PHP_METHOD(SoapFault, __toString)
Line 1030  PHP_METHOD(SoapFault, __toString) Line 928  PHP_METHOD(SoapFault, __toString)
         RETURN_STRINGL(str, len, 0);          RETURN_STRINGL(str, len, 0);
 }  }
 /* }}} */  /* }}} */
 #endif  
   
 /* {{{ proto object SoapVar::SoapVar ( mixed data, int encoding [, string type_name [, string type_namespace [, string node_name [, string node_namespace]]]])  /* {{{ proto object SoapVar::SoapVar ( mixed data, int encoding [, string type_name [, string type_namespace [, string node_name [, string node_namespace]]]])
    SoapVar constructor */     SoapVar constructor */
Line 1056  PHP_METHOD(SoapVar, SoapVar) Line 953  PHP_METHOD(SoapVar, SoapVar)
         }          }
   
         if (data) {          if (data) {
 #ifndef ZEND_ENGINE_2  
                 zval_add_ref(&data);  
 #endif  
                 add_property_zval(this_ptr, "enc_value", data);                  add_property_zval(this_ptr, "enc_value", data);
         }          }
   
Line 1220  PHP_METHOD(SoapServer, SoapServer) Line 1114  PHP_METHOD(SoapServer, SoapServer)
         memset(service, 0, sizeof(soapService));          memset(service, 0, sizeof(soapService));
         service->send_errors = 1;          service->send_errors = 1;
   
        cache_wsdl = SOAP_GLOBAL(cache);        cache_wsdl = SOAP_GLOBAL(cache_enabled) ? SOAP_GLOBAL(cache_mode) : 0;
   
         if (options != NULL) {          if (options != NULL) {
                 HashTable *ht = Z_ARRVAL_P(options);                  HashTable *ht = Z_ARRVAL_P(options);
Line 1315  PHP_METHOD(SoapServer, SoapServer) Line 1209  PHP_METHOD(SoapServer, SoapServer)
                 service->typemap = soap_create_typemap(service->sdl, typemap_ht TSRMLS_CC);                  service->typemap = soap_create_typemap(service->sdl, typemap_ht TSRMLS_CC);
         }          }
   
        ret = zend_list_insert(service, le_service);        ret = zend_list_insert(service, le_service TSRMLS_CC);
         add_property_resource(this_ptr, "service", ret);          add_property_resource(this_ptr, "service", ret);
   
         SOAP_SERVER_END_CODE();          SOAP_SERVER_END_CODE();
Line 1360  PHP_METHOD(SoapServer, setClass) Line 1254  PHP_METHOD(SoapServer, setClass)
 {  {
         soapServicePtr service;          soapServicePtr service;
         char *classname;          char *classname;
 #ifdef ZEND_ENGINE_2              
         zend_class_entry **ce;          zend_class_entry **ce;
#else
        zend_class_entry *ce; 
#endif 
         int classname_len, found, num_args = 0;          int classname_len, found, num_args = 0;
         zval ***argv = NULL;          zval ***argv = NULL;
   
Line 1376  PHP_METHOD(SoapServer, setClass) Line 1267  PHP_METHOD(SoapServer, setClass)
                 return;                  return;
         }          }
   
 #ifdef ZEND_ENGINE_2              
         found = zend_lookup_class(classname, classname_len, &ce TSRMLS_CC);          found = zend_lookup_class(classname, classname_len, &ce TSRMLS_CC);
#else
        char *class_name = estrdup(classname); 
        found = zend_hash_find(EG(class_table), php_strtolower(class_name, classname_len), classname_len + 1, (void **)&ce); 
        efree(class_name); 
#endif 
         if (found != FAILURE) {          if (found != FAILURE) {
                 service->type = SOAP_CLASS;                  service->type = SOAP_CLASS;
 #ifdef ZEND_ENGINE_2  
                 service->soap_class.ce = *ce;                  service->soap_class.ce = *ce;
#else
                service->soap_class.ce = ce; 
#endif 
                 service->soap_class.persistance = SOAP_PERSISTENCE_REQUEST;                  service->soap_class.persistance = SOAP_PERSISTENCE_REQUEST;
                 service->soap_class.argc = num_args;                  service->soap_class.argc = num_args;
                 if (service->soap_class.argc > 0) {                  if (service->soap_class.argc > 0) {
Line 1401  PHP_METHOD(SoapServer, setClass) Line 1284  PHP_METHOD(SoapServer, setClass)
                         }                          }
                 }                  }
         } else {          } else {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to set a non existant class (%s)", classname);                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to set a non existent class (%s)", classname);
                 return;                  return;
         }          }
   
Line 1532  PHP_METHOD(SoapServer, addFunction) Line 1415  PHP_METHOD(SoapServer, addFunction)
                                 zend_str_tolower_copy(key, Z_STRVAL_PP(tmp_function), key_len);                                  zend_str_tolower_copy(key, Z_STRVAL_PP(tmp_function), key_len);
   
                                 if (zend_hash_find(EG(function_table), key, key_len+1, (void**)&f) == FAILURE) {                                  if (zend_hash_find(EG(function_table), key, key_len+1, (void**)&f) == FAILURE) {
                                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to add a non existant function '%s'", Z_STRVAL_PP(tmp_function));                                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to add a non existent function '%s'", Z_STRVAL_PP(tmp_function));
                                         return;                                          return;
                                 }                                  }
   
Line 1554  PHP_METHOD(SoapServer, addFunction) Line 1437  PHP_METHOD(SoapServer, addFunction)
                 zend_str_tolower_copy(key, Z_STRVAL_P(function_name), key_len);                  zend_str_tolower_copy(key, Z_STRVAL_P(function_name), key_len);
   
                 if (zend_hash_find(EG(function_table), key, key_len+1, (void**)&f) == FAILURE) {                  if (zend_hash_find(EG(function_table), key, key_len+1, (void**)&f) == FAILURE) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to add a non existant function '%s'", Z_STRVAL_P(function_name));                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to add a non existent function '%s'", Z_STRVAL_P(function_name));
                         return;                          return;
                 }                  }
                 if (service->soap_functions.ft == NULL) {                  if (service->soap_functions.ft == NULL) {
Line 1666  PHP_METHOD(SoapServer, handle) Line 1549  PHP_METHOD(SoapServer, handle)
   
         ALLOC_INIT_ZVAL(retval);          ALLOC_INIT_ZVAL(retval);
   
        if (php_start_ob_buffer(NULL, 0, 0 TSRMLS_CC) != SUCCESS) {        if (php_output_start_default(TSRMLS_C) != SUCCESS) {
                 php_error_docref(NULL TSRMLS_CC, E_ERROR,"ob_start failed");                  php_error_docref(NULL TSRMLS_CC, E_ERROR,"ob_start failed");
         }          }
   
Line 1751  PHP_METHOD(SoapServer, handle) Line 1634  PHP_METHOD(SoapServer, handle)
         old_soap_version = SOAP_GLOBAL(soap_version);          old_soap_version = SOAP_GLOBAL(soap_version);
         function = deserialize_function_call(service->sdl, doc_request, service->actor, &function_name, &num_params, &params, &soap_version, &soap_headers TSRMLS_CC);          function = deserialize_function_call(service->sdl, doc_request, service->actor, &function_name, &num_params, &params, &soap_version, &soap_headers TSRMLS_CC);
         xmlFreeDoc(doc_request);          xmlFreeDoc(doc_request);
        
#ifdef ZEND_ENGINE_2 
         if (EG(exception)) {          if (EG(exception)) {
                php_end_ob_buffer(0, 0 TSRMLS_CC);                php_output_discard(TSRMLS_C);
                 if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&                  if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
                     instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {                      instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
                         soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);                          soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
                 }                  }
                 goto fail;                  goto fail;
         }          }
 #endif  
   
         service->soap_headers_ptr = &soap_headers;          service->soap_headers_ptr = &soap_headers;
   
Line 1788  PHP_METHOD(SoapServer, handle) Line 1669  PHP_METHOD(SoapServer, handle)
                         }                          }
                 }                  }
 #endif  #endif
                /* If new session or something wierd happned */                /* If new session or something weird happned */
                 if (soap_obj == NULL) {                  if (soap_obj == NULL) {
                         zval *tmp_soap;                          zval *tmp_soap;
   
Line 1796  PHP_METHOD(SoapServer, handle) Line 1677  PHP_METHOD(SoapServer, handle)
                         object_init_ex(tmp_soap, service->soap_class.ce);                          object_init_ex(tmp_soap, service->soap_class.ce);
   
                         /* Call constructor */                          /* Call constructor */
 #ifdef ZEND_ENGINE_2  
                         if (zend_hash_exists(&Z_OBJCE_P(tmp_soap)->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) {                          if (zend_hash_exists(&Z_OBJCE_P(tmp_soap)->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) {
                                 zval c_ret, constructor;                                  zval c_ret, constructor;
   
Line 1808  PHP_METHOD(SoapServer, handle) Line 1688  PHP_METHOD(SoapServer, handle)
                                         php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error calling constructor");                                          php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error calling constructor");
                                 }                                  }
                                 if (EG(exception)) {                                  if (EG(exception)) {
                                        php_end_ob_buffer(0, 0 TSRMLS_CC);                                        php_output_discard(TSRMLS_C);
                                         if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&                                          if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
                                             instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {                                              instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
                                                 soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);                                                  soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
Line 1821  PHP_METHOD(SoapServer, handle) Line 1701  PHP_METHOD(SoapServer, handle)
                                 zval_dtor(&constructor);                                  zval_dtor(&constructor);
                                 zval_dtor(&c_ret);                                  zval_dtor(&c_ret);
                         } else {                          } else {
 #else  
       {  
 #endif  
                                 int class_name_len = strlen(service->soap_class.ce->name);                                  int class_name_len = strlen(service->soap_class.ce->name);
                                 char *class_name = emalloc(class_name_len+1);                                  char *class_name = emalloc(class_name_len+1);
   
Line 1838  PHP_METHOD(SoapServer, handle) Line 1715  PHP_METHOD(SoapServer, handle)
                                         if (call_user_function(NULL, &tmp_soap, &constructor, &c_ret, service->soap_class.argc, service->soap_class.argv TSRMLS_CC) == FAILURE) {                                          if (call_user_function(NULL, &tmp_soap, &constructor, &c_ret, service->soap_class.argc, service->soap_class.argv TSRMLS_CC) == FAILURE) {
                                                 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error calling constructor");                                                  php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error calling constructor");
                                         }                                          }
#ifdef ZEND_ENGINE_2
                                         if (EG(exception)) {                                          if (EG(exception)) {
                                                php_end_ob_buffer(0, 0 TSRMLS_CC);                                                php_output_discard(TSRMLS_C);
                                                 if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&                                                  if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
                                                     instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {                                                      instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
                                                         soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);                                                          soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
Line 1851  PHP_METHOD(SoapServer, handle) Line 1728  PHP_METHOD(SoapServer, handle)
                                                 zval_ptr_dtor(&tmp_soap);                                                  zval_ptr_dtor(&tmp_soap);
                                                 goto fail;                                                  goto fail;
                                         }                                          }
#endif
                                         zval_dtor(&constructor);                                          zval_dtor(&constructor);
                                         zval_dtor(&c_ret);                                          zval_dtor(&c_ret);
                                 }                                  }
Line 1920  PHP_METHOD(SoapServer, handle) Line 1797  PHP_METHOD(SoapServer, handle)
                                             Z_TYPE_PP(tmp) != IS_NULL) {                                              Z_TYPE_PP(tmp) != IS_NULL) {
                                                 headerfault = *tmp;                                                  headerfault = *tmp;
                                         }                                          }
                                        php_end_ob_buffer(0, 0 TSRMLS_CC);                                        php_output_discard(TSRMLS_C);
                                         soap_server_fault_ex(function, &h->retval, h TSRMLS_CC);                                          soap_server_fault_ex(function, &h->retval, h TSRMLS_CC);
                                         efree(fn_name);                                          efree(fn_name);
                                         if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(&soap_obj);}                                          if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(&soap_obj);}
                                         goto fail;                                          goto fail;
 #ifdef ZEND_ENGINE_2  
                                 } else if (EG(exception)) {                                  } else if (EG(exception)) {
                                        php_end_ob_buffer(0, 0 TSRMLS_CC);                                        php_output_discard(TSRMLS_C);
                                         if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&                                          if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
                                             instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {                                              instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
                                                 zval *headerfault = NULL, **tmp;                                                  zval *headerfault = NULL, **tmp;
Line 1941  PHP_METHOD(SoapServer, handle) Line 1817  PHP_METHOD(SoapServer, handle)
                                         efree(fn_name);                                          efree(fn_name);
                                         if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(&soap_obj);}                                          if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(&soap_obj);}
                                         goto fail;                                          goto fail;
 #endif  
                                 }                                  }
                         } else if (h->mustUnderstand) {                          } else if (h->mustUnderstand) {
                                 soap_server_fault("MustUnderstand","Header not understood", NULL, NULL, NULL TSRMLS_CC);                                  soap_server_fault("MustUnderstand","Header not understood", NULL, NULL, NULL TSRMLS_CC);
Line 1975  PHP_METHOD(SoapServer, handle) Line 1850  PHP_METHOD(SoapServer, handle)
         }          }
         efree(fn_name);          efree(fn_name);
   
 #ifdef ZEND_ENGINE_2  
         if (EG(exception)) {          if (EG(exception)) {
                php_end_ob_buffer(0, 0 TSRMLS_CC);                php_output_discard(TSRMLS_C);
                 if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&                  if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
                     instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {                      instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
                         soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);                          soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
Line 1993  PHP_METHOD(SoapServer, handle) Line 1867  PHP_METHOD(SoapServer, handle)
                 }                  }
                 goto fail;                  goto fail;
         }          }
#endif
         if (call_status == SUCCESS) {          if (call_status == SUCCESS) {
                 char *response_name;                  char *response_name;
   
                 if (Z_TYPE_P(retval) == IS_OBJECT &&                  if (Z_TYPE_P(retval) == IS_OBJECT &&
                     instanceof_function(Z_OBJCE_P(retval), soap_fault_class_entry TSRMLS_CC)) {                      instanceof_function(Z_OBJCE_P(retval), soap_fault_class_entry TSRMLS_CC)) {
                        php_end_ob_buffer(0, 0 TSRMLS_CC);                        php_output_discard(TSRMLS_C);
                         soap_server_fault_ex(function, retval, NULL TSRMLS_CC);                          soap_server_fault_ex(function, retval, NULL TSRMLS_CC);
                         goto fail;                          goto fail;
                 }                  }
Line 2018  PHP_METHOD(SoapServer, handle) Line 1892  PHP_METHOD(SoapServer, handle)
                 return;                  return;
         }          }
   
 #ifdef ZEND_ENGINE_2  
         if (EG(exception)) {          if (EG(exception)) {
                php_end_ob_buffer(0, 0 TSRMLS_CC);                php_output_discard(TSRMLS_C);
                 if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&                  if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
                     instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {                      instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
                         soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);                          soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
Line 2036  PHP_METHOD(SoapServer, handle) Line 1909  PHP_METHOD(SoapServer, handle)
                 }                  }
                 goto fail;                  goto fail;
         }          }
 #endif  
   
         /* Flush buffer */          /* Flush buffer */
        php_end_ob_buffer(0, 0 TSRMLS_CC);        php_output_discard(TSRMLS_C);
   
         if (doc_return) {          if (doc_return) {
                 /* xmlDocDumpMemoryEnc(doc_return, &buf, &size, XML_CHAR_ENCODING_UTF8); */                  /* xmlDocDumpMemoryEnc(doc_return, &buf, &size, XML_CHAR_ENCODING_UTF8); */
Line 2057  PHP_METHOD(SoapServer, handle) Line 1929  PHP_METHOD(SoapServer, handle)
   
                 xmlFreeDoc(doc_return);                  xmlFreeDoc(doc_return);
   
                if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0) &&                                              if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) {
                    zend_hash_exists(EG(function_table), "ob_gzhandler", sizeof("ob_gzhandler"))) {                        sapi_add_header("Connection: close", sizeof("Connection: close")-1, 1);
                        zval nm_ob_gzhandler;                } else {
                        zval str; 
                        zval mode; 
                        zval result; 
                        zval *params[2]; 
 
                        INIT_ZVAL(result); 
                        ZVAL_STRINGL(&nm_ob_gzhandler, "ob_gzhandler", sizeof("ob_gzhandler") - 1, 0); 
                        INIT_PZVAL(&str); 
                        ZVAL_STRINGL(&str, (char*)buf, size, 0); 
                        params[0] = &str; 
                        INIT_PZVAL(&mode); 
                        ZVAL_LONG(&mode, PHP_OUTPUT_HANDLER_START | PHP_OUTPUT_HANDLER_END); 
                        params[1] = &mode; 
                        if (call_user_function(CG(function_table), NULL, &nm_ob_gzhandler, &result, 2, params TSRMLS_CC) != FAILURE && 
                            Z_TYPE(result) == IS_STRING && 
                                zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_compression"), "0", sizeof("0")-1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME) == SUCCESS) { 
                                xmlFree(buf); 
                                buf = NULL; 
                                snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", Z_STRLEN(result)); 
                                sapi_add_header(cont_len, strlen(cont_len), 1); 
                                php_write(Z_STRVAL(result), Z_STRLEN(result) TSRMLS_CC); 
                        } 
                        zval_dtor(&result); 
                } 
                if (buf) { 
                         snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);                          snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);
                         sapi_add_header(cont_len, strlen(cont_len), 1);                          sapi_add_header(cont_len, strlen(cont_len), 1);
                         php_write(buf, size TSRMLS_CC);  
                         xmlFree(buf);  
                 }                  }
                   php_write(buf, size TSRMLS_CC);
                   xmlFree(buf);
         } else {          } else {
                 sapi_add_header("HTTP/1.1 202 Accepted", sizeof("HTTP/1.1 202 Accepted")-1, 1);                  sapi_add_header("HTTP/1.1 202 Accepted", sizeof("HTTP/1.1 202 Accepted")-1, 1);
                 sapi_add_header("Content-Length: 0", sizeof("Content-Length: 0")-1, 1);                  sapi_add_header("Content-Length: 0", sizeof("Content-Length: 0")-1, 1);
Line 2228  static void soap_server_fault_ex(sdlFunctionPtr functi Line 2075  static void soap_server_fault_ex(sdlFunctionPtr functi
         if (use_http_error_status) {          if (use_http_error_status) {
                 sapi_add_header("HTTP/1.1 500 Internal Service Error", sizeof("HTTP/1.1 500 Internal Service Error")-1, 1);                  sapi_add_header("HTTP/1.1 500 Internal Service Error", sizeof("HTTP/1.1 500 Internal Service Error")-1, 1);
         }          }
           if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) {
                   sapi_add_header("Connection: close", sizeof("Connection: close")-1, 1);
           } else {
                   snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);
                   sapi_add_header(cont_len, strlen(cont_len), 1);
           }
         if (soap_version == SOAP_1_2) {          if (soap_version == SOAP_1_2) {
                 sapi_add_header("Content-Type: application/soap+xml; charset=utf-8", sizeof("Content-Type: application/soap+xml; charset=utf-8")-1, 1);                  sapi_add_header("Content-Type: application/soap+xml; charset=utf-8", sizeof("Content-Type: application/soap+xml; charset=utf-8")-1, 1);
         } else {          } else {
                 sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);                  sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
         }          }
   
        if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0) &&                                    php_write(buf, size TSRMLS_CC);
            zend_hash_exists(EG(function_table), "ob_gzhandler", sizeof("ob_gzhandler"))) { 
                zval nm_ob_gzhandler; 
                zval str; 
                zval mode; 
                zval result; 
                zval *params[2]; 
   
                 INIT_ZVAL(result);  
                 ZVAL_STRINGL(&nm_ob_gzhandler, "ob_gzhandler", sizeof("ob_gzhandler") - 1, 0);  
                 INIT_PZVAL(&str);  
                 ZVAL_STRINGL(&str, (char*)buf, size, 0);  
                 params[0] = &str;  
                 INIT_PZVAL(&mode);  
                 ZVAL_LONG(&mode, PHP_OUTPUT_HANDLER_START | PHP_OUTPUT_HANDLER_END);  
                 params[1] = &mode;  
                 if (call_user_function(CG(function_table), NULL, &nm_ob_gzhandler, &result, 2, params TSRMLS_CC) != FAILURE &&  
                     Z_TYPE(result) == IS_STRING &&  
                         zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_compression"), "0", sizeof("0")-1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME) == SUCCESS) {  
                         xmlFree(buf);  
                         buf = NULL;  
                         snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", Z_STRLEN(result));  
                         sapi_add_header(cont_len, strlen(cont_len), 1);  
                         php_write(Z_STRVAL(result), Z_STRLEN(result) TSRMLS_CC);  
                 }  
                 zval_dtor(&result);  
         }  
         if (buf) {  
                 snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);  
                 sapi_add_header(cont_len, strlen(cont_len), 1);  
                 php_write(buf, size TSRMLS_CC);  
                 xmlFree(buf);  
         }  
   
         xmlFreeDoc(doc_return);          xmlFreeDoc(doc_return);
           xmlFree(buf);
         zend_clear_exception(TSRMLS_C);          zend_clear_exception(TSRMLS_C);
 }  }
   
Line 2306  static void soap_error_handler(int error_num, const ch Line 2128  static void soap_error_handler(int error_num, const ch
         if (SOAP_GLOBAL(error_object) &&          if (SOAP_GLOBAL(error_object) &&
             Z_TYPE_P(SOAP_GLOBAL(error_object)) == IS_OBJECT &&              Z_TYPE_P(SOAP_GLOBAL(error_object)) == IS_OBJECT &&
             instanceof_function(Z_OBJCE_P(SOAP_GLOBAL(error_object)), soap_class_entry TSRMLS_CC)) {              instanceof_function(Z_OBJCE_P(SOAP_GLOBAL(error_object)), soap_class_entry TSRMLS_CC)) {
 #ifdef ZEND_ENGINE_2  
                 zval **tmp;                  zval **tmp;
                 int use_exceptions = 0;                  int use_exceptions = 0;
   
Line 2379  static void soap_error_handler(int error_num, const ch Line 2200  static void soap_error_handler(int error_num, const ch
                         /* Ignore libxml warnings during WSDL parsing */                          /* Ignore libxml warnings during WSDL parsing */
                         call_old_error_handler(error_num, error_filename, error_lineno, format, args);                          call_old_error_handler(error_num, error_filename, error_lineno, format, args);
                 }                  }
 #else  
                 call_old_error_handler(error_num, error_filename, error_lineno, format, args);  
 #endif  
         } else {          } else {
                 int old = PG(display_errors);                  int old = PG(display_errors);
                 int fault = 0;                  int fault = 0;
Line 2431  static void soap_error_handler(int error_num, const ch Line 2249  static void soap_error_handler(int error_num, const ch
                                 }                                  }
   
                                 /* Get output buffer and send as fault detials */                                  /* Get output buffer and send as fault detials */
                                if (php_ob_get_length(&outbuflen TSRMLS_CC) != FAILURE && Z_LVAL(outbuflen) != 0) {                                if (php_output_get_length(&outbuflen TSRMLS_CC) != FAILURE && Z_LVAL(outbuflen) != 0) {
                                         ALLOC_INIT_ZVAL(outbuf);                                          ALLOC_INIT_ZVAL(outbuf);
                                        php_ob_get_buffer(outbuf TSRMLS_CC);                                        php_output_get_contents(outbuf TSRMLS_CC);
                                 }                                  }
                                php_end_ob_buffer(0, 0 TSRMLS_CC);                                php_output_discard(TSRMLS_C);
   
                         }                          }
                         INIT_ZVAL(fault_obj);                          INIT_ZVAL(fault_obj);
Line 2512  PHP_METHOD(SoapClient, SoapClient) Line 2330  PHP_METHOD(SoapClient, SoapClient)
                 php_error_docref(NULL TSRMLS_CC, E_ERROR, "$wsdl must be string or null");                  php_error_docref(NULL TSRMLS_CC, E_ERROR, "$wsdl must be string or null");
         }          }
   
        cache_wsdl = SOAP_GLOBAL(cache);        cache_wsdl = SOAP_GLOBAL(cache_enabled) ? SOAP_GLOBAL(cache_mode) : 0;
   
         if (options != NULL) {          if (options != NULL) {
                 HashTable *ht = Z_ARRVAL_P(options);                  HashTable *ht = Z_ARRVAL_P(options);
Line 2591  PHP_METHOD(SoapClient, SoapClient) Line 2409  PHP_METHOD(SoapClient, SoapClient)
                 if (zend_hash_find(ht, "local_cert", sizeof("local_cert"), (void**)&tmp) == SUCCESS &&                  if (zend_hash_find(ht, "local_cert", sizeof("local_cert"), (void**)&tmp) == SUCCESS &&
                     Z_TYPE_PP(tmp) == IS_STRING) {                      Z_TYPE_PP(tmp) == IS_STRING) {
                   if (!context) {                    if (!context) {
                        context = php_stream_context_alloc();                        context = php_stream_context_alloc(TSRMLS_C);
                   }                    }
                         php_stream_context_set_option(context, "ssl", "local_cert", *tmp);                          php_stream_context_set_option(context, "ssl", "local_cert", *tmp);
                         if (zend_hash_find(ht, "passphrase", sizeof("passphrase"), (void**)&tmp) == SUCCESS &&                          if (zend_hash_find(ht, "passphrase", sizeof("passphrase"), (void**)&tmp) == SUCCESS &&
Line 2604  PHP_METHOD(SoapClient, SoapClient) Line 2422  PHP_METHOD(SoapClient, SoapClient)
                                 Z_LVAL_PP(tmp) == 1) {                                  Z_LVAL_PP(tmp) == 1) {
                         add_property_long(this_ptr, "trace", 1);                          add_property_long(this_ptr, "trace", 1);
                 }                  }
#ifdef ZEND_ENGINE_2
                 if (zend_hash_find(ht, "exceptions", sizeof("exceptions"), (void**)&tmp) == SUCCESS &&                  if (zend_hash_find(ht, "exceptions", sizeof("exceptions"), (void**)&tmp) == SUCCESS &&
                     (Z_TYPE_PP(tmp) == IS_BOOL || Z_TYPE_PP(tmp) == IS_LONG) &&                      (Z_TYPE_PP(tmp) == IS_BOOL || Z_TYPE_PP(tmp) == IS_LONG) &&
                                 Z_LVAL_PP(tmp) == 0) {                                  Z_LVAL_PP(tmp) == 0) {
                         add_property_bool(this_ptr, "_exceptions", 0);                          add_property_bool(this_ptr, "_exceptions", 0);
                 }                  }
#endif
                 if (zend_hash_find(ht, "compression", sizeof("compression"), (void**)&tmp) == SUCCESS &&                  if (zend_hash_find(ht, "compression", sizeof("compression"), (void**)&tmp) == SUCCESS &&
                     Z_TYPE_PP(tmp) == IS_LONG &&                      Z_TYPE_PP(tmp) == IS_LONG &&
               zend_hash_exists(EG(function_table), "gzinflate", sizeof("gzinflate")) &&                zend_hash_exists(EG(function_table), "gzinflate", sizeof("gzinflate")) &&
Line 2638  PHP_METHOD(SoapClient, SoapClient) Line 2456  PHP_METHOD(SoapClient, SoapClient)
   
                         MAKE_STD_ZVAL(class_map);                          MAKE_STD_ZVAL(class_map);
                         MAKE_COPY_ZVAL(tmp, class_map);                          MAKE_COPY_ZVAL(tmp, class_map);
 #ifdef ZEND_ENGINE_2  
                         Z_DELREF_P(class_map);                          Z_DELREF_P(class_map);
#endif
                         add_property_zval(this_ptr, "_classmap", class_map);                          add_property_zval(this_ptr, "_classmap", class_map);
                 }                  }
   
Line 2675  PHP_METHOD(SoapClient, SoapClient) Line 2492  PHP_METHOD(SoapClient, SoapClient)
                     Z_TYPE_PP(tmp) == IS_STRING) {                      Z_TYPE_PP(tmp) == IS_STRING) {
                         add_property_stringl(this_ptr, "_user_agent", Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);                          add_property_stringl(this_ptr, "_user_agent", Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
                 }                  }
                   
                   if (zend_hash_find(ht, "keep_alive", sizeof("keep_alive"), (void**)&tmp) == SUCCESS &&
                                   (Z_TYPE_PP(tmp) == IS_BOOL || Z_TYPE_PP(tmp) == IS_LONG) && Z_LVAL_PP(tmp) == 0) {
                           add_property_long(this_ptr, "_keep_alive", 0);
                   }
         } else if (Z_TYPE_P(wsdl) == IS_NULL) {          } else if (Z_TYPE_P(wsdl) == IS_NULL) {
                 php_error_docref(NULL TSRMLS_CC, E_ERROR, "'location' and 'uri' options are required in nonWSDL mode");                  php_error_docref(NULL TSRMLS_CC, E_ERROR, "'location' and 'uri' options are required in nonWSDL mode");
         }          }
Line 2688  PHP_METHOD(SoapClient, SoapClient) Line 2510  PHP_METHOD(SoapClient, SoapClient)
                 SOAP_GLOBAL(soap_version) = soap_version;                  SOAP_GLOBAL(soap_version) = soap_version;
   
                 sdl = get_sdl(this_ptr, Z_STRVAL_P(wsdl), cache_wsdl TSRMLS_CC);                  sdl = get_sdl(this_ptr, Z_STRVAL_P(wsdl), cache_wsdl TSRMLS_CC);
                ret = zend_list_insert(sdl, le_sdl);                ret = zend_list_insert(sdl, le_sdl TSRMLS_CC);
   
                 add_property_resource(this_ptr, "sdl", ret);                  add_property_resource(this_ptr, "sdl", ret);
   
Line 2700  PHP_METHOD(SoapClient, SoapClient) Line 2522  PHP_METHOD(SoapClient, SoapClient)
                 if (typemap) {                  if (typemap) {
                         int ret;                          int ret;
   
                        ret = zend_list_insert(typemap, le_typemap);                        ret = zend_list_insert(typemap, le_typemap TSRMLS_CC);
                         add_property_resource(this_ptr, "typemap", ret);                          add_property_resource(this_ptr, "typemap", ret);
                 }                  }
         }          }
Line 2958  static void do_soap_call(zval* this_ptr, Line 2780  static void do_soap_call(zval* this_ptr,
                         zval_copy_ctor(return_value);                          zval_copy_ctor(return_value);
                 }                  }
         }          }
#ifdef ZEND_ENGINE_2
         if (!EG(exception) &&          if (!EG(exception) &&
             Z_TYPE_P(return_value) == IS_OBJECT &&              Z_TYPE_P(return_value) == IS_OBJECT &&
             instanceof_function(Z_OBJCE_P(return_value), soap_fault_class_entry TSRMLS_CC) &&              instanceof_function(Z_OBJCE_P(return_value), soap_fault_class_entry TSRMLS_CC) &&
Line 2970  static void do_soap_call(zval* this_ptr, Line 2792  static void do_soap_call(zval* this_ptr,
                 MAKE_COPY_ZVAL(&return_value, exception);                  MAKE_COPY_ZVAL(&return_value, exception);
                 zend_throw_exception_object(exception TSRMLS_CC);                  zend_throw_exception_object(exception TSRMLS_CC);
         }          }
#endif
         if (SOAP_GLOBAL(encoding) != NULL) {          if (SOAP_GLOBAL(encoding) != NULL) {
                 xmlCharEncCloseFunc(SOAP_GLOBAL(encoding));                  xmlCharEncCloseFunc(SOAP_GLOBAL(encoding));
         }          }
Line 3379  PHP_METHOD(SoapClient, __setLocation) Line 3201  PHP_METHOD(SoapClient, __setLocation)
 }  }
 /* }}} */  /* }}} */
   
 #ifndef ZEND_ENGINE_2  
 static void soap_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference)  
 {  
         zval *object = property_reference->object;  
         zend_overloaded_element *function_name = (zend_overloaded_element *)property_reference->elements_list->tail->data;  
         char *function = Z_STRVAL(function_name->element);  
         zend_function *builtin_function;  
   
         /*  
            Find if the function being called is already defined...  
           ( IMHO: zend should handle this functionality )  
         */  
         if (zend_hash_find(&Z_OBJCE_P(this_ptr)->function_table, function, Z_STRLEN(function_name->element) + 1, (void **) &builtin_function) == SUCCESS) {  
                 builtin_function->internal_function.handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);  
         } else {  
                 int arg_count = ZEND_NUM_ARGS();  
                 zval **arguments = (zval **) safe_emalloc(sizeof(zval *), arg_count, 0);  
                 zval **soap_headers_p  
                 HashTable *soap_headers;  
   
                 zend_get_parameters_array(ht, arg_count, arguments);  
   
                 if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__default_headers", sizeof("__default_properties"), (void **) soap_headers_p)==SUCCESS  
                         && Z_TYPE_P(soap_headers_p)==IS_ARRAY) {  
                         soap_headers = Z_ARRVAL_P(soap_headers_p);  
                 } else {  
                         soap_headers = NULL;  
                 }  
                 do_soap_call(this_ptr, function, Z_STRLEN(function_name->element) + 1, arg_count, arguments, return_value, NULL, NULL, NULL, soap_headers, NULL TSRMLS_CC);  
                 efree(arguments);  
         }  
         zval_dtor(&function_name->element);  
 }  
 #endif  
   
 static void clear_soap_fault(zval *obj TSRMLS_DC)  static void clear_soap_fault(zval *obj TSRMLS_DC)
 {  {
         if (obj != NULL && obj->type == IS_OBJECT) {          if (obj != NULL && obj->type == IS_OBJECT) {
Line 3426  zval* add_soap_fault(zval *obj, char *fault_code, char Line 3213  zval* add_soap_fault(zval *obj, char *fault_code, char
         zval *fault;          zval *fault;
         ALLOC_INIT_ZVAL(fault);          ALLOC_INIT_ZVAL(fault);
         set_soap_fault(fault, NULL, fault_code, fault_string, fault_actor, fault_detail, NULL TSRMLS_CC);          set_soap_fault(fault, NULL, fault_code, fault_string, fault_actor, fault_detail, NULL TSRMLS_CC);
 #ifdef ZEND_ENGINE_2  
         Z_DELREF_P(fault);          Z_DELREF_P(fault);
#endif
         add_property_zval(obj, "__soap_fault", fault);          add_property_zval(obj, "__soap_fault", fault);
         return fault;          return fault;
 }  }
Line 3440  static void set_soap_fault(zval *obj, char *fault_code Line 3226  static void set_soap_fault(zval *obj, char *fault_code
         }          }
                   
         add_property_string(obj, "faultstring", fault_string ? fault_string : "", 1);          add_property_string(obj, "faultstring", fault_string ? fault_string : "", 1);
 #ifdef ZEND_ENGINE_2  
         zend_update_property_string(zend_exception_get_default(TSRMLS_C), obj, "message", sizeof("message")-1, (fault_string ? fault_string : "") TSRMLS_CC);          zend_update_property_string(zend_exception_get_default(TSRMLS_C), obj, "message", sizeof("message")-1, (fault_string ? fault_string : "") TSRMLS_CC);
 #endif  
                   
         if (fault_code != NULL) {          if (fault_code != NULL) {
                 int soap_version = SOAP_GLOBAL(soap_version);                  int soap_version = SOAP_GLOBAL(soap_version);
Line 3488  static void set_soap_fault(zval *obj, char *fault_code Line 3272  static void set_soap_fault(zval *obj, char *fault_code
         }          }
 }  }
   
static void deserialize_parameters(xmlNodePtr params, sdlFunctionPtr function, int *num_params, zval ***parameters)static void deserialize_parameters(xmlNodePtr params, sdlFunctionPtr function, int *num_params, zval ***parameters TSRMLS_DC)
 {  {
         int cur_param = 0,num_of_params = 0;          int cur_param = 0,num_of_params = 0;
         zval **tmp_parameters = NULL;          zval **tmp_parameters = NULL;
Line 3519  static void deserialize_parameters(xmlNodePtr params,  Line 3303  static void deserialize_parameters(xmlNodePtr params, 
                                         MAKE_STD_ZVAL(tmp_parameters[cur_param]);                                          MAKE_STD_ZVAL(tmp_parameters[cur_param]);
                                         ZVAL_NULL(tmp_parameters[cur_param]);                                          ZVAL_NULL(tmp_parameters[cur_param]);
                                 } else {                                  } else {
                                        tmp_parameters[cur_param] = master_to_zval((*param)->encode, val);                                        tmp_parameters[cur_param] = master_to_zval((*param)->encode, val TSRMLS_CC);
                                 }                                  }
                                 cur_param++;                                  cur_param++;
   
Line 3549  static void deserialize_parameters(xmlNodePtr params,  Line 3333  static void deserialize_parameters(xmlNodePtr params, 
                     ((sdlSoapBindingFunctionPtr)function->bindingAttributes)->style == SOAP_DOCUMENT &&                      ((sdlSoapBindingFunctionPtr)function->bindingAttributes)->style == SOAP_DOCUMENT &&
                     (function->requestParameters == NULL ||                      (function->requestParameters == NULL ||
                      zend_hash_num_elements(function->requestParameters) == 0) &&                       zend_hash_num_elements(function->requestParameters) == 0) &&
                    strcmp(params->name, function->functionName) == 0) {                    strcmp((char *)params->name, function->functionName) == 0) {
                         num_of_params = 0;                          num_of_params = 0;
                 } else if (num_of_params > 0) {                  } else if (num_of_params > 0) {
                         tmp_parameters = safe_emalloc(num_of_params, sizeof(zval *), 0);                          tmp_parameters = safe_emalloc(num_of_params, sizeof(zval *), 0);
Line 3569  static void deserialize_parameters(xmlNodePtr params,  Line 3353  static void deserialize_parameters(xmlNodePtr params, 
                                         } else {                                          } else {
                                                 enc = (*param)->encode;                                                  enc = (*param)->encode;
                                         }                                          }
                                        tmp_parameters[cur_param] = master_to_zval(enc, trav);                                        tmp_parameters[cur_param] = master_to_zval(enc, trav TSRMLS_CC);
                                         cur_param++;                                          cur_param++;
                                 }                                  }
                                 trav = trav->next;                                  trav = trav->next;
Line 3577  static void deserialize_parameters(xmlNodePtr params,  Line 3361  static void deserialize_parameters(xmlNodePtr params, 
                 }                  }
         }          }
         if (num_of_params > cur_param) {          if (num_of_params > cur_param) {
                 TSRMLS_FETCH();  
                 soap_server_fault("Client","Missing parameter", NULL, NULL, NULL TSRMLS_CC);                  soap_server_fault("Client","Missing parameter", NULL, NULL, NULL TSRMLS_CC);
         }          }
         (*parameters) = tmp_parameters;          (*parameters) = tmp_parameters;
Line 3837  static sdlFunctionPtr deserialize_function_call(sdlPtr Line 3620  static sdlFunctionPtr deserialize_function_call(sdlPtr
                                 if (h->hdr) {                                  if (h->hdr) {
                                         h->num_params = 1;                                          h->num_params = 1;
                                         h->parameters = emalloc(sizeof(zval*));                                          h->parameters = emalloc(sizeof(zval*));
                                        h->parameters[0] = master_to_zval(h->hdr->encode, hdr_func);                                        h->parameters[0] = master_to_zval(h->hdr->encode, hdr_func TSRMLS_CC);
                                 } else {                                  } else {
                                         if (h->function && h->function->binding && h->function->binding->bindingType == BINDING_SOAP) {                                          if (h->function && h->function->binding && h->function->binding->bindingType == BINDING_SOAP) {
                                                 sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)h->function->bindingAttributes;                                                  sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)h->function->bindingAttributes;
Line 3845  static sdlFunctionPtr deserialize_function_call(sdlPtr Line 3628  static sdlFunctionPtr deserialize_function_call(sdlPtr
                                                         hdr_func = hdr_func->children;                                                          hdr_func = hdr_func->children;
                                                 }                                                  }
                                         }                                          }
                                        deserialize_parameters(hdr_func, h->function, &h->num_params, &h->parameters);                                        deserialize_parameters(hdr_func, h->function, &h->num_params, &h->parameters TSRMLS_CC);
                                 }                                  }
                                 INIT_ZVAL(h->retval);                                  INIT_ZVAL(h->retval);
                                 if (last == NULL) {                                  if (last == NULL) {
Line 3868  ignore_header: Line 3651  ignore_header:
         } else {          } else {
                 func = func->children;                  func = func->children;
         }          }
        deserialize_parameters(func, function, num_params, parameters);        deserialize_parameters(func, function, num_params, parameters TSRMLS_CC);
                   
         encode_finish();          encode_finish();
   
         return function;          return function;
 }  }
   
static int serialize_response_call2(xmlNodePtr body, sdlFunctionPtr function, char *function_name, char *uri, zval *ret, int version, int main TSRMLS_DC)static void set_soap_header_attributes(xmlNodePtr h, HashTable *ht, int version)
 {  {
           zval **tmp;
   
           if (zend_hash_find(ht, "mustUnderstand", sizeof("mustUnderstand"), (void**)&tmp) == SUCCESS &&
               Z_TYPE_PP(tmp) == IS_BOOL && Z_LVAL_PP(tmp)) {
                   if (version == SOAP_1_1) {
                           xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":mustUnderstand"), BAD_CAST("1"));
                   } else {
                           xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":mustUnderstand"), BAD_CAST("true"));
                   }
           }
           if (zend_hash_find(ht, "actor", sizeof("actor"), (void**)&tmp) == SUCCESS) {
                   if (Z_TYPE_PP(tmp) == IS_STRING) {
                           if (version == SOAP_1_1) {
                                   xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":actor"), BAD_CAST(Z_STRVAL_PP(tmp)));
                           } else {
                                   xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(Z_STRVAL_PP(tmp)));
                           }
                   } else if (Z_TYPE_PP(tmp) == IS_LONG) {
                           if (version == SOAP_1_1) {
                                   if (Z_LVAL_PP(tmp) == SOAP_ACTOR_NEXT) {
                                           xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":actor"), BAD_CAST(SOAP_1_1_ACTOR_NEXT));
                                   }
                           } else {
                                   if (Z_LVAL_PP(tmp) == SOAP_ACTOR_NEXT) {
                                           xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_NEXT));
                                   } else if (Z_LVAL_PP(tmp) == SOAP_ACTOR_NONE) {
                                           xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_NONE));
                                   } else if (Z_LVAL_PP(tmp) == SOAP_ACTOR_UNLIMATERECEIVER) {
                                           xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_UNLIMATERECEIVER));
                                   }
                           }
                   }
           }
   }
   
   static int serialize_response_call2(xmlNodePtr body, sdlFunctionPtr function, char *function_name, char *uri, zval *ret, int version, int main, xmlNodePtr *node TSRMLS_DC)
   {
         xmlNodePtr method = NULL, param;          xmlNodePtr method = NULL, param;
         sdlParamPtr parameter = NULL;          sdlParamPtr parameter = NULL;
         int param_count;          int param_count;
Line 3975  static int serialize_response_call2(xmlNodePtr body, s Line 3795  static int serialize_response_call2(xmlNodePtr body, s
         if (use == SOAP_ENCODED && version == SOAP_1_2 && method != NULL) {          if (use == SOAP_ENCODED && version == SOAP_1_2 && method != NULL) {
                 xmlSetNsProp(method, body->ns, BAD_CAST("encodingStyle"), BAD_CAST(SOAP_1_2_ENC_NAMESPACE));                  xmlSetNsProp(method, body->ns, BAD_CAST("encodingStyle"), BAD_CAST(SOAP_1_2_ENC_NAMESPACE));
         }          }
           if (node) {
                   *node = method;
           }
         return use;          return use;
 }  }
   
Line 4056  static xmlDocPtr serialize_response_call(sdlFunctionPt Line 3879  static xmlDocPtr serialize_response_call(sdlFunctionPt
                         }                          }
   
                         if (headers->function) {                          if (headers->function) {
                                if (serialize_response_call2(head, headers->function, Z_STRVAL(headers->function_name), uri, hdr_ret, version, 0 TSRMLS_CC) == SOAP_ENCODED) {                                if (serialize_response_call2(head, headers->function, Z_STRVAL(headers->function_name), uri, hdr_ret, version, 0, NULL TSRMLS_CC) == SOAP_ENCODED) {
                                         use = SOAP_ENCODED;                                          use = SOAP_ENCODED;
                                 }                                  }
                         } else {                          } else {
                                xmlNodePtr xmlHdr = master_to_xml(hdr_enc, hdr_ret, hdr_use, head);                                xmlNodePtr xmlHdr = master_to_xml(hdr_enc, hdr_ret, hdr_use, head TSRMLS_CC);
                                 if (hdr_name) {                                  if (hdr_name) {
                                         xmlNodeSetName(xmlHdr, BAD_CAST(hdr_name));                                          xmlNodeSetName(xmlHdr, BAD_CAST(hdr_name));
                                 }                                  }
Line 4126  static xmlDocPtr serialize_response_call(sdlFunctionPt Line 3949  static xmlDocPtr serialize_response_call(sdlFunctionPt
   
                 if (version == SOAP_1_1) {                  if (version == SOAP_1_1) {
                         if (zend_hash_find(prop, "faultcode", sizeof("faultcode"), (void**)&tmp) == SUCCESS) {                          if (zend_hash_find(prop, "faultcode", sizeof("faultcode"), (void**)&tmp) == SUCCESS) {
                                int new_len;                                size_t new_len;
                                 xmlNodePtr node = xmlNewNode(NULL, BAD_CAST("faultcode"));                                  xmlNodePtr node = xmlNewNode(NULL, BAD_CAST("faultcode"));
                                 char *str = php_escape_html_entities((unsigned char*)Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC);                                  char *str = php_escape_html_entities((unsigned char*)Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC);
                                 xmlAddChild(param, node);                                  xmlAddChild(param, node);
Line 4136  static xmlDocPtr serialize_response_call(sdlFunctionPt Line 3959  static xmlDocPtr serialize_response_call(sdlFunctionPt
                                         xmlNodeSetContent(node, code);                                          xmlNodeSetContent(node, code);
                                         xmlFree(code);                                          xmlFree(code);
                                 } else {                                          } else {        
                                        xmlNodeSetContentLen(node, BAD_CAST(str), new_len);                                        xmlNodeSetContentLen(node, BAD_CAST(str), (int)new_len);
                                 }                                  }
                                 efree(str);                                  efree(str);
                         }                          }
                         if (zend_hash_find(prop, "faultstring", sizeof("faultstring"), (void**)&tmp) == SUCCESS) {                          if (zend_hash_find(prop, "faultstring", sizeof("faultstring"), (void**)&tmp) == SUCCESS) {
                                xmlNodePtr node = master_to_xml(get_conversion(IS_STRING), *tmp, SOAP_LITERAL, param);                                xmlNodePtr node = master_to_xml(get_conversion(IS_STRING), *tmp, SOAP_LITERAL, param TSRMLS_CC);
                                 xmlNodeSetName(node, BAD_CAST("faultstring"));                                  xmlNodeSetName(node, BAD_CAST("faultstring"));
                         }                          }
                         if (zend_hash_find(prop, "faultactor", sizeof("faultactor"), (void**)&tmp) == SUCCESS) {                          if (zend_hash_find(prop, "faultactor", sizeof("faultactor"), (void**)&tmp) == SUCCESS) {
                                xmlNodePtr node = master_to_xml(get_conversion(IS_STRING), *tmp, SOAP_LITERAL, param);                                xmlNodePtr node = master_to_xml(get_conversion(IS_STRING), *tmp, SOAP_LITERAL, param TSRMLS_CC);
                                 xmlNodeSetName(node, BAD_CAST("faultactor"));                                  xmlNodeSetName(node, BAD_CAST("faultactor"));
                         }                          }
                         detail_name = "detail";                          detail_name = "detail";
                 } else {                  } else {
                         if (zend_hash_find(prop, "faultcode", sizeof("faultcode"), (void**)&tmp) == SUCCESS) {                          if (zend_hash_find(prop, "faultcode", sizeof("faultcode"), (void**)&tmp) == SUCCESS) {
                                int new_len;                                size_t new_len;
                                 xmlNodePtr node = xmlNewChild(param, ns, BAD_CAST("Code"), NULL);                                  xmlNodePtr node = xmlNewChild(param, ns, BAD_CAST("Code"), NULL);
                                 char *str = php_escape_html_entities((unsigned char*)Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC);                                  char *str = php_escape_html_entities((unsigned char*)Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC);
                                 node = xmlNewChild(node, ns, BAD_CAST("Value"), NULL);                                  node = xmlNewChild(node, ns, BAD_CAST("Value"), NULL);
Line 4161  static xmlDocPtr serialize_response_call(sdlFunctionPt Line 3984  static xmlDocPtr serialize_response_call(sdlFunctionPt
                                         xmlNodeSetContent(node, code);                                          xmlNodeSetContent(node, code);
                                         xmlFree(code);                                          xmlFree(code);
                                 } else {                                          } else {        
                                        xmlNodeSetContentLen(node, BAD_CAST(str), new_len);                                        xmlNodeSetContentLen(node, BAD_CAST(str), (int)new_len);
                                 }                                  }
                                 efree(str);                                  efree(str);
                         }                          }
                         if (zend_hash_find(prop, "faultstring", sizeof("faultstring"), (void**)&tmp) == SUCCESS) {                          if (zend_hash_find(prop, "faultstring", sizeof("faultstring"), (void**)&tmp) == SUCCESS) {
                                 xmlNodePtr node = xmlNewChild(param, ns, BAD_CAST("Reason"), NULL);                                  xmlNodePtr node = xmlNewChild(param, ns, BAD_CAST("Reason"), NULL);
                                node = master_to_xml(get_conversion(IS_STRING), *tmp, SOAP_LITERAL, node);                                node = master_to_xml(get_conversion(IS_STRING), *tmp, SOAP_LITERAL, node TSRMLS_CC);
                                 xmlNodeSetName(node, BAD_CAST("Text"));                                  xmlNodeSetName(node, BAD_CAST("Text"));
                                 xmlSetNs(node, ns);                                  xmlSetNs(node, ns);
                         }                          }
Line 4242  static xmlDocPtr serialize_response_call(sdlFunctionPt Line 4065  static xmlDocPtr serialize_response_call(sdlFunctionPt
                                         zval *hdr_ret = &h->retval;                                          zval *hdr_ret = &h->retval;
                                         char *hdr_ns   = h->hdr?h->hdr->ns:NULL;                                          char *hdr_ns   = h->hdr?h->hdr->ns:NULL;
                                         char *hdr_name = Z_STRVAL(h->function_name);                                          char *hdr_name = Z_STRVAL(h->function_name);
                                           HashTable *ht = NULL;
   
   
                                         if (Z_TYPE(h->retval) == IS_OBJECT &&                                          if (Z_TYPE(h->retval) == IS_OBJECT &&
                                             instanceof_function(Z_OBJCE(h->retval), soap_header_class_entry TSRMLS_CC)) {                                              instanceof_function(Z_OBJCE(h->retval), soap_header_class_entry TSRMLS_CC)) {
                                                 HashTable* ht = Z_OBJPROP(h->retval);  
                                                 zval **tmp;                                                  zval **tmp;
                                                 sdlSoapBindingFunctionHeaderPtr *hdr;                                                  sdlSoapBindingFunctionHeaderPtr *hdr;
                                                 smart_str key = {0};                                                  smart_str key = {0};
   
                                                   ht = Z_OBJPROP(h->retval);
                                                 if (zend_hash_find(ht, "namespace", sizeof("namespace"), (void**)&tmp) == SUCCESS &&                                                  if (zend_hash_find(ht, "namespace", sizeof("namespace"), (void**)&tmp) == SUCCESS &&
                                               Z_TYPE_PP(tmp) == IS_STRING) {                                                Z_TYPE_PP(tmp) == IS_STRING) {
                                                         smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));                                                          smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
Line 4281  static xmlDocPtr serialize_response_call(sdlFunctionPt Line 4104  static xmlDocPtr serialize_response_call(sdlFunctionPt
                                         }                                          }
   
                                         if (h->function) {                                          if (h->function) {
                                                if (serialize_response_call2(head, h->function, Z_STRVAL(h->function_name), uri, hdr_ret, version, 0 TSRMLS_CC) == SOAP_ENCODED) {                                                xmlNodePtr xmlHdr = NULL;
 
                                                 if (serialize_response_call2(head, h->function, Z_STRVAL(h->function_name), uri, hdr_ret, version, 0, &xmlHdr TSRMLS_CC) == SOAP_ENCODED) {
                                                         use = SOAP_ENCODED;                                                          use = SOAP_ENCODED;
                                                 }                                                  }
                                                   if (ht) {
                                                           set_soap_header_attributes(xmlHdr, ht, version);
                                                   }
                                         } else {                                          } else {
                                                xmlNodePtr xmlHdr = master_to_xml(hdr_enc, hdr_ret, hdr_use, head);                                                xmlNodePtr xmlHdr = master_to_xml(hdr_enc, hdr_ret, hdr_use, head TSRMLS_CC);
                                                 if (hdr_name) {                                                  if (hdr_name) {
                                                         xmlNodeSetName(xmlHdr, BAD_CAST(hdr_name));                                                          xmlNodeSetName(xmlHdr, BAD_CAST(hdr_name));
                                                 }                                                  }
Line 4293  static xmlDocPtr serialize_response_call(sdlFunctionPt Line 4121  static xmlDocPtr serialize_response_call(sdlFunctionPt
                                                         xmlNsPtr nsptr = encode_add_ns(xmlHdr,hdr_ns);                                                          xmlNsPtr nsptr = encode_add_ns(xmlHdr,hdr_ns);
                                                         xmlSetNs(xmlHdr, nsptr);                                                          xmlSetNs(xmlHdr, nsptr);
                                                 }                                                  }
                                                   if (ht) {
                                                           set_soap_header_attributes(xmlHdr, ht, version);
                                                   }
                                         }                                          }
                                 }                                  }
                                 h = h->next;                                  h = h->next;
Line 4306  static xmlDocPtr serialize_response_call(sdlFunctionPt Line 4137  static xmlDocPtr serialize_response_call(sdlFunctionPt
   
                 body = xmlNewChild(envelope, ns, BAD_CAST("Body"), NULL);                  body = xmlNewChild(envelope, ns, BAD_CAST("Body"), NULL);
   
                if (serialize_response_call2(body, function, function_name, uri, ret, version, 1 TSRMLS_CC) == SOAP_ENCODED) {                if (serialize_response_call2(body, function, function_name, uri, ret, version, 1, NULL TSRMLS_CC) == SOAP_ENCODED) {
                         use = SOAP_ENCODED;                          use = SOAP_ENCODED;
                 }                  }
   
Line 4490  static xmlDocPtr serialize_function_call(zval *this_pt Line 4321  static xmlDocPtr serialize_function_call(zval *this_pt
                                 }                                  }
   
                                 if (zend_hash_find(ht, "data", sizeof("data"), (void**)&tmp) == SUCCESS) {                                  if (zend_hash_find(ht, "data", sizeof("data"), (void**)&tmp) == SUCCESS) {
                                        h = master_to_xml(enc, *tmp, hdr_use, head);                                        h = master_to_xml(enc, *tmp, hdr_use, head TSRMLS_CC);
                                         xmlNodeSetName(h, BAD_CAST(Z_STRVAL_PP(name)));                                          xmlNodeSetName(h, BAD_CAST(Z_STRVAL_PP(name)));
                                 } else {                                  } else {
                                         h = xmlNewNode(NULL, BAD_CAST(Z_STRVAL_PP(name)));                                          h = xmlNewNode(NULL, BAD_CAST(Z_STRVAL_PP(name)));
Line 4498  static xmlDocPtr serialize_function_call(zval *this_pt Line 4329  static xmlDocPtr serialize_function_call(zval *this_pt
                                 }                                  }
                                 nsptr = encode_add_ns(h, Z_STRVAL_PP(ns));                                  nsptr = encode_add_ns(h, Z_STRVAL_PP(ns));
                                 xmlSetNs(h, nsptr);                                  xmlSetNs(h, nsptr);
                                set_soap_header_attributes(h, ht, version);
                                if (zend_hash_find(ht, "mustUnderstand", sizeof("mustUnderstand"), (void**)&tmp) == SUCCESS && 
                                    Z_TYPE_PP(tmp) == IS_BOOL && Z_LVAL_PP(tmp)) { 
                                        if (version == SOAP_1_1) { 
                                                xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":mustUnderstand"), BAD_CAST("1")); 
                                        } else { 
                                                xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":mustUnderstand"), BAD_CAST("true")); 
                                        } 
                                } 
                                if (zend_hash_find(ht, "actor", sizeof("actor"), (void**)&tmp) == SUCCESS) { 
                                        if (Z_TYPE_PP(tmp) == IS_STRING) { 
                                                if (version == SOAP_1_1) { 
                                                        xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":actor"), BAD_CAST(Z_STRVAL_PP(tmp))); 
                                                } else { 
                                                        xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(Z_STRVAL_PP(tmp))); 
                                                } 
                                        } else if (Z_TYPE_PP(tmp) == IS_LONG) { 
                                                if (version == SOAP_1_1) { 
                                                        if (Z_LVAL_PP(tmp) == SOAP_ACTOR_NEXT) { 
                                                                xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":actor"), BAD_CAST(SOAP_1_1_ACTOR_NEXT)); 
                                                        } 
                                                } else { 
                                                        if (Z_LVAL_PP(tmp) == SOAP_ACTOR_NEXT) { 
                                                                xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_NEXT)); 
                                                        } else if (Z_LVAL_PP(tmp) == SOAP_ACTOR_NONE) { 
                                                                xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_NONE)); 
                                                        } else if (Z_LVAL_PP(tmp) == SOAP_ACTOR_UNLIMATERECEIVER) { 
                                                                xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_UNLIMATERECEIVER)); 
                                                        } 
                                                } 
                                        } 
                                } 
                         }                          }
                         zend_hash_move_forward(soap_headers);                          zend_hash_move_forward(soap_headers);
                 }                  }
Line 4610  static xmlNodePtr serialize_zval(zval *val, sdlParamPt Line 4410  static xmlNodePtr serialize_zval(zval *val, sdlParamPt
         } else {          } else {
                 enc = NULL;                  enc = NULL;
         }          }
        xmlParam = master_to_xml(enc, val, style, parent);        xmlParam = master_to_xml(enc, val, style, parent TSRMLS_CC);
         if (!strcmp((char*)xmlParam->name, "BOGUS")) {          if (!strcmp((char*)xmlParam->name, "BOGUS")) {
                 xmlNodeSetName(xmlParam, BAD_CAST(paramName));                  xmlNodeSetName(xmlParam, BAD_CAST(paramName));
         }          }

Removed from v.1.1  
changed lines
  Added in v.1.1.1.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>