]> granicus.if.org Git - php/commitdiff
Fixed array type autodetection (use namespace name, but not the namespace prefix
authorDmitry Stogov <dmitry@php.net>
Thu, 9 Jun 2005 08:17:37 +0000 (08:17 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 9 Jun 2005 08:17:37 +0000 (08:17 +0000)
)

ext/soap/php_encoding.c
ext/soap/tests/interop/Round2/Base/r2_base_008p.phpt
ext/soap/tests/interop/Round2/Base/r2_base_008s.phpt

index a0b5f7aa91c32d2349aa242a839bca0d6368b349..813c54b70e50fcdba4a4645729b60039b9aa8e1d 100644 (file)
@@ -81,7 +81,7 @@ static zval *guess_zval_convert(encodeTypePtr type, xmlNodePtr data);
 static xmlNodePtr guess_xml_convert(encodeTypePtr type, zval *data, int style, xmlNodePtr parent);
 
 static int is_map(zval *array);
-static void get_array_type(xmlNodePtr node, zval *array, smart_str *out_type TSRMLS_DC);
+static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *out_type TSRMLS_DC);
 
 static xmlNodePtr check_and_resolve_href(xmlNodePtr data);
 
@@ -1880,8 +1880,7 @@ static xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style, xmlNod
                                enc = elementType->encode;
                                get_type_str(xmlParam, elementType->encode->details.ns, elementType->encode->details.type_str, &array_type);
                        } else {
-                               get_array_type(xmlParam, data, &array_type TSRMLS_CC);
-                               enc = get_encoder_ex(SOAP_GLOBAL(sdl), array_type.c, array_type.len);
+                               enc = get_array_type(xmlParam, data, &array_type TSRMLS_CC);
                        }
                } else if (sdl_type && sdl_type->elements &&
                           zend_hash_num_elements(sdl_type->elements) == 1 &&
@@ -1900,8 +1899,7 @@ static xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style, xmlNod
                        dims[0] = i;
                } else {
 
-                       get_array_type(xmlParam, data, &array_type TSRMLS_CC);
-                       enc = get_encoder_ex(SOAP_GLOBAL(sdl), array_type.c, array_type.len);
+                       enc = get_array_type(xmlParam, data, &array_type TSRMLS_CC);
                        smart_str_append_long(&array_size, i);
                        dims = safe_emalloc(sizeof(int), dimension, 0);
                        dims[0] = i;
@@ -2886,19 +2884,21 @@ static int is_map(zval *array)
        return FALSE;
 }
 
-static void get_array_type(xmlNodePtr node, zval *array, smart_str *type TSRMLS_DC)
+static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type TSRMLS_DC)
 {
-       HashTable *ht = HASH_OF(array);
+       HashTable *ht;
        int i, count, cur_type, prev_type, different;
        zval **tmp;
        char *prev_stype = NULL, *cur_stype = NULL, *prev_ns = NULL, *cur_ns = NULL;
 
        if (!array || Z_TYPE_P(array) != IS_ARRAY) {
                smart_str_appendl(type, "xsd:anyType", 11);
+               return get_conversion(XSD_ANYTYPE);
        }
 
        different = FALSE;
        cur_type = prev_type = 0;
+       ht = HASH_OF(array);
        count = zend_hash_num_elements(ht);
 
        zend_hash_internal_pointer_reset(ht);
@@ -2955,20 +2955,33 @@ static void get_array_type(xmlNodePtr node, zval *array, smart_str *type TSRMLS_
 
        if (different || count == 0) {
                smart_str_appendl(type, "xsd:anyType", 11);
+               return get_conversion(XSD_ANYTYPE);             
        } else {
+               encodePtr enc;
+
                if (cur_stype != NULL) {
+                       smart_str array_type = {0};
+
                        if (cur_ns) {
                                xmlNsPtr ns = encode_add_ns(node,cur_ns);
-                               smart_str_appends(type,ns->prefix);
-                               smart_str_appendc(type,':');
+
+                               smart_str_appends(type, ns->prefix);
+                               smart_str_appendc(type, ':');
+                               smart_str_appends(&array_type, cur_ns);
+                               smart_str_appendc(&array_type, ':');
                        }
-                       smart_str_appends(type,cur_stype);
+                       smart_str_appends(type, cur_stype);
                        smart_str_0(type);
-               } else {
-                       encodePtr enc;
+                       smart_str_appends(&array_type, cur_stype);
+                       smart_str_0(&array_type);
 
+                       enc = get_encoder_ex(SOAP_GLOBAL(sdl), array_type.c, array_type.len);
+                       smart_str_free(&array_type);
+                       return enc;
+               } else {
                        enc = get_conversion(cur_type);
                        get_type_str(node, enc->details.ns, enc->details.type_str, type);
+                       return enc;
                }
        }
 }
index 28eae3dbd749261a51b9240d77419f2a85d3886c..b419a866db53f9664e713afc56dfd5935c36d163 100644 (file)
@@ -13,7 +13,7 @@ echo "ok\n";
 ?>
 --EXPECT--
 <?xml version="1.0" encoding="UTF-8"?>
-<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soapinterop.org/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:echoStringArray><param0 SOAP-ENC:arrayType="xsd:ur-type[0]" xsi:type="SOAP-ENC:Array"/></ns1:echoStringArray></SOAP-ENV:Body></SOAP-ENV:Envelope>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soapinterop.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:echoStringArray><param0 SOAP-ENC:arrayType="xsd:ur-type[0]" xsi:type="SOAP-ENC:Array"/></ns1:echoStringArray></SOAP-ENV:Body></SOAP-ENV:Envelope>
 <?xml version="1.0" encoding="UTF-8"?>
 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soapinterop.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://soapinterop.org/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:echoStringArrayResponse><outputStringArray SOAP-ENC:arrayType="xsd:string[0]" xsi:type="ns2:ArrayOfstring"/></ns1:echoStringArrayResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
 ok
index b23dda44a0317d5ddaf94690f7589b75e93b9423..2ee4b6de9c64f167d8e4602ccf033ee2a8e269c7 100644 (file)
@@ -15,7 +15,7 @@ echo "ok\n";
 ?>
 --EXPECT--
 <?xml version="1.0" encoding="UTF-8"?>
-<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soapinterop.org/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://soapinterop.org/xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:echoStringArray><inputStringArray SOAP-ENC:arrayType="xsd:ur-type[0]" xsi:type="ns2:ArrayOfstring"/></ns1:echoStringArray></SOAP-ENV:Body></SOAP-ENV:Envelope>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soapinterop.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://soapinterop.org/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:echoStringArray><inputStringArray SOAP-ENC:arrayType="xsd:ur-type[0]" xsi:type="ns2:ArrayOfstring"/></ns1:echoStringArray></SOAP-ENV:Body></SOAP-ENV:Envelope>
 <?xml version="1.0" encoding="UTF-8"?>
 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soapinterop.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://soapinterop.org/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:echoStringArrayResponse><outputStringArray SOAP-ENC:arrayType="xsd:string[0]" xsi:type="ns2:ArrayOfstring"/></ns1:echoStringArrayResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
 ok