From: Dmitry Stogov Date: Fri, 30 Jan 2004 16:32:53 +0000 (+0000) Subject: Server part support for "document" style encoding was implemented X-Git-Tag: php-5.0.0b4RC1~218 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b74d4fbbac84189b3e5566ade2fc81283ee6020;p=php Server part support for "document" style encoding was implemented --- diff --git a/ext/soap/TODO b/ext/soap/TODO index 2bda464236..537c327446 100644 --- a/ext/soap/TODO +++ b/ext/soap/TODO @@ -55,8 +55,7 @@ WSDL - support for portType operation parameterOrder attribute - support for binding operation input/output name attribute (part of overloading) - support for -- support for style "rpc"/"document" encoding (server part) - How to get function name from request? May be SoapAction HTTP header? +? support for style "document" encoding (server part) - function/method overloading/redeclaration (test(int); test(string)) - wsdl caching - wsdl auto generation diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index e4a6c9e0e7..3073ea73b8 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -298,9 +298,11 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *location, char *so smart_str_append_const(&soap_headers,"\"\r\n"); } else { smart_str_append_const(&soap_headers,"Content-Type: text/xml; charset=\"utf-8\"\r\n"); - smart_str_append_const(&soap_headers, "SOAPAction: \""); - smart_str_appends(&soap_headers, soapaction); - smart_str_append_const(&soap_headers, "\"\r\n"); + if (soapaction) { + smart_str_append_const(&soap_headers, "SOAPAction: \""); + smart_str_appends(&soap_headers, soapaction); + smart_str_append_const(&soap_headers, "\"\r\n"); + } } smart_str_append_const(&soap_headers,"Content-Length: "); smart_str_append_long(&soap_headers, buf_size); diff --git a/ext/soap/soap.c b/ext/soap/soap.c index cfae730052..ae58cf683c 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -38,6 +38,7 @@ static void set_soap_fault(zval *obj, char *fault_code, char *fault_string, char static sdlParamPtr get_param(sdlFunctionPtr function, char *param_name, int index, int); static sdlFunctionPtr get_function(sdlPtr sdl, const char *function_name); +static sdlFunctionPtr get_doc_function(sdlPtr sdl, xmlNodePtr node); static void deseralize_function_call(sdlPtr sdl, xmlDocPtr request, zval *function_name, int *num_params, zval **parameters[], int *version TSRMLS_DC); static xmlDocPtr seralize_response_call(sdlFunctionPtr function, char *function_name,char *uri,zval *ret, int version TSRMLS_DC); @@ -1857,15 +1858,31 @@ static void deseralize_function_call(sdlPtr sdl, xmlDocPtr request, zval *functi trav = trav->next; } if (func == NULL) { - php_error(E_ERROR,"looks like we got \"Body\" without function call"); - } - - function = get_function(sdl, func->name); - if (sdl != NULL && function == NULL) { - if (*version == SOAP_1_2) { - soap_server_fault("rpc:ProcedureNotPresent","Procedure not present", NULL, NULL); + function = get_doc_function(sdl, NULL); + if (function != NULL) { + func = body; } else { - php_error(E_ERROR, "Procedure '%s' not present", func->name); + php_error(E_ERROR,"looks like we got \"Body\" without function call"); + } + } else { + function = get_function(sdl, func->name); + if (function && function->binding && function->binding->bindingType == BINDING_SOAP) { + sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes; + if (fnb->style == SOAP_DOCUMENT) { + function = NULL; + } + } + if (sdl != NULL && function == NULL) { + function = get_doc_function(sdl, func); + if (function != NULL) { + func = body; + } else { + if (*version == SOAP_1_2) { + soap_server_fault("rpc:ProcedureNotPresent","Procedure not present", NULL, NULL); + } else { + php_error(E_ERROR, "Procedure '%s' not present", func->name); + } + } } } @@ -2094,9 +2111,9 @@ static xmlDocPtr seralize_response_call(sdlFunctionPtr function, char *function_ if (function && function->binding->bindingType == BINDING_SOAP) { sdlParamPtr *sparam; - if (zend_hash_index_find(function->responseParameters, 0, (void **)&sparam) == SUCCESS) { - ns = encode_add_ns(param, (*sparam)->encode->details.ns); - xmlNodeSetName(param, (*sparam)->encode->details.type_str); + if (zend_hash_index_find(function->responseParameters, 0, (void **)&sparam) == SUCCESS && (*sparam)->element) { + ns = encode_add_ns(param, (*sparam)->element->namens); + xmlNodeSetName(param, (*sparam)->element->name); xmlSetNs(param, ns); } } @@ -2353,6 +2370,63 @@ static sdlFunctionPtr get_function(sdlPtr sdl, const char *function_name) return NULL; } +static sdlFunctionPtr get_doc_function(sdlPtr sdl, xmlNodePtr params) +{ + if (sdl) { + sdlFunctionPtr *tmp; + sdlParamPtr *param; + + zend_hash_internal_pointer_reset(&sdl->functions); + while (zend_hash_get_current_data(&sdl->functions, (void**)&tmp) == SUCCESS) { + if ((*tmp)->binding && (*tmp)->binding->bindingType == BINDING_SOAP) { + sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)(*tmp)->bindingAttributes; + if (fnb->style == SOAP_DOCUMENT) { + if (params == NULL) { + if ((*tmp)->requestParameters == NULL || + zend_hash_num_elements((*tmp)->requestParameters) == 0) { + return *tmp; + } + } else if ((*tmp)->requestParameters != NULL) { + int ok = 1; + xmlNodePtr node = params; + + zend_hash_internal_pointer_reset((*tmp)->requestParameters); + while (zend_hash_get_current_data((*tmp)->requestParameters, (void**)¶m) == SUCCESS) { + if ((*param)->element) { + if (strcmp((*param)->element->name,node->name) != 0) { + ok = 0; + break; + } + if ((*param)->element->namens != NULL && node->ns != NULL) { + if (strcmp((*param)->element->namens,node->ns->href) != 0) { + ok = 0; + break; + } + } else if ((void*)(*param)->element->namens != (void*)node->ns) { + ok = 0; + break; + } + } else if (strcmp((*param)->paramName,node->name) != 0) { + ok = 0; + break; + } + zend_hash_move_forward((*tmp)->requestParameters); + do { + node = node->next; + } while (node != NULL && node->type != XML_ELEMENT_NODE); + } + if (ok && node == NULL) { + return (*tmp); + } + } + } + } + zend_hash_move_forward(&sdl->functions); + } + } + return NULL; +} + static void function_to_string(sdlFunctionPtr function, smart_str *buf) { int i = 0;