diff options
author | Dmitry Stogov <dmitry@php.net> | 2004-01-26 16:19:29 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2004-01-26 16:19:29 +0000 |
commit | 9387d78fd05771971d3831ab45f52b1945fd3ed0 (patch) | |
tree | 42497d1b475f181b777ec73a584e7c3c36fd2a2a | |
parent | 6fe26e966d2e44992050debad15b79109356aefd (diff) | |
download | php-git-9387d78fd05771971d3831ab45f52b1945fd3ed0.tar.gz |
SOAP 1.2 Fault support (Code,Reason,Datail instead of faultcode,faultstring,...)
-rw-r--r-- | ext/soap/TODO | 2 | ||||
-rw-r--r-- | ext/soap/php_packet_soap.c | 51 | ||||
-rw-r--r-- | ext/soap/soap.c | 58 |
3 files changed, 91 insertions, 20 deletions
diff --git a/ext/soap/TODO b/ext/soap/TODO index efa3f150af..80cbea48eb 100644 --- a/ext/soap/TODO +++ b/ext/soap/TODO @@ -14,7 +14,7 @@ SOAP + SOAP 1.1 fault codes ("client","server"), SOAP 1.1 fault codes ("Sender","Receiver") + SOAP 1.1 Content-Type - "text/xml", SOAP 1.2 - "application/soap+xml" + support for SOAP 1.2 <rpc:result> (ignore it) -- SOAP 1.2 uses the element names env:Code and env:Reason, respectively, for what used to be called faultcode and faultstring in SOAP 1.1. ++ SOAP 1.2 uses the element names env:Code and env:Reason, respectively, for what used to be called faultcode and faultstring in SOAP 1.1. - support for SOAP headers - actor attribute - mustUnderstend attribute diff --git a/ext/soap/php_packet_soap.c b/ext/soap/php_packet_soap.c index 327597ca0a..9bc874efeb 100644 --- a/ext/soap/php_packet_soap.c +++ b/ext/soap/php_packet_soap.c @@ -8,6 +8,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction xmlNodePtr trav, env, head, body, resp, cur, fault; int param_count = 0; int old_error_reporting; + int soap_version; ZVAL_NULL(return_value); @@ -37,9 +38,11 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_1_ENV_NAMESPACE)) { env = trav; envelope_ns = SOAP_1_1_ENV_NAMESPACE; + soap_version = SOAP_1_1; } else if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_2_ENV_NAMESPACE)) { env = trav; envelope_ns = SOAP_1_2_ENV_NAMESPACE; + soap_version = SOAP_1_2; } else { add_soap_fault(this_ptr, "Client", "looks like we got bad SOAP response\n", NULL, NULL TSRMLS_CC); xmlFreeDoc(response); @@ -92,26 +95,42 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction zval *details = NULL; xmlNodePtr tmp; - tmp = get_node(fault->children,"faultcode"); - if (tmp != NULL && tmp->children != NULL) { - faultcode = tmp->children->content; - } + if (soap_version == SOAP_1_1) { + 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,"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,"faultactor"); + if (tmp != NULL && tmp->children != NULL) { + faultactor = tmp->children->content; + } - tmp = get_node(fault->children,"detail"); - if (tmp != NULL) { - details = master_to_zval(NULL, tmp); - } + tmp = get_node(fault->children,"detail"); + if (tmp != NULL) { + details = master_to_zval(NULL, tmp); + } + } else { + tmp = get_node(fault->children,"Code"); + if (tmp != NULL && tmp->children != NULL) { + faultcode = tmp->children->content; + } + tmp = get_node(fault->children,"Reason"); + if (tmp != NULL && tmp->children != NULL) { + faultstring = tmp->children->content; + } + + tmp = get_node(fault->children,"Detail"); + if (tmp != NULL) { + details = master_to_zval(NULL, tmp); + } + } add_soap_fault(this_ptr, faultcode, faultstring, faultactor, details TSRMLS_CC); xmlFreeDoc(response); return FALSE; diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 6be76495d0..0e31a9fee7 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -1687,7 +1687,6 @@ static void soap_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_proper static void clear_soap_fault(zval *obj TSRMLS_DC) { if (obj != NULL && obj->type == IS_OBJECT) { -/* zend_hash_del(obj->value.obj.properties, "__soap_fault", sizeof("__soap_fault"));*/ zend_hash_del(Z_OBJPROP_P(obj), "__soap_fault", sizeof("__soap_fault")); } } @@ -1945,9 +1944,62 @@ static xmlDocPtr seralize_response_call(sdlFunctionPtr function, char *function_ Z_OBJCE_P(ret) == soap_fault_class_entry) { use = SOAP_ENCODED; if (version == SOAP_1_1) { - param = seralize_zval(ret, NULL, SOAP_1_1_ENV_NS_PREFIX":Fault", use TSRMLS_CC); + HashTable* prop; + zval **tmp; + + prop = Z_OBJPROP_P(ret); + param = xmlNewNode(NULL, SOAP_1_1_ENV_NS_PREFIX":Fault"); + if (zend_hash_find(prop, "faultcode", sizeof("faultcode"), (void**)&tmp) == SUCCESS) { + int new_len; + xmlNodePtr node = xmlNewChild(param, NULL, "faultcode", NULL); + char *str = php_escape_html_entities(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC); + xmlNodeSetContentLen(node, str, new_len); + efree(str); + } + if (zend_hash_find(prop, "faultstring", sizeof("faultstring"), (void**)&tmp) == SUCCESS) { + int new_len; + xmlNodePtr node = xmlNewChild(param, NULL, "faultstring", NULL); + char *str = php_escape_html_entities(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC); + xmlNodeSetContentLen(node, str, new_len); + efree(str); + } + if (zend_hash_find(prop, "faultactor", sizeof("faultactor"), (void**)&tmp) == SUCCESS) { + int new_len; + xmlNodePtr node = xmlNewChild(param, NULL, "faultactor", NULL); + char *str = php_escape_html_entities(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC); + xmlNodeSetContentLen(node, str, new_len); + efree(str); + } + if (zend_hash_find(prop, "detail", sizeof("detail"), (void**)&tmp) == SUCCESS && + Z_TYPE_PP(tmp) != IS_NULL) { + xmlNodePtr node = seralize_zval(*tmp, NULL, "detail", use TSRMLS_CC); + xmlAddChild(param,node); + } } else { - param = seralize_zval(ret, NULL, SOAP_1_2_ENV_NS_PREFIX":Fault", use TSRMLS_CC); + HashTable* prop; + zval **tmp; + + prop = Z_OBJPROP_P(ret); + param = xmlNewNode(NULL, SOAP_1_2_ENV_NS_PREFIX":Fault"); + if (zend_hash_find(prop, "faultcode", sizeof("faultcode"), (void**)&tmp) == SUCCESS) { + int new_len; + xmlNodePtr node = xmlNewChild(param, NULL, SOAP_1_2_ENV_NS_PREFIX":Code", NULL); + char *str = php_escape_html_entities(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC); + xmlNodeSetContentLen(node, str, new_len); + efree(str); + } + if (zend_hash_find(prop, "faultstring", sizeof("faultstring"), (void**)&tmp) == SUCCESS) { + int new_len; + xmlNodePtr node = xmlNewChild(param, NULL, SOAP_1_2_ENV_NS_PREFIX":Reason", NULL); + char *str = php_escape_html_entities(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC); + xmlNodeSetContentLen(node, str, new_len); + efree(str); + } + if (zend_hash_find(prop, "detail", sizeof("detail"), (void**)&tmp) == SUCCESS && + Z_TYPE_PP(tmp) != IS_NULL) { + xmlNodePtr node = seralize_zval(*tmp, NULL, SOAP_1_2_ENV_NS_PREFIX":Detail", use TSRMLS_CC); + xmlAddChild(param,node); + } } xmlAddChild(body, param); } else { |