From 51c86ab73f7d61f547593afbd6edd5f3f022f9ba Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 13 Jan 2004 07:59:13 +0000 Subject: [PATCH] Support for WSDL without message --- ext/soap/TODO | 3 + ext/soap/php_sdl.c | 137 +++++++++++++++++++++++---------------------- ext/soap/soap.c | 8 ++- 3 files changed, 79 insertions(+), 69 deletions(-) diff --git a/ext/soap/TODO b/ext/soap/TODO index 594260cb8e..b662ee3c47 100644 --- a/ext/soap/TODO +++ b/ext/soap/TODO @@ -63,6 +63,8 @@ Encoding WSDL ---- ++ wsdl and schema import ++ support for without ? support for style "rpc"/"document" encoding ? support for "encoded"/"literal" encoding ? support for "nillable" and "nil" @@ -120,6 +122,7 @@ Transport + support for persistent HTTP connections (keep_alive) - support for HTTP compression (gzip,x-gzip,defalte) + support for HTTP authentication ++ HTTP Cookies support - support for HTTP proxies - transport abstraction layer ? SoapAction HTTP header field diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c index 57423f13d9..507f5619f0 100644 --- a/ext/soap/php_sdl.c +++ b/ext/soap/php_sdl.c @@ -898,6 +898,7 @@ sdlPtr load_wsdl(char *struri) function->requestParameters = NULL; function->responseParameters = NULL; function->responseName = NULL; + function->requestName = NULL; function->bindingAttributes = NULL; function->bindingType = tmpbinding->bindingType; @@ -937,89 +938,91 @@ sdlPtr load_wsdl(char *struri) char *ns, *ctype; 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); - } + if (portTypeInput) { + 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); + } - function->requestName = strdup(function->functionName); - function->requestParameters = malloc(sizeof(HashTable)); - zend_hash_init(function->requestParameters, 0, NULL, delete_paramater, 1); + 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); - 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); + } + 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; + } + + 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); + } + } + } - 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; + trav3 = msgInput->children; + FOREACHNODE(trav3, "part", part) { + xmlAttrPtr element, type, name; + sdlParamPtr param; - if (ctype) {efree(ctype);} - if (ns) {efree(ns);} + param = malloc(sizeof(sdlParam)); + param->order = 0; - 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; + name = get_attribute(part->properties, "name"); + if (name == NULL) { + php_error(E_ERROR, "Error parsing wsdl (No name associated with part \"%s\")", msgInput->name); } - tmp = get_attribute(body->properties, "namespace"); - if (tmp) { - soapFunctionBinding->input.ns = strdup(tmp->children->content); - } + param->paramName = strdup(name->children->content); - tmp = get_attribute(body->properties, "parts"); - if (tmp) { - soapFunctionBinding->input.parts = strdup(tmp->children->content); + element = get_attribute(part->properties, "element"); + if (element != NULL) { + param->encode = get_encoder_from_prefix(ctx.root, part, element->children->content); } - tmp = get_attribute(body->properties, "encodingStyle"); - if (tmp) { - soapFunctionBinding->input.encodingStyle = strdup(tmp->children->content); + type = get_attribute(part->properties, "type"); + if (type != NULL) { + param->encode = get_encoder_from_prefix(ctx.root, part, type->children->content); } - } - } - - trav3 = msgInput->children; - FOREACHNODE(trav3, "part", part) { - xmlAttrPtr element, type, name; - sdlParamPtr param; - - 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); - } - - param->paramName = strdup(name->children->content); - element = get_attribute(part->properties, "element"); - if (element != NULL) { - param->encode = get_encoder_from_prefix(ctx.root, part, element->children->content); + zend_hash_next_index_insert(function->requestParameters, ¶m, sizeof(sdlParamPtr), NULL); } - - 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, ¶m, sizeof(sdlParamPtr), NULL); + ENDFOREACH(trav3); } - ENDFOREACH(trav3); - } - paramOrder = get_attribute(portTypeOperation->properties, "parameterOrder"); - if (paramOrder) { + paramOrder = get_attribute(portTypeOperation->properties, "parameterOrder"); + if (paramOrder) { + } } output = get_node(portTypeOperation->children, "output"); diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 466a876772..8d7318022a 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -2005,7 +2005,11 @@ xmlDocPtr seralize_function_call(zval *this_ptr, sdlFunctionPtr function, char * use = fnb->input.use; if (style == SOAP_RPC) { ns = xmlNewNs(body, fnb->input.ns, gen_ns->c); - method = xmlNewChild(body, ns, function->requestName , NULL); + if (function->requestName) { + method = xmlNewChild(body, ns, function->requestName, NULL); + } else { + method = xmlNewChild(body, ns, function->functionName, NULL); + } } } } else { @@ -2029,7 +2033,7 @@ xmlDocPtr seralize_function_call(zval *this_ptr, sdlFunctionPtr function, char * use = SOAP_ENCODED; } } - + for (i = 0;i < arg_count;i++) { xmlNodePtr param; sdlParamPtr parameter = get_param(function, NULL, i, FALSE); -- 2.50.1