]> granicus.if.org Git - php/commitdiff
Speed up SoapClient/SoapServer constructors by caching WSDL structures
authorAndrei Zmievski <andrei@php.net>
Sun, 9 Apr 2006 23:35:51 +0000 (23:35 +0000)
committerAndrei Zmievski <andrei@php.net>
Sun, 9 Apr 2006 23:35:51 +0000 (23:35 +0000)
in memory. All WSDL files will be cached, unless turned off via an
option to the constructor.

NEWS
ext/soap/php_encoding.c
ext/soap/php_encoding.h
ext/soap/php_schema.c
ext/soap/php_schema.h
ext/soap/php_sdl.c
ext/soap/php_sdl.h
ext/soap/php_soap.h
ext/soap/soap.c

diff --git a/NEWS b/NEWS
index 5481c52a66ba0d12bab64dd16d81c35c3a8fbe4f..b4341b84eb752845531b0aa32b539641727b305f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 06 Apr 2006, PHP 5.1.3RC3
+- Sped up SoapClient/SoapServer construction by making SOAP extension cache
+  WSDL structure in memory. (Andrei)
 - Fixed a bug that would not fill in the fifth argument to preg_replace() 
   properly, if the variable was not declared previously. (Andrei)
 - Fixed safe_mode check for source argument of the copy() function. (Ilia)
index 1d527aab53c47508e8f7bd24619e43efd37477d0..683e35ef59fe25528e1fd21222d8989e6d86f25a 100644 (file)
@@ -3300,3 +3300,17 @@ void delete_encoder(void *encode)
        }
        efree(t);
 }
+
+void delete_encoder_persistent(void *encode)
+{
+       encodePtr t = *((encodePtr*)encode);
+       if (t->details.ns) {
+               free(t->details.ns);
+       }
+       if (t->details.type_str) {
+               free(t->details.type_str);
+       }
+       /* we should never have mapping in persistent encoder */
+       assert(t->details.map == NULL);
+       free(t);
+}
index e6638b41fdf59d386dcfba3447892d613fed3e4a..2282a9ad71c9c60b89c6e136b9a2de24a25302a8 100644 (file)
@@ -219,6 +219,7 @@ xmlNsPtr encode_add_ns(xmlNodePtr node, const char* ns);
 encodePtr get_conversion(int encode);
 
 void delete_encoder(void *handle);
+void delete_encoder_persistent(void *handle);
 
 extern encode defaultEncoding[];
 
index 3753245bd51b4a2bc9d90779d0e63c8865c82383..c448cf5fb7f95658daf6dfd81e7eab7fa753f961 100644 (file)
@@ -2358,6 +2358,28 @@ void delete_model(void *handle)
        efree(tmp);
 }
 
+void delete_model_persistent(void *handle)
+{
+       sdlContentModelPtr tmp = *((sdlContentModelPtr*)handle);
+       switch (tmp->kind) {
+               case XSD_CONTENT_ELEMENT:
+               case XSD_CONTENT_GROUP:
+                       break;
+               case XSD_CONTENT_SEQUENCE:
+               case XSD_CONTENT_ALL:
+               case XSD_CONTENT_CHOICE:
+                       zend_hash_destroy(tmp->u.content);
+                       free(tmp->u.content);
+                       break;
+               case XSD_CONTENT_GROUP_REF:
+                       free(tmp->u.group_ref);
+                       break;
+               default:
+                       break;
+       }
+       free(tmp);
+}
+
 void delete_type(void *data)
 {
        sdlTypePtr type = *((sdlTypePtr*)data);
@@ -2405,6 +2427,53 @@ void delete_type(void *data)
        efree(type);
 }
 
+void delete_type_persistent(void *data)
+{
+       sdlTypePtr type = *((sdlTypePtr*)data);
+       if (type->name) {
+               free(type->name);
+       }
+       if (type->namens) {
+               free(type->namens);
+       }
+       if (type->def) {
+               free(type->def);
+       }
+       if (type->fixed) {
+               free(type->fixed);
+       }
+       if (type->elements) {
+               zend_hash_destroy(type->elements);
+               free(type->elements);
+       }
+       if (type->attributes) {
+               zend_hash_destroy(type->attributes);
+               free(type->attributes);
+       }
+       if (type->model) {
+               delete_model_persistent((void**)&type->model);
+       }
+       if (type->restrictions) {
+               delete_restriction_var_int_persistent(&type->restrictions->minExclusive);
+               delete_restriction_var_int_persistent(&type->restrictions->minInclusive);
+               delete_restriction_var_int_persistent(&type->restrictions->maxExclusive);
+               delete_restriction_var_int_persistent(&type->restrictions->maxInclusive);
+               delete_restriction_var_int_persistent(&type->restrictions->totalDigits);
+               delete_restriction_var_int_persistent(&type->restrictions->fractionDigits);
+               delete_restriction_var_int_persistent(&type->restrictions->length);
+               delete_restriction_var_int_persistent(&type->restrictions->minLength);
+               delete_restriction_var_int_persistent(&type->restrictions->maxLength);
+               delete_restriction_var_char_persistent(&type->restrictions->whiteSpace);
+               delete_restriction_var_char_persistent(&type->restrictions->pattern);
+               if (type->restrictions->enumeration) {
+                       zend_hash_destroy(type->restrictions->enumeration);
+                       free(type->restrictions->enumeration);
+               }
+               free(type->restrictions);
+       }
+       free(type);
+}
+
 void delete_extra_attribute(void *attribute)
 {
        sdlExtraAttributePtr attr = *((sdlExtraAttributePtr*)attribute);
@@ -2418,6 +2487,19 @@ void delete_extra_attribute(void *attribute)
        efree(attr);
 }
 
+void delete_extra_attribute_persistent(void *attribute)
+{
+       sdlExtraAttributePtr attr = *((sdlExtraAttributePtr*)attribute);
+
+       if (attr->ns) {
+               free(attr->ns);
+       }
+       if (attr->val) {
+               free(attr->val);
+       }
+       free(attr);
+}
+
 void delete_attribute(void *attribute)
 {
        sdlAttributePtr attr = *((sdlAttributePtr*)attribute);
@@ -2444,6 +2526,32 @@ void delete_attribute(void *attribute)
        efree(attr);
 }
 
+void delete_attribute_persistent(void *attribute)
+{
+       sdlAttributePtr attr = *((sdlAttributePtr*)attribute);
+
+       if (attr->def) {
+               free(attr->def);
+       }
+       if (attr->fixed) {
+               free(attr->fixed);
+       }
+       if (attr->name) {
+               free(attr->name);
+       }
+       if (attr->namens) {
+               free(attr->namens);
+       }
+       if (attr->ref) {
+               free(attr->ref);
+       }
+       if (attr->extraAttributes) {
+               zend_hash_destroy(attr->extraAttributes);
+               free(attr->extraAttributes);
+       }
+       free(attr);
+}
+
 void delete_restriction_var_int(void *rvi)
 {
        sdlRestrictionIntPtr ptr = *((sdlRestrictionIntPtr*)rvi);
@@ -2452,6 +2560,14 @@ void delete_restriction_var_int(void *rvi)
        }
 }
 
+void delete_restriction_var_int_persistent(void *rvi)
+{
+       sdlRestrictionIntPtr ptr = *((sdlRestrictionIntPtr*)rvi);
+       if (ptr) {
+               free(ptr);
+       }
+}
+
 void delete_restriction_var_char(void *srvc)
 {
        sdlRestrictionCharPtr ptr = *((sdlRestrictionCharPtr*)srvc);
@@ -2462,3 +2578,14 @@ void delete_restriction_var_char(void *srvc)
                efree(ptr);
        }
 }
+
+void delete_restriction_var_char_persistent(void *srvc)
+{
+       sdlRestrictionCharPtr ptr = *((sdlRestrictionCharPtr*)srvc);
+       if (ptr) {
+               if (ptr->value) {
+                       free(ptr->value);
+               }
+               free(ptr);
+       }
+}
index e5a3934767041f00ce25114865184c051f4409ee..fbc7372a103fe26e0cc30816af70815e072064f4 100644 (file)
@@ -26,9 +26,15 @@ int load_schema(sdlCtx *ctx, xmlNodePtr schema TSRMLS_DC);
 void schema_pass2(sdlCtx *ctx);
 
 void delete_model(void *handle);
+void delete_model_persistent(void *handle);
 void delete_type(void *data);
+void delete_type_persistent(void *data);
 void delete_extra_attribute(void *attribute);
+void delete_extra_attribute_persistent(void *attribute);
 void delete_attribute(void *attribute);
+void delete_attribute_persistent(void *attribute);
 void delete_restriction_var_int(void *rvi);
+void delete_restriction_var_int_persistent(void *rvi);
 void delete_restriction_var_char(void *srvc);
+void delete_restriction_var_char_persistent(void *srvc);
 #endif
index e2698ebcab3cd09b40236718287fbc7317220d82..bc5780594d4d558b3c2b8b101b2ae5edcc31e596 100644 (file)
 #endif
 
 static void delete_fault(void *fault);
+static void delete_fault_persistent(void *fault);
 static void delete_binding(void *binding);
+static void delete_binding_persistent(void *binding);
 static void delete_function(void *function);
+static void delete_function_persistent(void *function);
 static void delete_parameter(void *paramater);
+static void delete_parameter_persistent(void *paramater);
 static void delete_header(void *header);
+static void delete_header_persistent(void *header);
 static void delete_document(void *doc_ptr);
 
 encodePtr get_encoder_from_prefix(sdlPtr sdl, xmlNodePtr node, const char *type)
@@ -1407,7 +1412,7 @@ static HashTable* sdl_deserialize_parameters(encodePtr *encoders, sdlTypePtr *ty
        return ht;
 }
 
-static sdlPtr get_sdl_from_cache(const char *fn, const char *uri, time_t t)
+static sdlPtr get_sdl_from_cache(const char *fn, const char *uri, time_t t TSRMLS_DC)
 {
        sdlPtr sdl;
        time_t old_t;
@@ -1983,7 +1988,7 @@ static void sdl_serialize_soap_body(sdlSoapBindingFunctionBodyPtr body, HashTabl
        }
 }
 
-static void add_sdl_to_cache(const char *fn, const char *uri, time_t t, sdlPtr sdl)
+static void add_sdl_to_cache(const char *fn, const char *uri, time_t t, sdlPtr sdl TSRMLS_DC)
 {
        smart_str buf = {0};
        smart_str *out = &buf;
@@ -2258,7 +2263,762 @@ static void add_sdl_to_cache(const char *fn, const char *uri, time_t t, sdlPtr s
        zend_hash_destroy(&tmp_types);
 }
 
-sdlPtr get_sdl(zval *this_ptr, char *uri TSRMLS_DC)
+
+static void make_persistent_restriction_int(void *data)
+{
+       sdlRestrictionIntPtr *rest = (sdlRestrictionIntPtr *)data;
+       sdlRestrictionIntPtr prest = NULL;
+
+       prest = malloc(sizeof(sdlRestrictionIntPtr));
+       *prest = **rest;
+       *rest = prest;
+}
+
+
+static void make_persistent_restriction_char(void *data)
+{
+       sdlRestrictionCharPtr *rest = (sdlRestrictionCharPtr *)data;
+       sdlRestrictionCharPtr prest = NULL;
+
+       prest = malloc(sizeof(sdlRestrictionChar));
+       memset(prest, 0, sizeof(sdlRestrictionChar));
+       prest->value = strdup((*rest)->value);
+       prest->fixed = (*rest)->fixed;
+       *rest = prest;
+}
+
+
+static void make_persistent_sdl_type_ref(sdlTypePtr *type, HashTable *ptr_map, HashTable *bp_types)
+{
+       sdlTypePtr *tmp;
+
+       if (zend_hash_find(ptr_map, (char *)(*type), sizeof(sdlTypePtr), (void**)&tmp) == SUCCESS) {
+               *type = *tmp;
+       } else {
+               zend_hash_next_index_insert(bp_types, (void*)&type, sizeof(sdlTypePtr*), NULL);
+       }
+}
+
+
+static void make_persistent_sdl_encoder_ref(encodePtr *enc, HashTable *ptr_map, HashTable *bp_encoders)
+{
+       encodePtr *tmp;
+
+       /* do not process defaultEncoding's here */
+       if ((*enc)->details.sdl_type == NULL) {
+               return;
+       }
+
+       if (zend_hash_find(ptr_map, (char *)(*enc), sizeof(encodePtr), (void**)&tmp) == SUCCESS) {
+               *enc = *tmp;
+       } else {
+               zend_hash_next_index_insert(bp_encoders, (void*)&enc, sizeof(encodePtr*), NULL);
+       }
+}
+
+
+static HashTable* make_persistent_sdl_function_headers(HashTable *headers, HashTable *ptr_map)
+{
+       HashTable *pheaders;
+       sdlSoapBindingFunctionHeaderPtr *tmp, pheader;
+       encodePtr *penc;
+       sdlTypePtr *ptype;
+       ulong index;
+       char *key;
+       uint key_len;
+
+       pheaders = malloc(sizeof(HashTable));
+       zend_hash_init(pheaders, zend_hash_num_elements(headers), NULL, delete_header_persistent, 1);
+
+       zend_hash_internal_pointer_reset(headers);
+       while (zend_hash_get_current_data(headers, (void**)&tmp) == SUCCESS) {
+               pheader = malloc(sizeof(sdlSoapBindingFunctionHeader));
+               memset(pheader, 0, sizeof(sdlSoapBindingFunctionHeader));
+               *pheader = **tmp;
+
+               if (pheader->name) {
+                       pheader->name = strdup(pheader->name);
+               }
+               if (pheader->ns) {
+                       pheader->ns = strdup(pheader->ns);
+               }
+
+               if (pheader->encode->details.sdl_type) {
+                       if (zend_hash_find(ptr_map, (char*)&pheader->encode, sizeof(encodePtr), (void**)&penc) == FAILURE) {
+                               assert(0);
+                       }
+                       pheader->encode = *penc;
+               }
+               if (pheader->element) {
+                       if (zend_hash_find(ptr_map, (char*)&pheader->element, sizeof(sdlTypePtr), (void**)&ptype) == FAILURE) {
+                               assert(0);
+                       }
+                       pheader->element = *ptype;
+               }
+
+               if (pheader->headerfaults) {
+                       pheader->headerfaults = make_persistent_sdl_function_headers(pheader->headerfaults, ptr_map);
+               }
+
+               if (zend_hash_get_current_key_ex(headers, &key, &key_len, &index, 0, NULL) == HASH_KEY_IS_STRING) {
+                       zend_hash_add(pheaders, key, key_len, (void*)&pheader, sizeof(sdlSoapBindingFunctionHeaderPtr), NULL);
+               } else {
+                       zend_hash_next_index_insert(pheaders, (void*)&pheader, sizeof(sdlSoapBindingFunctionHeaderPtr), NULL);
+               }
+
+               zend_hash_move_forward(headers);
+       }
+
+       return pheaders;
+}
+
+
+static void make_persistent_sdl_soap_body(sdlSoapBindingFunctionBodyPtr body, HashTable *ptr_map)
+{
+       if (body->ns) {
+               body->ns = strdup(body->ns);
+       }
+
+       if (body->headers) {
+               body->headers = make_persistent_sdl_function_headers(body->headers, ptr_map);
+       }
+}
+
+
+static HashTable* make_persistent_sdl_parameters(HashTable *params, HashTable *ptr_map)
+{
+       HashTable *pparams;
+       sdlParamPtr *tmp, pparam;
+       sdlTypePtr *ptype;
+       encodePtr *penc;
+       ulong index;
+       char *key;
+       uint key_len;
+
+       pparams = malloc(sizeof(HashTable));
+       zend_hash_init(pparams, zend_hash_num_elements(params), NULL, delete_parameter_persistent, 1);
+
+       zend_hash_internal_pointer_reset(params);
+       while (zend_hash_get_current_data(params, (void**)&tmp) == SUCCESS) {
+               pparam = malloc(sizeof(sdlParam));
+               memset(pparam, 0, sizeof(sdlParam));
+               *pparam = **tmp;
+
+               if (pparam->paramName) {
+                       pparam->paramName = strdup(pparam->paramName);
+               }
+
+               if (pparam->encode && pparam->encode->details.sdl_type) {
+                       if (zend_hash_find(ptr_map, (char*)&pparam->encode, sizeof(encodePtr), (void**)&penc) == FAILURE) {
+                               assert(0);
+                       }
+                       pparam->encode = *penc;
+               }
+               if (pparam->element) {
+                       if (zend_hash_find(ptr_map, (char*)&pparam->element, sizeof(sdlTypePtr), (void**)&ptype) == FAILURE) {
+                               assert(0);
+                       }
+                       pparam->element = *ptype;
+               }
+
+               if (zend_hash_get_current_key_ex(params, &key, &key_len, &index, 0, NULL) == HASH_KEY_IS_STRING) {
+                       zend_hash_add(pparams, key, key_len, (void*)&pparam, sizeof(sdlParamPtr), NULL);
+               } else {
+                       zend_hash_next_index_insert(pparams, (void*)&pparam, sizeof(sdlParamPtr), NULL);
+               }
+
+               zend_hash_move_forward(params);
+       }
+
+
+       return pparams;
+}
+
+static HashTable* make_persistent_sdl_function_faults(sdlFunctionPtr func, HashTable *faults, HashTable *ptr_map)
+{
+       HashTable *pfaults;
+       sdlFaultPtr  *tmp, pfault;
+       ulong index;
+       char *key;
+       uint key_len;
+
+       pfaults = malloc(sizeof(HashTable));
+       zend_hash_init(pfaults, zend_hash_num_elements(faults), NULL, delete_fault_persistent, 1);
+
+       zend_hash_internal_pointer_reset(faults);
+       while (zend_hash_get_current_data(faults, (void**)&tmp) == SUCCESS) {
+               pfault = malloc(sizeof(sdlFault));
+               memset(pfault, 0, sizeof(sdlFault));
+               *pfault = **tmp;
+
+               if (pfault->name) {
+                       pfault->name = strdup(pfault->name);
+               }
+               if (pfault->details) {
+                       pfault->details = make_persistent_sdl_parameters(pfault->details, ptr_map);
+               }
+
+               if (func->binding->bindingType == BINDING_SOAP && pfault->bindingAttributes) {
+                       sdlSoapBindingFunctionFaultPtr soap_binding;
+
+                       soap_binding = malloc(sizeof(sdlSoapBindingFunctionFault));
+                       memset(soap_binding, 0, sizeof(sdlSoapBindingFunctionFault));
+                       *soap_binding = *(sdlSoapBindingFunctionFaultPtr)pfault->bindingAttributes;
+                       if (soap_binding->ns) {
+                               soap_binding->ns = strdup(soap_binding->ns);
+                       }
+                       pfault->bindingAttributes = soap_binding;
+               }
+
+               if (zend_hash_get_current_key_ex(faults, &key, &key_len, &index, 0, NULL) == HASH_KEY_IS_STRING) {
+                       zend_hash_add(pfaults, key, key_len, (void*)&pfault, sizeof(sdlParamPtr), NULL);
+               } else {
+                       zend_hash_next_index_insert(pfaults, (void*)&pfault, sizeof(sdlParamPtr), NULL);
+               }
+
+               zend_hash_move_forward(faults);
+       }
+
+
+       return pfaults;
+}
+
+
+static sdlAttributePtr make_persistent_sdl_attribute(sdlAttributePtr attr, HashTable *ptr_map, HashTable *bp_types, HashTable *bp_encoders)
+{
+       sdlAttributePtr pattr;
+       ulong index;
+       char *key;
+       uint key_len;
+
+       pattr = malloc(sizeof(sdlAttribute));
+       memset(pattr, 0, sizeof(sdlAttribute));
+
+       *pattr = *attr;
+
+       if (pattr->name) {
+               pattr->name = strdup(pattr->name);
+       }
+       if (pattr->namens) {
+               pattr->namens = strdup(pattr->namens);
+       }
+       if (pattr->ref) {
+               pattr->ref = strdup(pattr->ref);
+       }
+       if (pattr->def) {
+               pattr->def = strdup(pattr->def);
+       }
+       if (pattr->fixed) {
+               pattr->fixed = strdup(pattr->fixed);
+       }
+
+       /* we do not want to process defaultEncoding's here */
+       if (pattr->encode && pattr->encode->details.sdl_type) {
+               make_persistent_sdl_encoder_ref(&pattr->encode, ptr_map, bp_encoders);
+       }
+
+       if (pattr->extraAttributes) {
+               sdlExtraAttributePtr *tmp, pextra;
+
+               pattr->extraAttributes = malloc(sizeof(HashTable));
+               zend_hash_init(pattr->extraAttributes, zend_hash_num_elements(attr->extraAttributes), NULL, delete_extra_attribute_persistent, 1);
+
+               zend_hash_internal_pointer_reset(pattr->extraAttributes);
+               while (zend_hash_get_current_data(attr->extraAttributes, (void**)&tmp) == SUCCESS) {
+                       pextra = malloc(sizeof(sdlExtraAttribute));
+                       memset(pextra, 0, sizeof(sdlExtraAttribute));
+                       if ((*tmp)->ns) {
+                               pextra->ns = strdup((*tmp)->ns);
+                       }
+                       if ((*tmp)->val) {
+                               pextra->val = strdup((*tmp)->val);
+                       }
+
+                       if (zend_hash_get_current_key_ex(attr->extraAttributes, &key, &key_len, &index, 0, NULL) == HASH_KEY_IS_STRING) {
+                               zend_hash_add(pattr->extraAttributes, key, key_len, (void*)&pextra, sizeof(sdlExtraAttributePtr), NULL);
+                       }
+
+                       zend_hash_move_forward(attr->extraAttributes);
+               }
+       }
+
+       return pattr;
+}
+
+
+static sdlContentModelPtr make_persistent_sdl_model(sdlContentModelPtr model, HashTable *ptr_map, HashTable *bp_types, HashTable *bp_encoders)
+{
+       sdlContentModelPtr pmodel;
+       sdlContentModelPtr *tmp, pcontent;
+
+       pmodel = malloc(sizeof(sdlContentModel));
+       memset(pmodel, 0, sizeof(sdlContentModel));
+       *pmodel = *model;
+
+       switch (pmodel->kind) {
+               case XSD_CONTENT_ELEMENT:
+                       if (pmodel->u.element) {
+                               make_persistent_sdl_type_ref(&pmodel->u.element, ptr_map, bp_types);
+                       }
+                       break;
+
+               case XSD_CONTENT_SEQUENCE:
+               case XSD_CONTENT_ALL:
+               case XSD_CONTENT_CHOICE:
+                       pmodel->u.content = malloc(sizeof(HashTable));
+                       zend_hash_init(pmodel->u.content, zend_hash_num_elements(model->u.content), NULL, delete_model_persistent, 1);
+
+                       zend_hash_internal_pointer_reset(model->u.content);
+                       while (zend_hash_get_current_data(model->u.content, (void**)&tmp) == SUCCESS) {
+                               pcontent = make_persistent_sdl_model(*tmp, ptr_map, bp_types, bp_encoders);
+                               zend_hash_next_index_insert(pmodel->u.content, (void*)&pcontent, sizeof(sdlContentModelPtr), NULL);
+                               zend_hash_move_forward(model->u.content);
+                       }
+                       break;
+
+               case XSD_CONTENT_GROUP_REF:
+                       if (pmodel->u.group_ref) {
+                               pmodel->u.group_ref = strdup(pmodel->u.group_ref);
+                       }
+                       break;
+
+               case XSD_CONTENT_GROUP:
+                       if (pmodel->u.group) {
+                               make_persistent_sdl_type_ref(&pmodel->u.group, ptr_map, bp_types);
+                       }
+                       break;
+
+               default:
+                       break;
+       }
+
+       return pmodel;
+}
+
+
+static sdlTypePtr make_persistent_sdl_type(sdlTypePtr type, HashTable *ptr_map, HashTable *bp_types, HashTable *bp_encoders)
+{
+       ulong index;
+       char *key;
+       uint key_len;
+       sdlTypePtr ptype = NULL;
+
+       ptype = malloc(sizeof(sdlType));
+       memset(ptype, 0, sizeof(sdlType));
+
+       *ptype = *type;
+
+       if (ptype->name) {
+               ptype->name = strdup(ptype->name);
+       }
+       if (ptype->namens) {
+               ptype->namens = strdup(ptype->namens);
+       }
+       if (ptype->def) {
+               ptype->def = strdup(ptype->def);
+       }
+       if (ptype->fixed) {
+               ptype->fixed = strdup(ptype->fixed);
+       }
+       if (ptype->ref) {
+               ptype->ref = strdup(ptype->ref);
+       }
+
+       /* we do not want to process defaultEncoding's here */
+       if (ptype->encode && ptype->encode->details.sdl_type) {
+               make_persistent_sdl_encoder_ref(&ptype->encode, ptr_map, bp_encoders);
+       }
+
+       if (ptype->restrictions) {
+               ptype->restrictions = malloc(sizeof(sdlRestrictions));
+               memset(ptype->restrictions, 0, sizeof(sdlRestrictions));
+               *ptype->restrictions = *type->restrictions;
+
+               if (ptype->restrictions->minExclusive) {
+                       make_persistent_restriction_int(&ptype->restrictions->minExclusive);
+               }
+               if (ptype->restrictions->maxExclusive) {
+                       make_persistent_restriction_int(&ptype->restrictions->maxExclusive);
+               }
+               if (ptype->restrictions->minInclusive) {
+                       make_persistent_restriction_int(&ptype->restrictions->minInclusive);
+               }
+               if (ptype->restrictions->maxInclusive) {
+                       make_persistent_restriction_int(&ptype->restrictions->maxInclusive);
+               }
+               if (ptype->restrictions->totalDigits) {
+                       make_persistent_restriction_int(&ptype->restrictions->totalDigits);
+               }
+               if (ptype->restrictions->fractionDigits) {
+                       make_persistent_restriction_int(&ptype->restrictions->fractionDigits);
+               }
+               if (ptype->restrictions->length) {
+                       make_persistent_restriction_int(&ptype->restrictions->length);
+               }
+               if (ptype->restrictions->minLength) {
+                       make_persistent_restriction_int(&ptype->restrictions->minLength);
+               }
+               if (ptype->restrictions->maxLength) {
+                       make_persistent_restriction_int(&ptype->restrictions->maxLength);
+               }
+               if (ptype->restrictions->whiteSpace) {
+                       make_persistent_restriction_char(&ptype->restrictions->whiteSpace);
+               }
+               if (ptype->restrictions->pattern) {
+                       make_persistent_restriction_char(&ptype->restrictions->pattern);
+               }
+
+               if (type->restrictions->enumeration) {
+                       sdlRestrictionCharPtr tmp;
+
+                       ptype->restrictions->enumeration = malloc(sizeof(HashTable));
+                       zend_hash_init(ptype->restrictions->enumeration, zend_hash_num_elements(type->restrictions->enumeration), NULL, delete_restriction_var_char_persistent, 1);
+                       zend_hash_copy(ptype->restrictions->enumeration, type->restrictions->enumeration, make_persistent_restriction_char, (void*)&tmp, sizeof(sdlRestrictionCharPtr));
+               }
+       }
+
+       if (ptype->elements) {
+               sdlTypePtr *tmp, pelem;
+
+               ptype->elements = malloc(sizeof(HashTable));
+               zend_hash_init(ptype->elements, zend_hash_num_elements(type->elements), NULL, delete_type_persistent, 1);
+
+               zend_hash_internal_pointer_reset(type->elements);
+               while (zend_hash_get_current_data(type->elements, (void **)&tmp) == SUCCESS) {
+                       pelem = make_persistent_sdl_type(*tmp, ptr_map, bp_types, bp_encoders);
+                       if (zend_hash_get_current_key_ex(type->elements, &key, &key_len, &index, 0, NULL) == HASH_KEY_IS_STRING) {
+                               zend_hash_add(ptype->elements, key, key_len, (void*)&pelem, sizeof(sdlTypePtr), NULL);
+                       } else {
+                               zend_hash_next_index_insert(ptype->elements, (void*)&pelem, sizeof(sdlTypePtr), NULL);
+                       }
+                       zend_hash_add(ptr_map, (char*)tmp, sizeof(*tmp), (void*)&pelem, sizeof(sdlTypePtr), NULL);
+                       zend_hash_move_forward(type->elements);
+               }
+       }
+
+       if (ptype->attributes) {
+               sdlAttributePtr *tmp, pattr;
+
+               ptype->attributes = malloc(sizeof(HashTable));
+               zend_hash_init(ptype->attributes, zend_hash_num_elements(type->attributes), NULL, delete_attribute_persistent, 1);
+
+               zend_hash_internal_pointer_reset(type->attributes);
+               while (zend_hash_get_current_data(type->attributes, (void **)&tmp) == SUCCESS) {
+                       pattr = make_persistent_sdl_attribute(*tmp, ptr_map, bp_types, bp_encoders);
+                       if (zend_hash_get_current_key_ex(type->attributes, &key, &key_len, &index, 0, NULL) == HASH_KEY_IS_STRING) {
+                               zend_hash_add(ptype->attributes, key, key_len, (void*)&pattr, sizeof(sdlAttributePtr), NULL);
+                       } else {
+                               zend_hash_next_index_insert(ptype->attributes, (void*)&pattr, sizeof(sdlAttributePtr), NULL);
+                       }
+                       zend_hash_move_forward(type->attributes);
+               }
+       }
+
+       if (type->model) {
+               ptype->model = make_persistent_sdl_model(ptype->model, ptr_map, bp_types, bp_encoders);
+       }
+
+       return ptype;
+}
+
+static encodePtr make_persistent_sdl_encoder(encodePtr enc, HashTable *ptr_map, HashTable *bp_types, HashTable *bp_encoders)
+{
+       encodePtr penc = NULL;
+
+       penc = malloc(sizeof(encode));
+       memset(penc, 0, sizeof(encode));
+
+       *penc = *enc;
+
+       if (penc->details.type_str) {
+               penc->details.type_str = strdup(penc->details.type_str);
+       }
+       if (penc->details.ns) {
+               penc->details.ns = strdup(penc->details.ns);
+       }
+
+       if (penc->details.sdl_type) {
+               make_persistent_sdl_type_ref(&penc->details.sdl_type, ptr_map, bp_types);
+       }
+
+       return penc;
+}
+
+static sdlBindingPtr make_persistent_sdl_binding(sdlBindingPtr bind, HashTable *ptr_map)
+{
+       sdlBindingPtr pbind = NULL;
+
+       pbind = malloc(sizeof(sdlBinding));
+       memset(pbind, 0, sizeof(sdlBinding));
+
+       *pbind = *bind;
+
+       if (pbind->name) {
+               pbind->name = strdup(pbind->name);
+       }
+       if (pbind->location) {
+               pbind->location = strdup(pbind->location);
+       }
+
+       if (pbind->bindingType == BINDING_SOAP && pbind->bindingAttributes) {
+               sdlSoapBindingPtr soap_binding;
+          
+               soap_binding = malloc(sizeof(sdlSoapBinding));
+               memset(soap_binding, 0, sizeof(sdlSoapBinding));
+               *soap_binding = *(sdlSoapBindingPtr)pbind->bindingAttributes;
+               pbind->bindingAttributes = soap_binding;
+       }
+
+       return pbind;
+}
+
+static sdlFunctionPtr make_persistent_sdl_function(sdlFunctionPtr func, HashTable *ptr_map)
+{
+       sdlFunctionPtr pfunc = NULL;
+
+       pfunc = malloc(sizeof(sdlFunction));
+       memset(pfunc, 0, sizeof(sdlFunction));
+
+       *pfunc = *func;
+
+       if (pfunc->functionName) {
+               pfunc->functionName = strdup(pfunc->functionName);
+       }
+       if (pfunc->requestName) {
+               pfunc->requestName = strdup(pfunc->requestName);
+       }
+       if (pfunc->responseName) {
+               pfunc->responseName = strdup(pfunc->responseName);
+       }
+
+       if (pfunc->binding) {
+               sdlBindingPtr *tmp;
+
+               if (zend_hash_find(ptr_map, (char*)&pfunc->binding, sizeof(pfunc->binding), (void**)&tmp) == FAILURE) {
+                       assert(0);
+               }
+               pfunc->binding = *tmp;
+               
+               if (pfunc->binding->bindingType == BINDING_SOAP && pfunc->bindingAttributes) {
+                       sdlSoapBindingFunctionPtr soap_binding;
+
+                       soap_binding = malloc(sizeof(sdlSoapBindingFunction));
+                       memset(soap_binding, 0, sizeof(sdlSoapBindingFunction));
+                       *soap_binding = *(sdlSoapBindingFunctionPtr)pfunc->bindingAttributes;
+                       if (soap_binding->soapAction) {
+                               soap_binding->soapAction = strdup(soap_binding->soapAction);
+                       }
+                       make_persistent_sdl_soap_body(&soap_binding->input, ptr_map);
+                       make_persistent_sdl_soap_body(&soap_binding->output, ptr_map);
+                       pfunc->bindingAttributes = soap_binding;
+               }
+
+               if (pfunc->requestParameters) {
+                       pfunc->requestParameters = make_persistent_sdl_parameters(pfunc->requestParameters, ptr_map);
+               }
+               if (pfunc->responseParameters) {
+                       pfunc->responseParameters = make_persistent_sdl_parameters(pfunc->responseParameters, ptr_map);
+               }
+               if (pfunc->faults) {
+                       pfunc->faults = make_persistent_sdl_function_faults(pfunc, pfunc->faults, ptr_map);
+               }
+       }
+
+       return pfunc;
+}
+
+static sdlPtr make_persistent_sdl(sdlPtr sdl TSRMLS_DC)
+{
+       sdlPtr psdl = NULL;
+       HashTable ptr_map;
+       HashTable bp_types, bp_encoders;
+       ulong index;
+       char *key;
+       uint key_len;
+
+       zend_hash_init(&bp_types, 0, NULL, NULL, 0);
+       zend_hash_init(&bp_encoders, 0, NULL, NULL, 0);
+       zend_hash_init(&ptr_map, 0, NULL, NULL, 0);
+
+       psdl = malloc(sizeof(*sdl));
+       memset(psdl, 0, sizeof(*sdl));
+
+       psdl->source = strdup(sdl->source);
+       psdl->target_ns = strdup(sdl->target_ns);
+
+       if (sdl->groups) {
+               sdlTypePtr *tmp;
+               sdlTypePtr ptype;
+
+               psdl->groups = malloc(sizeof(HashTable));
+               zend_hash_init(psdl->groups, zend_hash_num_elements(sdl->groups), NULL, delete_type_persistent, 1);
+
+               zend_hash_internal_pointer_reset(sdl->groups);
+               while (zend_hash_get_current_data(sdl->groups, (void **)&tmp) == SUCCESS) {
+                       ptype = make_persistent_sdl_type(*tmp, &ptr_map, &bp_types, &bp_encoders);
+                       if (zend_hash_get_current_key_ex(sdl->groups, &key, &key_len, &index, 0, NULL) == HASH_KEY_IS_STRING) {
+                               zend_hash_add(psdl->groups, key, key_len, (void*)&ptype, sizeof(sdlTypePtr), NULL);
+                       } else {
+                               zend_hash_next_index_insert(psdl->groups, (void*)&ptype, sizeof(sdlTypePtr), NULL);
+                       }
+                       zend_hash_add(&ptr_map, (char*)tmp, sizeof(*tmp), (void*)&ptype, sizeof(sdlTypePtr), NULL);
+                       zend_hash_move_forward(sdl->groups);
+               }
+       }
+
+       if (sdl->types) {
+               sdlTypePtr *tmp;
+               sdlTypePtr ptype;
+
+               psdl->types = malloc(sizeof(HashTable));
+               zend_hash_init(psdl->types, zend_hash_num_elements(sdl->types), NULL, delete_type_persistent, 1);
+
+               zend_hash_internal_pointer_reset(sdl->types);
+               while (zend_hash_get_current_data(sdl->types, (void **)&tmp) == SUCCESS) {
+                       ptype = make_persistent_sdl_type(*tmp, &ptr_map, &bp_types, &bp_encoders);
+                       if (zend_hash_get_current_key_ex(sdl->types, &key, &key_len, &index, 0, NULL) == HASH_KEY_IS_STRING) {
+                               zend_hash_add(psdl->types, key, key_len, (void*)&ptype, sizeof(sdlTypePtr), NULL);
+                       } else {
+                               zend_hash_next_index_insert(psdl->types, (void*)&ptype, sizeof(sdlTypePtr), NULL);
+                       }
+                       zend_hash_add(&ptr_map, (char*)tmp, sizeof(*tmp), (void*)&ptype, sizeof(sdlTypePtr), NULL);
+                       zend_hash_move_forward(sdl->types);
+               }
+       }
+
+       if (sdl->elements) {
+               sdlTypePtr *tmp;
+               sdlTypePtr ptype;
+
+               psdl->elements = malloc(sizeof(HashTable));
+               zend_hash_init(psdl->elements, zend_hash_num_elements(sdl->elements), NULL, delete_type_persistent, 1);
+
+               zend_hash_internal_pointer_reset(sdl->elements);
+               while (zend_hash_get_current_data(sdl->elements, (void **)&tmp) == SUCCESS) {
+                       ptype = make_persistent_sdl_type(*tmp, &ptr_map, &bp_types, &bp_encoders);
+                       if (zend_hash_get_current_key_ex(sdl->elements, &key, &key_len, &index, 0, NULL) == HASH_KEY_IS_STRING) {
+                               zend_hash_add(psdl->elements, key, key_len, (void*)&ptype, sizeof(sdlTypePtr), NULL);
+                       } else {
+                               zend_hash_next_index_insert(psdl->elements, (void*)&ptype, sizeof(sdlTypePtr), NULL);
+                       }
+                       zend_hash_add(&ptr_map, (char*)tmp, sizeof(*tmp), (void*)&ptype, sizeof(sdlTypePtr), NULL);
+                       zend_hash_move_forward(sdl->elements);
+               }
+       }
+
+       if (sdl->encoders) {
+               encodePtr *tmp;
+               encodePtr penc;
+
+               psdl->encoders = malloc(sizeof(HashTable));
+               zend_hash_init(psdl->encoders, zend_hash_num_elements(sdl->encoders), NULL, delete_encoder_persistent, 1);
+
+               zend_hash_internal_pointer_reset(sdl->encoders);
+               while (zend_hash_get_current_data(sdl->encoders, (void **)&tmp) == SUCCESS) {
+                       penc = make_persistent_sdl_encoder(*tmp, &ptr_map, &bp_types, &bp_encoders);
+                       if (zend_hash_get_current_key_ex(sdl->encoders, &key, &key_len, &index, 0, NULL) == HASH_KEY_IS_STRING) {
+                               zend_hash_add(psdl->encoders, key, key_len, (void*)&penc, sizeof(encodePtr), NULL);
+                       } else {
+                               zend_hash_next_index_insert(psdl->encoders, (void*)&penc, sizeof(encodePtr), NULL);
+                       }
+                       zend_hash_add(&ptr_map, (char*)tmp, sizeof(*tmp), (void*)&penc, sizeof(encodePtr), NULL);
+                       zend_hash_move_forward(sdl->encoders);
+               }
+       }
+
+       /* do backpatching here */
+       if (zend_hash_num_elements(&bp_types)) {
+               sdlTypePtr **tmp, *ptype = NULL;
+
+               zend_hash_internal_pointer_reset(&bp_types);
+               while (zend_hash_get_current_data(&bp_types, (void**)&tmp) == SUCCESS) {
+                       if (zend_hash_find(&ptr_map, (char*)(*tmp), sizeof(**tmp), (void**)&ptype) == FAILURE) {
+                               assert(0);
+                       }
+                       **tmp = *ptype;
+                       zend_hash_move_forward(&bp_types);
+               }
+       }
+       if (zend_hash_num_elements(&bp_encoders)) {
+               encodePtr **tmp, *penc = NULL;
+
+               zend_hash_internal_pointer_reset(&bp_encoders);
+               while (zend_hash_get_current_data(&bp_encoders, (void**)&tmp) == SUCCESS) {
+                       if (zend_hash_find(&ptr_map, (char*)(*tmp), sizeof(**tmp), (void**)&penc) == FAILURE) {
+                               assert(0);
+                       }
+                       **tmp = *penc;
+                       zend_hash_move_forward(&bp_encoders);
+               }
+       }
+
+
+       if (sdl->bindings) {
+               sdlBindingPtr *tmp;
+               sdlBindingPtr pbind;
+
+               psdl->bindings = malloc(sizeof(HashTable));
+               zend_hash_init(psdl->bindings, zend_hash_num_elements(sdl->bindings), NULL, delete_binding_persistent, 1);
+
+               zend_hash_internal_pointer_reset(sdl->bindings);
+               while (zend_hash_get_current_data(sdl->bindings, (void **)&tmp) == SUCCESS) {
+                       pbind = make_persistent_sdl_binding(*tmp, &ptr_map);
+                       if (zend_hash_get_current_key_ex(sdl->bindings, &key, &key_len, &index, 0, NULL) == HASH_KEY_IS_STRING) {
+                               zend_hash_add(psdl->bindings, key, key_len, (void*)&pbind, sizeof(sdlBindingPtr), NULL);
+                       } else {
+                               zend_hash_next_index_insert(psdl->bindings, (void*)&pbind, sizeof(sdlBindingPtr), NULL);
+                       }
+                       zend_hash_add(&ptr_map, (char*)tmp, sizeof(*tmp), (void*)&pbind, sizeof(sdlBindingPtr), NULL);
+                       zend_hash_move_forward(sdl->bindings);
+               }
+       }
+
+       zend_hash_init(&psdl->functions, zend_hash_num_elements(&sdl->functions), NULL, delete_function_persistent, 1);
+       if (zend_hash_num_elements(&sdl->functions)) {
+               sdlFunctionPtr *tmp;
+               sdlFunctionPtr pfunc;
+
+               zend_hash_internal_pointer_reset(&sdl->functions);
+               while (zend_hash_get_current_data(&sdl->functions, (void **)&tmp) == SUCCESS) {
+                       pfunc = make_persistent_sdl_function(*tmp, &ptr_map);
+                       if (zend_hash_get_current_key_ex(&sdl->functions, &key, &key_len, &index, 0, NULL) == HASH_KEY_IS_STRING) {
+                               zend_hash_add(&psdl->functions, key, key_len, (void*)&pfunc, sizeof(sdlFunctionPtr), NULL);
+                       } else {
+                               zend_hash_next_index_insert(&psdl->functions, (void*)&pfunc, sizeof(sdlFunctionPtr), NULL);
+                       }
+                       zend_hash_add(&ptr_map, (char*)tmp, sizeof(*tmp), (void*)&pfunc, sizeof(sdlFunctionPtr), NULL);
+                       zend_hash_move_forward(&sdl->functions);
+               }
+       }
+
+       if (sdl->requests) {
+               sdlFunctionPtr *tmp;
+               sdlFunctionPtr *preq;
+
+               psdl->requests = malloc(sizeof(HashTable));
+               zend_hash_init(psdl->requests, zend_hash_num_elements(sdl->requests), NULL, NULL, 1);
+
+               zend_hash_internal_pointer_reset(sdl->requests);
+               while (zend_hash_get_current_data(sdl->requests, (void **)&tmp) == SUCCESS) {
+                       if (zend_hash_find(&ptr_map, (char*)tmp, sizeof(*tmp), (void**)&preq) == FAILURE) {
+                               assert(0);
+                       }
+                       *tmp = *preq;
+                       if (zend_hash_get_current_key_ex(sdl->requests, &key, &key_len, &index, 0, NULL) == HASH_KEY_IS_STRING) {
+                               zend_hash_add(psdl->requests, key, key_len, (void*)&preq, sizeof(sdlFunctionPtr), NULL);
+                       }
+                       zend_hash_move_forward(sdl->requests);
+               }
+       }
+
+       zend_hash_destroy(&ptr_map);
+       zend_hash_destroy(&bp_encoders);
+       zend_hash_destroy(&bp_types);
+
+       return psdl;
+}
+
+sdlPtr get_sdl(zval *this_ptr, char *uri, zend_bool persistent TSRMLS_DC)
 {
        sdlPtr sdl = NULL;
        char* old_error_code = SOAP_GLOBAL(error_code);
@@ -2330,6 +3090,7 @@ sdlPtr get_sdl(zval *this_ptr, char *uri TSRMLS_DC)
 
        SOAP_GLOBAL(error_code) = "WSDL";
 
+#if 0
        if (SOAP_GLOBAL(cache_enabled) && ((uri_len = strlen(uri)) < MAXPATHLEN)) {
                char  fn[MAXPATHLEN];
 
@@ -2356,10 +3117,10 @@ sdlPtr get_sdl(zval *this_ptr, char *uri TSRMLS_DC)
                        memcpy(key+len,"/wsdl-",sizeof("/wsdl-")-1);
                        memcpy(key+len+sizeof("/wsdl-")-1,md5str,sizeof(md5str));
 
-                       if ((sdl = get_sdl_from_cache(key, fn, t-SOAP_GLOBAL(cache_ttl))) == NULL) {
+                       if ((sdl = get_sdl_from_cache(key, fn, t-SOAP_GLOBAL(cache_ttl) TSRMLS_CC)) == NULL) {
                                sdl = load_wsdl(this_ptr, fn TSRMLS_CC);
                                if (sdl != NULL) {
-                                       add_sdl_to_cache(key, fn, t, sdl);
+                                       add_sdl_to_cache(key, fn, t, sdl TSRMLS_CC);
                                }
                        }
                        efree(key);
@@ -2367,6 +3128,43 @@ sdlPtr get_sdl(zval *this_ptr, char *uri TSRMLS_DC)
        } else {
                sdl = load_wsdl(this_ptr, uri TSRMLS_CC);
        }
+#endif
+
+       if (persistent) {
+               char *hashkey = NULL;
+               int plen;
+               zend_rsrc_list_entry le, *le_ptr;
+
+               plen = spprintf(&hashkey, 0, "SOAP:WSDL:%s", uri);
+               if (SUCCESS == zend_hash_find(&EG(persistent_list), hashkey, plen+1, (void*)&le_ptr)) {
+                       if (Z_TYPE_P(le_ptr) == php_soap_psdl_list_entry()) {
+                               sdl = (sdlPtr)le_ptr->ptr;
+                       }
+               } else {
+                       sdlPtr psdl = NULL;
+                       sdl = load_wsdl(this_ptr, uri TSRMLS_CC);
+                       psdl = make_persistent_sdl(sdl TSRMLS_CC);
+                       psdl->is_persistent = 1;
+                       le.type = php_soap_psdl_list_entry();
+                       le.ptr = psdl;
+                       if (SUCCESS == zend_hash_update(&EG(persistent_list), hashkey,
+                                                                                       plen+1, (void*)&le, sizeof(le), NULL)) {
+                               /* remove non-persitent sdl structure */
+                               delete_sdl_impl(sdl);
+                               /* and replace it with persistent one */
+                               sdl = psdl;
+                       } else {
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to register persistent entry");
+                               /* clean up persistent sdl */
+                               delete_psdl(le_ptr);
+                               /* keep non-persistent sdl and return it */
+                       }
+               }
+               efree(hashkey);
+       } else {
+               sdl = load_wsdl(this_ptr, uri TSRMLS_CC);
+               sdl->is_persistent = 0;
+       }
 
        SOAP_GLOBAL(error_code) = old_error_code;
 
@@ -2379,7 +3177,7 @@ sdlPtr get_sdl(zval *this_ptr, char *uri TSRMLS_DC)
 }
 
 /* Deletes */
-void delete_sdl(void *handle)
+void delete_sdl_impl(void *handle)
 {
        sdlPtr tmp = (sdlPtr)handle;
 
@@ -2417,6 +3215,55 @@ void delete_sdl(void *handle)
        efree(tmp);
 }
 
+void delete_sdl(void *handle)
+{
+       sdlPtr tmp = (sdlPtr)handle;
+
+       if (!tmp->is_persistent) {
+               delete_sdl_impl(tmp);
+       }
+}
+
+ZEND_RSRC_DTOR_FUNC(delete_psdl)
+{
+       if (rsrc->ptr) {
+               sdlPtr tmp = (sdlPtr)rsrc->ptr;
+
+               zend_hash_destroy(&tmp->functions);
+               if (tmp->source) {
+                       free(tmp->source);
+               }
+               if (tmp->target_ns) {
+                       free(tmp->target_ns);
+               }
+               if (tmp->elements) {
+                       zend_hash_destroy(tmp->elements);
+                       free(tmp->elements);
+               }
+               if (tmp->encoders) {
+                       zend_hash_destroy(tmp->encoders);
+                       free(tmp->encoders);
+               }
+               if (tmp->types) {
+                       zend_hash_destroy(tmp->types);
+                       free(tmp->types);
+               }
+               if (tmp->groups) {
+                       zend_hash_destroy(tmp->groups);
+                       free(tmp->groups);
+               }
+               if (tmp->bindings) {
+                       zend_hash_destroy(tmp->bindings);
+                       free(tmp->bindings);
+               }
+               if (tmp->requests) {
+                       zend_hash_destroy(tmp->requests);
+                       free(tmp->requests);
+               }
+               free(tmp);
+       }
+}
+
 static void delete_binding(void *data)
 {
        sdlBindingPtr binding = *((sdlBindingPtr*)data);
@@ -2437,6 +3284,26 @@ static void delete_binding(void *data)
        efree(binding);
 }
 
+static void delete_binding_persistent(void *data)
+{
+       sdlBindingPtr binding = *((sdlBindingPtr*)data);
+
+       if (binding->location) {
+               free(binding->location);
+       }
+       if (binding->name) {
+               free(binding->name);
+       }
+
+       if (binding->bindingType == BINDING_SOAP) {
+               sdlSoapBindingPtr soapBind = binding->bindingAttributes;
+               if (soapBind) {
+                       free(soapBind);
+               }
+       }
+       free(binding);
+}
+
 static void delete_sdl_soap_binding_function_body(sdlSoapBindingFunctionBody body)
 {
        if (body.ns) {
@@ -2448,6 +3315,17 @@ static void delete_sdl_soap_binding_function_body(sdlSoapBindingFunctionBody bod
        }
 }
 
+static void delete_sdl_soap_binding_function_body_persistent(sdlSoapBindingFunctionBody body)
+{
+       if (body.ns) {
+               free(body.ns);
+       }
+       if (body.headers) {
+               zend_hash_destroy(body.headers);
+               free(body.headers);
+       }
+}
+
 static void delete_function(void *data)
 {
        sdlFunctionPtr function = *((sdlFunctionPtr*)data);
@@ -2487,6 +3365,45 @@ static void delete_function(void *data)
        efree(function);
 }
 
+static void delete_function_persistent(void *data)
+{
+       sdlFunctionPtr function = *((sdlFunctionPtr*)data);
+
+       if (function->functionName) {
+               free(function->functionName);
+       }
+       if (function->requestName) {
+               free(function->requestName);
+       }
+       if (function->responseName) {
+               free(function->responseName);
+       }
+       if (function->requestParameters) {
+               zend_hash_destroy(function->requestParameters);
+               free(function->requestParameters);
+       }
+       if (function->responseParameters) {
+               zend_hash_destroy(function->responseParameters);
+               free(function->responseParameters);
+       }
+       if (function->faults) {
+               zend_hash_destroy(function->faults);
+               free(function->faults);
+       }
+
+       if (function->bindingAttributes &&
+           function->binding && function->binding->bindingType == BINDING_SOAP) {
+               sdlSoapBindingFunctionPtr soapFunction = function->bindingAttributes;
+               if (soapFunction->soapAction) {
+                       free(soapFunction->soapAction);
+               }
+               delete_sdl_soap_binding_function_body_persistent(soapFunction->input);
+               delete_sdl_soap_binding_function_body_persistent(soapFunction->output);
+               free(soapFunction);
+       }
+       free(function);
+}
+
 static void delete_parameter(void *data)
 {
        sdlParamPtr param = *((sdlParamPtr*)data);
@@ -2496,6 +3413,15 @@ static void delete_parameter(void *data)
        efree(param);
 }
 
+static void delete_parameter_persistent(void *data)
+{
+       sdlParamPtr param = *((sdlParamPtr*)data);
+       if (param->paramName) {
+               free(param->paramName);
+       }
+       free(param);
+}
+
 static void delete_header(void *data)
 {
        sdlSoapBindingFunctionHeaderPtr hdr = *((sdlSoapBindingFunctionHeaderPtr*)data);
@@ -2512,6 +3438,22 @@ static void delete_header(void *data)
        efree(hdr);
 }
 
+static void delete_header_persistent(void *data)
+{
+       sdlSoapBindingFunctionHeaderPtr hdr = *((sdlSoapBindingFunctionHeaderPtr*)data);
+       if (hdr->name) {
+               free(hdr->name);
+       }
+       if (hdr->ns) {
+               free(hdr->ns);
+       }
+       if (hdr->headerfaults) {
+               zend_hash_destroy(hdr->headerfaults);
+               free(hdr->headerfaults);
+       }
+       free(hdr);
+}
+
 static void delete_fault(void *data)
 {
        sdlFaultPtr fault = *((sdlFaultPtr*)data);
@@ -2533,8 +3475,30 @@ static void delete_fault(void *data)
        efree(fault);
 }
 
+static void delete_fault_persistent(void *data)
+{
+       sdlFaultPtr fault = *((sdlFaultPtr*)data);
+       if (fault->name) {
+               free(fault->name);
+       }
+       if (fault->details) {
+               zend_hash_destroy(fault->details);
+               free(fault->details);
+       }
+       if (fault->bindingAttributes) {
+               sdlSoapBindingFunctionFaultPtr binding = (sdlSoapBindingFunctionFaultPtr)fault->bindingAttributes;
+
+               if (binding->ns) {
+                       free(binding->ns);
+               }
+               free(fault->bindingAttributes);
+       }
+       free(fault);
+}
+
 static void delete_document(void *doc_ptr)
 {
        xmlDocPtr doc = *((xmlDocPtr*)doc_ptr);
        xmlFreeDoc(doc);
 }
+
index 7b135c7f24e71acbb029649d68ede7dff748a498..31a8a8a07305fba51bd42ebe511626147ed2da8a 100644 (file)
@@ -61,6 +61,7 @@ struct _sdl {
        HashTable *groups;           /* array of sdlTypesPtr */
        char      *target_ns;
        char      *source;
+       zend_bool  is_persistent;
 };
 
 typedef struct sdlCtx {
@@ -250,7 +251,10 @@ struct _sdlAttribute {
        encodePtr  encode;
 };
 
-sdlPtr get_sdl(zval *this_ptr, char *uri TSRMLS_DC);
+
+int php_soap_psdl_list_entry(void);
+
+sdlPtr get_sdl(zval *this_ptr, char *uri, zend_bool persistent TSRMLS_DC);
 
 encodePtr get_encoder_from_prefix(sdlPtr sdl, xmlNodePtr data, const char *type);
 encodePtr get_encoder(sdlPtr sdl, const char *ns, const char *type);
@@ -260,5 +264,7 @@ sdlBindingPtr get_binding_from_type(sdlPtr sdl, int type);
 sdlBindingPtr get_binding_from_name(sdlPtr sdl, char *name, char *ns);
 
 void delete_sdl(void *handle);
+void delete_sdl_impl(void *handle);
+ZEND_RSRC_DTOR_FUNC(delete_psdl);
 
 #endif
index ec193c0d83817f9edd52ca30674a892aa9f00d60..a0a7bf6dde7b05bb3772b2811e8ce272cdf4c6e2 100644 (file)
@@ -175,6 +175,7 @@ ZEND_BEGIN_MODULE_GLOBALS(soap)
        xmlCharEncodingHandlerPtr encoding;
        HashTable *class_map;
        int        features;
+       HashTable  wsdl_cache;
 ZEND_END_MODULE_GLOBALS(soap)
 
 #ifdef PHP_WIN32
index 3e73031b47ab165158c83d614fb9eb8821c698a1..0962d8e7856acaca8b251fe6add1bec4aade7870 100644 (file)
@@ -33,6 +33,7 @@
 static int le_sdl = 0;
 int le_url = 0;
 static int le_service = 0;
+static int le_psdl = 0;
 
 typedef struct _soapHeader {
        sdlFunctionPtr                    function;
@@ -226,6 +227,11 @@ static char *zend_str_tolower_copy(char *dest, const char *source, unsigned int
 }
 #endif
 
+int php_soap_psdl_list_entry(void)
+{
+       return le_psdl;
+}
+
 /*
   Registry Functions
   TODO: this!
@@ -492,7 +498,7 @@ PHP_MINIT_FUNCTION(soap)
        /* TODO: add ini entry for always use soap errors */
        php_soap_prepare_globals();
        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 */
@@ -552,6 +558,7 @@ PHP_MINIT_FUNCTION(soap)
        soap_header_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
 
        le_sdl = register_list_destructors(delete_sdl, NULL);
+       le_psdl = zend_register_list_destructors_ex(NULL, delete_psdl, "SOAP persistent WSDL", module_number);
        le_url = register_list_destructors(delete_url, NULL);
        le_service = register_list_destructors(delete_service, NULL);
 
@@ -905,6 +912,7 @@ PHP_METHOD(SoapServer, SoapServer)
        zval *wsdl, *options = NULL;
        int ret;
        int version = SOAP_1_1;
+       zend_bool persistent;
 
        SOAP_SERVER_BEGIN_CODE();
 
@@ -922,6 +930,8 @@ PHP_METHOD(SoapServer, SoapServer)
        service = emalloc(sizeof(soapService));
        memset(service, 0, sizeof(soapService));
 
+       persistent = SOAP_GLOBAL(cache_enabled);
+
        if (options != NULL) {
                HashTable *ht = Z_ARRVAL_P(options);
                zval **tmp;
@@ -972,6 +982,10 @@ PHP_METHOD(SoapServer, SoapServer)
                        service->features = Z_LVAL_PP(tmp);
                }
 
+               if (zend_hash_find(ht, "cache_wsdl", sizeof("cache_wsdl"), (void**)&tmp) == SUCCESS) {
+                       persistent = zend_is_true(*tmp);
+               }
+
        } else if (wsdl == NULL) {
                php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid arguments. 'uri' option is required in nonWSDL mode.");
        }
@@ -983,7 +997,7 @@ PHP_METHOD(SoapServer, SoapServer)
        zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0);
 
        if (wsdl) {
-               service->sdl = get_sdl(this_ptr, Z_STRVAL_P(wsdl) TSRMLS_CC);
+               service->sdl = get_sdl(this_ptr, Z_STRVAL_P(wsdl), persistent TSRMLS_CC);
                if (service->uri == NULL) {
                        if (service->sdl->target_ns) {
                                service->uri = estrdup(service->sdl->target_ns);
@@ -2100,6 +2114,7 @@ PHP_METHOD(SoapClient, SoapClient)
        zval *options = NULL;
        int  soap_version = SOAP_1_1;
        php_stream_context *context = NULL;
+       zend_bool persistent;
 
        SOAP_CLIENT_BEGIN_CODE();
 
@@ -2115,6 +2130,9 @@ PHP_METHOD(SoapClient, SoapClient)
        } else {
                wsdl = NULL;
        }
+
+       persistent = SOAP_GLOBAL(cache_enabled);
+
        if (options != NULL) {
                HashTable *ht = Z_ARRVAL_P(options);
                zval **tmp;
@@ -2262,6 +2280,10 @@ PHP_METHOD(SoapClient, SoapClient)
                        add_property_resource(this_ptr, "_stream_context", context->rsrc_id);
                }
        
+               if (zend_hash_find(ht, "cache_wsdl", sizeof("cache_wsdl"), (void**)&tmp) == SUCCESS) {
+                       persistent = zend_is_true(*tmp);
+               }
+
        } else if (wsdl == NULL) {
                php_error_docref(NULL TSRMLS_CC, E_ERROR, "'location' and 'uri' options are requred in nonWSDL mode");
                return;
@@ -2276,7 +2298,7 @@ PHP_METHOD(SoapClient, SoapClient)
                old_soap_version = SOAP_GLOBAL(soap_version);
                SOAP_GLOBAL(soap_version) = soap_version;
 
-               sdl = get_sdl(this_ptr, Z_STRVAL_P(wsdl) TSRMLS_CC);
+               sdl = get_sdl(this_ptr, Z_STRVAL_P(wsdl), persistent TSRMLS_CC);
                ret = zend_list_insert(sdl, le_sdl);
 
                add_property_resource(this_ptr, "sdl", ret);