]> granicus.if.org Git - php/commitdiff
XML Schema support (decoding of xsi:nil with attributes)
authorDmitry Stogov <dmitry@php.net>
Mon, 26 Jan 2004 09:51:07 +0000 (09:51 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 26 Jan 2004 09:51:07 +0000 (09:51 +0000)
Source Cleanup

ext/soap/TODO
ext/soap/php_encoding.c
ext/soap/php_encoding.h
ext/soap/php_packet_soap.c
ext/soap/php_schema.c
ext/soap/php_sdl.c
ext/soap/php_sdl.h
ext/soap/php_soap.h
ext/soap/soap.c

index 9f83a91a4bce877e912144369c581fdcc4023a85..ab232f1ad2c8220fa7380e0eeb2c738c959e12b9 100644 (file)
@@ -17,6 +17,7 @@ SOAP
 - support for SOAP headers
   - actor attribute
   - mustUnderstend attribute
+- root attribute
 - make sure soap 1.1 and 1.2 are supported fully
 
 Encoding
@@ -57,7 +58,6 @@ Encoding
 - references to external resources
 ? support for "nillable" and "nil"
 - default values
-- root attribute
 ? provide schema 1999/2001 support???
 ? make internal refrences for soap encoding (use seralization logic)???
 ? provide user space overriding of serialization certin objects and types???
@@ -75,7 +75,7 @@ WSDL
 - support for style "rpc"/"document" encoding (server part)
   How to get function name from request? May be SoapAction HTTP header?
 + support for "encoded"/"literal" encoding
-? arrayType and "literal" encoding
++ arrayType and "literal" encoding
 - function/method overloading/redeclaration (test(int); test(string))
 - wsdl caching
 - wsdl auto generation
index 324594f7869cb049ec56f42295c4779ea75e0297..16f3b8ca81cada5cd6eb060dde4f8d1870afa038 100644 (file)
@@ -41,12 +41,50 @@ static xmlNodePtr to_xml_gday(encodeTypePtr type, zval *data, int style);
 static xmlNodePtr to_xml_gmonth(encodeTypePtr type, zval *data, int style);
 static xmlNodePtr to_xml_duration(encodeTypePtr type, zval *data, int style);
 
+static zval *to_zval_object(encodeTypePtr type, xmlNodePtr data);
+static zval *to_zval_array(encodeTypePtr type, xmlNodePtr data);
+
+static xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style);
+static xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style);
+
+/* Try and guess for non-wsdl clients and servers */
+static zval *guess_zval_convert(encodeTypePtr type, xmlNodePtr data);
+static xmlNodePtr guess_xml_convert(encodeTypePtr type, zval *data, int style);
+
 static int is_map(zval *array);
 static void get_array_type(xmlNodePtr node, zval *array, smart_str *out_type TSRMLS_DC);
 
 static void get_type_str(xmlNodePtr node, const char* ns, const char* type, smart_str* ret);
 static void set_ns_and_type_ex(xmlNodePtr node, char *ns, char *type);
 
+static void set_ns_and_type(xmlNodePtr node, encodeTypePtr type);
+
+#define FIND_XML_NULL(xml,zval) \
+       { \
+               xmlAttrPtr null; \
+               if (!xml) { \
+                       ZVAL_NULL(zval); \
+                       return zval; \
+               } \
+               if (xml->properties) { \
+                       null = get_attribute(xml->properties, "nil"); \
+                       if (null) { \
+                               ZVAL_NULL(zval); \
+                               return zval; \
+                       } \
+               } \
+       }
+
+#define FIND_ZVAL_NULL(zval, xml, style) \
+{ \
+       if (!zval || Z_TYPE_P(zval) == IS_NULL) { \
+         if (style == SOAP_ENCODED) {\
+                       xmlSetProp(xml, "xsi:nil", "1"); \
+               }\
+               return xml; \
+       } \
+}
+
 encode defaultEncoding[] = {
        {{UNKNOWN_TYPE, NULL, NULL, NULL}, guess_zval_convert, guess_xml_convert},
 
@@ -653,10 +691,7 @@ static zval *to_zval_null(encodeTypePtr type, xmlNodePtr data)
 
 static xmlNodePtr to_xml_null(encodeTypePtr type, zval *data, int style)
 {
-       xmlNodePtr ret;
-
-       ret = xmlNewNode(NULL, "BOGUS");
-       FIND_ZVAL_NULL(data, ret, style);
+       xmlNodePtr ret = xmlNewNode(NULL, "BOGUS");
 
        if (style == SOAP_ENCODED) {
                xmlSetProp(ret, "xsi:nil", "1");
@@ -727,7 +762,7 @@ static void model_to_zval_object(zval *ret, sdlContentModelPtr model, xmlNodePtr
 }
 
 /* Struct encode/decode */
-zval *to_zval_object(encodeTypePtr type, xmlNodePtr data)
+static zval *to_zval_object(encodeTypePtr type, xmlNodePtr data)
 {
        zval *ret;
        xmlNodePtr trav;
@@ -752,7 +787,6 @@ zval *to_zval_object(encodeTypePtr type, xmlNodePtr data)
                                zval *base;
 
                                MAKE_STD_ZVAL(ret);
-                               FIND_XML_NULL(data, ret);
 
                                object_init(ret);
                                base = master_to_zval(enc, data);
@@ -778,7 +812,6 @@ zval *to_zval_object(encodeTypePtr type, xmlNodePtr data)
                                zval *base;
 
                                MAKE_STD_ZVAL(ret);
-                               FIND_XML_NULL(data, ret);
 
                                object_init(ret);
                                base = master_to_zval(sdlType->encode, data);
@@ -919,7 +952,7 @@ static int model_to_xml_object(xmlNodePtr node, sdlContentModelPtr model, HashTa
        return 1;
 }
 
-xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style)
+static xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style)
 {
        xmlNodePtr xmlParam;
        HashTable *prop;
@@ -1076,9 +1109,9 @@ xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style)
                                xmlAddChild(xmlParam, property);
                                zend_hash_move_forward(prop);
                        }
-                       if (style == SOAP_ENCODED) {
-                               set_ns_and_type(xmlParam, type);
-                       }
+               }
+               if (style == SOAP_ENCODED) {
+                       set_ns_and_type(xmlParam, type);
                }
        }
        return xmlParam;
@@ -1275,7 +1308,7 @@ static inline int array_num_elements(HashTable* ht)
        return 0;
 }
 
-xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style)
+static xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style)
 {
        sdlTypePtr sdl_type = type->sdl_type;
        smart_str array_type = {0}, array_size = {0};
@@ -1474,14 +1507,14 @@ xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style)
 
                add_xml_array_elements(xmlParam, sdl_type, enc, dimension, dims, data, style);
                efree(dims);
-               if (style == SOAP_ENCODED) {
-                       set_ns_and_type(xmlParam, type);
-               }
+       }
+       if (style == SOAP_ENCODED) {
+               set_ns_and_type(xmlParam, type);
        }
        return xmlParam;
 }
 
-zval *to_zval_array(encodeTypePtr type, xmlNodePtr data)
+static zval *to_zval_array(encodeTypePtr type, xmlNodePtr data)
 {
        zval *ret;
        xmlNodePtr trav;
@@ -1728,7 +1761,7 @@ static xmlNodePtr to_xml_map(encodeTypePtr type, zval *data, int style)
        if (Z_TYPE_P(data) == IS_ARRAY) {
                i = zend_hash_num_elements(Z_ARRVAL_P(data));
                /* TODO: Register namespace...??? */
-               xmlSetProp(xmlParam, "xmlns:apache", "http://xml.apache.org/xml-soap");
+//             xmlSetProp(xmlParam, APACHE_NS_PREFIX, APACHE_NAMESPACE);
                zend_hash_internal_pointer_reset(data->value.ht);
                for (;i > 0;i--) {
                        xmlNodePtr xparam, item;
@@ -1771,9 +1804,9 @@ static xmlNodePtr to_xml_map(encodeTypePtr type, zval *data, int style)
                        }
                        zend_hash_move_forward(data->value.ht);
                }
-               if (style == SOAP_ENCODED) {
-                       set_ns_and_type(xmlParam, type);
-               }
+       }
+       if (style == SOAP_ENCODED) {
+               set_ns_and_type(xmlParam, type);
        }
 
        return xmlParam;
@@ -1816,6 +1849,7 @@ static zval *to_zval_map(encodeTypePtr type, xmlNodePtr data)
                        } else {
                                php_error(E_ERROR, "Error encoding apache map, only Strings or Longs are allowd as keys");
                        }
+                       zval_ptr_dtor(&key);
                }
                ENDFOREACH(trav);
        } else {
@@ -1825,7 +1859,7 @@ static zval *to_zval_map(encodeTypePtr type, xmlNodePtr data)
 }
 
 /* Unknown encode/decode */
-xmlNodePtr guess_xml_convert(encodeTypePtr type, zval *data, int style)
+static xmlNodePtr guess_xml_convert(encodeTypePtr type, zval *data, int style)
 {
        encodePtr enc;
        TSRMLS_FETCH();
@@ -1838,7 +1872,7 @@ xmlNodePtr guess_xml_convert(encodeTypePtr type, zval *data, int style)
        return master_to_xml(enc, data, style);
 }
 
-zval *guess_zval_convert(encodeTypePtr type, xmlNodePtr data)
+static zval *guess_zval_convert(encodeTypePtr type, xmlNodePtr data)
 {
        encodePtr enc = NULL;
        xmlAttrPtr tmpattr;
@@ -1941,8 +1975,6 @@ static xmlNodePtr to_xml_datetime_ex(encodeTypePtr type, zval *data, char *forma
                strcpy(buf, Z_STRVAL_P(data));
 
                xmlNodeSetContentLen(xmlParam, buf, Z_STRLEN_P(data));
-       } else {
-               xmlSetProp(xmlParam, "xsi:nil", "1");
        }
 
        if (style == SOAP_ENCODED) {
@@ -1998,7 +2030,185 @@ static xmlNodePtr to_xml_gmonth(encodeTypePtr type, zval *data, int style)
        return to_xml_datetime_ex(type, data, "--%m--", style);
 }
 
-void set_ns_and_type(xmlNodePtr node, encodeTypePtr type)
+static zval* to_zval_list(encodeTypePtr enc, xmlNodePtr data) {
+       /*FIXME*/
+       return to_zval_stringc(enc, data);
+}
+
+static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style) {
+       xmlNodePtr ret;
+
+       ret = xmlNewNode(NULL, "BOGUS");
+       FIND_ZVAL_NULL(data, ret, style);
+       if (Z_TYPE_P(data) == IS_ARRAY) {
+               zval **tmp;
+               smart_str list = {0};
+               HashTable *ht = Z_ARRVAL_P(data);
+
+               zend_hash_internal_pointer_reset(ht);
+               while (zend_hash_get_current_data(ht, (void**)&tmp) == SUCCESS) {
+                       if (list.len != 0) {
+                               smart_str_appendc(&list, ' ');
+                       }
+                       if (Z_TYPE_PP(tmp) == IS_STRING) {
+                               smart_str_appendl(&list, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
+                       } else {
+                               zval copy = **tmp;
+                               zval_copy_ctor(&copy);
+                               convert_to_string(&copy);
+                               smart_str_appendl(&list, Z_STRVAL(copy), Z_STRLEN(copy));
+                               zval_dtor(&copy);
+                       }
+                       zend_hash_move_forward(ht);
+               }
+               smart_str_0(&list);
+               xmlNodeSetContentLen(ret, list.c, list.len);
+               smart_str_free(&list);
+       } else if (Z_TYPE_P(data) == IS_STRING) {
+               xmlNodeSetContentLen(ret, Z_STRVAL_P(data), Z_STRLEN_P(data));
+       } else {
+               zval tmp = *data;
+
+               zval_copy_ctor(&tmp);
+               convert_to_string(&tmp);
+               xmlNodeSetContentLen(ret, Z_STRVAL(tmp), Z_STRLEN(tmp));
+               zval_dtor(&tmp);
+       }
+       return ret;
+}
+
+static zval* to_zval_union(encodeTypePtr enc, xmlNodePtr data) {
+       /*FIXME*/
+       return to_zval_list(enc, data);
+}
+
+static xmlNodePtr to_xml_union(encodeTypePtr enc, zval *data, int style) {
+       /*FIXME*/
+       return to_xml_list(enc,data,style);
+}
+
+zval *sdl_guess_convert_zval(encodeTypePtr enc, xmlNodePtr data)
+{
+       sdlTypePtr type;
+
+       type = enc->sdl_type;
+
+       if (type && type->restrictions &&
+           data &&  data->children && data->children->content) {
+               if (type->restrictions->whiteSpace && type->restrictions->whiteSpace->value) {
+                       if (strcmp(type->restrictions->whiteSpace->value,"replace") == 0) {
+                               whiteSpace_replace(data->children->content);
+                       } else if (strcmp(type->restrictions->whiteSpace->value,"collapse") == 0) {
+                               whiteSpace_collapse(data->children->content);
+                       }
+               }
+               if (type->restrictions->enumeration) {
+                       if (!zend_hash_exists(type->restrictions->enumeration,data->children->content,strlen(data->children->content)+1)) {
+                               php_error(E_WARNING,"Restriction: invalid enumeration value \"%s\"",data->children->content);
+                       }
+               }
+               if (type->restrictions->minLength &&
+                   strlen(data->children->content) < type->restrictions->minLength->value) {
+                 php_error(E_WARNING,"Restriction: length less then 'minLength'");
+               }
+               if (type->restrictions->maxLength &&
+                   strlen(data->children->content) > type->restrictions->maxLength->value) {
+                 php_error(E_WARNING,"Restriction: length greater then 'maxLength'");
+               }
+               if (type->restrictions->length &&
+                   strlen(data->children->content) != type->restrictions->length->value) {
+                 php_error(E_WARNING,"Restriction: length is not equal to 'length'");
+               }
+       }
+       switch (type->kind) {
+               case XSD_TYPEKIND_SIMPLE:
+                       if (type->encode && enc != &type->encode->details) {
+                               return master_to_zval(type->encode, data);
+                       }
+                       break;
+               case XSD_TYPEKIND_LIST:
+                       return to_zval_list(enc, data);
+               case XSD_TYPEKIND_UNION:
+                       return to_zval_union(enc, data);
+               case XSD_TYPEKIND_COMPLEX:
+               case XSD_TYPEKIND_RESTRICTION:
+               case XSD_TYPEKIND_EXTENSION:
+                       if (type->encode &&
+                           (type->encode->details.type == IS_ARRAY ||
+                            type->encode->details.type == SOAP_ENC_ARRAY)) {
+                               return to_zval_array(enc, data);
+                       }
+                       return to_zval_object(enc, data);
+               default:
+                       break;
+       }
+       return guess_zval_convert(enc, data);
+}
+
+xmlNodePtr sdl_guess_convert_xml(encodeTypePtr enc, zval *data, int style)
+{
+       sdlTypePtr type;
+       xmlNodePtr ret = NULL;
+
+       type = enc->sdl_type;
+
+       if (type) {
+               if (type->restrictions && Z_TYPE_P(data) == IS_STRING) {
+                       if (type->restrictions->enumeration) {
+                               if (!zend_hash_exists(type->restrictions->enumeration,Z_STRVAL_P(data),Z_STRLEN_P(data)+1)) {
+                                       php_error(E_WARNING,"Restriction: invalid enumeration value \"%s\".",Z_STRVAL_P(data));
+                               }
+                       }
+                       if (type->restrictions->minLength &&
+                           Z_STRLEN_P(data) < type->restrictions->minLength->value) {
+                       php_error(E_WARNING,"Restriction: length less then 'minLength'");
+                       }
+                       if (type->restrictions->maxLength &&
+                           Z_STRLEN_P(data) > type->restrictions->maxLength->value) {
+                       php_error(E_WARNING,"Restriction: length greater then 'maxLength'");
+                       }
+                       if (type->restrictions->length &&
+                           Z_STRLEN_P(data) != type->restrictions->length->value) {
+                       php_error(E_WARNING,"Restriction: length is not equal to 'length'");
+                       }
+               }
+       }
+       switch(type->kind) {
+               case XSD_TYPEKIND_SIMPLE:
+                       if (type->encode && enc != &type->encode->details) {
+                               ret = master_to_xml(type->encode, data, style);
+                       }
+                       break;
+               case XSD_TYPEKIND_LIST:
+                       ret = to_xml_list(enc, data, style);
+                       break;
+               case XSD_TYPEKIND_UNION:
+                       ret = to_xml_union(enc, data, style);
+                       break;
+               case XSD_TYPEKIND_COMPLEX:
+               case XSD_TYPEKIND_RESTRICTION:
+               case XSD_TYPEKIND_EXTENSION:
+                       if (type->encode &&
+                           (type->encode->details.type == IS_ARRAY ||
+                            type->encode->details.type == SOAP_ENC_ARRAY)) {
+                               ret = to_xml_array(enc, data, style);
+                       } else {
+                               ret = to_xml_object(enc, data, style);
+                       }
+                       break;
+               default:
+                       break;
+       }
+       if (ret == NULL) {
+               ret = guess_xml_convert(enc, data, style);
+       }
+       if (style == SOAP_ENCODED) {
+               set_ns_and_type(ret, enc);
+       }
+       return ret;
+}
+
+static void set_ns_and_type(xmlNodePtr node, encodeTypePtr type)
 {
        set_ns_and_type_ex(node, type->ns, type->type_str);
 }
@@ -2252,6 +2462,40 @@ smart_str *build_soap_action(zval *this_ptr, char *soapaction)
        return tmp;
 }
 
+static void delete_mapping(void *data)
+{
+       soapMappingPtr map = (soapMappingPtr)data;
+
+       if (map->ns) {
+               efree(map->ns);
+       }
+       if (map->ctype) {
+               efree(map->ctype);
+       }
+
+       if (map->type == SOAP_MAP_FUNCTION) {
+               if (map->map_functions.to_xml_before) {
+                       zval_ptr_dtor(&map->map_functions.to_xml_before);
+               }
+               if (map->map_functions.to_xml) {
+                       zval_ptr_dtor(&map->map_functions.to_xml);
+               }
+               if (map->map_functions.to_xml_after) {
+                       zval_ptr_dtor(&map->map_functions.to_xml_after);
+               }
+               if (map->map_functions.to_zval_before) {
+                       zval_ptr_dtor(&map->map_functions.to_zval_before);
+               }
+               if (map->map_functions.to_zval) {
+                       zval_ptr_dtor(&map->map_functions.to_zval);
+               }
+               if (map->map_functions.to_zval_after) {
+                       zval_ptr_dtor(&map->map_functions.to_zval_after);
+               }
+       }
+       efree(map);
+}
+
 void delete_encoder(void *encode)
 {
        encodePtr t = *((encodePtr*)encode);
index 068861fe156cb6ee65958573e0f0fb07cf1bed41..f518ca54870c08e19cfa899352aaa56ec26a6867 100644 (file)
 #define XSD_NMTOKENS_STRING "NMTOKENS"
 
 #define APACHE_NAMESPACE "http://xml.apache.org/xml-soap"
-#define APACHE_NS_PREFIX "apache"
 #define APACHE_MAP 200
 #define APACHE_MAP_STRING "Map"
 
@@ -182,15 +181,8 @@ zval *to_zval_after_user(encodeTypePtr type, zval *data);
 void whiteSpace_replace(char* str);
 void whiteSpace_collapse(char* str);
 
-zval *to_zval_object(encodeTypePtr type, xmlNodePtr data);
-zval *to_zval_array(encodeTypePtr type, xmlNodePtr data);
-
-xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style);
-xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style);
-
-/* Try and guess for non-wsdl clients and servers */
-zval *guess_zval_convert(encodeTypePtr type, xmlNodePtr data);
-xmlNodePtr guess_xml_convert(encodeTypePtr type, zval *data, int style);
+xmlNodePtr sdl_guess_convert_xml(encodeTypePtr enc, zval* data, int style);
+zval *sdl_guess_convert_zval(encodeTypePtr enc, xmlNodePtr data);
 
 #define get_conversion(e) get_conversion_ex(SOAP_GLOBAL(defEncIndex), e)
 #define get_conversion_from_type(n, t) get_conversion_from_type_ex(SOAP_GLOBAL(defEnc), n, t)
@@ -198,7 +190,6 @@ xmlNodePtr guess_xml_convert(encodeTypePtr type, zval *data, int style);
 
 void encode_reset_ns();
 smart_str *encode_new_ns();
-void set_ns_and_type(xmlNodePtr node, encodeTypePtr type);
 
 encodePtr get_conversion_ex(HashTable *encoding, int encode);
 encodePtr get_conversion_from_type_ex(HashTable *encoding, xmlNodePtr node, const char *type);
@@ -208,31 +199,4 @@ void delete_encoder(void *handle);
 
 extern encode defaultEncoding[];
 
-#define FIND_XML_NULL(xml,zval) \
-       { \
-               xmlAttrPtr null; \
-               if (!xml) { \
-                       ZVAL_NULL(zval); \
-                       return zval; \
-               } \
-               if (xml->properties) { \
-                       null = get_attribute(xml->properties, "nil"); \
-                       if (null) { \
-                               ZVAL_NULL(zval); \
-                               return zval; \
-                       } \
-               } \
-       }
-
-#define FIND_ZVAL_NULL(zval, xml, style) \
-{ \
-       if (!zval || Z_TYPE_P(zval) == IS_NULL) { \
-         if (style == SOAP_ENCODED) {\
-                       xmlSetProp(xml, "xsi:nil", "1"); \
-               }\
-               return xml; \
-       } \
-}
-
-
 #endif
index fb37a2b080a316b47e83254e0eac36b126c34653..88dae3c0fb8e6f2fded99cc7c6f48f838d61b13f 100644 (file)
@@ -109,9 +109,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
 
                tmp = get_node(fault->children,"detail");
                if (tmp != NULL) {
-                       encodePtr enc;
-                       enc = get_conversion(UNKNOWN_TYPE);
-                       details = master_to_zval(enc, tmp);
+                       details = master_to_zval(NULL, tmp);
                }
 
                add_soap_fault(this_ptr, faultcode, faultstring, faultactor, details TSRMLS_CC);
@@ -180,7 +178,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
                                        if (param != NULL) {
                                                tmp = master_to_zval(param->encode, val);
                                        } else {
-                                               tmp = master_to_zval(get_conversion(UNKNOWN_TYPE), val);
+                                               tmp = master_to_zval(NULL, val);
                                        }
                                }
                                add_assoc_zval(return_value, param->paramName, tmp);
@@ -199,10 +197,8 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
                                        val = val->next;
                                }
                                if (val != NULL) {
-                                       encodePtr enc;
                                        zval *tmp;
-                                       enc = get_conversion(UNKNOWN_TYPE);
-                                       tmp = master_to_zval(enc, val);
+                                       tmp = master_to_zval(NULL, val);
                                        if (val->name) {
                                                add_assoc_zval(return_value, (char*)val->name, tmp);
                                        } else {
index 192afa658da3feb5a53c1aa6dea4f1d2a3ac9053..041658bcc6c965334404617bf918bf0b0a897ed4 100644 (file)
@@ -25,6 +25,73 @@ static int schema_restriction_var_char(xmlNodePtr val, sdlRestrictionCharPtr *va
 static void schema_type_fixup(sdlPtr sdl, sdlTypePtr type);
 
 static void delete_model(void *handle);
+static void delete_type(void *data);
+static void delete_attribute(void *attribute);
+static void delete_restriction_var_int(void *rvi);
+static void delete_schema_restriction_var_char(void *srvc);
+
+static encodePtr create_encoder(sdlPtr sdl, sdlTypePtr cur_type, const char *ns, const char *type)
+{
+       smart_str nscat = {0};
+       encodePtr enc, *enc_ptr;
+
+       if (sdl->encoders == NULL) {
+               sdl->encoders = malloc(sizeof(HashTable));
+               zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, 1);
+       }
+       smart_str_appends(&nscat, ns);
+       smart_str_appendc(&nscat, ':');
+       smart_str_appends(&nscat, type);
+       smart_str_0(&nscat);
+       if (zend_hash_find(sdl->encoders, nscat.c, nscat.len + 1, (void**)&enc_ptr) == SUCCESS) {
+               enc = *enc_ptr;
+               if (enc->details.ns) {
+                       free(enc->details.ns);
+               }
+               if (enc->details.type_str) {
+                       free(enc->details.type_str);
+               }
+       } else {
+               enc_ptr = NULL;
+               enc = malloc(sizeof(encode));
+       }
+       memset(enc, 0, sizeof(encode));
+
+       enc->details.ns = strdup(ns);
+       enc->details.type_str = strdup(type);
+       enc->details.sdl_type = cur_type;
+       enc->to_xml = sdl_guess_convert_xml;
+       enc->to_zval = sdl_guess_convert_zval;
+
+       if (enc_ptr == NULL) {
+               zend_hash_update(sdl->encoders, nscat.c, nscat.len + 1, &enc, sizeof(encodePtr), NULL);
+       }
+       smart_str_free(&nscat);
+       return enc;
+}
+
+static encodePtr get_create_encoder(sdlPtr sdl, sdlTypePtr cur_type, const char *ns, const char *type)
+{
+       encodePtr enc = NULL;
+       smart_str nscat = {0};
+       TSRMLS_FETCH();
+
+       smart_str_appends(&nscat, ns);
+       smart_str_appendc(&nscat, ':');
+       smart_str_appends(&nscat, type);
+       smart_str_0(&nscat);
+
+       enc = get_conversion_from_href_type(nscat.c);
+       if (enc == NULL) {
+               enc = get_conversion_from_href_type_ex(sdl->encoders, nscat.c, nscat.len);
+       }
+       if (enc == NULL) {
+               enc = create_encoder(sdl, cur_type, ns, type);
+       }
+
+       smart_str_free(&nscat);
+       return enc;
+}
 
 static int is_blank(const char* str)
 {
@@ -718,7 +785,7 @@ static int schema_restriction_complexContent(sdlPtr sdl, xmlAttrPtr tsn, xmlNode
 
 static int schema_restriction_var_int(xmlNodePtr val, sdlRestrictionIntPtr *valptr)
 {
-       xmlAttrPtr fixed, value, id;
+       xmlAttrPtr fixed, value;
 
        if ((*valptr) == NULL) {
                (*valptr) = malloc(sizeof(sdlRestrictionInt));
@@ -733,11 +800,6 @@ static int schema_restriction_var_int(xmlNodePtr val, sdlRestrictionIntPtr *valp
                        (*valptr)->fixed = TRUE;
        }
 
-       id = get_attribute(val->properties, "id");
-       if (id != NULL) {
-               (*valptr)->id = strdup(id->children->content);
-       }
-
        value = get_attribute(val->properties, "value");
        if (value == NULL) {
                php_error(E_ERROR, "Error parsing wsdl (missing restriction value)");
@@ -750,7 +812,7 @@ static int schema_restriction_var_int(xmlNodePtr val, sdlRestrictionIntPtr *valp
 
 static int schema_restriction_var_char(xmlNodePtr val, sdlRestrictionCharPtr *valptr)
 {
-       xmlAttrPtr fixed, value, id;
+       xmlAttrPtr fixed, value;
 
        if ((*valptr) == NULL) {
                (*valptr) = malloc(sizeof(sdlRestrictionChar));
@@ -766,11 +828,6 @@ static int schema_restriction_var_char(xmlNodePtr val, sdlRestrictionCharPtr *va
                }
        }
 
-       id = get_attribute(val->properties, "id");
-       if (id != NULL) {
-               (*valptr)->id = strdup(id->children->content);
-       }
-
        value = get_attribute(val->properties, "value");
        if (value == NULL) {
                php_error(E_ERROR, "Error parsing wsdl (missing restriction value)");
@@ -1527,6 +1584,9 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTyp
        attrs = element->properties;
        attr = get_attribute(attrs, "nillable");
        if (attr) {
+               if (ref != NULL) {
+                       php_error(E_ERROR, "Error parsing schema (element have both 'ref' and 'nillable' attributes)");
+               }
                if (!stricmp(attr->children->content, "true") ||
                        !stricmp(attr->children->content, "1")) {
                        cur_type->nillable = TRUE;
@@ -1537,6 +1597,24 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTyp
                cur_type->nillable = FALSE;
        }
 
+       attr = get_attribute(attrs, "fixed");
+       if (attr) {
+               if (ref != NULL) {
+                       php_error(E_ERROR, "Error parsing schema (element have both 'ref' and 'fixed' attributes)");
+               }
+               cur_type->fixed = strdup(attr->children->content);
+       }
+
+       attr = get_attribute(attrs, "default");
+       if (attr) {
+               if (ref != NULL) {
+                       php_error(E_ERROR, "Error parsing schema (element have both 'ref' and 'fixed' attributes)");
+               } else if (ref != NULL) {
+                       php_error(E_ERROR, "Error parsing schema (element have both 'default' and 'fixed' attributes)");
+               }
+               cur_type->def = strdup(attr->children->content);
+       }
+
        /* type = QName */
        type = get_attribute(attrs, "type");
        if (type) {
@@ -1703,9 +1781,15 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdl
                } else if (attr_is_equal_ex(attr, "fixed", SCHEMA_NAMESPACE)) {
                        newAttr->fixed = strdup(attr->children->content);
                } else if (attr_is_equal_ex(attr, "form", SCHEMA_NAMESPACE)) {
-                       newAttr->form = strdup(attr->children->content);
+                       if (strcmp(attr->children->content,"qualified") == 0) {
+                         newAttr->form = XSD_FORM_QUALIFIED;
+                       } else if (strcmp(attr->children->content,"unqualified") == 0) {
+                         newAttr->form = XSD_FORM_UNQUALIFIED;
+                       } else {
+                         newAttr->form = XSD_FORM_DEFAULT;
+                       }
                } else if (attr_is_equal_ex(attr, "id", SCHEMA_NAMESPACE)) {
-                       newAttr->id = strdup(attr->children->content);
+                       /* skip */
                } else if (attr_is_equal_ex(attr, "name", SCHEMA_NAMESPACE)) {
                        newAttr->name = strdup(attr->children->content);
                } else if (attr_is_equal_ex(attr, "ref", SCHEMA_NAMESPACE)) {
@@ -1713,7 +1797,15 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdl
                } else if (attr_is_equal_ex(attr, "type", SCHEMA_NAMESPACE)) {
                        /* already processed */
                } else if (attr_is_equal_ex(attr, "use", SCHEMA_NAMESPACE)) {
-                       newAttr->use = strdup(attr->children->content);
+                       if (strcmp(attr->children->content,"prohibited") == 0) {
+                         newAttr->use = XSD_USE_PROHIBITED;
+                       } else if (strcmp(attr->children->content,"required") == 0) {
+                         newAttr->use = XSD_USE_REQUIRED;
+                       } else if (strcmp(attr->children->content,"optional") == 0) {
+                         newAttr->use = XSD_USE_OPTIONAL;
+                       } else {
+                         newAttr->use = XSD_USE_DEFAULT;
+                       }
                } else {
                        xmlNsPtr nsPtr = attr_find_ns(attr);
 
@@ -1885,11 +1977,11 @@ static void schema_attribute_fixup(sdlPtr sdl, sdlAttributePtr attr)
                                if ((*tmp)->fixed != NULL && attr->fixed == NULL) {
                                        attr->fixed = strdup((*tmp)->fixed);
                                }
-                               if ((*tmp)->form != NULL && attr->form == NULL) {
-                                       attr->form = strdup((*tmp)->form);
+                               if (attr->form == XSD_FORM_DEFAULT) {
+                                       attr->form = (*tmp)->form;
                                }
-                               if ((*tmp)->use != NULL && attr->use == NULL) {
-                                       attr->use = strdup((*tmp)->use);
+                               if (attr->use == XSD_USE_DEFAULT) {
+                                       attr->use  = (*tmp)->use;
                                }
                                if ((*tmp)->extraAttributes != NULL) {
                                  xmlNodePtr node;
@@ -1929,9 +2021,7 @@ static void schema_attributegroup_fixup(sdlPtr sdl, sdlAttributePtr attr, HashTa
                                                        memcpy(newAttr, *tmp_attr, sizeof(sdlAttribute));
                                                        if (newAttr->def) {newAttr->def = strdup(newAttr->def);}
                                                        if (newAttr->fixed) {newAttr->fixed = strdup(newAttr->fixed);}
-                                                       if (newAttr->form) {newAttr->form = strdup(newAttr->form);}
                                                        if (newAttr->name) {newAttr->name = strdup(newAttr->name);}
-                                                       if (newAttr->use) {newAttr->use = strdup(newAttr->use);}
                                                        if (newAttr->extraAttributes) {
                                                          xmlNodePtr node;
                                                                HashTable *ht = malloc(sizeof(HashTable));
@@ -2120,3 +2210,89 @@ static void delete_model(void *handle)
        }
        free(tmp);
 }
+
+static void delete_type(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->restrictions) {
+               delete_restriction_var_int(&type->restrictions->minExclusive);
+               delete_restriction_var_int(&type->restrictions->minInclusive);
+               delete_restriction_var_int(&type->restrictions->maxExclusive);
+               delete_restriction_var_int(&type->restrictions->maxInclusive);
+               delete_restriction_var_int(&type->restrictions->totalDigits);
+               delete_restriction_var_int(&type->restrictions->fractionDigits);
+               delete_restriction_var_int(&type->restrictions->length);
+               delete_restriction_var_int(&type->restrictions->minLength);
+               delete_restriction_var_int(&type->restrictions->maxLength);
+               delete_schema_restriction_var_char(&type->restrictions->whiteSpace);
+               delete_schema_restriction_var_char(&type->restrictions->pattern);
+               if (type->restrictions->enumeration) {
+                       zend_hash_destroy(type->restrictions->enumeration);
+                       free(type->restrictions->enumeration);
+               }
+               free(type->restrictions);
+       }
+       free(type);
+}
+
+static void delete_attribute(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->ref) {
+               free(attr->ref);
+       }
+       if (attr->extraAttributes) {
+               zend_hash_destroy(attr->extraAttributes);
+               free(attr->extraAttributes);
+       }
+}
+
+static void delete_restriction_var_int(void *rvi)
+{
+       sdlRestrictionIntPtr ptr = *((sdlRestrictionIntPtr*)rvi);
+       if (ptr) {
+               free(ptr);
+       }
+}
+
+static void delete_schema_restriction_var_char(void *srvc)
+{
+       sdlRestrictionCharPtr ptr = *((sdlRestrictionCharPtr*)srvc);
+       if (ptr) {
+               if (ptr->value) {
+                       free(ptr->value);
+               }
+               free(ptr);
+       }
+}
+
index 30ca6383b52f903d055c29f1a170cba33d2db3fc..bf2d457fa6b985146760c9a2d7b7a1fe78a707cf 100644 (file)
@@ -98,259 +98,6 @@ encodePtr get_encoder_ex(sdlPtr sdl, const char *nscat)
        return enc;
 }
 
-encodePtr get_create_encoder(sdlPtr sdl, sdlTypePtr cur_type, const char *ns, const char *type)
-{
-       encodePtr enc = NULL;
-       smart_str nscat = {0};
-       TSRMLS_FETCH();
-
-       smart_str_appends(&nscat, ns);
-       smart_str_appendc(&nscat, ':');
-       smart_str_appends(&nscat, type);
-       smart_str_0(&nscat);
-
-       enc = get_conversion_from_href_type(nscat.c);
-       if (enc == NULL) {
-               enc = get_conversion_from_href_type_ex(sdl->encoders, nscat.c, nscat.len);
-       }
-       if (enc == NULL) {
-               enc = create_encoder(sdl, cur_type, ns, type);
-       }
-
-       smart_str_free(&nscat);
-       return enc;
-}
-
-encodePtr create_encoder(sdlPtr sdl, sdlTypePtr cur_type, const char *ns, const char *type)
-{
-       smart_str nscat = {0};
-       encodePtr enc, *enc_ptr;
-
-       if (sdl->encoders == NULL) {
-               sdl->encoders = malloc(sizeof(HashTable));
-               zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, 1);
-       }
-       smart_str_appends(&nscat, ns);
-       smart_str_appendc(&nscat, ':');
-       smart_str_appends(&nscat, type);
-       smart_str_0(&nscat);
-       if (zend_hash_find(sdl->encoders, nscat.c, nscat.len + 1, (void**)&enc_ptr) == SUCCESS) {
-               enc = *enc_ptr;
-               if (enc->details.ns) {
-                       free(enc->details.ns);
-               }
-               if (enc->details.type_str) {
-                       free(enc->details.type_str);
-               }
-       } else {
-               enc_ptr = NULL;
-               enc = malloc(sizeof(encode));
-       }
-       memset(enc, 0, sizeof(encode));
-
-       enc->details.ns = strdup(ns);
-       enc->details.type_str = strdup(type);
-       enc->details.sdl_type = cur_type;
-       enc->to_xml = sdl_guess_convert_xml;
-       enc->to_zval = sdl_guess_convert_zval;
-
-       if (enc_ptr == NULL) {
-               zend_hash_update(sdl->encoders, nscat.c, nscat.len + 1, &enc, sizeof(encodePtr), NULL);
-       }
-       smart_str_free(&nscat);
-       return enc;
-}
-
-static zval* to_zval_list(encodeTypePtr enc, xmlNodePtr data) {
-       zval *ret;
-       MAKE_STD_ZVAL(ret);
-       FIND_XML_NULL(data, ret);
-       if (data && data->children) {
-               if (data->children->type == XML_TEXT_NODE && data->children->next == NULL) {
-                       whiteSpace_collapse(data->children->content);
-                       ZVAL_STRING(ret, data->children->content, 1);
-               } else {
-                       php_error(E_ERROR,"Violation of encoding rules");
-               }
-       } else {
-               ZVAL_EMPTY_STRING(ret);
-       }
-       return ret;
-}
-
-static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style) {
-       xmlNodePtr ret;
-
-       ret = xmlNewNode(NULL, "BOGUS");
-       FIND_ZVAL_NULL(data, ret, style);
-       if (Z_TYPE_P(data) == IS_ARRAY) {
-               zval **tmp;
-               smart_str list = {0};
-               HashTable *ht = Z_ARRVAL_P(data);
-
-               zend_hash_internal_pointer_reset(ht);
-               while (zend_hash_get_current_data(ht, (void**)&tmp) == SUCCESS) {
-                       if (list.len != 0) {
-                               smart_str_appendc(&list, ' ');
-                       }
-                       if (Z_TYPE_PP(tmp) == IS_STRING) {
-                               smart_str_appendl(&list, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
-                       } else {
-                               zval copy = **tmp;
-                               zval_copy_ctor(&copy);
-                               convert_to_string(&copy);
-                               smart_str_appendl(&list, Z_STRVAL(copy), Z_STRLEN(copy));
-                               zval_dtor(&copy);
-                       }
-                       zend_hash_move_forward(ht);
-               }
-               smart_str_0(&list);
-               xmlNodeSetContentLen(ret, list.c, list.len);
-               smart_str_free(&list);
-       } else if (Z_TYPE_P(data) == IS_STRING) {
-               xmlNodeSetContentLen(ret, Z_STRVAL_P(data), Z_STRLEN_P(data));
-       } else {
-               zval tmp = *data;
-
-               zval_copy_ctor(&tmp);
-               convert_to_string(&tmp);
-               xmlNodeSetContentLen(ret, Z_STRVAL(tmp), Z_STRLEN(tmp));
-               zval_dtor(&tmp);
-       }
-       return ret;
-}
-
-static zval* to_zval_union(encodeTypePtr enc, xmlNodePtr data) {
-       /*FIXME*/
-       return to_zval_list(enc, data);
-}
-
-static xmlNodePtr to_xml_union(encodeTypePtr enc, zval *data, int style) {
-       /*FIXME*/
-       return to_xml_list(enc,data,style);
-}
-
-zval *sdl_guess_convert_zval(encodeTypePtr enc, xmlNodePtr data)
-{
-       sdlTypePtr type;
-
-       type = enc->sdl_type;
-
-       if (type && type->restrictions &&
-           data &&  data->children && data->children->content) {
-               if (type->restrictions->whiteSpace && type->restrictions->whiteSpace->value) {
-                       if (strcmp(type->restrictions->whiteSpace->value,"replace") == 0) {
-                               whiteSpace_replace(data->children->content);
-                       } else if (strcmp(type->restrictions->whiteSpace->value,"collapse") == 0) {
-                               whiteSpace_collapse(data->children->content);
-                       }
-               }
-               if (type->restrictions->enumeration) {
-                       if (!zend_hash_exists(type->restrictions->enumeration,data->children->content,strlen(data->children->content)+1)) {
-                               php_error(E_WARNING,"Restriction: invalid enumeration value \"%s\"",data->children->content);
-                       }
-               }
-               if (type->restrictions->minLength &&
-                   strlen(data->children->content) < type->restrictions->minLength->value) {
-                 php_error(E_WARNING,"Restriction: length less then 'minLength'");
-               }
-               if (type->restrictions->maxLength &&
-                   strlen(data->children->content) > type->restrictions->maxLength->value) {
-                 php_error(E_WARNING,"Restriction: length greater then 'maxLength'");
-               }
-               if (type->restrictions->length &&
-                   strlen(data->children->content) != type->restrictions->length->value) {
-                 php_error(E_WARNING,"Restriction: length is not equal to 'length'");
-               }
-       }
-       switch (type->kind) {
-               case XSD_TYPEKIND_SIMPLE:
-                       if (type->encode && enc != &type->encode->details) {
-                               return master_to_zval(type->encode, data);
-                       }
-                       break;
-               case XSD_TYPEKIND_LIST:
-                       return to_zval_list(enc, data);
-               case XSD_TYPEKIND_UNION:
-                       return to_zval_union(enc, data);
-               case XSD_TYPEKIND_COMPLEX:
-               case XSD_TYPEKIND_RESTRICTION:
-               case XSD_TYPEKIND_EXTENSION:
-                       if (type->encode &&
-                           (type->encode->details.type == IS_ARRAY ||
-                            type->encode->details.type == SOAP_ENC_ARRAY)) {
-                               return to_zval_array(enc, data);
-                       }
-                       return to_zval_object(enc, data);
-               default:
-                       break;
-       }
-       return guess_zval_convert(enc, data);
-}
-
-xmlNodePtr sdl_guess_convert_xml(encodeTypePtr enc, zval *data, int style)
-{
-       sdlTypePtr type;
-       xmlNodePtr ret = NULL;
-
-       type = enc->sdl_type;
-
-       if (type) {
-               if (type->restrictions && Z_TYPE_P(data) == IS_STRING) {
-                       if (type->restrictions->enumeration) {
-                               if (!zend_hash_exists(type->restrictions->enumeration,Z_STRVAL_P(data),Z_STRLEN_P(data)+1)) {
-                                       php_error(E_WARNING,"Restriction: invalid enumeration value \"%s\".",Z_STRVAL_P(data));
-                               }
-                       }
-                       if (type->restrictions->minLength &&
-                           Z_STRLEN_P(data) < type->restrictions->minLength->value) {
-                       php_error(E_WARNING,"Restriction: length less then 'minLength'");
-                       }
-                       if (type->restrictions->maxLength &&
-                           Z_STRLEN_P(data) > type->restrictions->maxLength->value) {
-                       php_error(E_WARNING,"Restriction: length greater then 'maxLength'");
-                       }
-                       if (type->restrictions->length &&
-                           Z_STRLEN_P(data) != type->restrictions->length->value) {
-                       php_error(E_WARNING,"Restriction: length is not equal to 'length'");
-                       }
-               }
-       }
-       switch(type->kind) {
-               case XSD_TYPEKIND_SIMPLE:
-                       if (type->encode && enc != &type->encode->details) {
-                               ret = master_to_xml(type->encode, data, style);
-                       }
-                       break;
-               case XSD_TYPEKIND_LIST:
-                       ret = to_xml_list(enc, data, style);
-                       break;
-               case XSD_TYPEKIND_UNION:
-                       ret = to_xml_union(enc, data, style);
-                       break;
-               case XSD_TYPEKIND_COMPLEX:
-               case XSD_TYPEKIND_RESTRICTION:
-               case XSD_TYPEKIND_EXTENSION:
-                       if (type->encode &&
-                           (type->encode->details.type == IS_ARRAY ||
-                            type->encode->details.type == SOAP_ENC_ARRAY)) {
-                               ret = to_xml_array(enc, data, style);
-                       } else {
-                               ret = to_xml_object(enc, data, style);
-                       }
-                       break;
-               default:
-                       break;
-       }
-       if (ret == NULL) {
-               ret = guess_xml_convert(enc, data, style);
-       }
-       if (style == SOAP_ENCODED) {
-               set_ns_and_type(ret, enc);
-       }
-       return ret;
-}
-
 sdlBindingPtr get_binding_from_type(sdlPtr sdl, int type)
 {
        sdlBindingPtr *binding;
@@ -1087,134 +834,6 @@ static void delete_paramater(void *data)
        free(param);
 }
 
-void delete_mapping(void *data)
-{
-       soapMappingPtr map = (soapMappingPtr)data;
-
-       if (map->ns) {
-               efree(map->ns);
-       }
-       if (map->ctype) {
-               efree(map->ctype);
-       }
-
-       if (map->type == SOAP_MAP_FUNCTION) {
-               if (map->map_functions.to_xml_before) {
-                       zval_ptr_dtor(&map->map_functions.to_xml_before);
-               }
-               if (map->map_functions.to_xml) {
-                       zval_ptr_dtor(&map->map_functions.to_xml);
-               }
-               if (map->map_functions.to_xml_after) {
-                       zval_ptr_dtor(&map->map_functions.to_xml_after);
-               }
-               if (map->map_functions.to_zval_before) {
-                       zval_ptr_dtor(&map->map_functions.to_zval_before);
-               }
-               if (map->map_functions.to_zval) {
-                       zval_ptr_dtor(&map->map_functions.to_zval);
-               }
-               if (map->map_functions.to_zval_after) {
-                       zval_ptr_dtor(&map->map_functions.to_zval_after);
-               }
-       }
-       efree(map);
-}
-
-void delete_type(void *data)
-{
-       sdlTypePtr type = *((sdlTypePtr*)data);
-       if (type->name) {
-               free(type->name);
-       }
-       if (type->namens) {
-               free(type->namens);
-       }
-       if (type->elements) {
-               zend_hash_destroy(type->elements);
-               free(type->elements);
-       }
-       if (type->attributes) {
-               zend_hash_destroy(type->attributes);
-               free(type->attributes);
-       }
-       if (type->restrictions) {
-               delete_restriction_var_int(&type->restrictions->minExclusive);
-               delete_restriction_var_int(&type->restrictions->minInclusive);
-               delete_restriction_var_int(&type->restrictions->maxExclusive);
-               delete_restriction_var_int(&type->restrictions->maxInclusive);
-               delete_restriction_var_int(&type->restrictions->totalDigits);
-               delete_restriction_var_int(&type->restrictions->fractionDigits);
-               delete_restriction_var_int(&type->restrictions->length);
-               delete_restriction_var_int(&type->restrictions->minLength);
-               delete_restriction_var_int(&type->restrictions->maxLength);
-               delete_schema_restriction_var_char(&type->restrictions->whiteSpace);
-               delete_schema_restriction_var_char(&type->restrictions->pattern);
-               if (type->restrictions->enumeration) {
-                       zend_hash_destroy(type->restrictions->enumeration);
-                       free(type->restrictions->enumeration);
-               }
-               free(type->restrictions);
-       }
-       free(type);
-}
-
-void delete_attribute(void *attribute)
-{
-       sdlAttributePtr attr = *((sdlAttributePtr*)attribute);
-
-       if (attr->def) {
-               free(attr->def);
-       }
-       if (attr->fixed) {
-               free(attr->fixed);
-       }
-       if (attr->form) {
-               free(attr->form);
-       }
-       if (attr->id) {
-               free(attr->id);
-       }
-       if (attr->name) {
-               free(attr->name);
-       }
-       if (attr->ref) {
-               free(attr->ref);
-       }
-       if (attr->use) {
-               free(attr->use);
-       }
-       if (attr->extraAttributes) {
-               zend_hash_destroy(attr->extraAttributes);
-               free(attr->extraAttributes);
-       }
-}
-
-void delete_restriction_var_int(void *rvi)
-{
-       sdlRestrictionIntPtr ptr = *((sdlRestrictionIntPtr*)rvi);
-       if (ptr) {
-               if (ptr->id) {
-                       free(ptr->id);
-               }
-               free(ptr);
-       }
-}
-
-void delete_schema_restriction_var_char(void *srvc)
-{
-       sdlRestrictionCharPtr ptr = *((sdlRestrictionCharPtr*)srvc);
-       if (ptr) {
-               if (ptr->id) {
-                       free(ptr->id);
-               }
-               if (ptr->value) {
-                       free(ptr->value);
-               }
-               free(ptr);
-       }
-}
-
 static void delete_document(void *doc_ptr)
 {
        xmlDocPtr doc = *((xmlDocPtr*)doc_ptr);
index 796d25f1cb1281d8ef8cd99907763d62c0ed1f6e..66b422264ad76d0523edadc3bb170d4397ec19c4 100644 (file)
@@ -15,8 +15,8 @@
 #define SOAP_LITERAL 2
 
 struct _sdl {
-       HashTable docs;              /* pointer to the parsed xml file */
-       HashTable functions;         /* array of sdlFunction */
+       HashTable  docs;             /* pointer to the parsed xml file */
+       HashTable  functions;        /* array of sdlFunction */
        HashTable *types;            /* array of sdlTypesPtr */
        HashTable *elements;         /* array of sdlTypesPtr */
        HashTable *encoders;         /* array of encodePtr */
@@ -25,33 +25,33 @@ struct _sdl {
        HashTable *attributes;       /* array of sdlAttributePtr */
        HashTable *attributeGroups;  /* array of sdlTypesPtr */
        HashTable *groups;           /* array of sdlTypesPtr */
-       char *target_ns;
-       char *source;
+       char      *target_ns;
+       char      *source;
 };
 
 struct _sdlBinding {
        char *name;
        char *location;
-       int bindingType;
+       int   bindingType;
        void *bindingAttributes; /* sdlSoapBindingPtr */
 };
 
 /* Soap Binding Specfic stuff */
 struct _sdlSoapBinding {
        char *transport;
-       int style;
+       int   style;
 };
 
 struct _sdlSoapBindingFunctionBody {
        char *ns;
-       int use;
+       int   use;
        char *parts;         /* not implemented yet */
        char *encodingStyle; /* not implemented yet */
 };
 
 struct _sdlSoapBindingFunction {
        char *soapAction;
-       int style;
+       int   style;
 
        sdlSoapBindingFunctionBody input;
        sdlSoapBindingFunctionBody output;
@@ -59,15 +59,13 @@ struct _sdlSoapBindingFunction {
 };
 
 struct _sdlRestrictionInt {
-       int value;
-       char fixed;
-       char *id;
+       int   value;
+       char  fixed;
 };
 
 struct _sdlRestrictionChar {
        char *value;
-       char fixed;
-       char *id;
+       char  fixed;
 };
 
 struct _sdlRestrictions {
@@ -119,44 +117,59 @@ typedef enum _sdlTypeKind {
 } sdlTypeKind;
 
 struct _sdlType {
-       sdlTypeKind kind;
-       char *name;
-       char *namens;
-       int nillable;
-       HashTable *elements;             /* array of sdlTypePtr */
-       HashTable *attributes;           /* array of sdlAttributePtr */
-       sdlRestrictionsPtr restrictions;
-       encodePtr encode;
-       char *ref;
-       sdlContentModelPtr model;
+       sdlTypeKind         kind;
+       char               *name;
+       char               *namens;
+       int                 nillable;
+       HashTable          *elements;             /* array of sdlTypePtr */
+       HashTable          *attributes;           /* array of sdlAttributePtr */
+       sdlRestrictionsPtr  restrictions;
+       encodePtr           encode;
+       sdlContentModelPtr  model;
+       char               *def;
+       char               *fixed;
+       char               *ref;
 };
 
 struct _sdlParam {
-       int order;
-       encodePtr encode;
-       char *paramName;
+       int        order;
+       encodePtr  encode;
+       char      *paramName;
 };
 
 struct _sdlFunction {
-       char *functionName;
-       char *requestName;
-       char *responseName;
-       HashTable *requestParameters;  /* array of sdlParamPtr */
-       HashTable *responseParameters; /* array of sdlParamPtr (this should only be one) */
-       struct _sdlBindingbinding;
-       void* bindingAttributes;       /* sdlSoapBindingFunctionPtr */
+       char               *functionName;
+       char               *requestName;
+       char               *responseName;
+       HashTable          *requestParameters;  /* array of sdlParamPtr */
+       HashTable          *responseParameters; /* array of sdlParamPtr (this should only be one) */
+       struct _sdlBinding *binding;
+       void               *bindingAttributes;  /* sdlSoapBindingFunctionPtr */
 };
 
+typedef enum _sdlUse {
+       XSD_USE_DEFAULT,
+       XSD_USE_OPTIONAL,
+       XSD_USE_PROHIBITED,
+       XSD_USE_REQUIRED
+} sdlUse;
+
+typedef enum _sdlForm {
+       XSD_FORM_DEFAULT,
+       XSD_FORM_QUALIFIED,
+       XSD_FORM_UNQUALIFIED
+} sdlForm;
+
+
 struct _sdlAttribute {
-       char *def;
-       char *fixed;
-       char *form;
-       char *id;
-       char *name;
-       char *ref;
-       char *use;
+       char      *name;
+       char      *ref;
+       char      *def;
+       char      *fixed;
+       sdlForm    form;
+       sdlUse     use;
        HashTable *extraAttributes;                     /* array of xmlNodePtr */
-       encodePtr encode;
+       encodePtr  encode;
 };
 
 sdlPtr get_sdl(char *uri);
@@ -164,20 +177,10 @@ sdlPtr get_sdl(char *uri);
 encodePtr get_encoder_from_prefix(sdlPtr sdl, xmlNodePtr data, const char *type);
 encodePtr get_encoder(sdlPtr sdl, const char *ns, const char *type);
 encodePtr get_encoder_ex(sdlPtr sdl, const char *nscat);
-encodePtr get_create_encoder(sdlPtr sdl, sdlTypePtr cur_type, const char *ns, const char *type);
-encodePtr create_encoder(sdlPtr sdl, sdlTypePtr cur_type, const char *ns, const char *type);
 
 sdlBindingPtr get_binding_from_type(sdlPtr sdl, int type);
 sdlBindingPtr get_binding_from_name(sdlPtr sdl, char *name, char *ns);
 
-xmlNodePtr sdl_guess_convert_xml(encodeTypePtr enc, zval* data, int style);
-zval *sdl_guess_convert_zval(encodeTypePtr enc, xmlNodePtr data);
-
 void delete_sdl(void *handle);
-void delete_type(void *type);
-void delete_attribute(void *attribute);
-void delete_mapping(void *data);
-void delete_restriction_var_int(void *rvi);
-void delete_schema_restriction_var_char(void *srvc);
 
 #endif
index 821da970eb2c7a24f745289fa69eaf87af564148..2d79745e154e2c2eb54ff2dbe8a93fb435dbedc7 100644 (file)
@@ -125,12 +125,11 @@ ZEND_BEGIN_MODULE_GLOBALS(soap)
        HashTable *defEnc;
        HashTable *defEncIndex;
        HashTable *sdls;
-       HashTable *services;
        HashTable *overrides;
-       int cur_uniq_ns;
-       int soap_version;
-       sdlPtr sdl;
-       zend_bool use_soap_error_handler;
+       int        cur_uniq_ns;
+       int        soap_version;
+       sdlPtr     sdl;
+       zend_bool  use_soap_error_handler;
 ZEND_END_MODULE_GLOBALS(soap)
 
 #ifdef PHP_WIN32
index f69c131b776d1d9d2fbd696a33caac3a7681b341..5db2e984579323c2f1261e7291b41c3eeba814bc 100644 (file)
@@ -245,9 +245,6 @@ static void php_soap_init_globals(zend_soap_globals *soap_globals)
        soap_globals->sdls = malloc(sizeof(HashTable));
        zend_hash_init(soap_globals->sdls, 0, NULL, delete_sdl, 1);
 
-       soap_globals->services = malloc(sizeof(HashTable));
-       zend_hash_init(soap_globals->services, 0, NULL, delete_service, 1);
-
        soap_globals->defEnc = malloc(sizeof(HashTable));
        zend_hash_init(soap_globals->defEnc, 0, NULL, NULL, 1);
 
@@ -288,13 +285,11 @@ static void php_soap_init_globals(zend_soap_globals *soap_globals)
        /* hash by namespace */
        zend_hash_add(soap_globals->defEncNs, XSD_1999_NAMESPACE, sizeof(XSD_1999_NAMESPACE), XSD_NS_PREFIX, sizeof(XSD_NS_PREFIX), NULL);
        zend_hash_add(soap_globals->defEncNs, XSD_NAMESPACE, sizeof(XSD_NAMESPACE), XSD_NS_PREFIX, sizeof(XSD_NS_PREFIX), NULL);
-       zend_hash_add(soap_globals->defEncNs, APACHE_NAMESPACE, sizeof(APACHE_NAMESPACE), APACHE_NS_PREFIX, sizeof(APACHE_NS_PREFIX), NULL);
        zend_hash_add(soap_globals->defEncNs, SOAP_1_1_ENC_NAMESPACE, sizeof(SOAP_1_1_ENC_NAMESPACE), SOAP_1_1_ENC_NS_PREFIX, sizeof(SOAP_1_1_ENC_NS_PREFIX), NULL);
        zend_hash_add(soap_globals->defEncNs, SOAP_1_2_ENC_NAMESPACE, sizeof(SOAP_1_2_ENC_NAMESPACE), SOAP_1_2_ENC_NS_PREFIX, sizeof(SOAP_1_2_ENC_NS_PREFIX), NULL);
 
        /* and by prefix */
        zend_hash_add(soap_globals->defEncPrefix, XSD_NS_PREFIX, sizeof(XSD_NS_PREFIX), XSD_NAMESPACE, sizeof(XSD_NAMESPACE), NULL);
-       zend_hash_add(soap_globals->defEncPrefix, APACHE_NS_PREFIX, sizeof(APACHE_NS_PREFIX), APACHE_NAMESPACE, sizeof(APACHE_NAMESPACE), NULL);
        zend_hash_add(soap_globals->defEncPrefix, SOAP_1_1_ENC_NS_PREFIX, sizeof(SOAP_1_1_ENC_NS_PREFIX), SOAP_1_1_ENC_NAMESPACE, sizeof(SOAP_1_1_ENC_NAMESPACE), NULL);
        zend_hash_add(soap_globals->defEncPrefix, SOAP_1_2_ENC_NS_PREFIX, sizeof(SOAP_1_2_ENC_NS_PREFIX), SOAP_1_2_ENC_NAMESPACE, sizeof(SOAP_1_2_ENC_NAMESPACE), NULL);
 
@@ -316,7 +311,6 @@ PHP_MSHUTDOWN_FUNCTION(soap)
 {
        zend_error_cb = old_error_handler;
        zend_hash_destroy(SOAP_GLOBAL(sdls));
-       zend_hash_destroy(SOAP_GLOBAL(services));
        zend_hash_destroy(SOAP_GLOBAL(defEnc));
        zend_hash_destroy(SOAP_GLOBAL(defEncIndex));
        zend_hash_destroy(SOAP_GLOBAL(defEncNs));
@@ -497,7 +491,7 @@ PHP_FUNCTION(soap_encode_to_zval)
        }
 
        node = (xmlNodePtr)Z_LVAL_PP(addr);
-       ret = master_to_zval(get_conversion(UNKNOWN_TYPE), node);
+       ret = master_to_zval(NULL, node);
        *return_value = *ret;
 }
 #endif
@@ -1903,7 +1897,7 @@ static void deseralize_function_call(sdlPtr sdl, xmlDocPtr request, zval *functi
                                                php_error(E_ERROR, "Error cannot find parameter");
                                        }
                                        if (param == NULL) {
-                                               enc = get_conversion(UNKNOWN_TYPE);
+                                               enc = NULL;
                                        } else {
                                                enc = (*param)->encode;
                                        }
@@ -2049,7 +2043,6 @@ static xmlDocPtr seralize_response_call(sdlFunctionPtr function, char *function_
        if (use == SOAP_ENCODED) {
                xmlSetProp(envelope, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
                xmlSetProp(envelope, "xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
-               xmlSetProp(envelope, "xmlns:" APACHE_NS_PREFIX , APACHE_NAMESPACE);
                if (version == SOAP_1_1) {
                        xmlSetProp(envelope, "xmlns:"SOAP_1_1_ENC_NS_PREFIX, SOAP_1_1_ENC_NAMESPACE);
                        xmlSetProp(envelope, SOAP_1_1_ENV_NS_PREFIX":encodingStyle", SOAP_1_1_ENC_NAMESPACE);
@@ -2140,7 +2133,6 @@ static xmlDocPtr seralize_function_call(zval *this_ptr, sdlFunctionPtr function,
        if (use == SOAP_ENCODED) {
                xmlSetProp(envelope, "xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
                xmlSetProp(envelope, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
-               xmlSetProp(envelope, "xmlns:" APACHE_NS_PREFIX , APACHE_NAMESPACE);
                if (version == SOAP_1_1) {
                        xmlSetProp(envelope, "xmlns:"SOAP_1_1_ENC_NS_PREFIX, SOAP_1_1_ENC_NAMESPACE);
                        xmlSetProp(envelope, SOAP_1_1_ENV_NS_PREFIX":encodingStyle", SOAP_1_1_ENC_NAMESPACE);