]> granicus.if.org Git - php/commitdiff
SOAP 1.2 support was improved
authorDmitry Stogov <dmitry@php.net>
Thu, 15 Jan 2004 10:59:24 +0000 (10:59 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 15 Jan 2004 10:59:24 +0000 (10:59 +0000)
ext/soap/TODO
ext/soap/php_encoding.c
ext/soap/php_encoding.h
ext/soap/php_http.c
ext/soap/php_packet_soap.c
ext/soap/soap.c

index c85b1dd1bf65e9a81a1a801c59bd957da8803d8d..f8afb7bcb73d9f604009a9e0d0c538abe1056466 100644 (file)
@@ -56,7 +56,7 @@ Encoding
   + position attribute
   + multidimensional arrays
   + arrays of arrays
-       - SOAP 1.2 array encoding/decoding (itemType, arraySize)
+       + SOAP 1.2 array encoding/decoding (itemType, arraySize)
   - SOAP 1.1 - arrayType="xsd:ur-type[]", SOAP 1.2 - itemType="xsd:anyType"
   - SOAP 1.1 encoding of arrays with holes (partially transmitted and sparse arrays)
          SOAP 1.2 doesn't support partially transmitted and sparse arrays
index f82a4d99b93a325a5707e4111e473778eb387a2d..90acb5fa305d5a0565c19ae8f29ba76ca1e6fc9e 100644 (file)
@@ -50,9 +50,12 @@ encode defaultEncoding[] = {
        {{IS_DOUBLE, XSD_FLOAT_STRING, XSD_NAMESPACE, NULL}, to_zval_double, to_xml_double},
        {{IS_BOOL, XSD_BOOLEAN_STRING, XSD_NAMESPACE, NULL}, to_zval_bool, to_xml_bool},
        {{IS_CONSTANT, XSD_STRING_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_string},
-       {{IS_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_ENC_NAMESPACE, NULL}, to_zval_array, guess_array_map},
-       {{IS_CONSTANT_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_ENC_NAMESPACE, NULL}, to_zval_array, to_xml_array},
-       {{IS_OBJECT, SOAP_ENC_OBJECT_STRING, SOAP_ENC_NAMESPACE, NULL}, to_zval_object, to_xml_object},
+       {{IS_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_1_1_ENC_NAMESPACE, NULL}, to_zval_array, guess_array_map},
+       {{IS_CONSTANT_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_1_1_ENC_NAMESPACE, NULL}, to_zval_array, to_xml_array},
+       {{IS_OBJECT, SOAP_ENC_OBJECT_STRING, SOAP_1_1_ENC_NAMESPACE, NULL}, to_zval_object, to_xml_object},
+       {{IS_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_1_2_ENC_NAMESPACE, NULL}, to_zval_array, guess_array_map},
+       {{IS_CONSTANT_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_1_2_ENC_NAMESPACE, NULL}, to_zval_array, to_xml_array},
+       {{IS_OBJECT, SOAP_ENC_OBJECT_STRING, SOAP_1_2_ENC_NAMESPACE, NULL}, to_zval_object, to_xml_object},
 
        {{XSD_STRING, XSD_STRING_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_string},
        {{XSD_BOOLEAN, XSD_BOOLEAN_STRING, XSD_NAMESPACE, NULL}, to_zval_bool, to_xml_bool},
@@ -106,8 +109,10 @@ encode defaultEncoding[] = {
 
        {{APACHE_MAP, APACHE_MAP_STRING, APACHE_NAMESPACE, NULL}, to_zval_map, to_xml_map},
 
-       {{SOAP_ENC_OBJECT, SOAP_ENC_OBJECT_STRING, SOAP_ENC_NAMESPACE, NULL}, to_zval_object, to_xml_object},
-       {{SOAP_ENC_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_ENC_NAMESPACE, NULL}, to_zval_array, to_xml_array},
+       {{SOAP_ENC_OBJECT, SOAP_ENC_OBJECT_STRING, SOAP_1_1_ENC_NAMESPACE, NULL}, to_zval_object, to_xml_object},
+       {{SOAP_ENC_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_1_1_ENC_NAMESPACE, NULL}, to_zval_array, to_xml_array},
+       {{SOAP_ENC_OBJECT, SOAP_ENC_OBJECT_STRING, SOAP_1_2_ENC_NAMESPACE, NULL}, to_zval_object, to_xml_object},
+       {{SOAP_ENC_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_1_2_ENC_NAMESPACE, NULL}, to_zval_array, to_xml_array},
 
        /* support some of the 1999 data types */
        {{XSD_STRING, XSD_STRING_STRING, XSD_1999_NAMESPACE, NULL}, to_zval_string, to_xml_string},
@@ -776,6 +781,51 @@ static xmlNodePtr guess_array_map(encodeType type, zval *data, int style)
        return master_to_xml(enc, data, style);
 }
 
+static int calc_dimension_12(const char* str)
+{
+       int i = 1, flag = 1;
+       while (*str != '\0' && (*str < '0' || *str > '9')) {
+               str++;
+       }
+       while (*str != '\0') {
+               if (*str >= '0' && *str <= '9') {
+                       if (flag == 0) {
+                       i++;
+                       flag = 1;
+               }
+               } else {
+                 flag = 0;
+               }
+               str++;
+       }
+       return i;
+}
+
+static int* get_position_12(int dimension, const char* str)
+{
+       int *pos;
+       int i = 0, flag = 1;
+
+       pos = emalloc(sizeof(int)*dimension);
+       memset(pos,0,sizeof(int)*dimension);
+       while (*str != '\0' && (*str < '0' || *str > '9')) {
+               str++;
+       }
+       while (*str != '\0') {
+               if (*str >= '0' && *str <= '9') {
+                       if (flag == 0) {
+                       i++;
+                       flag = 1;
+               }
+               pos[i] = (pos[i]*10)+(*str-'0');
+               } else {
+                 flag = 0;
+               }
+               str++;
+       }
+       return pos;
+}
+
 static int calc_dimension(const char* str)
 {
        int i = 1;
@@ -863,15 +913,18 @@ static inline int array_num_elements(HashTable* ht)
 xmlNodePtr to_xml_array(encodeType type, zval *data, int style)
 {
        sdlTypePtr sdl_type = type.sdl_type;
-       smart_str array_type_and_size = {0}, array_type = {0};
+       smart_str array_type = {0}, array_size = {0};
        int i;
        xmlNodePtr xmlParam;
        encodePtr enc = NULL;
        int dimension = 1;
        int* dims;
+       int soap_version;
 
        TSRMLS_FETCH();
 
+       soap_version = SOAP_GLOBAL(soap_version);
+
        xmlParam = xmlNewNode(NULL,"BOGUS");
 
        FIND_ZVAL_NULL(data, xmlParam, style);
@@ -887,8 +940,8 @@ xmlNodePtr to_xml_array(encodeType type, zval *data, int style)
 
                        if (sdl_type &&
                            sdl_type->attributes &&
-                           zend_hash_find(sdl_type->attributes, SOAP_ENC_NAMESPACE":arrayType",
-                             sizeof(SOAP_ENC_NAMESPACE":arrayType"),
+                           zend_hash_find(sdl_type->attributes, SOAP_1_1_ENC_NAMESPACE":arrayType",
+                             sizeof(SOAP_1_1_ENC_NAMESPACE":arrayType"),
                              (void **)&arrayType) == SUCCESS &&
                            zend_hash_find((*arrayType)->extraAttributes, WSDL_NAMESPACE":arrayType", sizeof(WSDL_NAMESPACE":arrayType"), (void **)&arrayTypeAttr) == SUCCESS) {
 
@@ -909,8 +962,8 @@ xmlNodePtr to_xml_array(encodeType type, zval *data, int style)
                                        enc = get_encoder(SOAP_GLOBAL(sdl), myNs->href, value);
 
                                        if (strcmp(myNs->href,XSD_NAMESPACE) == 0) {
-                                               smart_str_appendl(&array_type_and_size, XSD_NS_PREFIX, sizeof(XSD_NS_PREFIX) - 1);
-                                               smart_str_appendc(&array_type_and_size, ':');
+                                               smart_str_appendl(&array_type, XSD_NS_PREFIX, sizeof(XSD_NS_PREFIX) - 1);
+                                               smart_str_appendc(&array_type, ':');
                                        } else {
                                                smart_str *prefix = encode_new_ns();
                                                smart_str smart_ns = {0};
@@ -921,8 +974,8 @@ xmlNodePtr to_xml_array(encodeType type, zval *data, int style)
                                                xmlSetProp(xmlParam, smart_ns.c, myNs->href);
                                                smart_str_free(&smart_ns);
 
-                                               smart_str_appends(&array_type_and_size, prefix->c);
-                                               smart_str_appendc(&array_type_and_size, ':');
+                                               smart_str_appends(&array_type, prefix->c);
+                                               smart_str_appendc(&array_type, ':');
                                                smart_str_free(prefix);
                                                efree(prefix);
                                        }
@@ -942,15 +995,13 @@ xmlNodePtr to_xml_array(encodeType type, zval *data, int style)
                                        }
                                }
 
-                               smart_str_appends(&array_type_and_size, value);
-                               smart_str_appendc(&array_type_and_size, '[');
-                               smart_str_append_long(&array_type_and_size, dims[0]);
+                               smart_str_appends(&array_type, value);
+
+                               smart_str_append_long(&array_size, dims[0]);
                                for (i=1; i<dimension; i++) {
-                                       smart_str_appendc(&array_type_and_size, ',');
-                                       smart_str_append_long(&array_type_and_size, dims[i]);
+                                       smart_str_appendc(&array_size, ',');
+                                       smart_str_append_long(&array_size, dims[i]);
                                }
-                               smart_str_appendc(&array_type_and_size, ']');
-                               smart_str_0(&array_type_and_size);
 
                                efree(value);
                                if (ns) efree(ns);
@@ -963,8 +1014,8 @@ xmlNodePtr to_xml_array(encodeType type, zval *data, int style)
 
                                if (ns) {
                                        if (strcmp(ns,XSD_NAMESPACE) == 0) {
-                                               smart_str_appendl(&array_type_and_size, XSD_NS_PREFIX, sizeof(XSD_NS_PREFIX) - 1);
-                                               smart_str_appendc(&array_type_and_size, ':');
+                                               smart_str_appendl(&array_type, XSD_NS_PREFIX, sizeof(XSD_NS_PREFIX) - 1);
+                                               smart_str_appendc(&array_type, ':');
                                        } else {
                                                smart_str *prefix = encode_new_ns();
                                                smart_str smart_ns = {0};
@@ -975,37 +1026,48 @@ xmlNodePtr to_xml_array(encodeType type, zval *data, int style)
                                                xmlSetProp(xmlParam, smart_ns.c, ns);
                                                smart_str_free(&smart_ns);
 
-                                               smart_str_appends(&array_type_and_size, prefix->c);
-                                               smart_str_appendc(&array_type_and_size, ':');
+                                               smart_str_appends(&array_type, prefix->c);
+                                               smart_str_appendc(&array_type, ':');
                                                smart_str_free(prefix);
                                                efree(prefix);
                                        }
                                }
                                enc = elementType->encode;
-                               smart_str_appends(&array_type_and_size, elementType->encode->details.type_str);
-                               smart_str_free(&array_type);
-                               smart_str_appendc(&array_type_and_size, '[');
-                               smart_str_append_long(&array_type_and_size, i);
-                               smart_str_appendc(&array_type_and_size, ']');
-                               smart_str_0(&array_type_and_size);
+                               smart_str_appends(&array_type, elementType->encode->details.type_str);
+                               smart_str_append_long(&array_size, i);
 
                                dims = emalloc(sizeof(int)*dimension);
                                dims[0] = i;
                        } else {
+
                                get_array_type(data, &array_type TSRMLS_CC);
                                enc = get_encoder_ex(SOAP_GLOBAL(sdl), array_type.c);
-                               smart_str_append(&array_type_and_size, &array_type);
-                               smart_str_appendc(&array_type_and_size, '[');
-                               smart_str_append_long(&array_type_and_size, i);
-                               smart_str_appendc(&array_type_and_size, ']');
-                               smart_str_0(&array_type_and_size);
+                               smart_str_append_long(&array_size, i);
                                dims = emalloc(sizeof(int)*dimension);
                                dims[0] = i;
                        }
-                       xmlSetProp(xmlParam, "SOAP-ENC:arrayType", array_type_and_size.c);
 
-                       smart_str_free(&array_type_and_size);
+                       if (soap_version == SOAP_1_1) {
+                               smart_str_appendc(&array_type, '[');
+                               smart_str_append(&array_type, &array_size);
+                               smart_str_appendc(&array_type, ']');
+                               smart_str_0(&array_type);
+                               xmlSetProp(xmlParam, SOAP_1_1_ENC_NS_PREFIX":arrayType", array_type.c);
+                       } else {
+                               int i = 0;
+                               while (i < array_size.len) {
+                                       if (array_size.c[i] == ',') {array_size.c[i] = ' ';}
+                                       ++i;
+                               }
+                               smart_str_0(&array_type);
+                               smart_str_0(&array_size);
+                               xmlSetProp(xmlParam, SOAP_1_2_ENC_NS_PREFIX":itemType", array_type.c);
+                               xmlSetProp(xmlParam, SOAP_1_2_ENC_NS_PREFIX":arraySize", array_size.c);
+                       }
+
                        smart_str_free(&array_type);
+                       smart_str_free(&array_size);
+
                } else {
                        dims = emalloc(sizeof(int)*dimension);
                        dims[0] = i;
@@ -1016,30 +1078,6 @@ xmlNodePtr to_xml_array(encodeType type, zval *data, int style)
                if (style == SOAP_ENCODED) {
                        set_ns_and_type(xmlParam, type);
                }
-/*
-               zend_hash_internal_pointer_reset(data->value.ht);
-               for (;i > 0;i--) {
-                       xmlNodePtr xparam;
-                       zval **zdata;
-                       encodePtr enc;
-                       zend_hash_get_current_data(data->value.ht, (void **)&zdata);
-
-                       enc = get_conversion((*zdata)->type);
-                       xparam = master_to_xml(enc, (*zdata), style);
-
-                       if (style == SOAP_LITERAL) {
-                               xmlNodeSetName(xparam, enc->details.type_str);
-                       } else {
-                               xmlNodeSetName(xparam, "val");
-                       }
-
-                       xmlAddChild(xmlParam, xparam);
-                       zend_hash_move_forward(data->value.ht);
-               }
-               if (style == SOAP_ENCODED) {
-                       set_ns_and_type(xmlParam, type);
-               }
-*/
        }
        return xmlParam;
 }
@@ -1052,9 +1090,7 @@ zval *to_zval_array(encodeType type, xmlNodePtr data)
        int dimension = 1;
        int* dims = NULL;
        int* pos = NULL;
-       xmlAttrPtr arrayTypeAttr;
-       xmlAttrPtr offsetAttr;
-       xmlAttrPtr *tmp;
+       xmlAttrPtr attr, *tmp;
        sdlPtr sdl;
        sdlAttributePtr *arrayType;
 
@@ -1065,14 +1101,13 @@ zval *to_zval_array(encodeType type, xmlNodePtr data)
        sdl = SOAP_GLOBAL(sdl);
 
        if (data &&
-           (arrayTypeAttr = get_attribute(data->properties,"arrayType")) &&
-           arrayTypeAttr->children &&
-           arrayTypeAttr->children->content) {
+           (attr = get_attribute(data->properties,"arrayType")) &&
+           attr->children && attr->children->content) {
                char *type, *end, *ns;
                xmlNsPtr nsptr;
 
-               parse_namespace(arrayTypeAttr->children->content, &type, &ns);
-               nsptr = xmlSearchNs(arrayTypeAttr->doc, arrayTypeAttr->parent, ns);
+               parse_namespace(attr->children->content, &type, &ns);
+               nsptr = xmlSearchNs(attr->doc, attr->parent, ns);
 
                end = strrchr(type,'[');
                if (end) {
@@ -1085,18 +1120,48 @@ zval *to_zval_array(encodeType type, xmlNodePtr data)
                }
                efree(type);
                if (ns) {efree(ns);}
+
+       } else if ((attr = get_attribute(data->properties,"itemType")) &&
+           attr->children &&
+           attr->children->content) {
+               char *type, *ns;
+               xmlNsPtr nsptr;
+
+               parse_namespace(attr->children->content, &type, &ns);
+               nsptr = xmlSearchNs(attr->doc, attr->parent, ns);
+               if (nsptr != NULL) {
+                       enc = get_encoder(SOAP_GLOBAL(sdl), nsptr->href, type);
+               }
+               efree(type);
+               if (ns) {efree(ns);}
+
+               if ((attr = get_attribute(data->properties,"arraySize")) &&
+                   attr->children && attr->children->content) {
+                       dimension = calc_dimension_12(attr->children->content);
+                       dims = get_position_12(dimension, attr->children->content);
+               } else {
+                       dims = emalloc(sizeof(int));
+                       *dims = 0;
+               }
+
+       } else if ((attr = get_attribute(data->properties,"arraySize")) &&
+           attr->children && attr->children->content) {
+
+               dimension = calc_dimension_12(attr->children->content);
+               dims = get_position_12(dimension, attr->children->content);
+
        } else if (type.sdl_type != NULL &&
                   type.sdl_type->attributes != NULL &&
-                  zend_hash_find(type.sdl_type->attributes, SOAP_ENC_NAMESPACE":arrayType",
-                                 sizeof(SOAP_ENC_NAMESPACE":arrayType"),
+                  zend_hash_find(type.sdl_type->attributes, SOAP_1_1_ENC_NAMESPACE":arrayType",
+                                 sizeof(SOAP_1_1_ENC_NAMESPACE":arrayType"),
                                  (void **)&arrayType) == SUCCESS &&
                   zend_hash_find((*arrayType)->extraAttributes, WSDL_NAMESPACE":arrayType", sizeof(WSDL_NAMESPACE":arrayType"), (void **)&tmp) == SUCCESS) {
                char *type, *end, *ns;
                xmlNsPtr nsptr;
 
-               arrayTypeAttr = *tmp;
-               parse_namespace(arrayTypeAttr->children->content, &type, &ns);
-               nsptr = xmlSearchNs(arrayTypeAttr->doc, arrayTypeAttr->parent, ns);
+               attr = *tmp;
+               parse_namespace(attr->children->content, &type, &ns);
+               nsptr = xmlSearchNs(attr->doc, attr->parent, ns);
 
                end = strrchr(type,'[');
                if (end) {
@@ -1109,21 +1174,63 @@ zval *to_zval_array(encodeType type, xmlNodePtr data)
                if (ns) {efree(ns);}
                dims = emalloc(sizeof(int));
                *dims = 0;
+
+       } else if (type.sdl_type != NULL &&
+                  type.sdl_type->attributes != NULL &&
+                  zend_hash_find(type.sdl_type->attributes, SOAP_1_2_ENC_NAMESPACE":itemType",
+                                 sizeof(SOAP_1_2_ENC_NAMESPACE":itemType"),
+                                 (void **)&arrayType) == SUCCESS &&
+                  zend_hash_find((*arrayType)->extraAttributes, WSDL_NAMESPACE":itemType", sizeof(WSDL_NAMESPACE":itemType"), (void **)&tmp) == SUCCESS) {
+
+               char *name, *ns;
+               xmlNsPtr nsptr;
+
+               attr = *tmp;
+               parse_namespace(attr->children->content, &name, &ns);
+               nsptr = xmlSearchNs(attr->doc, attr->parent, ns);
+
+               if (nsptr != NULL) {
+                       enc = get_encoder(SOAP_GLOBAL(sdl), nsptr->href, name);
+               }
+               efree(name);
+               if (ns) {efree(ns);}
+
+               if (zend_hash_find(type.sdl_type->attributes, SOAP_1_2_ENC_NAMESPACE":arraySize",
+                                  sizeof(SOAP_1_2_ENC_NAMESPACE":arraySize"),
+                                  (void **)&arrayType) == SUCCESS &&
+                   zend_hash_find((*arrayType)->extraAttributes, WSDL_NAMESPACE":arraySize", sizeof(WSDL_NAMESPACE":arraysize"), (void **)&tmp) == SUCCESS) {
+                       attr = *tmp;
+                       dimension = calc_dimension_12(attr->children->content);
+                       dims = get_position_12(dimension, attr->children->content);
+               } else {
+                       dims = emalloc(sizeof(int));
+                       *dims = 0;
+               }
+       } else if (type.sdl_type != NULL &&
+                  type.sdl_type->attributes != NULL &&
+                  zend_hash_find(type.sdl_type->attributes, SOAP_1_2_ENC_NAMESPACE":arraySize",
+                                 sizeof(SOAP_1_2_ENC_NAMESPACE":arraySize"),
+                                 (void **)&arrayType) == SUCCESS &&
+                  zend_hash_find((*arrayType)->extraAttributes, WSDL_NAMESPACE":arraySize", sizeof(WSDL_NAMESPACE":arraysize"), (void **)&tmp) == SUCCESS) {
+
+               attr = *tmp;
+               dimension = calc_dimension_12(attr->children->content);
+               dims = get_position_12(dimension, attr->children->content);
        }
        if (dims == NULL) {
+               dimension = 1;
                dims = emalloc(sizeof(int));
                *dims = 0;
        }
        pos = emalloc(sizeof(int)*dimension);
        memset(pos,0,sizeof(int)*dimension);
        if (data &&
-           (offsetAttr = get_attribute(data->properties,"offset")) &&
-            offsetAttr->children &&
-            offsetAttr->children->content) {
-               char* tmp = strrchr(offsetAttr->children->content,'[');
+           (attr = get_attribute(data->properties,"offset")) &&
+            attr->children && attr->children->content) {
+               char* tmp = strrchr(attr->children->content,'[');
 
                if (tmp == NULL) {
-                       tmp = offsetAttr->children->content;
+                       tmp = attr->children->content;
                }
                get_position_ex(dimension, tmp, &pos);
        }
@@ -1151,7 +1258,7 @@ zval *to_zval_array(encodeType type, xmlNodePtr data)
                        if (position != NULL && position->children && position->children->content) {
                                char* tmp = strrchr(position->children->content,'[');
                                if (tmp == NULL) {
-                                       tmp = offsetAttr->children->content;
+                                       tmp = position->children->content;
                                }
                                get_position_ex(dimension, tmp, &pos);
                        }
@@ -1351,7 +1458,9 @@ zval *guess_zval_convert(encodeType type, xmlNodePtr data)
                        /* Logic: has children = IS_OBJECT else IS_STRING */
                        xmlNodePtr trav;
 
-                       if (get_attribute(data->properties, "arrayType")) {
+                       if (get_attribute(data->properties, "arrayType") ||
+                           get_attribute(data->properties, "itemType") ||
+                           get_attribute(data->properties, "arraySize")) {
                                enc = get_conversion(SOAP_ENC_ARRAY);
                        } else {
                                enc = get_conversion(XSD_STRING);
index a0eced451701cc35682a1b649a88239dddc0eb35..061cd847d5d9f410ea331d2a2fa148e943ba1c3e 100644 (file)
@@ -5,11 +5,17 @@
 #define XSD_1999_TIMEINSTANT 401
 #define XSD_1999_TIMEINSTANT_STRING "timeInstant"
 
-#define SOAP_1_1_ENC "http://schemas.xmlsoap.org/soap/encoding/"
-#define SOAP_1_1_ENV "http://schemas.xmlsoap.org/soap/envelope/"
+#define SOAP_1_1_ENV_NAMESPACE "http://schemas.xmlsoap.org/soap/envelope/"
+#define SOAP_1_1_ENV_NS_PREFIX "SOAP-ENV"
 
-#define SOAP_1_2_ENC "http://www.w3.org/2003/05/soap-encoding"
-#define SOAP_1_2_ENV "http://www.w3.org/2003/05/soap-envelope"
+#define SOAP_1_2_ENV_NAMESPACE "http://www.w3.org/2003/05/soap-envelope"
+#define SOAP_1_2_ENV_NS_PREFIX "env"
+
+#define SOAP_1_1_ENC_NAMESPACE "http://schemas.xmlsoap.org/soap/encoding/"
+#define SOAP_1_1_ENC_NS_PREFIX "SOAP-ENC"
+
+#define SOAP_1_2_ENC_NAMESPACE "http://www.w3.org/2003/05/soap-encoding"
+#define SOAP_1_2_ENC_NS_PREFIX "enc"
 
 #define SCHEMA_NAMESPACE "http://www.w3.org/2001/XMLSchema"
 #define XSD_NAMESPACE "http://www.w3.org/2001/XMLSchema"
 #define APACHE_MAP 200
 #define APACHE_MAP_STRING "Map"
 
-#define SOAP_ENC_NAMESPACE "http://schemas.xmlsoap.org/soap/encoding/"
-#define SOAP_ENC_NS_PREFIX "SOAP-ENC"
 #define SOAP_ENC_ARRAY 300
 #define SOAP_ENC_ARRAY_STRING "Array"
 #define SOAP_ENC_OBJECT 301
index ca81f6de067719ea318f51da34ba57fc4cf8f5d8..c7254e4280548e3d5aaecf20b19967f1b9184582 100644 (file)
@@ -29,7 +29,7 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *location, char *so
 
        xmlDocDumpMemory(doc, &buf, &buf_size);
        if (!buf) {
-               add_soap_fault(this_ptr, "SOAP-ENV:Client", "Error build soap request", NULL, NULL TSRMLS_CC);
+               add_soap_fault(this_ptr, "Client", "Error build soap request", NULL, NULL TSRMLS_CC);
                return FALSE;
        }
        if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
@@ -59,7 +59,7 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *location, char *so
        }
        if (phpurl == NULL) {
                xmlFree(buf);
-               add_soap_fault(this_ptr, "SOAP-ENV:Client", "Unable to parse URL", NULL, NULL TSRMLS_CC);
+               add_soap_fault(this_ptr, "Client", "Unable to parse URL", NULL, NULL TSRMLS_CC);
                return FALSE;
        }
 
@@ -69,7 +69,7 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *location, char *so
                if (use_ssl && php_stream_locate_url_wrapper("https://", NULL, STREAM_LOCATE_WRAPPERS_ONLY TSRMLS_CC) == NULL) {
                        xmlFree(buf);
                        php_url_free(phpurl);
-                       add_soap_fault(this_ptr, "SOAP-ENV:Client", "SSL support not available in this build", NULL, NULL TSRMLS_CC);
+                       add_soap_fault(this_ptr, "Client", "SSL support not available in this build", NULL, NULL TSRMLS_CC);
                        return FALSE;
                }
 
@@ -99,7 +99,7 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *location, char *so
                        if (FAILURE == php_stream_sock_ssl_activate(stream, 1)) {
                                xmlFree(buf);
                                php_url_free(phpurl);
-                               add_soap_fault(this_ptr, "SOAP-ENV:Client", "SSL Connection attempt failed", NULL, NULL TSRMLS_CC);
+                               add_soap_fault(this_ptr, "Client", "SSL Connection attempt failed", NULL, NULL TSRMLS_CC);
                                return FALSE;
                        }
                }
@@ -111,7 +111,7 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *location, char *so
                } else {
                        xmlFree(buf);
                        php_url_free(phpurl);
-                       add_soap_fault(this_ptr, "SOAP-ENV:Client", "Could not connect to host", NULL, NULL TSRMLS_CC);
+                       add_soap_fault(this_ptr, "Client", "Could not connect to host", NULL, NULL TSRMLS_CC);
                        return FALSE;
                }
        }
@@ -197,7 +197,7 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *location, char *so
                        smart_str_free(&soap_headers);
                        php_stream_close(stream);
                        zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket"));
-                       add_soap_fault(this_ptr, "SOAP-ENV:Client", "Failed Sending HTTP SOAP request", NULL, NULL TSRMLS_CC);
+                       add_soap_fault(this_ptr, "Client", "Failed Sending HTTP SOAP request", NULL, NULL TSRMLS_CC);
                        return FALSE;
                }
                smart_str_free(&soap_headers);
@@ -229,7 +229,7 @@ int get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len TSRMLS
        if (!get_http_headers(stream, &http_headers, &http_header_size TSRMLS_CC)) {
                php_stream_close(stream);
                zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket"));
-               add_soap_fault(this_ptr, "SOAP-ENV:Client", "Error Fetching http headers", NULL, NULL TSRMLS_CC);
+               add_soap_fault(this_ptr, "Client", "Error Fetching http headers", NULL, NULL TSRMLS_CC);
                return FALSE;
        }
 
@@ -261,7 +261,7 @@ int get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len TSRMLS
                        ZVAL_STRING(err, http_body, 1);
                        http_err = emalloc(strlen("HTTP request failed ()") + 4);
                        sprintf(http_err, "HTTP request failed (%s)", http_status);
-                       add_soap_fault(thisObj, "SOAP-ENV:Client", http_err, NULL, err TSRMLS_CC);
+                       add_soap_fault(thisObj, "Client", http_err, NULL, err TSRMLS_CC);
                        efree(http_err);
                        return;
                }*/
@@ -272,7 +272,7 @@ int get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len TSRMLS
                        if (!get_http_headers(stream, &http_headers, &http_header_size TSRMLS_CC)) {
                                php_stream_close(stream);
                                zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket"));
-                               add_soap_fault(this_ptr, "SOAP-ENV:Client", "Error Fetching http headers", NULL, NULL TSRMLS_CC);
+                               add_soap_fault(this_ptr, "Client", "Error Fetching http headers", NULL, NULL TSRMLS_CC);
                                return FALSE;
                        }
                }
@@ -286,7 +286,7 @@ int get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len TSRMLS
        if (!get_http_body(stream, http_headers, &http_body, &http_body_size TSRMLS_CC)) {
                php_stream_close(stream);
                zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket"));
-               add_soap_fault(this_ptr, "SOAP-ENV:Client", "Error Fetching http body", NULL, NULL TSRMLS_CC);
+               add_soap_fault(this_ptr, "Client", "Error Fetching http body", NULL, NULL TSRMLS_CC);
                return FALSE;
        }
 
@@ -330,7 +330,7 @@ int get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len TSRMLS
                                zval *err;
                                MAKE_STD_ZVAL(err);
                                ZVAL_STRINGL(err, http_body, http_body_size, 1);
-                               add_soap_fault(this_ptr, "SOAP-ENV:Client", "Didn't recieve an xml document", NULL, err TSRMLS_CC);
+                               add_soap_fault(this_ptr, "Client", "Didn't recieve an xml document", NULL, err TSRMLS_CC);
                                efree(content_type);
                                efree(http_headers);
                                efree(http_body);
index cc5a352bc2173b27091261a3550001678b804af5..4fa122e3bd5064ddd8f03210e4243483b697709c 100644 (file)
@@ -21,11 +21,11 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
        EG(error_reporting) = old_error_reporting;
        
        if (!response) {
-               add_soap_fault(this_ptr, "SOAP-ENV:Client", "looks like we got no XML document", NULL, NULL TSRMLS_CC);
+               add_soap_fault(this_ptr, "Client", "looks like we got no XML document", NULL, NULL TSRMLS_CC);
                return FALSE;
        }
        if (xmlGetIntSubset(response) != NULL) {
-               add_soap_fault(this_ptr, "SOAP-ENV:Client", "DTD are not supported by SOAP", NULL, NULL TSRMLS_CC);
+               add_soap_fault(this_ptr, "Client", "DTD are not supported by SOAP", NULL, NULL TSRMLS_CC);
                return FALSE;
        }
 
@@ -34,14 +34,14 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
        trav = response->children;
        while (trav != NULL) {
                if (trav->type == XML_ELEMENT_NODE) {
-                       if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_1_ENV)) {
+                       if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_1_ENV_NAMESPACE)) {
                                env = trav;
-                               envelope_ns = SOAP_1_1_ENV;
-                       } else if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_2_ENV)) {
+                               envelope_ns = SOAP_1_1_ENV_NAMESPACE;
+                       } else if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_2_ENV_NAMESPACE)) {
                                env = trav;
-                               envelope_ns = SOAP_1_2_ENV;
+                               envelope_ns = SOAP_1_2_ENV_NAMESPACE;
                        } else {
-                               add_soap_fault(this_ptr, "SOAP-ENV:Client", "looks like we got bad SOAP response\n", NULL, NULL TSRMLS_CC);
+                               add_soap_fault(this_ptr, "Client", "looks like we got bad SOAP response\n", NULL, NULL TSRMLS_CC);
                                xmlFreeDoc(response);
                                return FALSE;
                        }
@@ -49,7 +49,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
                trav = trav->next;
        }
        if (env == NULL) {
-               add_soap_fault(this_ptr, "SOAP-ENV:Client", "looks like we got XML without \"Envelope\" element\n", NULL, NULL TSRMLS_CC);
+               add_soap_fault(this_ptr, "Client", "looks like we got XML without \"Envelope\" element\n", NULL, NULL TSRMLS_CC);
                xmlFreeDoc(response);
                return FALSE;
        }
@@ -72,7 +72,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
                        if (body == NULL && node_is_equal_ex(trav,"Body",envelope_ns)) {
                                body = trav;
                        } else {
-                               add_soap_fault(this_ptr, "SOAP-ENV:Client", "looks like we got bad SOAP response\n", NULL, NULL TSRMLS_CC);
+                               add_soap_fault(this_ptr, "Client", "looks like we got bad SOAP response\n", NULL, NULL TSRMLS_CC);
                                xmlFreeDoc(response);
                                return FALSE;
                        }
@@ -80,7 +80,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
                trav = trav->next;
        }
        if (body == NULL) {
-               add_soap_fault(this_ptr, "SOAP-ENV:Client", "looks like we got \"Envelope\" without \"Body\" element\n", NULL, NULL TSRMLS_CC);
+               add_soap_fault(this_ptr, "Client", "looks like we got \"Envelope\" without \"Body\" element\n", NULL, NULL TSRMLS_CC);
                xmlFreeDoc(response);
                return FALSE;
        }
@@ -171,7 +171,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
                                        MAKE_STD_ZVAL(tmp);
                                        ZVAL_NULL(tmp);
 /*
-                                       add_soap_fault(this_ptr, "SOAP-ENV:Client", "Can't find response data", NULL, NULL TSRMLS_CC);
+                                       add_soap_fault(this_ptr, "Client", "Can't find response data", NULL, NULL TSRMLS_CC);
                                        xmlFreeDoc(response);
                                        return FALSE;
 */
index 54cea6cd5c07ec4f966a21adf4a30acaa29c9e2a..ef248b486231a2b0fccafcd454eb87ba0cbf224e 100644 (file)
@@ -287,11 +287,14 @@ static void php_soap_init_globals(zend_soap_globals *soap_globals)
        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_ENC_NAMESPACE, sizeof(SOAP_ENC_NAMESPACE), SOAP_ENC_NS_PREFIX, sizeof(SOAP_ENC_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_ENC_NS_PREFIX, sizeof(SOAP_ENC_NS_PREFIX), SOAP_ENC_NAMESPACE, sizeof(SOAP_ENC_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);
 
        soap_globals->use_soap_error_handler = 0;
        soap_globals->sdl = NULL;
@@ -1245,7 +1248,7 @@ static void soap_error_handler(int error_num, const char *error_filename, const
                }
                php_end_ob_buffer(0, 0 TSRMLS_CC);
 
-               set_soap_fault(&ret, "SOAP-ENV:Server", buffer, NULL, &outbuf TSRMLS_CC);
+               set_soap_fault(&ret, "Server", buffer, NULL, &outbuf TSRMLS_CC);
                doc_return = seralize_response_call(NULL, NULL, NULL, &ret, soap_version TSRMLS_CC);
 
                /* Build and send our headers + http 500 status */
@@ -1437,7 +1440,7 @@ zend_try {
                        smart_str_appends(&error,function);
                        smart_str_appends(&error,"\") is not a valid method for this service");
                        smart_str_0(&error);
-                       add_soap_fault(thisObj, "SOAP-ENV:Client", error.c, NULL, NULL TSRMLS_CC);
+                       add_soap_fault(thisObj, "Client", error.c, NULL, NULL TSRMLS_CC);
                        smart_str_free(&error);
                }
        } else {
@@ -1445,9 +1448,9 @@ zend_try {
                smart_str *action;
 
                if (zend_hash_find(Z_OBJPROP_P(thisObj), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
-                       add_soap_fault(thisObj, "SOAP-ENV:Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
+                       add_soap_fault(thisObj, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
                } else if (zend_hash_find(Z_OBJPROP_P(thisObj), "location", sizeof("location"),(void **) &location) == FAILURE) {
-                       add_soap_fault(thisObj, "SOAP-ENV:Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
+                       add_soap_fault(thisObj, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
                } else {
                        request = seralize_function_call(thisObj, NULL, function, Z_STRVAL_PP(uri), real_args, arg_count, soap_version TSRMLS_CC);
                        action = build_soap_action(thisObj, function);
@@ -1475,7 +1478,7 @@ zend_try {
                        *return_value = **fault;
                        zval_copy_ctor(return_value);
                } else {
-                       *return_value = *add_soap_fault(thisObj, "SOAP-ENV:Client", "Unknown Error", NULL, NULL TSRMLS_CC);
+                       *return_value = *add_soap_fault(thisObj, "Client", "Unknown Error", NULL, NULL TSRMLS_CC);
                        zval_copy_ctor(return_value);
                }
        } else {
@@ -1732,15 +1735,15 @@ static void deseralize_function_call(sdlPtr sdl, xmlDocPtr request, zval *functi
        trav = request->children;
        while (trav != NULL) {
                if (trav->type == XML_ELEMENT_NODE) {
-                       if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_1_ENV)) {
+                       if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_1_ENV_NAMESPACE)) {
                                env = trav;
                                *version = SOAP_1_1;
-                               envelope_ns = SOAP_1_1_ENV;
+                               envelope_ns = SOAP_1_1_ENV_NAMESPACE;
                                SOAP_GLOBAL(soap_version) = SOAP_1_1;
-                       } else if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_2_ENV)) {
+                       } else if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_2_ENV_NAMESPACE)) {
                                env = trav;
                                *version = SOAP_1_2;
-                               envelope_ns = SOAP_1_2_ENV;
+                               envelope_ns = SOAP_1_2_ENV_NAMESPACE;
                                SOAP_GLOBAL(soap_version) = SOAP_1_2;
                        } else {
                                php_error(E_ERROR,"looks like we got bad SOAP request\n");
@@ -1855,23 +1858,28 @@ static xmlDocPtr seralize_response_call(sdlFunctionPtr function, char *function_
        doc = xmlNewDoc("1.0");
        doc->charset = XML_CHAR_ENCODING_UTF8;
        doc->encoding = xmlStrdup((xmlChar*)"UTF-8");
-       doc->children = xmlNewDocNode(doc, NULL, "SOAP-ENV:Envelope", NULL);
-       envelope = doc->children;
 
        if (version == SOAP_1_1) {
-               ns = xmlNewNs(envelope, SOAP_1_1_ENV,"SOAP-ENV");
+               envelope = xmlNewDocNode(doc, NULL, SOAP_1_1_ENV_NS_PREFIX":Envelope", NULL);
+               ns = xmlNewNs(envelope, SOAP_1_1_ENV_NAMESPACE, SOAP_1_1_ENV_NS_PREFIX);
        } else if (version == SOAP_1_2) {
-               ns = xmlNewNs(envelope, SOAP_1_2_ENV,"SOAP-ENV");
+               envelope = xmlNewDocNode(doc, NULL, SOAP_1_2_ENV_NS_PREFIX":Envelope", NULL);
+               ns = xmlNewNs(envelope, SOAP_1_2_ENV_NAMESPACE, SOAP_1_2_ENV_NS_PREFIX);
        } else {
          php_error(E_ERROR, "Unknown SOAP version");
        }
+       doc->children = envelope;
 
        body = xmlNewChild(envelope, ns, "Body", NULL);
 
        if (Z_TYPE_P(ret) == IS_OBJECT &&
                Z_OBJCE_P(ret) == soap_fault_class_entry) {
                use = SOAP_ENCODED;
-               param = seralize_zval(ret, NULL, "SOAP-ENV:Fault", use TSRMLS_CC);
+               if (version == SOAP_1_1) {
+                       param = seralize_zval(ret, NULL, SOAP_1_1_ENV_NS_PREFIX":Fault", use TSRMLS_CC);
+               } else {
+                       param = seralize_zval(ret, NULL, SOAP_1_2_ENV_NS_PREFIX":Fault", use TSRMLS_CC);
+               }
                xmlAddChild(body, param);
        } else {
                gen_ns = encode_new_ns();
@@ -1964,11 +1972,11 @@ static xmlDocPtr seralize_response_call(sdlFunctionPtr function, char *function_
                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-ENC", SOAP_1_1_ENC);
-                       xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_1_ENC);
+                       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);
                } else if (version == SOAP_1_2) {
-                       xmlSetProp(envelope, "xmlns:SOAP-ENC", SOAP_1_2_ENC);
-                       /*xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_2_ENC);*/
+                       xmlSetProp(envelope, "xmlns:"SOAP_1_2_ENC_NS_PREFIX, SOAP_1_2_ENC_NAMESPACE);
+                       /*xmlSetProp(envelope, SOAP_1_2_ENV_NS_PREFIX"encodingStyle", SOAP_1_2_ENC_NAMESPACE);*/
                }
        }
 
@@ -1994,15 +2002,16 @@ static xmlDocPtr seralize_function_call(zval *this_ptr, sdlFunctionPtr function,
        doc = xmlNewDoc("1.0");
        doc->encoding = xmlStrdup((xmlChar*)"UTF-8");
        doc->charset = XML_CHAR_ENCODING_UTF8;
-       envelope = xmlNewDocNode(doc, NULL, "SOAP-ENV:Envelope", NULL);
-       xmlDocSetRootElement(doc, envelope);
        if (version == SOAP_1_1) {
-               ns = xmlNewNs(envelope, SOAP_1_1_ENV, "SOAP-ENV");
+               envelope = xmlNewDocNode(doc, NULL, SOAP_1_1_ENV_NS_PREFIX":Envelope", NULL);
+               ns = xmlNewNs(envelope, SOAP_1_1_ENV_NAMESPACE, SOAP_1_1_ENV_NS_PREFIX);
        } else if (version == SOAP_1_2) {
-               ns = xmlNewNs(envelope, SOAP_1_2_ENV, "SOAP-ENV");
+               envelope = xmlNewDocNode(doc, NULL, SOAP_1_2_ENV_NS_PREFIX":Envelope", NULL);
+               ns = xmlNewNs(envelope, SOAP_1_2_ENV_NAMESPACE, SOAP_1_2_ENV_NS_PREFIX);
        } else {
                php_error(E_ERROR, "Unknown SOAP version");
        }
+       xmlDocSetRootElement(doc, envelope);
 
        body = xmlNewChild(envelope, ns, "Body", NULL);
 
@@ -2052,11 +2061,11 @@ static xmlDocPtr seralize_function_call(zval *this_ptr, sdlFunctionPtr function,
                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-ENC", SOAP_1_1_ENC);
-                       xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_1_ENC);
+                       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);
                } else if (version == SOAP_1_2) {
-                       xmlSetProp(envelope, "xmlns:SOAP-ENC", SOAP_1_2_ENC);
-                       /*xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_2_ENC);*/
+                       xmlSetProp(envelope, "xmlns:"SOAP_1_2_ENC_NS_PREFIX, SOAP_1_2_ENC_NAMESPACE);
+                       /*xmlSetProp(envelope, SOAP_1_2_ENV_NS_PREFIX":encodingStyle", SOAP_1_2_ENC_NAMESPACE);*/
                }
        }