encodePtr enc = NULL;
HashTable *ht = Z_OBJPROP_P(data);
char *stype_str = NULL, *ns_str = NULL;
- int free_stype = 0, free_ns = 0;
if (zend_hash_find(ht, "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) {
soap_error0(E_ERROR, "Encoding: SoapVar hasn't 'enc_type' propery");
}
if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS) {
- if (Z_TYPE_PP(zstype) == IS_STRING) {
- stype_str = Z_STRVAL_PP(zstype);
- } else if (Z_TYPE_PP(zstype) == IS_UNICODE) {
- stype_str = soap_unicode_to_string(Z_USTRVAL_PP(zstype), Z_USTRLEN_PP(zstype) TSRMLS_CC);
- free_stype = 1;
- }
+ stype_str = soap_encode_string(*zstype, NULL TSRMLS_CC);
if (stype_str && zend_hash_find(ht, "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS) {
- if (Z_TYPE_PP(zns) == IS_STRING) {
- ns_str = Z_STRVAL_PP(zns);
- } else if (Z_TYPE_PP(zns) == IS_UNICODE) {
- ns_str = soap_unicode_to_string(Z_USTRVAL_PP(zns), Z_USTRLEN_PP(zns) TSRMLS_CC);
- free_ns = 1;
- }
+ ns_str = soap_encode_string(*zns, NULL TSRMLS_CC);
}
}
set_ns_and_type_ex(node, ns_str, stype_str);
}
}
-
- if (free_stype) {
+
+ if (stype_str) {
efree(stype_str);
}
- if (free_ns) {
+ if (ns_str) {
efree(ns_str);
}
if (zend_hash_find(ht, "enc_name", sizeof("enc_name"), (void **)&zname) == SUCCESS) {
- if (Z_TYPE_PP(zname) == IS_STRING) {
- xmlNodeSetName(node, BAD_CAST(Z_STRVAL_PP(zname)));
- } else if (Z_TYPE_PP(zname) == IS_UNICODE) {
- char *str = soap_unicode_to_string(Z_USTRVAL_PP(zname), Z_USTRLEN_PP(zname) TSRMLS_CC);
+ char *str = soap_encode_string(*zname, NULL TSRMLS_CC);
- xmlNodeSetName(node, BAD_CAST(str));
- efree(str);
- }
+ xmlNodeSetName(node, BAD_CAST(str));
+ efree(str);
}
if (zend_hash_find(ht, "enc_namens", sizeof("enc_namens"), (void **)&znamens) == SUCCESS) {
- if (Z_TYPE_PP(znamens) == IS_STRING) {
- xmlNsPtr nsp = encode_add_ns(node, Z_STRVAL_PP(znamens));
- xmlSetNs(node, nsp);
- } if (Z_TYPE_PP(znamens) == IS_UNICODE) {
- char *str = soap_unicode_to_string(Z_USTRVAL_PP(znamens), Z_USTRLEN_PP(znamens) TSRMLS_CC);
+ char *str = soap_encode_string(*znamens, NULL TSRMLS_CC);
+ xmlNsPtr nsp = encode_add_ns(node, str);
- xmlNsPtr nsp = encode_add_ns(node, str);
- efree(str);
- xmlSetNs(node, nsp);
- }
+ efree(str);
+ xmlSetNs(node, nsp);
}
} else {
if (SOAP_GLOBAL(class_map) && data &&
if (utype == HASH_KEY_IS_STRING || utype == HASH_KEY_IS_UNICODE) {
encodePtr enc;
- if (utype == HASH_KEY_IS_UNICODE) {
- type_name.s = soap_unicode_to_string(type_name.u, type_len TSRMLS_CC);
- }
+ type_name.s = soap_encode_string_ex(utype, type_name, type_len TSRMLS_CC);
+
/* TODO: namespace isn't stored */
enc = get_encoder(SOAP_GLOBAL(sdl), SOAP_GLOBAL(sdl)->target_ns, type_name.s);
if (enc) {
encode = enc;
}
}
- if (utype == HASH_KEY_IS_UNICODE) {
- efree(type_name.v);
- }
+ efree(type_name.v);
break;
}
}
if (data->children->type == XML_TEXT_NODE && data->children->next == NULL) {
TSRMLS_FETCH();
- if (UG(unicode)) {
- /* TODO: unicode support */
- ZVAL_STRING(ret, (char*)data->children->content, 1);
- zval_string_to_unicode_ex(ret, UG(utf8_conv) TSRMLS_CC);
- } else if (SOAP_GLOBAL(encoding) != NULL) {
- xmlBufferPtr in = xmlBufferCreateStatic(data->children->content, xmlStrlen(data->children->content));
- xmlBufferPtr out = xmlBufferCreate();
- int n = xmlCharEncOutFunc(SOAP_GLOBAL(encoding), out, in);
-
- if (n >= 0) {
- ZVAL_STRING(ret, (char*)xmlBufferContent(out), 1);
- } else {
- ZVAL_STRING(ret, (char*)data->children->content, 1);
- }
- xmlBufferFree(out);
- xmlBufferFree(in);
- } else {
- ZVAL_STRING(ret, (char*)data->children->content, 1);
- }
+ soap_decode_string(ret, (char*)data->children->content TSRMLS_CC);
} else if (data->children->type == XML_CDATA_SECTION_NODE && data->children->next == NULL) {
ZVAL_STRING(ret, (char*)data->children->content, 1);
} else {
TSRMLS_FETCH();
whiteSpace_replace(data->children->content);
- if (UG(unicode)) {
- /* TODO: unicode support */
- ZVAL_STRING(ret, (char*)data->children->content, 1);
- zval_string_to_unicode_ex(ret, UG(utf8_conv) TSRMLS_CC);
- } else if (SOAP_GLOBAL(encoding) != NULL) {
- xmlBufferPtr in = xmlBufferCreateStatic(data->children->content, xmlStrlen(data->children->content));
- xmlBufferPtr out = xmlBufferCreate();
- int n = xmlCharEncOutFunc(SOAP_GLOBAL(encoding), out, in);
-
- if (n >= 0) {
- ZVAL_STRING(ret, (char*)xmlBufferContent(out), 1);
- } else {
- ZVAL_STRING(ret, (char*)data->children->content, 1);
- }
- xmlBufferFree(out);
- xmlBufferFree(in);
- } else {
- ZVAL_STRING(ret, (char*)data->children->content, 1);
- }
+ soap_decode_string(ret, (char*)data->children->content TSRMLS_CC);
} else if (data->children->type == XML_CDATA_SECTION_NODE && data->children->next == NULL) {
ZVAL_STRING(ret, (char*)data->children->content, 1);
} else {
TSRMLS_FETCH();
whiteSpace_collapse(data->children->content);
- if (UG(unicode)) {
- /* TODO: unicode support */
- ZVAL_STRING(ret, (char*)data->children->content, 1);
- zval_string_to_unicode_ex(ret, UG(utf8_conv) TSRMLS_CC);
- } else if (SOAP_GLOBAL(encoding) != NULL) {
- xmlBufferPtr in = xmlBufferCreateStatic(data->children->content, xmlStrlen(data->children->content));
- xmlBufferPtr out = xmlBufferCreate();
- int n = xmlCharEncOutFunc(SOAP_GLOBAL(encoding), out, in);
-
- if (n >= 0) {
- ZVAL_STRING(ret, (char*)xmlBufferContent(out), 1);
- } else {
- ZVAL_STRING(ret, (char*)data->children->content, 1);
- }
- xmlBufferFree(out);
- xmlBufferFree(in);
- } else {
- ZVAL_STRING(ret, (char*)data->children->content, 1);
- }
+ soap_decode_string(ret, (char*)data->children->content TSRMLS_CC);
} else if (data->children->type == XML_CDATA_SECTION_NODE && data->children->next == NULL) {
ZVAL_STRING(ret, (char*)data->children->content, 1);
} else {
xmlAddChild(parent, ret);
FIND_ZVAL_NULL(data, ret, style);
- if (Z_TYPE_P(data) == IS_UNICODE) {
- str = soap_unicode_to_string(Z_USTRVAL_P(data), Z_USTRLEN_P(data) TSRMLS_CC);
- new_len = strlen(str);
- } else {
- if (Z_TYPE_P(data) == IS_STRING) {
- str = estrndup(Z_STRVAL_P(data), Z_STRLEN_P(data));
- new_len = Z_STRLEN_P(data);
- } else {
- zval tmp = *data;
-
- zval_copy_ctor(&tmp);
- convert_to_string(&tmp);
- str = estrndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
- new_len = Z_STRLEN(tmp);
- zval_dtor(&tmp);
- }
-
- if (SOAP_GLOBAL(encoding) != NULL) {
- xmlBufferPtr in = xmlBufferCreateStatic(str, new_len);
- xmlBufferPtr out = xmlBufferCreate();
- int n = xmlCharEncInFunc(SOAP_GLOBAL(encoding), out, in);
-
- if (n >= 0) {
- efree(str);
- str = estrdup((char*)xmlBufferContent(out));
- new_len = n;
- } else if (!php_libxml_xmlCheckUTF8(BAD_CAST(str))) {
- soap_error1(E_ERROR, "Encoding: string '%s' is not a valid utf-8 string", str);
- }
- xmlBufferFree(out);
- xmlBufferFree(in);
- } else if (!php_libxml_xmlCheckUTF8(BAD_CAST(str))) {
- soap_error1(E_ERROR, "Encoding: string '%s' is not a valid utf-8 string", str);
- }
- }
+ str = soap_encode_string(data, &new_len TSRMLS_CC);
text = xmlNewTextLen(BAD_CAST(str), new_len);
xmlAddChild(ret, text);
efree(str);
if (key_type != HASH_KEY_IS_LONG) {
char *prop_name;
- if (key_type == IS_UNICODE) {
- key.s = soap_unicode_to_string(key.u, key_len TSRMLS_CC);
- }
+ key.s = soap_encode_string_ex(key_type, key, key_len TSRMLS_CC);
if (Z_TYPE_P(data) == IS_OBJECT) {
char *class_name;
if (prop_name) {
xmlNodeSetName(property, BAD_CAST(prop_name));
}
- if (key_type == IS_UNICODE) {
- efree(key.v);
- }
+ efree(key.s);
}
zend_hash_move_forward(prop);
}
key = xmlNewNode(NULL, BAD_CAST("key"));
xmlAddChild(item,key);
key_type = zend_hash_get_current_key_ex(data->value.ht, &key_val, &key_len, &int_val, FALSE, NULL);
- if (key_type == HASH_KEY_IS_STRING) {
- if (style == SOAP_ENCODED) {
- set_xsi_type(key, "xsd:string");
- }
- xmlNodeSetContent(key, BAD_CAST(key_val.s));
- } else if (key_type == HASH_KEY_IS_UNICODE) {
+ if (key_type == HASH_KEY_IS_STRING || key_type == HASH_KEY_IS_UNICODE) {
char *str;
TSRMLS_FETCH();
if (style == SOAP_ENCODED) {
set_xsi_type(key, "xsd:string");
}
- str = soap_unicode_to_string(key_val.u, key_len TSRMLS_CC);
+ str = soap_encode_string_ex(key_type, key_val, key_len TSRMLS_CC);
xmlNodeSetContent(key, BAD_CAST(str));
efree(str);
} else {
} else if (data->properties && get_attribute_ex(data->properties, "nil", XSI_NAMESPACE)) {
enc = get_conversion(IS_NULL);
} else {
- tmpattr = get_attribute_ex(data->properties,"type", XSI_NAMESPACE);
+ tmpattr = get_attribute_ex(data->properties, "type", XSI_NAMESPACE);
if (tmpattr != NULL) {
- type_name = tmpattr->children->content;
+ type_name = tmpattr->children->content;
enc = get_encoder_from_prefix(SOAP_GLOBAL(sdl), data, tmpattr->children->content);
if (enc && type == &enc->details) {
enc = NULL;
parse_namespace(type_name, &cptype, &ns);
nsptr = xmlSearchNs(data->doc, data, BAD_CAST(ns));
MAKE_STD_ZVAL(tmp);
- ZVAL_STRING(tmp, cptype, 1);
+ soap_decode_string(tmp, cptype TSRMLS_CC);
tmp->refcount--;
add_property_zval(soapvar, "enc_stype", tmp);
if (nsptr) {
MAKE_STD_ZVAL(tmp);
- ZVAL_STRING(tmp, (char*)nsptr->href, 1);
+ soap_decode_string(tmp, (char*)nsptr->href TSRMLS_CC);
tmp->refcount--;
add_property_zval(soapvar, "enc_ns", tmp);
}
xmlNodeSetContent(xmlParam, BAD_CAST(buf));
efree(buf);
- } else if (Z_TYPE_P(data) == IS_STRING) {
- xmlNodeSetContentLen(xmlParam, BAD_CAST(Z_STRVAL_P(data)), Z_STRLEN_P(data));
- } else if (Z_TYPE_P(data) == IS_UNICODE) {
+ } else if (Z_TYPE_P(data) == IS_STRING || Z_TYPE_P(data) == IS_UNICODE) {
char *str;
TSRMLS_FETCH();
- str = soap_unicode_to_string(Z_USTRVAL_P(data), Z_USTRLEN_P(data) TSRMLS_CC);
+ str = soap_encode_string(data, NULL TSRMLS_CC);
xmlNodeSetContent(xmlParam, BAD_CAST(str));
efree(str);
}
buf = xmlBufferCreate();
xmlNodeDump(buf, NULL, data, 0, 0);
MAKE_STD_ZVAL(ret);
- ZVAL_STRING(ret, (char*)xmlBufferContent(buf), 1);
- if (UG(unicode)) {
- zval_string_to_unicode_ex(ret, UG(utf8_conv) TSRMLS_CC);
- }
+ soap_decode_string(ret, (char*)xmlBufferContent(buf) TSRMLS_CC);
xmlBufferFree(buf);
return ret;
}
#include "ext/session/php_session.h"
#endif
#include "zend_exceptions.h"
+#include "ext/libxml/php_libxml.h"
typedef struct _soapHeader {
sdlFunctionPtr function;
PHP_METHOD(SoapClient, __getTypes);
PHP_METHOD(SoapClient, __doRequest);
PHP_METHOD(SoapClient, __setCookie);
+PHP_METHOD(SoapClient, __getCookies);
PHP_METHOD(SoapClient, __setLocation);
PHP_METHOD(SoapClient, __setSoapHeaders);
PHP_ME(SoapClient, __getTypes, NULL, 0)
PHP_ME(SoapClient, __doRequest, NULL, 0)
PHP_ME(SoapClient, __setCookie, NULL, 0)
+ PHP_ME(SoapClient, __getCookies, NULL, 0)
PHP_ME(SoapClient, __setLocation, NULL, 0)
PHP_ME(SoapClient, __setSoapHeaders, NULL, 0)
{NULL, NULL, NULL}
return tmp;
}
+void soap_decode_string(zval *ret, char* str TSRMLS_DC)
+{
+ if (UG(unicode)) {
+ /* TODO: unicode support */
+ ZVAL_STRING(ret, str, 1);
+ zval_string_to_unicode_ex(ret, UG(utf8_conv) TSRMLS_CC);
+ } else if (SOAP_GLOBAL(encoding) != NULL) {
+ xmlBufferPtr in = xmlBufferCreateStatic(str, strlen(str));
+ xmlBufferPtr out = xmlBufferCreate();
+ int n = xmlCharEncOutFunc(SOAP_GLOBAL(encoding), out, in);
+
+ if (n >= 0) {
+ ZVAL_STRING(ret, (char*)xmlBufferContent(out), 1);
+ } else {
+ ZVAL_STRING(ret, str, 1);
+ }
+ xmlBufferFree(out);
+ xmlBufferFree(in);
+ } else {
+ ZVAL_STRING(ret, str, 1);
+ }
+}
+
+char* soap_encode_string_ex(zend_uchar type, zstr data, int len TSRMLS_DC)
+{
+ char *str;
+ int new_len;
+
+ if (type == IS_UNICODE) {
+ str = soap_unicode_to_string(data.u, len TSRMLS_CC);
+ } else {
+ str = estrndup(data.s, len);
+ new_len = len;
+
+ if (SOAP_GLOBAL(encoding) != NULL) {
+ xmlBufferPtr in = xmlBufferCreateStatic(str, new_len);
+ xmlBufferPtr out = xmlBufferCreate();
+ int n = xmlCharEncInFunc(SOAP_GLOBAL(encoding), out, in);
+
+ if (n >= 0) {
+ efree(str);
+ str = estrdup((char*)xmlBufferContent(out));
+ } else if (!php_libxml_xmlCheckUTF8(BAD_CAST(str))) {
+ soap_error1(E_ERROR, "Encoding: string '%s' is not a valid utf-8 string", str);
+ }
+ xmlBufferFree(out);
+ xmlBufferFree(in);
+ } else if (!php_libxml_xmlCheckUTF8(BAD_CAST(str))) {
+ soap_error1(E_ERROR, "Encoding: string '%s' is not a valid utf-8 string", str);
+ }
+ }
+ return str;
+}
+
+char* soap_encode_string(zval *data, int* len TSRMLS_DC)
+{
+ char *str;
+ int new_len;
+
+ if (Z_TYPE_P(data) == IS_UNICODE) {
+ str = soap_unicode_to_string(Z_USTRVAL_P(data), Z_USTRLEN_P(data) TSRMLS_CC);
+ new_len = strlen(str);
+ } else {
+ if (Z_TYPE_P(data) == IS_STRING) {
+ str = estrndup(Z_STRVAL_P(data), Z_STRLEN_P(data));
+ new_len = Z_STRLEN_P(data);
+ } else {
+ zval tmp = *data;
+
+ zval_copy_ctor(&tmp);
+ convert_to_string(&tmp);
+ str = estrndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
+ new_len = Z_STRLEN(tmp);
+ zval_dtor(&tmp);
+ }
+
+ if (SOAP_GLOBAL(encoding) != NULL) {
+ xmlBufferPtr in = xmlBufferCreateStatic(str, new_len);
+ xmlBufferPtr out = xmlBufferCreate();
+ int n = xmlCharEncInFunc(SOAP_GLOBAL(encoding), out, in);
+
+ if (n >= 0) {
+ efree(str);
+ str = estrdup((char*)xmlBufferContent(out));
+ new_len = n;
+ } else if (!php_libxml_xmlCheckUTF8(BAD_CAST(str))) {
+ soap_error1(E_ERROR, "Encoding: string '%s' is not a valid utf-8 string", str);
+ }
+ xmlBufferFree(out);
+ xmlBufferFree(in);
+ } else if (!php_libxml_xmlCheckUTF8(BAD_CAST(str))) {
+ soap_error1(E_ERROR, "Encoding: string '%s' is not a valid utf-8 string", str);
+ }
+ }
+ if (len) {
+ *len = new_len;
+ }
+ return str;
+}
ZEND_INI_MH(OnUpdateCacheEnabled)
{
zend_hash_internal_pointer_reset_ex(ft, &pos);
while (zend_hash_get_current_data_ex(ft, (void **)&f, &pos) != FAILURE) {
if ((service->type != SOAP_CLASS) || (f->common.fn_flags & ZEND_ACC_PUBLIC)) {
- /* FIXME: Unicode support??? */
add_next_index_text(return_value, f->common.function_name, 1);
}
zend_hash_move_forward_ex(ft, &pos);
HashTable *function_table;
soapHeader *soap_headers = NULL;
sdlFunctionPtr function;
- char *arg = NULL;
+ zstr arg = NULL_ZSTR;
int arg_len;
xmlCharEncodingHandlerPtr old_encoding;
HashTable *old_class_map;
int old_features;
+ zend_uchar arg_type;
SOAP_SERVER_BEGIN_CODE();
service = (soap_server_object*)zend_object_store_get_object(this_ptr TSRMLS_CC);
SOAP_GLOBAL(soap_version) = service->version;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &arg, &arg_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|t", &arg, &arg_len, &arg_type) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
}
INIT_ZVAL(retval);
soap_server_fault("Server", "Bad Request. Can't find HTTP_RAW_POST_DATA", NULL, NULL, NULL TSRMLS_CC);
return;
}
+ } else if (arg_type == IS_UNICODE) {
+ /* TODO: remove unicode->string conversion */
+ char *str_req = soap_unicode_to_string(arg.u, arg_len TSRMLS_CC);
+
+ doc_request = soap_xmlParseMemory(str_req, strlen(str_req));
+ efree(str_req);
} else {
- doc_request = soap_xmlParseMemory(arg,arg_len);
+ doc_request = soap_xmlParseMemory(arg.s, arg_len);
}
if (doc_request == NULL) {
ZVAL_STRINGL(&func,"__doRequest",sizeof("__doRequest")-1,0);
INIT_ZVAL(param0);
params[0] = ¶m0;
- ZVAL_STRINGL(params[0], buf, buf_size, 0);
+ ZVAL_STRINGL(params[0], buf, buf_size, 1);
+ if (UG(unicode)) {
+ zval_string_to_unicode_ex(params[0], UG(utf8_conv) TSRMLS_CC);
+ }
INIT_ZVAL(param1);
params[1] = ¶m1;
if (location == NULL) {
ZVAL_NULL(params[1]);
} else {
- /* TODO: Unicode support */
- ZVAL_STRING(params[1], location, 0);
+ ZVAL_STRING(params[1], location, 1);
+ if (UG(unicode)) {
+ zval_string_to_unicode_ex(params[1], UG(utf8_conv) TSRMLS_CC);
+ }
}
INIT_ZVAL(param2);
params[2] = ¶m2;
if (action == NULL) {
ZVAL_NULL(params[2]);
} else {
- /* TODO: Unicode support */
- ZVAL_STRING(params[2], action, 0);
+ ZVAL_STRING(params[2], action, 1);
+ if (UG(unicode)) {
+ zval_string_to_unicode_ex(params[2], UG(utf8_conv) TSRMLS_CC);
+ }
}
INIT_ZVAL(param3);
params[3] = ¶m3;
ret = FALSE;
} else {
if (Z_TYPE_P(response) == IS_UNICODE) {
- zval_unicode_to_string_ex(response, ZEND_U_CONVERTER(UG(runtime_encoding_conv)) TSRMLS_CC);
+ zval_unicode_to_string_ex(response, UG(utf8_conv) TSRMLS_CC);
}
if (client->trace) {
if (client->last_response) {
}
}
xmlFree(buf);
+ zval_dtor(params[0]);
+ zval_dtor(params[1]);
+ zval_dtor(params[2]);
if (ret && client->fault) {
return FALSE;
}
if (output_headers) {
array_init(output_headers);
}
- if (function_type == IS_UNICODE) {
- function.s = soap_unicode_to_string(function.u, function_len TSRMLS_CC);
- function_len = strlen(function.s);
- }
+
+ function.s = soap_encode_string_ex(function_type, function, function_len TSRMLS_CC);
+ function_len = strlen(function.s);
do_soap_call(this_ptr, function.s, function_len, arg_count, real_args, return_value, location, soap_action, uri, soap_headers, output_headers TSRMLS_CC);
- if (function_type == IS_UNICODE) {
- efree(function.s);
- }
+ efree(function.s);
+
if (arg_count > 0) {
efree(real_args);
}
SoapClient::__doRequest() */
PHP_METHOD(SoapClient, __doRequest)
{
- char *buf, *location, *action;
+ zstr buf, location, action;
int buf_size, location_size, action_size;
+ zend_uchar buf_type, location_type, action_type;
long version;
long one_way = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sssl|l",
- &buf, &buf_size,
- &location, &location_size,
- &action, &action_size,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "tttl|l",
+ &buf, &buf_size, &buf_type,
+ &location, &location_size, &location_type,
+ &action, &action_size, &action_type,
&version, &one_way) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
}
+ if (buf_type == IS_UNICODE) {
+ buf.s = soap_unicode_to_string(buf.u, buf_size TSRMLS_CC);
+ buf_size = strlen(buf.s);
+ }
+ if (location_type == IS_UNICODE) {
+ location.s = soap_unicode_to_string(location.u, location_size TSRMLS_CC);
+ }
+ if (action_type == IS_UNICODE) {
+ action.s = soap_unicode_to_string(action.u, action_size TSRMLS_CC);
+ }
if (SOAP_GLOBAL(features) & SOAP_WAIT_ONE_WAY_CALLS) {
one_way = 0;
}
if (one_way) {
- if (make_http_soap_request(this_ptr, buf, buf_size, location, action, version, NULL, NULL TSRMLS_CC)) {
- RETURN_EMPTY_STRING();
+ if (make_http_soap_request(this_ptr, buf.s, buf_size, location.s, action.s, version, NULL, NULL TSRMLS_CC)) {
+ RETVAL_EMPTY_STRING();
}
- } else if (make_http_soap_request(this_ptr, buf, buf_size, location, action, version,
+ } else if (make_http_soap_request(this_ptr, buf.s, buf_size, location.s, action.s, version,
&Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value) TSRMLS_CC)) {
return_value->type = IS_STRING;
- return;
+ if (UG(unicode)) {
+ zval_string_to_unicode_ex(return_value, UG(utf8_conv) TSRMLS_CC);
+ }
+ }
+ if (buf_type == IS_UNICODE) {
+ efree(buf.s);
+ }
+ if (location_type == IS_UNICODE) {
+ efree(location.s);
+ }
+ if (action_type == IS_UNICODE) {
+ efree(action.s);
}
- RETURN_NULL();
}
/* }}} */
If value is not specified cookie is removed. */
PHP_METHOD(SoapClient, __setCookie)
{
- char *name;
- char *val = NULL;
+ zstr name;
+ zstr val = NULL_ZSTR;
int name_len, val_len;
+ zend_uchar name_type, val_type;
soap_client_object *client;
client = (soap_client_object*)zend_object_store_get_object(this_ptr TSRMLS_CC);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s",
- &name, &name_len, &val, &val_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|t",
+ &name, &name_len, &name_type, &val, &val_len, &val_type) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
RETURN_NULL();
}
- if (val == NULL) {
+ if (val.v == NULL) {
if (client->cookies) {
- zend_hash_del(Z_ARRVAL_P(client->cookies), name, name_len+1);
+ zend_u_hash_del(Z_ARRVAL_P(client->cookies), name_type, name, name_len+1);
}
} else {
zval *zcookie;
ALLOC_INIT_ZVAL(zcookie);
array_init(zcookie);
- add_index_stringl(zcookie, 0, val, val_len, 1);
- add_assoc_zval_ex(client->cookies, name, name_len+1, zcookie);
+ if (val_type == IS_STRING) {
+ add_index_stringl(zcookie, 0, val.s, val_len, 1);
+ } else {
+ add_index_unicodel(zcookie, 0, val.u, val_len, 1);
+ }
+ add_u_assoc_zval_ex(client->cookies, name_type, name, name_len+1, zcookie);
+ }
+}
+/* }}} */
+
+/* {{{ proto array SoapClient::__getCookies()
+ Returns array of cookies. */
+PHP_METHOD(SoapClient, __getCookies)
+{
+ soap_client_object *client;
+
+ client = (soap_client_object*)zend_object_store_get_object(this_ptr TSRMLS_CC);
+
+ if (!client->cookies) {
+ array_init(return_value);
+ } else {
+ *return_value = *client->cookies;
+ zval_copy_ctor(return_value);
+ INIT_PZVAL(return_value);
}
}
/* }}} */
ulong param_index = i;
param_name_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(ret), ¶m_name, ¶m_name_len, ¶m_index, 0, &pos);
- if (param_name_type == IS_UNICODE) {
- param_name.s = soap_unicode_to_string(param_name.u, param_name_len TSRMLS_CC);
- param_name_len = strlen(param_name.s);
- }
+ param_name.s = soap_encode_string_ex(param_name_type, param_name, param_name_len TSRMLS_CC);
+ param_name_len = strlen(param_name.s);
parameter = get_param(function, param_name.s, param_index, TRUE);
if (style == SOAP_RPC) {
param = serialize_parameter(parameter, *data, i, param_name.s, use, method TSRMLS_CC);
}
}
}
- if (param_name_type == IS_UNICODE) {
- efree(param_name.v);
- }
+ efree(param_name.s);
zend_hash_move_forward_ex(Z_ARRVAL_P(ret), &pos);
i++;
smart_str key = {0};
if (zend_hash_find(ht, "namespace", sizeof("namespace"), (void**)&tmp) == SUCCESS) {
- if (Z_TYPE_PP(tmp) == IS_STRING) {
- smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
- smart_str_appendc(&key, ':');
- hdr_ns = Z_STRVAL_PP(tmp);
- } else if (Z_TYPE_PP(tmp) == IS_UNICODE) {
- char *str = soap_unicode_to_string(Z_USTRVAL_PP(tmp), Z_USTRLEN_PP(tmp) TSRMLS_CC);
+ if (Z_TYPE_PP(tmp) == IS_STRING || Z_TYPE_PP(tmp) == IS_UNICODE) {
+ char *str = soap_encode_string(*tmp, NULL TSRMLS_CC);
smart_str_appends(&key, str);
smart_str_appendc(&key, ':');
}
}
if (zend_hash_find(ht, "name", sizeof("name"), (void**)&tmp) == SUCCESS) {
- if (Z_TYPE_PP(tmp) == IS_STRING) {
- smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
- hdr_name = Z_STRVAL_PP(tmp);
- } else if (Z_TYPE_PP(tmp) == IS_UNICODE) {
- char *str = soap_unicode_to_string(Z_USTRVAL_PP(tmp), Z_USTRLEN_PP(tmp) TSRMLS_CC);
+ if (Z_TYPE_PP(tmp) == IS_STRING || Z_TYPE_PP(tmp) == IS_UNICODE) {
+ char *str = soap_encode_string(*tmp, NULL TSRMLS_CC);
smart_str_appends(&key, str);
hdr_name = str;
smart_str key = {0};
if (zend_hash_find(ht, "namespace", sizeof("namespace"), (void**)&tmp) == SUCCESS) {
- if (Z_TYPE_PP(tmp) == IS_STRING) {
- smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
- smart_str_appendc(&key, ':');
- hdr_ns = Z_STRVAL_PP(tmp);
- } else if (Z_TYPE_PP(tmp) == IS_UNICODE) {
- char *str = soap_unicode_to_string(Z_USTRVAL_PP(tmp), Z_USTRLEN_PP(tmp) TSRMLS_CC);
+ if (Z_TYPE_PP(tmp) == IS_STRING || Z_TYPE_PP(tmp) == IS_UNICODE) {
+ char *str = soap_encode_string(*tmp, NULL TSRMLS_CC);
smart_str_appends(&key, str);
smart_str_appendc(&key, ':');
}
}
if (zend_hash_find(ht, "name", sizeof("name"), (void**)&tmp) == SUCCESS) {
- if (Z_TYPE_PP(tmp) == IS_STRING) {
- smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
- hdr_name = Z_STRVAL_PP(tmp);
- } else if (Z_TYPE_PP(tmp) == IS_UNICODE) {
- char *str = soap_unicode_to_string(Z_USTRVAL_PP(tmp), Z_USTRLEN_PP(tmp) TSRMLS_CC);
+ if (Z_TYPE_PP(tmp) == IS_STRING || Z_TYPE_PP(tmp) == IS_UNICODE) {
+ char *str = soap_encode_string(*tmp, NULL TSRMLS_CC);
smart_str_appends(&key, str);
hdr_name = str;
smart_str key = {0};
sdlSoapBindingFunctionHeaderPtr *hdr;
- if (Z_TYPE_PP(ns) == IS_STRING) {
- smart_str_appendl(&key, Z_STRVAL_PP(ns), Z_STRLEN_PP(ns));
- } else {
- char *str = soap_unicode_to_string(Z_USTRVAL_PP(ns), Z_USTRLEN_PP(ns) TSRMLS_CC);
+ ns_str = soap_encode_string(*ns, NULL TSRMLS_CC);
+ smart_str_appends(&key, ns_str);
- smart_str_appends(&key, str);
- ns_str = str;
- }
smart_str_appendc(&key, ':');
- if (Z_TYPE_PP(name) == IS_STRING) {
- smart_str_appendl(&key, Z_STRVAL_PP(name), Z_STRLEN_PP(name));
- } else {
- char *str = soap_unicode_to_string(Z_USTRVAL_PP(name), Z_USTRLEN_PP(name) TSRMLS_CC);
- smart_str_appends(&key, str);
- name_str = str;
- }
+ name_str = soap_encode_string(*name, NULL TSRMLS_CC);
+
+ smart_str_appends(&key, name_str);
smart_str_0(&key);
+
if (zend_hash_find(hdrs, key.c, key.len+1,(void**)&hdr) == SUCCESS) {
hdr_use = (*hdr)->use;
enc = (*hdr)->encode;
}
smart_str_free(&key);
} else {
- if (Z_TYPE_PP(ns) == IS_UNICODE) {
- ns_str = soap_unicode_to_string(Z_USTRVAL_PP(ns), Z_USTRLEN_PP(ns) TSRMLS_CC);
- }
- if (Z_TYPE_PP(name) == IS_UNICODE) {
- name_str = soap_unicode_to_string(Z_USTRVAL_PP(name), Z_USTRLEN_PP(name) TSRMLS_CC);
- }
+ ns_str = soap_encode_string(*ns, NULL TSRMLS_CC);
+ name_str = soap_encode_string(*name, NULL TSRMLS_CC);
}
if (zend_hash_find(ht, "data", sizeof("data"), (void**)&tmp) == SUCCESS) {
}
}
if (zend_hash_find(ht, "actor", sizeof("actor"), (void**)&tmp) == SUCCESS) {
- if (Z_TYPE_PP(tmp) == IS_STRING) {
- if (version == SOAP_1_1) {
- xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":actor"), BAD_CAST(Z_STRVAL_PP(tmp)));
- } else {
- xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(Z_STRVAL_PP(tmp)));
- }
- } else if (Z_TYPE_PP(tmp) == IS_UNICODE) {
- char *str = soap_unicode_to_string(Z_USTRVAL_PP(tmp), Z_STRLEN_PP(tmp) TSRMLS_CC);
+ if (Z_TYPE_PP(tmp) == IS_STRING || Z_TYPE_PP(tmp) == IS_UNICODE) {
+ char *str = soap_encode_string(*tmp, NULL TSRMLS_CC);
if (version == SOAP_1_1) {
xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":actor"), BAD_CAST(str));
(Z_TYPE_PP(param_name) == IS_STRING || Z_TYPE_PP(param_name) == IS_UNICODE) &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
- if (Z_TYPE_PP(param_name) == IS_STRING) {
- name = Z_STRVAL_PP(param_name);
- } else {
- name = soap_unicode_to_string(Z_USTRVAL_PP(param_name), Z_USTRLEN_PP(param_name) TSRMLS_CC);
- free_name = 1;
- }
+ name = soap_encode_string(*param_name, NULL TSRMLS_CC);
+ free_name = 1;
}
}