summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/soap/php_schema.c6
-rw-r--r--ext/soap/php_sdl.c669
-rw-r--r--ext/soap/php_sdl.h6
-rw-r--r--ext/soap/soap.c2
4 files changed, 381 insertions, 302 deletions
diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c
index 1b0756e4d8..054b5085cc 100644
--- a/ext/soap/php_schema.c
+++ b/ext/soap/php_schema.c
@@ -124,7 +124,7 @@ static int schema_simpleType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr simpleType,
smart_str_0(&key);
}
- zend_hash_add(ht, key.c, key.len + 1, &newType, sizeof(sdlTypePtr), (void **)&ptr);
+ zend_hash_update(ht, key.c, key.len + 1, &newType, sizeof(sdlTypePtr), (void **)&ptr);
cur_type = (*ptr);
create_encoder((*sdl), cur_type, ns->children->content, name->children->content);
smart_str_free(&key);
@@ -783,7 +783,7 @@ static int schema_complexType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr compType,
smart_str_0(&key);
}
- zend_hash_add(ht, key.c, key.len + 1, &newType, sizeof(sdlTypePtr), (void **)&ptr);
+ zend_hash_update(ht, key.c, key.len + 1, &newType, sizeof(sdlTypePtr), (void **)&ptr);
cur_type = (*ptr);
create_encoder((*sdl), cur_type, ns->children->content, name->children->content);
smart_str_free(&key);
@@ -896,7 +896,7 @@ static int schema_element(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTy
}
smart_str_0(&key);
- zend_hash_add(addHash, key.c, key.len + 1, &newType, sizeof(sdlTypePtr), (void **)&tmp);
+ zend_hash_update(addHash, key.c, key.len + 1, &newType, sizeof(sdlTypePtr), (void **)&tmp);
cur_type = (*tmp);
/*
create_encoder((*sdl), cur_type, ns->children->content, name->children->content);
diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c
index cb927224e9..43e3615169 100644
--- a/ext/soap/php_sdl.c
+++ b/ext/soap/php_sdl.c
@@ -439,7 +439,7 @@ sdlPtr get_sdl(char *uri)
tmp = NULL;
hndl = NULL;
if (zend_hash_find(SOAP_GLOBAL(sdls), uri, strlen(uri), (void **)&hndl) == FAILURE) {
- tmp = load_wsdl(uri, NULL);
+ tmp = load_wsdl(uri);
zend_hash_add(SOAP_GLOBAL(sdls), uri, strlen(uri), &tmp, sizeof(sdlPtr), NULL);
} else {
tmp = *hndl;
@@ -633,22 +633,20 @@ int write_php_sdl()
return TRUE;
}
-sdlPtr load_wsdl(char *struri, sdlPtr parent)
+typedef struct sdlCtx {
+ sdlPtr root;
+ HashTable messages;
+ HashTable bindings;
+ HashTable portTypes;
+ HashTable services;
+} sdlCtx;
+
+static void load_wsdl_ex(char *struri, sdlCtx *ctx)
{
+ sdlPtr tmpsdl = ctx->root;
xmlDocPtr wsdl;
- xmlNodePtr root, definitions, types, binding, schema, service, import;
- xmlNodePtr trav, trav2, trav3;
+ xmlNodePtr root, definitions, trav;
xmlAttrPtr targetNamespace;
- sdlPtr tmpsdl;
- TSRMLS_FETCH();
-
- if (!parent) {
- tmpsdl = malloc(sizeof(sdl));
- memset(tmpsdl, 0, sizeof(sdl));
- tmpsdl->source = strdup(struri);
- } else {
- tmpsdl = parent;
- }
/* TODO: WSDL Caching */
@@ -659,11 +657,12 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent)
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Couldn't load from %s", struri);
}
- tmpsdl->doc = wsdl;
+ zend_hash_next_index_insert(&tmpsdl->docs, (void**)&wsdl, sizeof(xmlDocPtr), NULL);
+
root = wsdl->children;
definitions = get_node(root, "definitions");
if (!definitions) {
- php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Couldn't find definitions in %s", struri);
+ php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Couldn't find \"definitions\" in %s", struri);
}
targetNamespace = get_attribute(definitions->properties, "targetNamespace");
@@ -671,385 +670,465 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent)
tmpsdl->target_ns = strdup(targetNamespace->children->content);
}
- types = get_node(definitions->children, "types");
- if (types) {
- trav = types->children;
- FOREACHNODE(trav, "schema", schema) {
- load_schema(&tmpsdl, schema);
- }
- ENDFOREACH(trav);
- }
-
trav = definitions->children;
- FOREACHNODE(trav, "import", import) {
- xmlAttrPtr tmp = get_attribute(import->properties, "location");
- if (tmp) {
- load_wsdl(tmp->children->content, tmpsdl);
- }
- }
- ENDFOREACH(trav);
+ while (trav != NULL) {
+ if (trav->type == XML_ELEMENT_NODE) {
+ if (strcmp(trav->name,"types") == 0) {
+ /* TODO: Only one "types" is allowed */
+ xmlNodePtr trav2 = trav->children;
+ xmlNodePtr schema;
+ FOREACHNODE(trav2, "schema", schema) {
+ load_schema(&tmpsdl, schema);
+ }
+ ENDFOREACH(trav2);
- service = get_node(definitions->children, "service");
- if (service != NULL) {
- xmlAttrPtr name;
- xmlNodePtr trav, port;
+ } else if (strcmp(trav->name,"import") == 0) {
+ /* TODO: namespace ??? */
+ xmlAttrPtr tmp = get_attribute(trav->properties, "location");
+ if (tmp) {
+ load_wsdl_ex(tmp->children->content, ctx);
+ }
- name = get_attribute(service->properties, "name");
- if (!name) {
- php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No name associated with service");
- }
+ } else if (strcmp(trav->name,"message") == 0) {
+ xmlAttrPtr name = get_attribute(trav->properties, "name");
+ if (name && name->children && name->children->content) {
+ zend_hash_add(&ctx->messages, name->children->content, strlen(name->children->content)+1,&trav, sizeof(xmlNodePtr), NULL);
+ /* TODO: redeclaration handling */
+ } else {
+ php_error(E_ERROR,"SOAP-ERROR: Parsing WSDL: <message> hasn't name attribute");
+ }
- trav = service->children;
- FOREACHNODE(trav, "port", port) {
- xmlAttrPtr type, name, bindingAttr, location;
- xmlNodePtr portType, operation;
- xmlNodePtr address;
- char *ns, *ctype;
- sdlBindingPtr tmpbinding;
+ } else if (strcmp(trav->name,"portType") == 0) {
+ xmlAttrPtr name = get_attribute(trav->properties, "name");
+ if (name && name->children && name->children->content) {
+ zend_hash_add(&ctx->portTypes, name->children->content, strlen(name->children->content)+1,&trav, sizeof(xmlNodePtr), NULL);
+ /* TODO: redeclaration handling */
+ } else {
+ php_error(E_ERROR,"SOAP-ERROR: Parsing WSDL: <portType> hasn't name attribute");
+ }
- tmpbinding = malloc(sizeof(sdlBinding));
- memset(tmpbinding, 0, sizeof(sdlBinding));
+ } else if (strcmp(trav->name,"binding") == 0) {
+ xmlAttrPtr name = get_attribute(trav->properties, "name");
+ if (name && name->children && name->children->content) {
+ zend_hash_add(&ctx->bindings, name->children->content, strlen(name->children->content)+1,&trav, sizeof(xmlNodePtr), NULL);
+ /* TODO: redeclaration handling */
+ } else {
+ php_error(E_ERROR,"SOAP-ERROR: Parsing WSDL: <binding> hasn't name attribute");
+ }
- name = get_attribute(port->properties, "name");
- if (!name) {
- php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No name associated with port");
- }
+ } else if (strcmp(trav->name,"service") == 0) {
+ xmlAttrPtr name = get_attribute(trav->properties, "name");
+ if (name && name->children && name->children->content) {
+ zend_hash_add(&ctx->services, name->children->content, strlen(name->children->content)+1,&trav, sizeof(xmlNodePtr), NULL);
+ /* TODO: redeclaration handling */
+ } else {
+ php_error(E_ERROR,"SOAP-ERROR: Parsing WSDL: <service> hasn't name attribute");
+ }
- bindingAttr = get_attribute(port->properties, "binding");
- if (bindingAttr == NULL) {
- php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No binding associated with port");
+ } else {
+ /* TODO: extensibility elements */
}
+ }
+ trav = trav->next;
+ }
+}
- /* find address and figure out binding type */
- address = get_node(port->children, "address");
- if (!address) {
- php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No address associated with port");
- }
+sdlPtr load_wsdl(char *struri)
+{
+ sdlCtx ctx;
+ int i,n;
- location = get_attribute(address->properties, "location");
- if (!location) {
- php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No location associated with port");
- }
+ ctx.root = malloc(sizeof(sdl));
+ memset(ctx.root, 0, sizeof(sdl));
+ ctx.root->source = strdup(struri);
+ zend_hash_init(&ctx.root->docs, 0, NULL, xmlFreeDoc, 1);
- tmpbinding->location = strdup(location->children->content);
+ zend_hash_init(&ctx.messages, 0, NULL, NULL, 0);
+ zend_hash_init(&ctx.bindings, 0, NULL, NULL, 0);
+ zend_hash_init(&ctx.portTypes, 0, NULL, NULL, 0);
+ zend_hash_init(&ctx.services, 0, NULL, NULL, 0);
- if (address->ns && !strcmp(address->ns->href, WSDL_SOAP_NAMESPACE)) {
- tmpbinding->bindingType = BINDING_SOAP;
- } else if (address->ns && !strcmp(address->ns->href, WSDL_HTTP_NAMESPACE)) {
- tmpbinding->bindingType = BINDING_HTTP;
- }
+ load_wsdl_ex(struri,&ctx);
- parse_namespace(bindingAttr->children->content, &ctype, &ns);
- binding = get_node_with_attribute(definitions->children, "binding", "name", ctype);
+ n = zend_hash_num_elements(&ctx.services);
+ if (n > 0) {
+ zend_hash_internal_pointer_reset(&ctx.services);
+ for (i = 0; i < n; i++) {
+ xmlNodePtr *tmp, service;
+ xmlAttrPtr name;
+ xmlNodePtr trav, port;
- if (!binding) {
- php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No binding element with name \"%s\"", ctype);
+ zend_hash_get_current_data(&ctx.services, (void **)&tmp);
+ service = *tmp;
+
+ name = get_attribute(service->properties, "name");
+ if (!name) {
+ php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No name associated with service");
}
- if (ns) {efree(ns);}
- if (ctype) {efree(ctype);}
+ trav = service->children;
+ FOREACHNODE(trav, "port", port) {
+ xmlAttrPtr type, name, bindingAttr, location;
+ xmlNodePtr portType, operation;
+ xmlNodePtr address, binding, trav2;
+ char *ns, *ctype;
+ sdlBindingPtr tmpbinding;
- if (tmpbinding->bindingType == BINDING_SOAP) {
- sdlSoapBindingPtr soapBinding;
- xmlNodePtr soapBindingNode;
- xmlAttrPtr tmp;
+ tmpbinding = malloc(sizeof(sdlBinding));
+ memset(tmpbinding, 0, sizeof(sdlBinding));
- soapBinding = malloc(sizeof(sdlSoapBinding));
- memset(soapBinding, 0, sizeof(sdlSoapBinding));
+ name = get_attribute(port->properties, "name");
+ if (!name) {
+ php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No name associated with port");
+ }
- soapBindingNode = get_node_ex(binding->children, "binding", WSDL_SOAP_NAMESPACE);
- if (soapBindingNode) {
- tmp = get_attribute(soapBindingNode->properties, "style");
- if (tmp && !strcmp(tmp->children->content, "document")) {
- soapBinding->style = SOAP_DOCUMENT;
- } else {
- soapBinding->style = SOAP_RPC;
- }
+ bindingAttr = get_attribute(port->properties, "binding");
+ if (bindingAttr == NULL) {
+ php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No binding associated with port");
+ }
- tmp = get_attribute(soapBindingNode->properties, "transport");
- if (tmp) {
- if (strcmp(tmp->children->content, WSDL_HTTP_TRANSPORT)) {
- php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: PHP-SOAP doesn't support transport '%s'", tmp->children->content);
- }
- soapBinding->transport = strdup(tmp->children->content);
- }
- tmpbinding->bindingAttributes = (void *)soapBinding;
+ /* find address and figure out binding type */
+ address = get_node(port->children, "address");
+ if (!address) {
+ php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No address associated with port");
}
- }
- name = get_attribute(binding->properties, "name");
- if (name == NULL) {
- php_error(E_ERROR, "Error parsing wsdl (Missing \"name\" attribute for \"binding\")");
- }
+ location = get_attribute(address->properties, "location");
+ if (!location) {
+ php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No location associated with port");
+ }
- tmpbinding->name = strdup(name->children->content);
+ tmpbinding->location = strdup(location->children->content);
- type = get_attribute(binding->properties, "type");
- if (type == NULL) {
- php_error(E_ERROR, "Error parsing wsdl (Missing \"type\" attribute for \"binding\")");
- }
- parse_namespace(type->children->content, &ctype, &ns);
- portType = get_node_with_attribute(definitions->children, "portType", "name", ctype);
- if (portType == NULL) {
- php_error(E_ERROR, "Error parsing wsdl (Missing \"portType\" with name \"%s\")", name->children->content);
- }
- if (ctype) {efree(ctype);}
- if (ns) {efree(ns);}
-
- trav2 = binding->children;
- FOREACHNODE(trav2, "operation", operation) {
- sdlFunctionPtr function;
- xmlNodePtr input, output, fault, portTypeOperation, portTypeInput, msgInput, msgOutput;
- xmlAttrPtr op_name, paramOrder;
-
- op_name = get_attribute(operation->properties, "name");
- if (op_name == NULL) {
- php_error(E_ERROR, "Error parsing wsdl (Missing \"name\" attribute for \"operation\")");
+ if (address->ns && !strcmp(address->ns->href, WSDL_SOAP_NAMESPACE)) {
+ tmpbinding->bindingType = BINDING_SOAP;
+ } else if (address->ns && !strcmp(address->ns->href, WSDL_HTTP_NAMESPACE)) {
+ tmpbinding->bindingType = BINDING_HTTP;
}
- portTypeOperation = get_node_with_attribute(portType->children, "operation", "name", op_name->children->content);
- if (portTypeOperation == NULL) {
- php_error(E_ERROR, "Error parsing wsdl (Missing \"portType/operation\" with name \"%s\")", op_name->children->content);
+ parse_namespace(bindingAttr->children->content, &ctype, &ns);
+ if (zend_hash_find(&ctx.bindings, ctype, strlen(ctype)+1, (void*)&tmp) != SUCCESS) {
+ php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No binding element with name \"%s\"", ctype);
}
+ binding = *tmp;
- function = malloc(sizeof(sdlFunction));
- function->functionName = strdup(op_name->children->content);
- function->requestParameters = NULL;
- function->responseParameters = NULL;
- function->responseName = NULL;
- function->bindingAttributes = NULL;
- function->bindingType = tmpbinding->bindingType;
+ if (ns) {efree(ns);}
+ if (ctype) {efree(ctype);}
if (tmpbinding->bindingType == BINDING_SOAP) {
- sdlSoapBindingFunctionPtr soapFunctionBinding;
sdlSoapBindingPtr soapBinding;
- xmlNodePtr soapOperation;
+ xmlNodePtr soapBindingNode;
xmlAttrPtr tmp;
- soapFunctionBinding = malloc(sizeof(sdlSoapBindingFunction));
- memset(soapFunctionBinding, 0, sizeof(sdlSoapBindingFunction));
- soapBinding = (sdlSoapBindingPtr)tmpbinding->bindingAttributes;
- soapFunctionBinding->style = soapBinding->style;
+ soapBinding = malloc(sizeof(sdlSoapBinding));
+ memset(soapBinding, 0, sizeof(sdlSoapBinding));
- soapOperation = get_node_ex(operation->children, "operation", WSDL_SOAP_NAMESPACE);
- if (soapOperation) {
- tmp = get_attribute(soapOperation->properties, "soapAction");
- if (tmp) {
- soapFunctionBinding->soapAction = strdup(tmp->children->content);
+ soapBindingNode = get_node_ex(binding->children, "binding", WSDL_SOAP_NAMESPACE);
+ if (soapBindingNode) {
+ tmp = get_attribute(soapBindingNode->properties, "style");
+ if (tmp && !strcmp(tmp->children->content, "document")) {
+ soapBinding->style = SOAP_DOCUMENT;
+ } else {
+ soapBinding->style = SOAP_RPC;
}
- tmp = get_attribute(soapOperation->properties, "style");
- if (tmp && !strcmp(tmp->children->content, "rpc")) {
- soapFunctionBinding->style = SOAP_RPC;
- } else if (!soapBinding->style) {
- soapFunctionBinding->style = SOAP_DOCUMENT;
+ tmp = get_attribute(soapBindingNode->properties, "transport");
+ if (tmp) {
+ if (strcmp(tmp->children->content, WSDL_HTTP_TRANSPORT)) {
+ php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: PHP-SOAP doesn't support transport '%s'", tmp->children->content);
+ }
+ soapBinding->transport = strdup(tmp->children->content);
}
+ tmpbinding->bindingAttributes = (void *)soapBinding;
}
+ }
- function->bindingAttributes = (void *)soapFunctionBinding;
+ name = get_attribute(binding->properties, "name");
+ if (name == NULL) {
+ php_error(E_ERROR, "Error parsing wsdl (Missing \"name\" attribute for \"binding\")");
}
- input = get_node(operation->children, "input");
- if (input != NULL) {
- xmlAttrPtr message;
- xmlNodePtr part;
- char *ns, *ctype;
+ tmpbinding->name = strdup(name->children->content);
- portTypeInput = get_node(portTypeOperation->children, "input");
- message = get_attribute(portTypeInput->properties, "message");
- if (message == NULL) {
- php_error(E_ERROR, "Error parsing wsdl (Missing name for \"input\" of \"%s\")", op_name->children->content);
- }
+ type = get_attribute(binding->properties, "type");
+ if (type == NULL) {
+ php_error(E_ERROR, "Error parsing wsdl (Missing \"type\" attribute for \"binding\")");
+ }
+ parse_namespace(type->children->content, &ctype, &ns);
+
+ if (zend_hash_find(&ctx.portTypes, ctype, strlen(ctype)+1, (void**)&tmp) != SUCCESS) {
+ php_error(E_ERROR, "Error parsing wsdl (Missing \"portType\" with name \"%s\")", name->children->content);
+ }
+ portType = *tmp;
+
+ if (ctype) {efree(ctype);}
+ if (ns) {efree(ns);}
- function->requestName = strdup(function->functionName);
- function->requestParameters = malloc(sizeof(HashTable));
- zend_hash_init(function->requestParameters, 0, NULL, delete_paramater, 1);
+ trav2 = binding->children;
+ FOREACHNODE(trav2, "operation", operation) {
+ sdlFunctionPtr function;
+ xmlNodePtr input, output, fault, portTypeOperation, portTypeInput, msgInput, msgOutput;
+ xmlAttrPtr op_name, paramOrder;
+
+ op_name = get_attribute(operation->properties, "name");
+ if (op_name == NULL) {
+ php_error(E_ERROR, "Error parsing wsdl (Missing \"name\" attribute for \"operation\")");
+ }
- parse_namespace(message->children->content, &ctype, &ns);
- msgInput = get_node_with_attribute(definitions->children, "message", "name", ctype);
- if (msgInput == NULL) {
- php_error(E_ERROR, "Error parsing wsdl (Missing \"message\" with name \"%s\")", message->children->content);
+ portTypeOperation = get_node_with_attribute(portType->children, "operation", "name", op_name->children->content);
+ if (portTypeOperation == NULL) {
+ php_error(E_ERROR, "Error parsing wsdl (Missing \"portType/operation\" with name \"%s\")", op_name->children->content);
}
- if (ctype) {efree(ctype);}
- if (ns) {efree(ns);}
+
+ function = malloc(sizeof(sdlFunction));
+ function->functionName = strdup(op_name->children->content);
+ function->requestParameters = NULL;
+ function->responseParameters = NULL;
+ function->responseName = NULL;
+ function->bindingAttributes = NULL;
+ function->bindingType = tmpbinding->bindingType;
if (tmpbinding->bindingType == BINDING_SOAP) {
- sdlSoapBindingFunctionPtr soapFunctionBinding = function->bindingAttributes;
- xmlNodePtr body;
+ sdlSoapBindingFunctionPtr soapFunctionBinding;
+ sdlSoapBindingPtr soapBinding;
+ xmlNodePtr soapOperation;
xmlAttrPtr tmp;
- body = get_node_ex(input->children, "body", WSDL_SOAP_NAMESPACE);
- if (body) {
- tmp = get_attribute(body->properties, "use");
- if (tmp && !strcmp(tmp->children->content, "literal")) {
- soapFunctionBinding->input.use = SOAP_LITERAL;
- } else {
- soapFunctionBinding->input.use = SOAP_ENCODED;
- }
+ soapFunctionBinding = malloc(sizeof(sdlSoapBindingFunction));
+ memset(soapFunctionBinding, 0, sizeof(sdlSoapBindingFunction));
+ soapBinding = (sdlSoapBindingPtr)tmpbinding->bindingAttributes;
+ soapFunctionBinding->style = soapBinding->style;
- tmp = get_attribute(body->properties, "namespace");
+ soapOperation = get_node_ex(operation->children, "operation", WSDL_SOAP_NAMESPACE);
+ if (soapOperation) {
+ tmp = get_attribute(soapOperation->properties, "soapAction");
if (tmp) {
- soapFunctionBinding->input.ns = strdup(tmp->children->content);
+ soapFunctionBinding->soapAction = strdup(tmp->children->content);
}
- tmp = get_attribute(body->properties, "parts");
- if (tmp) {
- soapFunctionBinding->input.parts = strdup(tmp->children->content);
- }
-
- tmp = get_attribute(body->properties, "encodingStyle");
- if (tmp) {
- soapFunctionBinding->input.encodingStyle = strdup(tmp->children->content);
+ tmp = get_attribute(soapOperation->properties, "style");
+ if (tmp && !strcmp(tmp->children->content, "rpc")) {
+ soapFunctionBinding->style = SOAP_RPC;
+ } else if (!soapBinding->style) {
+ soapFunctionBinding->style = SOAP_DOCUMENT;
}
}
- }
- trav3 = msgInput->children;
- FOREACHNODE(trav3, "part", part) {
- xmlAttrPtr element, type, name;
- sdlParamPtr param;
+ function->bindingAttributes = (void *)soapFunctionBinding;
+ }
- param = malloc(sizeof(sdlParam));
- param->order = 0;
+ input = get_node(operation->children, "input");
+ if (input != NULL) {
+ xmlAttrPtr message;
+ xmlNodePtr part, trav3;
+ char *ns, *ctype;
- name = get_attribute(part->properties, "name");
- if (name == NULL) {
- php_error(E_ERROR, "Error parsing wsdl (No name associated with part \"%s\")", msgInput->name);
+ portTypeInput = get_node(portTypeOperation->children, "input");
+ message = get_attribute(portTypeInput->properties, "message");
+ if (message == NULL) {
+ php_error(E_ERROR, "Error parsing wsdl (Missing name for \"input\" of \"%s\")", op_name->children->content);
}
- param->paramName = strdup(name->children->content);
+ function->requestName = strdup(function->functionName);
+ function->requestParameters = malloc(sizeof(HashTable));
+ zend_hash_init(function->requestParameters, 0, NULL, delete_paramater, 1);
+
+ parse_namespace(message->children->content, &ctype, &ns);
- element = get_attribute(part->properties, "element");
- if (element != NULL) {
- param->encode = get_encoder_from_prefix(tmpsdl, part, element->children->content);
+ if (zend_hash_find(&ctx.messages, ctype, strlen(ctype)+1, (void**)&tmp) != SUCCESS) {
+ php_error(E_ERROR, "Error parsing wsdl (Missing \"message\" with name \"%s\")", message->children->content);
}
+ msgInput = *tmp;
+
+ if (ctype) {efree(ctype);}
+ if (ns) {efree(ns);}
+
+ if (tmpbinding->bindingType == BINDING_SOAP) {
+ sdlSoapBindingFunctionPtr soapFunctionBinding = function->bindingAttributes;
+ xmlNodePtr body;
+ xmlAttrPtr tmp;
+
+ body = get_node_ex(input->children, "body", WSDL_SOAP_NAMESPACE);
+ if (body) {
+ tmp = get_attribute(body->properties, "use");
+ if (tmp && !strcmp(tmp->children->content, "literal")) {
+ soapFunctionBinding->input.use = SOAP_LITERAL;
+ } else {
+ soapFunctionBinding->input.use = SOAP_ENCODED;
+ }
- type = get_attribute(part->properties, "type");
- if (type != NULL) {
- param->encode = get_encoder_from_prefix(tmpsdl, part, type->children->content);
+ tmp = get_attribute(body->properties, "namespace");
+ if (tmp) {
+ soapFunctionBinding->input.ns = strdup(tmp->children->content);
+ }
+
+ tmp = get_attribute(body->properties, "parts");
+ if (tmp) {
+ soapFunctionBinding->input.parts = strdup(tmp->children->content);
+ }
+
+ tmp = get_attribute(body->properties, "encodingStyle");
+ if (tmp) {
+ soapFunctionBinding->input.encodingStyle = strdup(tmp->children->content);
+ }
+ }
}
- zend_hash_next_index_insert(function->requestParameters, &param, sizeof(sdlParamPtr), NULL);
- }
- ENDFOREACH(trav3);
- }
+ trav3 = msgInput->children;
+ FOREACHNODE(trav3, "part", part) {
+ xmlAttrPtr element, type, name;
+ sdlParamPtr param;
- paramOrder = get_attribute(portTypeOperation->properties, "parameterOrder");
- if (paramOrder) {
+ param = malloc(sizeof(sdlParam));
+ param->order = 0;
- }
+ name = get_attribute(part->properties, "name");
+ if (name == NULL) {
+ php_error(E_ERROR, "Error parsing wsdl (No name associated with part \"%s\")", msgInput->name);
+ }
- output = get_node(portTypeOperation->children, "output");
- if (output != NULL) {
- xmlAttrPtr message;
- xmlNodePtr part;
- char *ns, *ctype;
+ param->paramName = strdup(name->children->content);
- function->responseName = malloc(strlen(function->functionName) + strlen("Response") + 1);
- sprintf(function->responseName, "%sResponse", function->functionName);
- function->responseParameters = malloc(sizeof(HashTable));
- zend_hash_init(function->responseParameters, 0, NULL, delete_paramater, 1);
+ element = get_attribute(part->properties, "element");
+ if (element != NULL) {
+ param->encode = get_encoder_from_prefix(ctx.root, part, element->children->content);
+ }
- message = get_attribute(output->properties, "message");
- if (message == NULL) {
- php_error(E_ERROR, "Error parsing wsdl (Missing name for \"output\" of \"%s\")", op_name->children->content);
+ type = get_attribute(part->properties, "type");
+ if (type != NULL) {
+ param->encode = get_encoder_from_prefix(ctx.root, part, type->children->content);
+ }
+
+ zend_hash_next_index_insert(function->requestParameters, &param, sizeof(sdlParamPtr), NULL);
+ }
+ ENDFOREACH(trav3);
}
- parse_namespace(message->children->content, &ctype, &ns);
- msgOutput = get_node_with_attribute(definitions->children, "message", "name", ctype);
- if (msgOutput == NULL) {
- php_error(E_ERROR, "Error parsing wsdl (Missing \"message\" with name \"%s\")", message->children->content);
+ paramOrder = get_attribute(portTypeOperation->properties, "parameterOrder");
+ if (paramOrder) {
+
}
- if (ctype) {efree(ctype);}
- if (ns) {efree(ns);}
- if (tmpbinding->bindingType == BINDING_SOAP) {
- sdlSoapBindingFunctionPtr soapFunctionBinding = function->bindingAttributes;
- xmlNodePtr body;
- xmlAttrPtr tmp;
+ output = get_node(portTypeOperation->children, "output");
+ if (output != NULL) {
+ xmlAttrPtr message;
+ xmlNodePtr part, trav3;
+ char *ns, *ctype;
- body = get_node_ex(output->children, "body", WSDL_SOAP_NAMESPACE);
- if (body) {
- tmp = get_attribute(body->properties, "use");
- if (tmp && !strcmp(tmp->children->content, "literal")) {
- soapFunctionBinding->output.use = SOAP_LITERAL;
- } else {
- soapFunctionBinding->output.use = SOAP_ENCODED;
- }
+ function->responseName = malloc(strlen(function->functionName) + strlen("Response") + 1);
+ sprintf(function->responseName, "%sResponse", function->functionName);
+ function->responseParameters = malloc(sizeof(HashTable));
+ zend_hash_init(function->responseParameters, 0, NULL, delete_paramater, 1);
- tmp = get_attribute(body->properties, "namespace");
- if (tmp) {
- soapFunctionBinding->output.ns = strdup(tmp->children->content);
- }
+ message = get_attribute(output->properties, "message");
+ if (message == NULL) {
+ php_error(E_ERROR, "Error parsing wsdl (Missing name for \"output\" of \"%s\")", op_name->children->content);
+ }
- tmp = get_attribute(body->properties, "parts");
- if (tmp) {
- soapFunctionBinding->output.parts = strdup(tmp->children->content);
- }
+ parse_namespace(message->children->content, &ctype, &ns);
+ if (zend_hash_find(&ctx.messages, ctype, strlen(ctype)+1, (void**)&tmp) != SUCCESS) {
+ php_error(E_ERROR, "Error parsing wsdl (Missing \"message\" with name \"%s\")", message->children->content);
+ }
+ msgOutput = *tmp;
+
+ if (ctype) {efree(ctype);}
+ if (ns) {efree(ns);}
+
+ if (tmpbinding->bindingType == BINDING_SOAP) {
+ sdlSoapBindingFunctionPtr soapFunctionBinding = function->bindingAttributes;
+ xmlNodePtr body;
+ xmlAttrPtr tmp;
+
+ body = get_node_ex(output->children, "body", WSDL_SOAP_NAMESPACE);
+ if (body) {
+ tmp = get_attribute(body->properties, "use");
+ if (tmp && !strcmp(tmp->children->content, "literal")) {
+ soapFunctionBinding->output.use = SOAP_LITERAL;
+ } else {
+ soapFunctionBinding->output.use = SOAP_ENCODED;
+ }
- tmp = get_attribute(body->properties, "encodingStyle");
- if (tmp) {
- soapFunctionBinding->output.encodingStyle = strdup(tmp->children->content);
+ tmp = get_attribute(body->properties, "namespace");
+ if (tmp) {
+ soapFunctionBinding->output.ns = strdup(tmp->children->content);
+ }
+
+ tmp = get_attribute(body->properties, "parts");
+ if (tmp) {
+ soapFunctionBinding->output.parts = strdup(tmp->children->content);
+ }
+
+ tmp = get_attribute(body->properties, "encodingStyle");
+ if (tmp) {
+ soapFunctionBinding->output.encodingStyle = strdup(tmp->children->content);
+ }
}
}
- }
- trav3 = msgOutput->children;
- FOREACHNODE(trav3, "part", part) {
- sdlParamPtr param;
- xmlAttrPtr element, type, name;
+ trav3 = msgOutput->children;
+ FOREACHNODE(trav3, "part", part) {
+ sdlParamPtr param;
+ xmlAttrPtr element, type, name;
- param = malloc(sizeof(sdlParam));
- param->order = 0;
+ param = malloc(sizeof(sdlParam));
+ param->order = 0;
- name = get_attribute(part->properties, "name");
- if (name == NULL) {
- php_error(E_ERROR, "Error parsing wsdl (No name associated with part \"%s\")", msgOutput->name);
- }
+ name = get_attribute(part->properties, "name");
+ if (name == NULL) {
+ php_error(E_ERROR, "Error parsing wsdl (No name associated with part \"%s\")", msgOutput->name);
+ }
- param->paramName = strdup(name->children->content);
+ param->paramName = strdup(name->children->content);
- element = get_attribute(part->properties, "element");
- if (element) {
- param->encode = get_encoder_from_prefix(tmpsdl, part, element->children->content);
- }
+ element = get_attribute(part->properties, "element");
+ if (element) {
+ param->encode = get_encoder_from_prefix(ctx.root, part, element->children->content);
+ }
+
+ type = get_attribute(part->properties, "type");
+ if (type) {
+ param->encode = get_encoder_from_prefix(ctx.root, part, type->children->content);
+ }
- type = get_attribute(part->properties, "type");
- if (type) {
- param->encode = get_encoder_from_prefix(tmpsdl, part, type->children->content);
+ zend_hash_next_index_insert(function->responseParameters, &param, sizeof(sdlParamPtr), NULL);
}
+ ENDFOREACH(trav3);
+ }
- zend_hash_next_index_insert(function->responseParameters, &param, sizeof(sdlParamPtr), NULL);
+ fault = get_node(operation->children, "fault");
+ if (!fault) {
}
- ENDFOREACH(trav3);
- }
- fault = get_node(operation->children, "fault");
- if (!fault) {
- }
+ if (!tmpbinding->functions) {
+ tmpbinding->functions = malloc(sizeof(HashTable));
+ zend_hash_init(tmpbinding->functions, 0, NULL, delete_function, 1);
+ }
- if (!tmpbinding->functions) {
- tmpbinding->functions = malloc(sizeof(HashTable));
- zend_hash_init(tmpbinding->functions, 0, NULL, delete_function, 1);
+ zend_hash_add(tmpbinding->functions, php_strtolower(function->functionName, strlen(function->functionName)), strlen(function->functionName), &function, sizeof(sdlFunctionPtr), NULL);
}
+ ENDFOREACH(trav2);
- zend_hash_add(tmpbinding->functions, php_strtolower(function->functionName, strlen(function->functionName)), strlen(function->functionName), &function, sizeof(sdlFunctionPtr), NULL);
- }
- ENDFOREACH(trav2);
+ if (!ctx.root->bindings) {
+ ctx.root->bindings = malloc(sizeof(HashTable));
+ zend_hash_init(ctx.root->bindings, 0, NULL, delete_binding, 1);
+ }
- if (!tmpsdl->bindings) {
- tmpsdl->bindings = malloc(sizeof(HashTable));
- zend_hash_init(tmpsdl->bindings, 0, NULL, delete_binding, 1);
+ zend_hash_add(ctx.root->bindings, tmpbinding->name, strlen(tmpbinding->name), &tmpbinding, sizeof(sdlBindingPtr), NULL);
}
+ ENDFOREACH(trav);
- zend_hash_add(tmpsdl->bindings, tmpbinding->name, strlen(tmpbinding->name), &tmpbinding, sizeof(sdlBindingPtr), NULL);
+ zend_hash_move_forward(&ctx.services);
}
- ENDFOREACH(trav);
-
} else {
php_error(E_ERROR, "Error parsing wsdl (\"Couldn't bind to service\")");
}
- return tmpsdl;
+
+ zend_hash_destroy(&ctx.messages);
+ zend_hash_destroy(&ctx.bindings);
+ zend_hash_destroy(&ctx.portTypes);
+ zend_hash_destroy(&ctx.services);
+
+ return ctx.root;
}
int write_wsdl()
diff --git a/ext/soap/php_sdl.h b/ext/soap/php_sdl.h
index 1d37882e3c..5d61fc716b 100644
--- a/ext/soap/php_sdl.h
+++ b/ext/soap/php_sdl.h
@@ -15,8 +15,8 @@
#define SOAP_LITERAL 2
struct _sdl {
- xmlDocPtr doc; /* pointer to the parsed xml file */
- HashTable *types; /* array of sdlTypesPtr */
+ HashTable docs; /* pointer to the parsed xml file */
+ HashTable *types; /* array of sdlTypesPtr */
HashTable *encoders; /* array of encodePtr */
HashTable *bindings; /* array of sdlBindings (key'd by name) */
char *target_ns;
@@ -129,7 +129,7 @@ struct _sdlAttribute {
};
sdlPtr get_sdl(char *uri);
-sdlPtr load_wsdl(char *struri, sdlPtr parent);
+sdlPtr load_wsdl(char *struri);
int load_sdl(char *struri, int force_load);
int load_ms_sdl(char *struri, int force_load);
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index 624cf5c167..0b1f28aad9 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -2224,7 +2224,7 @@ void delete_sdl(void *handle)
{
sdlPtr tmp = *((sdlPtr*)handle);
- xmlFreeDoc(tmp->doc);
+ zend_hash_destroy(&tmp->docs);
if (tmp->source) {
free(tmp->source);
}