xmlNodePtr trav, env, head, body, resp, cur, fault;
int param_count = 0;
int old_error_reporting;
+ int soap_version;
ZVAL_NULL(return_value);
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);
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;
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"));
}
}
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 {