cvs: pear /PECL/soap php_encoding.c php_encoding.h php_http.c php_http.h php_packet_soap.c php_packet_soap.h php_schema.c php_sdl.c php_sdl.h
php_soap.h php_xml.c php_xml.h soap.c

From: Date: Mon, 08 Jul 2002 01:23:06 +0000
Subject: cvs: pear /PECL/soap php_encoding.c php_encoding.h php_http.c php_http.h php_packet_soap.c php_packet_soap.h php_schema.c php_sdl.c php_sdl.h
php_soap.h php_xml.c php_xml.h soap.c
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-4959@lists.php.net to get a copy of this message
shane Sun Jul 7 21:23:06 2002 EDT Modified files: /pear/PECL/soap php_encoding.c php_encoding.h php_http.c php_http.h php_packet_soap.c php_packet_soap.h php_schema.c php_sdl.c php_sdl.h php_soap.h php_xml.c php_xml.h soap.c Log: fix the line ending problems in the files

Index: pear/PECL/soap/php_encoding.c diff -u pear/PECL/soap/php_encoding.c:1.1 pear/PECL/soap/php_encoding.c:1.2 --- pear/PECL/soap/php_encoding.c:1.1 Sun Jul 7 19:03:43 2002 +++ pear/PECL/soap/php_encoding.c Sun Jul 7 21:23:06 2002 @@ -266,7 +266,7 @@ zval *ret; MAKE_STD_ZVAL(ret); FIND_XML_NULL(data, ret); - + if(data && data->children) ZVAL_STRING(ret, data->children->content, 1); return ret; @@ -285,14 +285,14 @@ xmlNodePtr to_xml_string(encodeType type, zval *data) { - xmlNodePtr ret; - char *str; + xmlNodePtr ret; + char *str; int new_len; ret = xmlNewNode(NULL, "BOGUS"); FIND_ZVAL_NULL(data, ret); - convert_to_string(data); + convert_to_string(data); str = php_escape_html_entities(Z_STRVAL_P(data), Z_STRLEN_P(data), &new_len, 0, 0, NULL); xmlNodeSetContentLen(ret, str, new_len); set_ns_and_type(ret, type); Index: pear/PECL/soap/php_encoding.h diff -u pear/PECL/soap/php_encoding.h:1.1 pear/PECL/soap/php_encoding.h:1.2 --- pear/PECL/soap/php_encoding.h:1.1 Sun Jul 7 19:03:43 2002 +++ pear/PECL/soap/php_encoding.h Sun Jul 7 21:23:06 2002 @@ -105,12 +105,12 @@ #define SOAP_ENC_ARRAY_STRING "Array" #define SOAP_ENC_OBJECT 301 #define SOAP_ENC_OBJECT_STRING "Struct" - -#define SCHEMA_NAMESPACE "http://www.w3.org/2001/XMLSchema" -#define SCHEMA_NS_PREFIX "s" - -#define WSDL_NAMESPACE "http://schemas.xmlsoap.org/wsdl/" -#define WSDL_NS_PREFIX "wsdl" + +#define SCHEMA_NAMESPACE "http://www.w3.org/2001/XMLSchema" +#define SCHEMA_NS_PREFIX "s" + +#define WSDL_NAMESPACE "http://schemas.xmlsoap.org/wsdl/" +#define WSDL_NS_PREFIX "wsdl" #define UNKNOWN_TYPE 999998 #define END_KNOWN_TYPES 999999 @@ -121,7 +121,7 @@ char *type_str; char *ns; sdlTypePtr sdl_type; - soapMappingPtr map; + soapMappingPtr map; }; struct _encode Index: pear/PECL/soap/php_http.c diff -u pear/PECL/soap/php_http.c:1.1 pear/PECL/soap/php_http.c:1.2 --- pear/PECL/soap/php_http.c:1.1 Sun Jul 7 19:03:43 2002 +++ pear/PECL/soap/php_http.c Sun Jul 7 21:23:06 2002 @@ -45,7 +45,7 @@ #ifdef PHP_STREAMS stream = php_stream_sock_open_host(phpurl->host, (unsigned short)(phpurl->port == 0 ? 80 : phpurl->port), SOCK_STREAM, 0, 0); -#else +#else stream = get_socket(phpurl->host, (phpurl->port == 0 ? 80 : phpurl->port), 10); #endif if(stream) @@ -147,7 +147,7 @@ xmlFree(buf); } -void get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len) +void get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len) { char *http_headers, *http_body, *content_type, *http_version, http_status[4], *cookie_itt, *connection; int http_header_size, http_body_size, http_close; @@ -325,10 +325,10 @@ efree(cookie); cookie_itt = FALSE; } - - *buffer = http_body; - *buffer_len = http_body_size; - efree(http_headers); + + *buffer = http_body; + *buffer_len = http_body_size; + efree(http_headers); } char *get_http_header_value(char *headers, char *type) Index: pear/PECL/soap/php_http.h diff -u pear/PECL/soap/php_http.h:1.1 pear/PECL/soap/php_http.h:1.2 --- pear/PECL/soap/php_http.h:1.1 Sun Jul 7 19:03:43 2002 +++ pear/PECL/soap/php_http.h Sun Jul 7 21:23:06 2002 @@ -2,7 +2,7 @@ #define PHP_HTTP_H void send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *function_name, char *soapaction); -void get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len); +void get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len); char *get_http_header_value(char *headers, char *type); int get_http_body(SOAP_STREAM socketd, char *headers, char **response, int *out_size); Index: pear/PECL/soap/php_packet_soap.c diff -u pear/PECL/soap/php_packet_soap.c:1.1 pear/PECL/soap/php_packet_soap.c:1.2 --- pear/PECL/soap/php_packet_soap.c:1.1 Sun Jul 7 19:03:43 2002 +++ pear/PECL/soap/php_packet_soap.c Sun Jul 7 21:23:06 2002 @@ -1,124 +1,124 @@ -#include "php_soap.h" - -int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctionPtr fn, char *fn_name, zval ***ret, int *num_params) -{ - xmlDocPtr response; - xmlNodePtr trav, trav2, env, body, resp, cur, fault; - zval **tmp_ret; - TSRMLS_FETCH(); - - response = xmlParseMemory(buffer, buffer_size); - xmlCleanupParser(); - - trav = response->children; - FOREACHNODE(trav,"Envelope",env) - { - trav2 = env->children; - FOREACHNODE(trav2,"Body",body) - { - fault = get_node(body->children,"Fault"); - if(fault != NULL) - { - char *faultcode = NULL, *faultstring = NULL, *faultactor = NULL; - zval *details = NULL; - xmlNodePtr tmp; - - tmp = get_node(fault->children,"faultcode"); - if(tmp != NULL && tmp->children != NULL) - faultcode = tmp->children->content; - - tmp = get_node(fault->children,"faultstring"); - if(tmp != NULL && tmp->children != NULL) - faultstring = tmp->children->content; - - tmp = get_node(fault->children,"faultactor"); - if(tmp != NULL && tmp->children != NULL) - faultactor = tmp->children->content; - - tmp = get_node(fault->children,"detail"); - if(tmp != NULL) - { - encodePtr enc; - enc = get_conversion(UNKNOWN_TYPE); - details = enc->to_zval(enc->details, tmp); - } - - add_soap_fault(this_ptr, faultcode, faultstring, faultactor, details); - } - else - { - resp = body->children; - if(fn != NULL) - { - cur = get_node(resp, fn->responseName); - if(cur != NULL) - { - int num_resp = zend_hash_num_elements(fn->responseParameters); - if(num_resp <= 1) - { - sdlParamPtr *h_param, param; - xmlNodePtr val; - - zend_hash_internal_pointer_reset(fn->responseParameters); - if(zend_hash_get_current_data(fn->responseParameters, (void **)&h_param) != SUCCESS) - { - (*num_params) = 0; - } - else - { - 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); - } - } - else - { - php_error(E_ERROR,"Doesn't handle multiple return values"); - } - } - } - else - { - cur = resp; - while(cur && cur->type != XML_ELEMENT_NODE) - cur = cur->next; - if(cur != NULL) - { - xmlNodePtr val; - val = cur->children; - while(val && val->type != XML_ELEMENT_NODE) - val = val->next; - - if(val != NULL) - { - encodePtr enc; - enc = get_conversion(UNKNOWN_TYPE); - tmp_ret = emalloc(sizeof(zval **)); - tmp_ret[0] = master_to_zval(enc, val); - (*ret) = tmp_ret; - (*num_params) = 1; - } - } - } - } - } - ENDFOREACH(trav2); - } - ENDFOREACH(trav); - xmlFreeDoc(response); - return TRUE; -} +#include "php_soap.h" + +int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctionPtr fn, char *fn_name, zval ***ret, int *num_params) +{ + xmlDocPtr response; + xmlNodePtr trav, trav2, env, body, resp, cur, fault; + zval **tmp_ret; + TSRMLS_FETCH(); + + response = xmlParseMemory(buffer, buffer_size); + xmlCleanupParser(); + + trav = response->children; + FOREACHNODE(trav,"Envelope",env) + { + trav2 = env->children; + FOREACHNODE(trav2,"Body",body) + { + fault = get_node(body->children,"Fault"); + if(fault != NULL) + { + char *faultcode = NULL, *faultstring = NULL, *faultactor = NULL; + zval *details = NULL; + xmlNodePtr tmp; + + tmp = get_node(fault->children,"faultcode"); + if(tmp != NULL && tmp->children != NULL) + faultcode = tmp->children->content; + + tmp = get_node(fault->children,"faultstring"); + if(tmp != NULL && tmp->children != NULL) + faultstring = tmp->children->content; + + tmp = get_node(fault->children,"faultactor"); + if(tmp != NULL && tmp->children != NULL) + faultactor = tmp->children->content; + + tmp = get_node(fault->children,"detail"); + if(tmp != NULL) + { + encodePtr enc; + enc = get_conversion(UNKNOWN_TYPE); + details = enc->to_zval(enc->details, tmp); + } + + add_soap_fault(this_ptr, faultcode, faultstring, faultactor, details); + } + else + { + resp = body->children; + if(fn != NULL) + { + cur = get_node(resp, fn->responseName); + if(cur != NULL) + { + int num_resp = zend_hash_num_elements(fn->responseParameters); + if(num_resp <= 1) + { + sdlParamPtr *h_param, param; + xmlNodePtr val; + + zend_hash_internal_pointer_reset(fn->responseParameters); + if(zend_hash_get_current_data(fn->responseParameters, (void **)&h_param) != SUCCESS) + { + (*num_params) = 0; + } + else + { + 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); + } + } + else + { + php_error(E_ERROR,"Doesn't handle multiple return values"); + } + } + } + else + { + cur = resp; + while(cur && cur->type != XML_ELEMENT_NODE) + cur = cur->next; + if(cur != NULL) + { + xmlNodePtr val; + val = cur->children; + while(val && val->type != XML_ELEMENT_NODE) + val = val->next; + + if(val != NULL) + { + encodePtr enc; + enc = get_conversion(UNKNOWN_TYPE); + tmp_ret = emalloc(sizeof(zval **)); + tmp_ret[0] = master_to_zval(enc, val); + (*ret) = tmp_ret; + (*num_params) = 1; + } + } + } + } + } + ENDFOREACH(trav2); + } + ENDFOREACH(trav); + xmlFreeDoc(response); + return TRUE; +} Index: pear/PECL/soap/php_packet_soap.h diff -u pear/PECL/soap/php_packet_soap.h:1.1 pear/PECL/soap/php_packet_soap.h:1.2 --- pear/PECL/soap/php_packet_soap.h:1.1 Sun Jul 7 19:03:43 2002 +++ pear/PECL/soap/php_packet_soap.h Sun Jul 7 21:23:06 2002 @@ -1,6 +1,6 @@ -#ifndef PHP_PACKET_SOAP_H -#define PHP_PACKET_SOAP_H - -int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctionPtr fn, char *fn_name, zval ***ret, int *num_params); - +#ifndef PHP_PACKET_SOAP_H +#define PHP_PACKET_SOAP_H + +int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctionPtr fn, char *fn_name, zval ***ret, int *num_params); + #endif Index: pear/PECL/soap/php_schema.c diff -u pear/PECL/soap/php_schema.c:1.1 pear/PECL/soap/php_schema.c:1.2 --- pear/PECL/soap/php_schema.c:1.1 Sun Jul 7 19:03:43 2002 +++ pear/PECL/soap/php_schema.c Sun Jul 7 21:23:06 2002 @@ -24,13 +24,13 @@ xmlNodePtr trav, element, compType, simpleType, attribute; xmlAttrPtr tns; - if(!(*sdl)->types) + if(!(*sdl)->types) { (*sdl)->types = malloc(sizeof(HashTable)); - zend_hash_init((*sdl)->types, 0, NULL, delete_type, 1); + zend_hash_init((*sdl)->types, 0, NULL, delete_type, 1); } - - tns = get_attribute(schema->properties, "targetNamespace"); + + tns = get_attribute(schema->properties, "targetNamespace"); trav = schema->children; FOREACHNODE(trav,"complexType",compType) @@ -323,10 +323,10 @@ { schema_sequence(sdl, tsn, trav, cur_type); return TRUE; - } - else if(!strcmp(trav->name, "attribute")) - { - schema_attribute(sdl, tsn, trav, cur_type); + } + else if(!strcmp(trav->name, "attribute")) + { + schema_attribute(sdl, tsn, trav, cur_type); } } }while(trav = trav->next); @@ -946,102 +946,102 @@ */ int schema_attribute(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdlTypePtr cur_type) { - xmlAttrPtr attr; - sdlAttributePtr newAttr; - xmlAttrPtr trav; - smart_str key = {0}; - - newAttr = malloc(sizeof(sdlAttribute)); - memset(newAttr, 0, sizeof(sdlAttribute)); - - if(cur_type->attributes == NULL) - { - cur_type->attributes = malloc(sizeof(HashTable)); - zend_hash_init(cur_type->attributes, 0, NULL, delete_attribute, 1); - } - - trav = attrType->properties; - FOREACHATTRNODE(trav, NULL, attr) - { - if(attr_is_equal_ex(trav, "default", SCHEMA_NAMESPACE)) - newAttr->def = strdup(attr->children->content); - else if(attr_is_equal_ex(trav, "fixed", SCHEMA_NAMESPACE)) - newAttr->fixed = strdup(attr->children->content); - else if(attr_is_equal_ex(trav, "form", SCHEMA_NAMESPACE)) - newAttr->form = strdup(attr->children->content); - else if(attr_is_equal_ex(trav, "id", SCHEMA_NAMESPACE)) - newAttr->id = strdup(attr->children->content); - else if(attr_is_equal_ex(trav, "name", SCHEMA_NAMESPACE)) - newAttr->name = strdup(attr->children->content); - else if(attr_is_equal_ex(trav, "ref", SCHEMA_NAMESPACE)) - newAttr->ref= strdup(attr->children->content); - else if(attr_is_equal_ex(trav, "type", SCHEMA_NAMESPACE)) - newAttr->type = strdup(attr->children->content); - else if(attr_is_equal_ex(trav, "use", SCHEMA_NAMESPACE)) - newAttr->use = strdup(attr->children->content); - else - { - xmlNsPtr nsPtr = attr_find_ns(trav); - - if(strcmp(nsPtr->href, SCHEMA_NAMESPACE)) - { - smart_str key2 = {0}; - - if(!newAttr->extraAttributes) - { - newAttr->extraAttributes = malloc(sizeof(HashTable)); - zend_hash_init(newAttr->extraAttributes, 0, NULL, NULL, 1); - } - - smart_str_appends(&key2, nsPtr->href); - smart_str_appendc(&key2, ':'); - smart_str_appends(&key2, trav->name); - smart_str_0(&key2); - zend_hash_add(newAttr->extraAttributes, key2.c, key2.len + 1, &trav, sizeof(xmlAttrPtr), NULL); - smart_str_free(&key2); - } - } - } - ENDFOREACH(trav); - - - if(newAttr->ref || newAttr->name) - { - xmlNsPtr ns; - - if(newAttr->ref) - { - char *value, *prefix = NULL; - - parse_namespace(newAttr->ref, &value, &prefix); - ns = xmlSearchNs(attrType->doc, attrType, prefix); - smart_str_appends(&key, ns->href); - smart_str_appendc(&key, ':'); - smart_str_appends(&key, value); - - if(value) - efree(value); - if(prefix) - efree(prefix); - } - else - { - ns = node_find_ns(attrType); - smart_str_appends(&key, ns->href); - smart_str_appendc(&key, ':'); - smart_str_appends(&key, newAttr->name); - } - - - if(ns) - { - smart_str_0(&key); - zend_hash_add(cur_type->attributes, key.c, key.len + 1, &newAttr, sizeof(sdlAttributePtr), NULL); - smart_str_free(&key); - return TRUE; - } - } - - zend_hash_next_index_insert(cur_type->attributes, &newAttr, sizeof(sdlAttributePtr), NULL); + xmlAttrPtr attr; + sdlAttributePtr newAttr; + xmlAttrPtr trav; + smart_str key = {0}; + + newAttr = malloc(sizeof(sdlAttribute)); + memset(newAttr, 0, sizeof(sdlAttribute)); + + if(cur_type->attributes == NULL) + { + cur_type->attributes = malloc(sizeof(HashTable)); + zend_hash_init(cur_type->attributes, 0, NULL, delete_attribute, 1); + } + + trav = attrType->properties; + FOREACHATTRNODE(trav, NULL, attr) + { + if(attr_is_equal_ex(trav, "default", SCHEMA_NAMESPACE)) + newAttr->def = strdup(attr->children->content); + else if(attr_is_equal_ex(trav, "fixed", SCHEMA_NAMESPACE)) + newAttr->fixed = strdup(attr->children->content); + else if(attr_is_equal_ex(trav, "form", SCHEMA_NAMESPACE)) + newAttr->form = strdup(attr->children->content); + else if(attr_is_equal_ex(trav, "id", SCHEMA_NAMESPACE)) + newAttr->id = strdup(attr->children->content); + else if(attr_is_equal_ex(trav, "name", SCHEMA_NAMESPACE)) + newAttr->name = strdup(attr->children->content); + else if(attr_is_equal_ex(trav, "ref", SCHEMA_NAMESPACE)) + newAttr->ref= strdup(attr->children->content); + else if(attr_is_equal_ex(trav, "type", SCHEMA_NAMESPACE)) + newAttr->type = strdup(attr->children->content); + else if(attr_is_equal_ex(trav, "use", SCHEMA_NAMESPACE)) + newAttr->use = strdup(attr->children->content); + else + { + xmlNsPtr nsPtr = attr_find_ns(trav); + + if(strcmp(nsPtr->href, SCHEMA_NAMESPACE)) + { + smart_str key2 = {0}; + + if(!newAttr->extraAttributes) + { + newAttr->extraAttributes = malloc(sizeof(HashTable)); + zend_hash_init(newAttr->extraAttributes, 0, NULL, NULL, 1); + } + + smart_str_appends(&key2, nsPtr->href); + smart_str_appendc(&key2, ':'); + smart_str_appends(&key2, trav->name); + smart_str_0(&key2); + zend_hash_add(newAttr->extraAttributes, key2.c, key2.len + 1, &trav, sizeof(xmlAttrPtr), NULL); + smart_str_free(&key2); + } + } + } + ENDFOREACH(trav); + + + if(newAttr->ref || newAttr->name) + { + xmlNsPtr ns; + + if(newAttr->ref) + { + char *value, *prefix = NULL; + + parse_namespace(newAttr->ref, &value, &prefix); + ns = xmlSearchNs(attrType->doc, attrType, prefix); + smart_str_appends(&key, ns->href); + smart_str_appendc(&key, ':'); + smart_str_appends(&key, value); + + if(value) + efree(value); + if(prefix) + efree(prefix); + } + else + { + ns = node_find_ns(attrType); + smart_str_appends(&key, ns->href); + smart_str_appendc(&key, ':'); + smart_str_appends(&key, newAttr->name); + } + + + if(ns) + { + smart_str_0(&key); + zend_hash_add(cur_type->attributes, key.c, key.len + 1, &newAttr, sizeof(sdlAttributePtr), NULL); + smart_str_free(&key); + return TRUE; + } + } + + zend_hash_next_index_insert(cur_type->attributes, &newAttr, sizeof(sdlAttributePtr), NULL); return TRUE; } Index: pear/PECL/soap/php_sdl.c diff -u pear/PECL/soap/php_sdl.c:1.1 pear/PECL/soap/php_sdl.c:1.2 --- pear/PECL/soap/php_sdl.c:1.1 Sun Jul 7 19:03:43 2002 +++ pear/PECL/soap/php_sdl.c Sun Jul 7 21:23:06 2002 @@ -94,134 +94,134 @@ xmlNodePtr ret; ret = xmlNewNode(NULL, "BOGUS"); - type = enc.sdl_type; - - if(type->encode->details.type == IS_ARRAY || - type->encode->details.type == SOAP_ENC_ARRAY) - { - ret = sdl_to_xml_array(type, data); + type = enc.sdl_type; + + if(type->encode->details.type == IS_ARRAY || + type->encode->details.type == SOAP_ENC_ARRAY) + { + ret = sdl_to_xml_array(type, data); } else if(type->encode != NULL) { ret = master_to_xml(type->encode, data); - } - else if(type->elements != NULL) - { - ret = sdl_to_xml_object(type, data); - } - else - { - ret = guess_xml_convert(enc, data); + } + else if(type->elements != NULL) + { + ret = sdl_to_xml_object(type, data); + } + else + { + ret = guess_xml_convert(enc, data); } //set_ns_and_type(ret, enc); return ret; } - -xmlNodePtr sdl_to_xml_object(sdlTypePtr type, zval *data) -{ - xmlNodePtr ret; - sdlTypePtr *t, tmp; - - ret = xmlNewNode(NULL, "BOGUS"); - - zend_hash_internal_pointer_reset(type->elements); - while(zend_hash_get_current_data(type->elements, (void **)&t) != FAILURE) - { - zval **prop; - tmp = *t; - if(zend_hash_find(Z_OBJPROP_P(data), tmp->name, strlen(tmp->name) + 1, (void **)&prop) == FAILURE) - { - if(tmp->nullable == FALSE) - php_error(E_ERROR, "Error encoding object to xml missing property \"%s\"", tmp->name); - } - else - { - xmlNodePtr newNode; - - newNode = master_to_xml(tmp->encode, (*prop)); - xmlNodeSetName(newNode, tmp->name); - xmlAddChild(ret, newNode); - } - zend_hash_move_forward(type->elements); - } - - return ret; -} - -xmlNodePtr sdl_to_xml_array(sdlTypePtr type, zval *data) -{ - smart_str array_type_and_size = {0}, array_type = {0}; - int i; - xmlNodePtr xmlParam; - TSRMLS_FETCH(); - - xmlParam = xmlNewNode(NULL,"BOGUS"); - - FIND_ZVAL_NULL(data, xmlParam); - - if(Z_TYPE_P(data) == IS_ARRAY) - { - 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) - { - 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 - { - 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); - - smart_str_free(&array_type_and_size); - smart_str_free(&array_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)); - - xmlNodeSetName(xparam, "val"); - xmlAddChild(xmlParam, xparam); - zend_hash_move_forward(data->value.ht); - } - } - set_ns_and_type_ex(xmlParam, type->namens, type->name); - return xmlParam; -} + +xmlNodePtr sdl_to_xml_object(sdlTypePtr type, zval *data) +{ + xmlNodePtr ret; + sdlTypePtr *t, tmp; + + ret = xmlNewNode(NULL, "BOGUS"); + + zend_hash_internal_pointer_reset(type->elements); + while(zend_hash_get_current_data(type->elements, (void **)&t) != FAILURE) + { + zval **prop; + tmp = *t; + if(zend_hash_find(Z_OBJPROP_P(data), tmp->name, strlen(tmp->name) + 1, (void **)&prop) == FAILURE) + { + if(tmp->nullable == FALSE) + php_error(E_ERROR, "Error encoding object to xml missing property \"%s\"", tmp->name); + } + else + { + xmlNodePtr newNode; + + newNode = master_to_xml(tmp->encode, (*prop)); + xmlNodeSetName(newNode, tmp->name); + xmlAddChild(ret, newNode); + } + zend_hash_move_forward(type->elements); + } + + return ret; +} + +xmlNodePtr sdl_to_xml_array(sdlTypePtr type, zval *data) +{ + smart_str array_type_and_size = {0}, array_type = {0}; + int i; + xmlNodePtr xmlParam; + TSRMLS_FETCH(); + + xmlParam = xmlNewNode(NULL,"BOGUS"); + + FIND_ZVAL_NULL(data, xmlParam); + + if(Z_TYPE_P(data) == IS_ARRAY) + { + 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) + { + 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 + { + 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); + + smart_str_free(&array_type_and_size); + smart_str_free(&array_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)); + + xmlNodeSetName(xparam, "val"); + xmlAddChild(xmlParam, xparam); + zend_hash_move_forward(data->value.ht); + } + } + set_ns_and_type_ex(xmlParam, type->namens, type->name); + return xmlParam; +} zval *sdl_convert_zval(encodeType enc, xmlNodePtr data) { @@ -455,12 +455,12 @@ tmpsdl->source = strdup(struri); - wsdl = xmlParseFile(struri); - xmlCleanupParser(); + wsdl = xmlParseFile(struri); + xmlCleanupParser(); if(!wsdl) php_error(E_ERROR, "Error parsing wsdl file"); - + tmpsdl->doc = wsdl; root = wsdl->children; definitions = get_node(root, "definitions"); @@ -885,31 +885,31 @@ 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->type) - free(attr->type); - if(attr->use) - free(attr->use); - if(attr->extraAttributes) - { - zend_hash_destroy(attr->extraAttributes); - free(attr->extraAttributes); - } +} + +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->type) + free(attr->type); + if(attr->use) + free(attr->use); + if(attr->extraAttributes) + { + zend_hash_destroy(attr->extraAttributes); + free(attr->extraAttributes); + } } Index: pear/PECL/soap/php_sdl.h diff -u pear/PECL/soap/php_sdl.h:1.1 pear/PECL/soap/php_sdl.h:1.2 --- pear/PECL/soap/php_sdl.h:1.1 Sun Jul 7 19:03:43 2002 +++ pear/PECL/soap/php_sdl.h Sun Jul 7 21:23:06 2002 @@ -6,7 +6,7 @@ #define XSD_WHITESPACE_REPLACE 1 struct _sdl -{ +{ xmlDocPtr doc; HashTable *functions; //array of SoapFunctionsPtr HashTable *types; //array of sdlTypesPtr @@ -71,23 +71,23 @@ int enabled; char *functionName; char *requestName; - char *responseName; + char *responseName; HashTable *requestParameters; //array of sdlParamPtr HashTable *responseParameters; //array of sdlParamPtr (this should only be one) char *soapAction; -}; - -struct _sdlAttribute -{ - char *def; - char *fixed; - char *form; - char *id; - char *name; - char *ref; - char *type; - char *use; - HashTable *extraAttributes; +}; + +struct _sdlAttribute +{ + char *def; + char *fixed; + char *form; + char *id; + char *name; + char *ref; + char *type; + char *use; + HashTable *extraAttributes; }; sdlPtr get_sdl(char *uri); @@ -102,11 +102,11 @@ encodePtr create_encoder(sdlPtr sdl, sdlTypePtr cur_type, char *ns, char *type); xmlNodePtr sdl_guess_convert_xml(encodeType enc, zval* data); - -xmlNodePtr sdl_to_xml_array(sdlTypePtr type, zval *data); -xmlNodePtr sdl_to_xml_object(sdlTypePtr type, zval *data); -void delete_type(void *type); +xmlNodePtr sdl_to_xml_array(sdlTypePtr type, zval *data); +xmlNodePtr sdl_to_xml_object(sdlTypePtr type, zval *data); + +void delete_type(void *type); void delete_attribute(void *attribute); #endif Index: pear/PECL/soap/php_soap.h diff -u pear/PECL/soap/php_soap.h:1.1 pear/PECL/soap/php_soap.h:1.2 --- pear/PECL/soap/php_soap.h:1.1 Sun Jul 7 19:03:43 2002 +++ pear/PECL/soap/php_soap.h Sun Jul 7 21:23:06 2002 @@ -49,7 +49,7 @@ typedef struct _sdlRestrictions sdlRestrictions, *sdlRestrictionsPtr; typedef struct _sdlType sdlType, *sdlTypePtr; typedef struct _sdlParam sdlParam, *sdlParamPtr; -typedef struct _sdlFunction sdlFunction, *sdlFunctionPtr; +typedef struct _sdlFunction sdlFunction, *sdlFunctionPtr; typedef struct _sdlAttribute sdlAttribute, *sdlAttributePtr; typedef struct _soapMapping soapMapping, *soapMappingPtr; @@ -59,7 +59,7 @@ #include "php_encoding.h" #include "php_sdl.h" #include "php_schema.h" -#include "php_http.h" +#include "php_http.h" #include "php_packet_soap.h" extern int le_sdl; @@ -185,7 +185,7 @@ PHP_FUNCTION(soapobject); PHP_FUNCTION(__isfault); PHP_FUNCTION(__getfault); -PHP_FUNCTION(__call); +PHP_FUNCTION(__call); PHP_FUNCTION(__parse); #ifdef PHP_DEBUG PHP_FUNCTION(__getfunctions); @@ -261,11 +261,11 @@ do \ { \ if(n == NULL) \ - break; \ + break; \ if(c) \ - i = get_attribute(n,c); \ - else \ - i = n; \ + i = get_attribute(n,c); \ + else \ + i = n; \ if(i != NULL) \ { \ n = i; @@ -274,10 +274,10 @@ do \ { \ if(n == NULL) \ - break; \ + break; \ if(c) \ - i = get_node(n,c); \ - else \ + i = get_node(n,c); \ + else \ i = n; \ if(i != NULL) \ { \ Index: pear/PECL/soap/php_xml.c diff -u pear/PECL/soap/php_xml.c:1.1 pear/PECL/soap/php_xml.c:1.2 --- pear/PECL/soap/php_xml.c:1.1 Sun Jul 7 19:03:43 2002 +++ pear/PECL/soap/php_xml.c Sun Jul 7 21:23:06 2002 @@ -1,71 +1,71 @@ #include "php_soap.h" - -xmlNsPtr attr_find_ns(xmlAttrPtr node) -{ - if(node->ns) - return node->ns; - else if(node->parent->ns) - return node->parent->ns; - else - return xmlSearchNs(node->doc, node->parent, NULL); -} - -xmlNsPtr node_find_ns(xmlNodePtr node) -{ - if(node->ns) - return node->ns; - else - return xmlSearchNs(node->doc, node, NULL); -} - -int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns) -{ - if(!strcmp(node->name, name)) - { - if(ns) - { - xmlNsPtr nsPtr; - if(node->ns) - nsPtr = node->ns; - else if(node->parent->ns) - nsPtr = node->parent->ns; - else - nsPtr = xmlSearchNs(node->doc, node->parent, NULL); - if(!strcmp(nsPtr->href, ns)) - return TRUE; - return FALSE; - } - return TRUE; - } - return FALSE; -} - -int node_is_equal_ex(xmlNodePtr node, char *name, char *ns) -{ - if(!strcmp(node->name, name)) - { - if(ns) - { - xmlNsPtr nsPtr; - if(node->ns) - nsPtr = node->ns; - else - nsPtr = xmlSearchNs(node->doc, node, NULL); - if(!strcmp(nsPtr->href, ns)) - return TRUE; - return FALSE; - } - return TRUE; - } - return FALSE; -} - + +xmlNsPtr attr_find_ns(xmlAttrPtr node) +{ + if(node->ns) + return node->ns; + else if(node->parent->ns) + return node->parent->ns; + else + return xmlSearchNs(node->doc, node->parent, NULL); +} + +xmlNsPtr node_find_ns(xmlNodePtr node) +{ + if(node->ns) + return node->ns; + else + return xmlSearchNs(node->doc, node, NULL); +} + +int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns) +{ + if(!strcmp(node->name, name)) + { + if(ns) + { + xmlNsPtr nsPtr; + if(node->ns) + nsPtr = node->ns; + else if(node->parent->ns) + nsPtr = node->parent->ns; + else + nsPtr = xmlSearchNs(node->doc, node->parent, NULL); + if(!strcmp(nsPtr->href, ns)) + return TRUE; + return FALSE; + } + return TRUE; + } + return FALSE; +} + +int node_is_equal_ex(xmlNodePtr node, char *name, char *ns) +{ + if(!strcmp(node->name, name)) + { + if(ns) + { + xmlNsPtr nsPtr; + if(node->ns) + nsPtr = node->ns; + else + nsPtr = xmlSearchNs(node->doc, node, NULL); + if(!strcmp(nsPtr->href, ns)) + return TRUE; + return FALSE; + } + return TRUE; + } + return FALSE; +} + xmlAttrPtr get_attribute_ex(xmlAttrPtr node, char *name, char *ns) { - xmlAttrPtr trav = node; + xmlAttrPtr trav = node; if(node == NULL) return NULL; - do { - if(attr_is_equal_ex(trav, name, ns)) + do { + if(attr_is_equal_ex(trav, name, ns)) return trav; } while(trav = trav->next); return NULL; @@ -75,7 +75,7 @@ { xmlNodePtr trav = node; if(node == NULL) return NULL; - do { + do { if(node_is_equal_ex(trav, name, ns)) return trav; } while(trav = trav->next); Index: pear/PECL/soap/php_xml.h diff -u pear/PECL/soap/php_xml.h:1.1 pear/PECL/soap/php_xml.h:1.2 --- pear/PECL/soap/php_xml.h:1.1 Sun Jul 7 19:03:43 2002 +++ pear/PECL/soap/php_xml.h Sun Jul 7 21:23:06 2002 @@ -1,17 +1,17 @@ #ifndef PHP_SOAP_XML_H #define PHP_SOAP_XML_H - -#define get_attribute(node, name) get_attribute_ex(node, name, NULL) -#define get_node(node, name) get_node_ex(node, name, NULL) -#define get_node_recursive(node, name) get_node_recursive_ex(node, name, NULL) -#define get_node_with_attribute(node, name, attr, val) get_node_with_attribute_ex(node, name, NULL, attr, val, NULL) -#define get_node_with_attribute_recursive(node, name, attr, val) get_node_with_attribute_recursive_ex(node, name, NULL, attr, val, NULL) -#define attr_is_equal(node, name) attr_is_equal_ex(node, name, NULL) - -xmlNsPtr attr_find_ns(xmlAttrPtr node); -xmlNsPtr node_find_ns(xmlNodePtr node); -int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns); -int node_is_equal_ex(xmlNodePtr node, char *name, char *ns); + +#define get_attribute(node, name) get_attribute_ex(node, name, NULL) +#define get_node(node, name) get_node_ex(node, name, NULL) +#define get_node_recursive(node, name) get_node_recursive_ex(node, name, NULL) +#define get_node_with_attribute(node, name, attr, val) get_node_with_attribute_ex(node, name, NULL, attr, val, NULL) +#define get_node_with_attribute_recursive(node, name, attr, val) get_node_with_attribute_recursive_ex(node, name, NULL, attr, val, NULL) +#define attr_is_equal(node, name) attr_is_equal_ex(node, name, NULL) + +xmlNsPtr attr_find_ns(xmlAttrPtr node); +xmlNsPtr node_find_ns(xmlNodePtr node); +int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns); +int node_is_equal_ex(xmlNodePtr node, char *name, char *ns); xmlAttrPtr get_attribute_ex(xmlAttrPtr node,char *name, char *ns); xmlNodePtr get_node_ex(xmlNodePtr node,char *name, char *ns); xmlNodePtr get_node_recurisve_ex(xmlNodePtr node,char *name, char *ns); Index: pear/PECL/soap/soap.c diff -u pear/PECL/soap/soap.c:1.1 pear/PECL/soap/soap.c:1.2 --- pear/PECL/soap/soap.c:1.1 Sun Jul 7 19:03:43 2002 +++ pear/PECL/soap/soap.c Sun Jul 7 21:23:06 2002 @@ -50,7 +50,8 @@ PHP_FE(soapobject, NULL) PHP_FE(__isfault, NULL) PHP_FE(__getfault, NULL) - PHP_FE(__call, NULL) + PHP_FE(__call, NULL) + PHP_FE(__parse, NULL) #ifdef PHP_DEBUG PHP_FE(__getlastrequest, NULL) @@ -1139,39 +1140,72 @@ zend_list_addref(ret); } } -} - -PHP_FUNCTION(__parse) -{ - char *message, *function; - int message_len, function_len; - int num_params; - zval **ret_params; - sdlPtr sdl; - sdlFunctionPtr fn; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &message, &message_len, &function, &function_len) == FAILURE) - php_error(E_ERROR, "Invalid arguments to SoapObject->__parse"); - - FETCH_THIS_SDL(sdl); - - if(sdl != NULL) - { - fn = get_function(sdl, function); - if(fn != NULL) - parse_packet_soap(getThis(), message, message_len, fn, NULL, &ret_params, &num_params); - } - else - parse_packet_soap(getThis(), message, message_len, NULL, function, &ret_params, &num_params); - - if(num_params > 0) - { - *return_value = *ret_params[0]; - zval_add_ref(&return_value); - efree(ret_params); - } - else - ZVAL_NULL(return_value) +} + + + +PHP_FUNCTION(__parse) + +{ + + char *message, *function; + + int message_len, function_len; + + int num_params; + + zval **ret_params; + + sdlPtr sdl; + + sdlFunctionPtr fn; + + + + if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &message, &message_len, &function, &function_len) == FAILURE) + + php_error(E_ERROR, "Invalid arguments to SoapObject->__parse"); + + + + FETCH_THIS_SDL(sdl); + + + + if(sdl != NULL) + + { + + fn = get_function(sdl, function); + + if(fn != NULL) + + parse_packet_soap(getThis(), message, message_len, fn, NULL, &ret_params, &num_params); + + } + + else + + parse_packet_soap(getThis(), message, message_len, NULL, function, &ret_params, &num_params); + + + + if(num_params > 0) + + { + + *return_value = *ret_params[0]; + + zval_add_ref(&return_value); + + efree(ret_params); + + } + + else + + ZVAL_NULL(return_value) + } PHP_FUNCTION(__call) @@ -1183,8 +1217,10 @@ zval **param; xmlDocPtr request = NULL; int num_params, arg_count; - zval **ret_params; - char *buffer; + zval **ret_params; + + char *buffer; + int len; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa|ss", @@ -1206,13 +1242,17 @@ send_http_soap_request(getThis(), request, function, soap_action); xmlFreeDoc(request); - get_http_soap_response(getThis(), &buffer, &len); - parse_packet_soap(getThis(), buffer, len, NULL, function, &ret_params, &num_params); - efree(buffer); + get_http_soap_response(getThis(), &buffer, &len); + + parse_packet_soap(getThis(), buffer, len, NULL, function, &ret_params, &num_params); + + efree(buffer); + if(num_params > 0) { - *return_value = *ret_params[0]; + *return_value = *ret_params[0]; + zval_add_ref(&return_value); efree(ret_params); } @@ -1374,8 +1414,10 @@ if(fn != NULL) { int num_params; - zval **ret_params; - char *buffer; + zval **ret_params; + + char *buffer; + int len; request = seralize_function_call(fn, sdl->target_ns, NULL, arguments, arg_count); @@ -1384,9 +1426,12 @@ xmlFreeDoc(request); - get_http_soap_response(getThis(), &buffer, &len); - parse_packet_soap(getThis(), buffer, len, fn, NULL, &ret_params, &num_params); - efree(buffer); + get_http_soap_response(getThis(), &buffer, &len); + + parse_packet_soap(getThis(), buffer, len, fn, NULL, &ret_params, &num_params); + + efree(buffer); + if(num_params > 0) { @@ -1408,8 +1453,10 @@ zval **ret_params; zval **uri; smart_str *action; - char *buffer; - int len; + char *buffer; + + int len; + if(zend_hash_find(Z_OBJPROP_P(thisObj), "uri", sizeof("uri"), (void *)&uri) == FAILURE) php_error(E_ERROR, "Error finding uri in soap_call_function_handler"); @@ -1421,9 +1468,12 @@ smart_str_free(action); xmlFreeDoc(request); - get_http_soap_response(getThis(), &buffer, &len); - parse_packet_soap(getThis(), buffer, len, NULL, function, &ret_params, &num_params); - efree(buffer); + get_http_soap_response(getThis(), &buffer, &len); + + parse_packet_soap(getThis(), buffer, len, NULL, function, &ret_params, &num_params); + + efree(buffer); + if(num_params > 0) { @@ -1475,8 +1525,10 @@ zval_add_ref(&fault_detail); add_property_zval(obj, "detail", fault_detail); } -} - +} + + + void deseralize_function_call(sdlPtr sdl, xmlDocPtr request, zval *function_name, int *num_params, zval ***parameters) { xmlNodePtr trav,trav2,trav3,trav4,env,body; @@ -1555,8 +1607,10 @@ } ENDFOREACH(trav); } - - + + + + xmlDocPtr seralize_response_call(sdlFunctionPtr function, char *function_name, char *uri, zval *ret) { @@ -1855,7 +1909,8 @@ void delete_sdl(void *handle) { sdlPtr tmp = *((sdlPtr*)handle); - + + xmlFreeDoc(tmp->doc); if(tmp->source) free(tmp->source);
« previous php.pear.cvs (#4959) next »