cvs: pear /PECL/soap Makefile Makefile.in config.m4 php_encoding.c php_encoding.h php_packet_soap.c php_schema.c php_sdl.c php_sdl.h soap.c

From: Date: Wed, 14 Aug 2002 05:26:25 +0000
Subject: cvs: pear /PECL/soap Makefile Makefile.in config.m4 php_encoding.c php_encoding.h php_packet_soap.c php_schema.c php_sdl.c php_sdl.h soap.c
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-5729@lists.php.net to get a copy of this message
rodif_bl Wed Aug 14 01:26:25 2002 EDT Modified files: /pear/PECL/soap Makefile Makefile.in config.m4 php_encoding.c php_encoding.h php_packet_soap.c php_schema.c php_sdl.c php_sdl.h soap.c Log: some more doc/lit stuff some more wsdl stuff

Index: pear/PECL/soap/Makefile diff -u pear/PECL/soap/Makefile:1.2 pear/PECL/soap/Makefile:1.3 --- pear/PECL/soap/Makefile:1.2 Tue Aug 6 23:03:09 2002 +++ pear/PECL/soap/Makefile Wed Aug 14 01:26:25 2002 @@ -3,7 +3,7 @@ srcdir = /usr/local/src/php-4.2.0/ext/soap builddir = /usr/local/src/php-4.2.0/ext/soap VPATH = /usr/local/src/php-4.2.0/ext/soap -# $Id: Makefile,v 1.2 2002/08/07 03:03:09 rodif_bl Exp $ +# $Id: Makefile,v 1.3 2002/08/14 05:26:25 rodif_bl Exp $ LTLIBRARY_NAME = libsoap.la LTLIBRARY_SOURCES = soap.c php_sdl.c php_schema.c php_xml.c php_encoding.c php_http.c php_packet_soap.c Index: pear/PECL/soap/Makefile.in diff -u pear/PECL/soap/Makefile.in:1.2 pear/PECL/soap/Makefile.in:1.3 --- pear/PECL/soap/Makefile.in:1.2 Tue Aug 6 23:03:09 2002 +++ pear/PECL/soap/Makefile.in Wed Aug 14 01:26:25 2002 @@ -1,4 +1,4 @@ -# $Id: Makefile.in,v 1.2 2002/08/07 03:03:09 rodif_bl Exp $ +# $Id: Makefile.in,v 1.3 2002/08/14 05:26:25 rodif_bl Exp $ LTLIBRARY_NAME = libsoap.la LTLIBRARY_SOURCES = soap.c php_sdl.c php_schema.c php_xml.c php_encoding.c php_http.c php_packet_soap.c Index: pear/PECL/soap/config.m4 diff -u pear/PECL/soap/config.m4:1.2 pear/PECL/soap/config.m4:1.3 --- pear/PECL/soap/config.m4:1.2 Tue Aug 6 23:03:09 2002 +++ pear/PECL/soap/config.m4 Wed Aug 14 01:26:25 2002 @@ -1,4 +1,4 @@ -dnl $Id: config.m4,v 1.2 2002/08/07 03:03:09 rodif_bl Exp $ +dnl $Id: config.m4,v 1.3 2002/08/14 05:26:25 rodif_bl Exp $ dnl config.m4 for extension soap dnl Comments in this file start with the string 'dnl'. Index: pear/PECL/soap/php_encoding.c diff -u pear/PECL/soap/php_encoding.c:1.4 pear/PECL/soap/php_encoding.c:1.5 --- pear/PECL/soap/php_encoding.c:1.4 Tue Aug 6 23:03:09 2002 +++ pear/PECL/soap/php_encoding.c Wed Aug 14 01:26:25 2002 @@ -342,7 +342,7 @@ ret = xmlNewNode(NULL, "BOGUS"); FIND_ZVAL_NULL(data, ret); - + convert_to_long(data); convert_to_string(data); xmlNodeSetContentLen(ret, Z_STRVAL_P(data), Z_STRLEN_P(data)); @@ -956,14 +956,14 @@ return *enc; } -encodePtr get_conversion_from_href_type_ex(HashTable *encoding, char *type) +encodePtr get_conversion_from_href_type_ex(HashTable *encoding, char *type, int len) { encodePtr *enc = NULL; if(encoding == NULL) return NULL; - if(zend_hash_find(encoding, type, strlen(type), (void **)&enc) == FAILURE) + if(zend_hash_find(encoding, type, len + 1, (void **)&enc) == FAILURE) return NULL; return (*enc); Index: pear/PECL/soap/php_encoding.h diff -u pear/PECL/soap/php_encoding.h:1.3 pear/PECL/soap/php_encoding.h:1.4 --- pear/PECL/soap/php_encoding.h:1.3 Tue Aug 6 23:03:09 2002 +++ pear/PECL/soap/php_encoding.h Wed Aug 14 01:26:25 2002 @@ -206,7 +206,7 @@ #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) -#define get_conversion_from_href_type(t) get_conversion_from_href_type_ex(SOAP_GLOBAL(defEnc), t) +#define get_conversion_from_href_type(t) get_conversion_from_href_type_ex(SOAP_GLOBAL(defEnc), t, strlen(t)) void encode_reset_ns(); smart_str *encode_new_ns(); @@ -215,7 +215,7 @@ void set_ns_and_type_ex(xmlNodePtr node, char *ns, char *type); encodePtr get_conversion_ex(HashTable *encoding, int encode); encodePtr get_conversion_from_type_ex(HashTable *encoding, xmlNodePtr node, char *type); -encodePtr get_conversion_from_href_type_ex(HashTable *encoding, char *type); +encodePtr get_conversion_from_href_type_ex(HashTable *encoding, char *type, int len); int is_map(zval *array); void get_array_type(zval *array, smart_str *out_type); Index: pear/PECL/soap/php_packet_soap.c diff -u pear/PECL/soap/php_packet_soap.c:1.3 pear/PECL/soap/php_packet_soap.c:1.4 --- pear/PECL/soap/php_packet_soap.c:1.3 Tue Aug 6 23:03:09 2002 +++ pear/PECL/soap/php_packet_soap.c Wed Aug 14 01:26:25 2002 @@ -52,41 +52,57 @@ resp = body->children; if(fn != NULL) { - cur = get_node(resp, fn->responseName); - if(cur != NULL) + sdlParamPtr *h_param, param = NULL; + xmlNodePtr val = NULL; + encodePtr enc; + char *name, *ns; + + if(fn->bindingType == BINDING_SOAP) { - int num_resp = zend_hash_num_elements(fn->responseParameters); - if(num_resp <= 1) - { - sdlParamPtr *h_param, param; - xmlNodePtr val; + sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)fn->bindingAttributes; + + zend_hash_internal_pointer_reset(fn->responseParameters); + if(zend_hash_get_current_data(fn->responseParameters, (void **)&h_param) != SUCCESS) + php_error(E_ERROR, "Can't find response parameter \"%s\"", param->paramName); - zend_hash_internal_pointer_reset(fn->responseParameters); - if(zend_hash_get_current_data(fn->responseParameters, (void **)&h_param) == SUCCESS) - { - param = (*h_param); - val = get_node(cur->children, param->paramName); - if(val != NULL) - { - encodePtr enc; - tmp_ret = emalloc(sizeof(zval **)); - if(param != NULL) - enc = param->encode; - else - enc = get_conversion(UNKNOWN_TYPE); - - tmp_ret[0] = master_to_zval(enc, val); - (*ret) = tmp_ret; - (*num_params) = 1; - } - else - php_error(E_ERROR, "Can't find response parameter \"%s\"", param->paramName); - } + param = (*h_param); + if(fnb->style == SOAP_DOCUMENT) + { + name = (*h_param)->encode->details.type_str; + ns = (*h_param)->encode->details.ns; } else { - php_error(E_ERROR,"Doesn't handle multiple return values"); + name = fn->responseName; + /* ns = ? */ } + + cur = get_node_ex(resp, name, ns); + /* TODO: produce warning invalid ns */ + if(!cur) + cur = get_node(resp, name); + + if(!cur) + php_error(E_ERROR, "Can't find response data"); + + + if(fnb->style == SOAP_DOCUMENT) + val = cur; + else + val = get_node(cur->children, param->paramName); + + if(!val) + php_error(E_ERROR, "Can't find response data"); + + tmp_ret = emalloc(sizeof(zval **)); + if(param != NULL) + enc = param->encode; + else + enc = get_conversion(UNKNOWN_TYPE); + + tmp_ret[0] = master_to_zval(enc, val); + (*ret) = tmp_ret; + (*num_params) = 1; } } else Index: pear/PECL/soap/php_schema.c diff -u pear/PECL/soap/php_schema.c:1.3 pear/PECL/soap/php_schema.c:1.4 --- pear/PECL/soap/php_schema.c:1.3 Tue Aug 6 23:03:09 2002 +++ pear/PECL/soap/php_schema.c Wed Aug 14 01:26:25 2002 @@ -442,7 +442,6 @@ sdlRestrictionIntPtr ptr = *((sdlRestrictionIntPtr*)rvi); if(ptr->id); free(ptr->id); - free(ptr); } Index: pear/PECL/soap/php_sdl.c diff -u pear/PECL/soap/php_sdl.c:1.3 pear/PECL/soap/php_sdl.c:1.4 --- pear/PECL/soap/php_sdl.c:1.3 Tue Aug 6 23:03:09 2002 +++ pear/PECL/soap/php_sdl.c Wed Aug 14 01:26:25 2002 @@ -36,7 +36,7 @@ enc = get_conversion_from_href_type(nscat); if(enc == NULL && sdl) - enc = get_conversion_from_href_type_ex(sdl->encoders, nscat); + enc = get_conversion_from_href_type_ex(sdl->encoders, nscat, strlen(nscat)); if(enc == NULL) enc = get_conversion(UNKNOWN_TYPE); return enc; @@ -45,19 +45,21 @@ encodePtr get_create_encoder(sdlPtr sdl, sdlTypePtr cur_type, char *ns, char *type) { encodePtr enc = NULL; - char *nscat; + smart_str nscat = {0}; TSRMLS_FETCH(); + + smart_str_appends(&nscat, ns); + smart_str_appendc(&nscat, ':'); + smart_str_appends(&nscat, type); + smart_str_0(&nscat); - nscat = emalloc(strlen(ns) + strlen(type) + 2); - sprintf(nscat, "%s:%s", ns, type); - - enc = get_conversion_from_href_type(nscat); + enc = get_conversion_from_href_type(nscat.c); if(enc == NULL) - enc = get_conversion_from_href_type_ex(sdl->encoders, nscat); + enc = get_conversion_from_href_type_ex(sdl->encoders, nscat.c, nscat.len); if(enc == NULL) enc = create_encoder(sdl, cur_type, ns, type); - - efree(nscat); + + smart_str_free(&nscat); return enc; } @@ -76,9 +78,9 @@ enc->details.ns = strdup(ns); enc->details.type_str = strdup(type); - enc->details.sdl_type = cur_type; + enc->details.sdl_type = cur_type; enc->to_xml = sdl_guess_convert_xml; - enc->to_zval = guess_zval_convert; + enc->to_zval = sdl_guess_convert_zval; if(sdl->encoders == NULL) { @@ -88,33 +90,67 @@ zend_hash_add(sdl->encoders, nscat.c, nscat.len + 1, &enc, sizeof(encodePtr), NULL); smart_str_free(&nscat); return enc; +} + +zval *sdl_guess_convert_zval(encodeType enc, xmlNodePtr data) +{ + sdlTypePtr type; + zval *ret; + + type = enc.sdl_type; + + if(type->encode) + { + if(type->encode->details.type == IS_ARRAY || + type->encode->details.type == SOAP_ENC_ARRAY) + ret = to_zval_array(enc, data); + else + ret = master_to_zval(type->encode, data); + } + else if(zend_hash_num_elements(type->elements) == 1) + { + sdlTypePtr *t; + zend_hash_internal_pointer_reset(type->elements); + if(zend_hash_get_current_data(type->elements, (void **)&t) != FAILURE && + (*t)->max_occurs != 1) + ret = to_zval_array(enc, data); + } + if(ret) + return ret; + else + return guess_zval_convert(enc, data); } xmlNodePtr sdl_guess_convert_xml(encodeType enc, zval *data, int style) { sdlTypePtr type; - xmlNodePtr ret; + xmlNodePtr ret = NULL; - ret = xmlNewNode(NULL, "BOGUS"); type = enc.sdl_type; - if(type->encode->details.type == IS_ARRAY || - type->encode->details.type == SOAP_ENC_ARRAY) + if(type->encode) { - ret = sdl_to_xml_array(type, data, style); - } - else if(type->encode != NULL) - { - ret = master_to_xml(type->encode, data, style); + if(type->encode->details.type == IS_ARRAY || + type->encode->details.type == SOAP_ENC_ARRAY) + ret = sdl_to_xml_array(type, data, style); + else + ret = master_to_xml(type->encode, data, style); } - else if(type->elements != NULL) + else if(type->elements) { - ret = sdl_to_xml_object(type, data, style); + sdlTypePtr *t; + if(zend_hash_num_elements(type->elements) == 1) + { + zend_hash_internal_pointer_reset(type->elements); + if(zend_hash_get_current_data(type->elements, (void **)&t) != FAILURE && + (*t)->max_occurs != 1) + ret = sdl_to_xml_array((*t), data, style); + } + if(!ret) + ret = sdl_to_xml_object(type, data, style); } else - { ret = guess_xml_convert(enc, data, style); - } //set_ns_and_type(ret, enc); return ret; @@ -167,43 +203,48 @@ sdlAttributePtr *arrayType; i = zend_hash_num_elements(Z_ARRVAL_P(data)); - if(zend_hash_find(type->attributes, SOAP_ENC_NAMESPACE":arrayType", sizeof(SOAP_ENC_NAMESPACE":arrayType"), (void **)&arrayType) == SUCCESS) + if(style == SOAP_ENCODED) { - xmlAttrPtr *wsdl; - if(zend_hash_find((*arrayType)->extraAttributes, WSDL_NAMESPACE":arrayType", sizeof(WSDL_NAMESPACE":arrayType"), (void **)&wsdl) == SUCCESS) + if(type->attributes && + zend_hash_find(type->attributes, SOAP_ENC_NAMESPACE":arrayType", + sizeof(SOAP_ENC_NAMESPACE":arrayType"), + (void **)&arrayType) == SUCCESS) + { + xmlAttrPtr *wsdl; + if(zend_hash_find((*arrayType)->extraAttributes, WSDL_NAMESPACE":arrayType", sizeof(WSDL_NAMESPACE":arrayType"), (void **)&wsdl) == SUCCESS) + { + char *ns = NULL, *value; + smart_str *prefix = encode_new_ns(); + smart_str smart_ns = {0}; + xmlNsPtr myNs; + + parse_namespace((*wsdl)->children->content, &value, &ns); + myNs = xmlSearchNs((*wsdl)->doc, (*wsdl)->parent, ns); + + smart_str_appendl(&smart_ns, "xmlns:", sizeof("xmlns:") - 1); + smart_str_appendl(&smart_ns, prefix->c, prefix->len); + smart_str_0(&smart_ns); + + xmlSetProp(xmlParam, smart_ns.c, myNs->href); + smart_str_appends(&array_type_and_size, prefix->c); + smart_str_appendc(&array_type_and_size, ':'); + smart_str_appends(&array_type_and_size, value); + smart_str_0(&array_type_and_size); + } + } + else { - char *ns = NULL, *value; - smart_str *prefix = encode_new_ns(); - smart_str smart_ns = {0}; - xmlNsPtr myNs; - - parse_namespace((*wsdl)->children->content, &value, &ns); - myNs = xmlSearchNs((*wsdl)->doc, (*wsdl)->parent, ns); - - smart_str_appendl(&smart_ns, "xmlns:", sizeof("xmlns:") - 1); - smart_str_appendl(&smart_ns, prefix->c, prefix->len); - smart_str_0(&smart_ns); - - xmlSetProp(xmlParam, smart_ns.c, myNs->href); - smart_str_appends(&array_type_and_size, prefix->c); - smart_str_appendc(&array_type_and_size, ':'); - smart_str_appends(&array_type_and_size, value); + smart_str_appends(&array_type_and_size, type->name); + 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); } - } - else - { - smart_str_appends(&array_type_and_size, type->name); - 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); - } + xmlSetProp(xmlParam, SOAP_ENC_NS_PREFIX":arrayType", array_type_and_size.c); - xmlSetProp(xmlParam, SOAP_ENC_NS_PREFIX":arrayType", array_type_and_size.c); - - smart_str_free(&array_type_and_size); - smart_str_free(&array_type); + smart_str_free(&array_type_and_size); + smart_str_free(&array_type); + } zend_hash_internal_pointer_reset(data->value.ht); for(;i > 0;i--) @@ -216,12 +257,14 @@ enc = get_conversion((*zdata)->type); xparam = master_to_xml(enc, (*zdata), style); - xmlNodeSetName(xparam, "val"); + xmlNodeSetName(xparam, type->name); xmlAddChild(xmlParam, xparam); zend_hash_move_forward(data->value.ht); } } - set_ns_and_type_ex(xmlParam, type->namens, type->name); + + if(style == SOAP_ENCODED) + set_ns_and_type_ex(xmlParam, type->namens, type->name); return xmlParam; } @@ -249,7 +292,6 @@ { } */ - sdlPtr get_sdl(char *uri) { Index: pear/PECL/soap/php_sdl.h diff -u pear/PECL/soap/php_sdl.h:1.3 pear/PECL/soap/php_sdl.h:1.4 --- pear/PECL/soap/php_sdl.h:1.3 Tue Aug 6 23:03:09 2002 +++ pear/PECL/soap/php_sdl.h Wed Aug 14 01:26:25 2002 @@ -154,7 +154,8 @@ 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(encodeType enc, zval* data, int style); +xmlNodePtr sdl_guess_convert_xml(encodeType enc, zval* data, int style); +zval *sdl_guess_convert_zval(encodeType enc, xmlNodePtr data); xmlNodePtr sdl_to_xml_array(sdlTypePtr type, zval *data, int style); xmlNodePtr sdl_to_xml_object(sdlTypePtr type, zval *data, int style); Index: pear/PECL/soap/soap.c diff -u pear/PECL/soap/soap.c:1.5 pear/PECL/soap/soap.c:1.6 --- pear/PECL/soap/soap.c:1.5 Tue Aug 6 23:03:09 2002 +++ pear/PECL/soap/soap.c Wed Aug 14 01:26:25 2002 @@ -18,8 +18,8 @@ ZEND_DECLARE_MODULE_GLOBALS(soap); static void (*old_handler)(int, const char *, const uint, const char*, va_list); - -static zend_function_entry soap_functions[] = { + +static zend_function_entry soap_functions[] = { #ifdef HAVE_PHP_DOMXML PHP_FE(soap_encode_to_xml, NULL) PHP_FE(soap_encode_to_zval, NULL) @@ -134,12 +134,12 @@ char *ns_type; ns_type = emalloc(strlen(defaultEncoding[i].details.ns) + strlen(defaultEncoding[i].details.type_str) + 2); sprintf(ns_type, "%s:%s", defaultEncoding[i].details.ns, defaultEncoding[i].details.type_str); - zend_hash_add(soap_globals->defEnc, ns_type, strlen(ns_type), &enc, sizeof(encodePtr), NULL); + zend_hash_add(soap_globals->defEnc, ns_type, strlen(ns_type) + 1, &enc, sizeof(encodePtr), NULL); efree(ns_type); } else { - zend_hash_add(soap_globals->defEnc, defaultEncoding[i].details.type_str, strlen(defaultEncoding[i].details.type_str), &enc, sizeof(encodePtr), NULL); + zend_hash_add(soap_globals->defEnc, defaultEncoding[i].details.type_str, strlen(defaultEncoding[i].details.type_str) + 1, &enc, sizeof(encodePtr), NULL); } } //Index everything by number @@ -399,8 +399,8 @@ ret = master_to_zval(get_conversion(UNKNOWN_TYPE), node); *return_value = *ret; } -#endif - +#endif + //SoapParam functions PHP_FUNCTION(soapparam) { @@ -1807,11 +1807,13 @@ { sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes; - ns = xmlNewNs(body, fnb->input.ns, gen_ns->c); style = fnb->style; use = fnb->input.use; if(style == SOAP_RPC) + { + ns = xmlNewNs(body, fnb->input.ns, gen_ns->c); method = xmlNewChild(body, ns, function->requestName , NULL); + } } } else @@ -2263,6 +2265,4 @@ } } return FAILURE; -} - - +} \ No newline at end of file
« previous php.pear.cvs (#5729) next »