mirror of
https://github.com/php/php-src.git
synced 2025-01-22 03:34:19 +08:00
some more doc/lit stuff
some more wsdl stuff
This commit is contained in:
parent
b806a8e247
commit
7c1d2ff2e4
@ -956,14 +956,14 @@ encodePtr get_conversion_ex(HashTable *encoding, int encode)
|
||||
return *enc;
|
||||
}
|
||||
|
||||
encodePtr get_conversion_from_href_type_ex(HashTable *encoding, char *type)
|
||||
encodePtr get_conversion_from_href_type_ex(HashTable *encoding, char *type, int len)
|
||||
{
|
||||
encodePtr *enc = NULL;
|
||||
|
||||
if(encoding == NULL)
|
||||
return NULL;
|
||||
|
||||
if(zend_hash_find(encoding, type, strlen(type), (void **)&enc) == FAILURE)
|
||||
if(zend_hash_find(encoding, type, len + 1, (void **)&enc) == FAILURE)
|
||||
return NULL;
|
||||
|
||||
return (*enc);
|
||||
|
@ -206,7 +206,7 @@ xmlNodePtr to_xml_gmonth(encodeType type, zval *data, int style);
|
||||
|
||||
#define get_conversion(e) get_conversion_ex(SOAP_GLOBAL(defEncIndex), e)
|
||||
#define get_conversion_from_type(n, t) get_conversion_from_type_ex(SOAP_GLOBAL(defEnc), n, t)
|
||||
#define get_conversion_from_href_type(t) get_conversion_from_href_type_ex(SOAP_GLOBAL(defEnc), t)
|
||||
#define get_conversion_from_href_type(t) get_conversion_from_href_type_ex(SOAP_GLOBAL(defEnc), t, strlen(t))
|
||||
|
||||
void encode_reset_ns();
|
||||
smart_str *encode_new_ns();
|
||||
@ -215,7 +215,7 @@ void set_ns_and_type(xmlNodePtr node, encodeType type);
|
||||
void set_ns_and_type_ex(xmlNodePtr node, char *ns, char *type);
|
||||
encodePtr get_conversion_ex(HashTable *encoding, int encode);
|
||||
encodePtr get_conversion_from_type_ex(HashTable *encoding, xmlNodePtr node, char *type);
|
||||
encodePtr get_conversion_from_href_type_ex(HashTable *encoding, char *type);
|
||||
encodePtr get_conversion_from_href_type_ex(HashTable *encoding, char *type, int len);
|
||||
|
||||
int is_map(zval *array);
|
||||
void get_array_type(zval *array, smart_str *out_type);
|
||||
|
@ -52,41 +52,57 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
|
||||
resp = body->children;
|
||||
if(fn != NULL)
|
||||
{
|
||||
cur = get_node(resp, fn->responseName);
|
||||
if(cur != NULL)
|
||||
sdlParamPtr *h_param, param = NULL;
|
||||
xmlNodePtr val = NULL;
|
||||
encodePtr enc;
|
||||
char *name, *ns;
|
||||
|
||||
if(fn->bindingType == BINDING_SOAP)
|
||||
{
|
||||
int num_resp = zend_hash_num_elements(fn->responseParameters);
|
||||
if(num_resp <= 1)
|
||||
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)fn->bindingAttributes;
|
||||
|
||||
zend_hash_internal_pointer_reset(fn->responseParameters);
|
||||
if(zend_hash_get_current_data(fn->responseParameters, (void **)&h_param) != SUCCESS)
|
||||
php_error(E_ERROR, "Can't find response parameter \"%s\"", param->paramName);
|
||||
|
||||
param = (*h_param);
|
||||
if(fnb->style == SOAP_DOCUMENT)
|
||||
{
|
||||
sdlParamPtr *h_param, param;
|
||||
xmlNodePtr val;
|
||||
|
||||
zend_hash_internal_pointer_reset(fn->responseParameters);
|
||||
if(zend_hash_get_current_data(fn->responseParameters, (void **)&h_param) == SUCCESS)
|
||||
{
|
||||
param = (*h_param);
|
||||
val = get_node(cur->children, param->paramName);
|
||||
if(val != NULL)
|
||||
{
|
||||
encodePtr enc;
|
||||
tmp_ret = emalloc(sizeof(zval **));
|
||||
if(param != NULL)
|
||||
enc = param->encode;
|
||||
else
|
||||
enc = get_conversion(UNKNOWN_TYPE);
|
||||
|
||||
tmp_ret[0] = master_to_zval(enc, val);
|
||||
(*ret) = tmp_ret;
|
||||
(*num_params) = 1;
|
||||
}
|
||||
else
|
||||
php_error(E_ERROR, "Can't find response parameter \"%s\"", param->paramName);
|
||||
}
|
||||
name = (*h_param)->encode->details.type_str;
|
||||
ns = (*h_param)->encode->details.ns;
|
||||
}
|
||||
else
|
||||
{
|
||||
php_error(E_ERROR,"Doesn't handle multiple return values");
|
||||
name = fn->responseName;
|
||||
/* ns = ? */
|
||||
}
|
||||
|
||||
cur = get_node_ex(resp, name, ns);
|
||||
/* TODO: produce warning invalid ns */
|
||||
if(!cur)
|
||||
cur = get_node(resp, name);
|
||||
|
||||
if(!cur)
|
||||
php_error(E_ERROR, "Can't find response data");
|
||||
|
||||
|
||||
if(fnb->style == SOAP_DOCUMENT)
|
||||
val = cur;
|
||||
else
|
||||
val = get_node(cur->children, param->paramName);
|
||||
|
||||
if(!val)
|
||||
php_error(E_ERROR, "Can't find response data");
|
||||
|
||||
tmp_ret = emalloc(sizeof(zval **));
|
||||
if(param != NULL)
|
||||
enc = param->encode;
|
||||
else
|
||||
enc = get_conversion(UNKNOWN_TYPE);
|
||||
|
||||
tmp_ret[0] = master_to_zval(enc, val);
|
||||
(*ret) = tmp_ret;
|
||||
(*num_params) = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -442,7 +442,6 @@ void delete_restriction_var_int(void *rvi)
|
||||
sdlRestrictionIntPtr ptr = *((sdlRestrictionIntPtr*)rvi);
|
||||
if(ptr->id);
|
||||
free(ptr->id);
|
||||
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ encodePtr get_encoder_ex(sdlPtr sdl, char *nscat)
|
||||
|
||||
enc = get_conversion_from_href_type(nscat);
|
||||
if(enc == NULL && sdl)
|
||||
enc = get_conversion_from_href_type_ex(sdl->encoders, nscat);
|
||||
enc = get_conversion_from_href_type_ex(sdl->encoders, nscat, strlen(nscat));
|
||||
if(enc == NULL)
|
||||
enc = get_conversion(UNKNOWN_TYPE);
|
||||
return enc;
|
||||
@ -45,19 +45,21 @@ encodePtr get_encoder_ex(sdlPtr sdl, char *nscat)
|
||||
encodePtr get_create_encoder(sdlPtr sdl, sdlTypePtr cur_type, char *ns, char *type)
|
||||
{
|
||||
encodePtr enc = NULL;
|
||||
char *nscat;
|
||||
smart_str nscat = {0};
|
||||
TSRMLS_FETCH();
|
||||
|
||||
nscat = emalloc(strlen(ns) + strlen(type) + 2);
|
||||
sprintf(nscat, "%s:%s", ns, type);
|
||||
smart_str_appends(&nscat, ns);
|
||||
smart_str_appendc(&nscat, ':');
|
||||
smart_str_appends(&nscat, type);
|
||||
smart_str_0(&nscat);
|
||||
|
||||
enc = get_conversion_from_href_type(nscat);
|
||||
enc = get_conversion_from_href_type(nscat.c);
|
||||
if(enc == NULL)
|
||||
enc = get_conversion_from_href_type_ex(sdl->encoders, nscat);
|
||||
enc = get_conversion_from_href_type_ex(sdl->encoders, nscat.c, nscat.len);
|
||||
if(enc == NULL)
|
||||
enc = create_encoder(sdl, cur_type, ns, type);
|
||||
|
||||
efree(nscat);
|
||||
smart_str_free(&nscat);
|
||||
return enc;
|
||||
}
|
||||
|
||||
@ -78,7 +80,7 @@ encodePtr create_encoder(sdlPtr sdl, sdlTypePtr cur_type, char *ns, char *type)
|
||||
enc->details.type_str = strdup(type);
|
||||
enc->details.sdl_type = cur_type;
|
||||
enc->to_xml = sdl_guess_convert_xml;
|
||||
enc->to_zval = guess_zval_convert;
|
||||
enc->to_zval = sdl_guess_convert_zval;
|
||||
|
||||
if(sdl->encoders == NULL)
|
||||
{
|
||||
@ -89,32 +91,66 @@ encodePtr create_encoder(sdlPtr sdl, sdlTypePtr cur_type, char *ns, char *type)
|
||||
smart_str_free(&nscat);
|
||||
return enc;
|
||||
}
|
||||
|
||||
zval *sdl_guess_convert_zval(encodeType enc, xmlNodePtr data)
|
||||
{
|
||||
sdlTypePtr type;
|
||||
zval *ret;
|
||||
|
||||
type = enc.sdl_type;
|
||||
|
||||
if(type->encode)
|
||||
{
|
||||
if(type->encode->details.type == IS_ARRAY ||
|
||||
type->encode->details.type == SOAP_ENC_ARRAY)
|
||||
ret = to_zval_array(enc, data);
|
||||
else
|
||||
ret = master_to_zval(type->encode, data);
|
||||
}
|
||||
else if(zend_hash_num_elements(type->elements) == 1)
|
||||
{
|
||||
sdlTypePtr *t;
|
||||
zend_hash_internal_pointer_reset(type->elements);
|
||||
if(zend_hash_get_current_data(type->elements, (void **)&t) != FAILURE &&
|
||||
(*t)->max_occurs != 1)
|
||||
ret = to_zval_array(enc, data);
|
||||
}
|
||||
if(ret)
|
||||
return ret;
|
||||
else
|
||||
return guess_zval_convert(enc, data);
|
||||
}
|
||||
|
||||
xmlNodePtr sdl_guess_convert_xml(encodeType enc, zval *data, int style)
|
||||
{
|
||||
sdlTypePtr type;
|
||||
xmlNodePtr ret;
|
||||
xmlNodePtr ret = NULL;
|
||||
|
||||
ret = xmlNewNode(NULL, "BOGUS");
|
||||
type = enc.sdl_type;
|
||||
|
||||
if(type->encode->details.type == IS_ARRAY ||
|
||||
type->encode->details.type == SOAP_ENC_ARRAY)
|
||||
if(type->encode)
|
||||
{
|
||||
ret = sdl_to_xml_array(type, data, style);
|
||||
if(type->encode->details.type == IS_ARRAY ||
|
||||
type->encode->details.type == SOAP_ENC_ARRAY)
|
||||
ret = sdl_to_xml_array(type, data, style);
|
||||
else
|
||||
ret = master_to_xml(type->encode, data, style);
|
||||
}
|
||||
else if(type->encode != NULL)
|
||||
else if(type->elements)
|
||||
{
|
||||
ret = master_to_xml(type->encode, data, style);
|
||||
}
|
||||
else if(type->elements != NULL)
|
||||
{
|
||||
ret = sdl_to_xml_object(type, data, style);
|
||||
sdlTypePtr *t;
|
||||
if(zend_hash_num_elements(type->elements) == 1)
|
||||
{
|
||||
zend_hash_internal_pointer_reset(type->elements);
|
||||
if(zend_hash_get_current_data(type->elements, (void **)&t) != FAILURE &&
|
||||
(*t)->max_occurs != 1)
|
||||
ret = sdl_to_xml_array((*t), data, style);
|
||||
}
|
||||
if(!ret)
|
||||
ret = sdl_to_xml_object(type, data, style);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = guess_xml_convert(enc, data, style);
|
||||
}
|
||||
|
||||
//set_ns_and_type(ret, enc);
|
||||
return ret;
|
||||
@ -167,43 +203,48 @@ xmlNodePtr sdl_to_xml_array(sdlTypePtr type, zval *data, int style)
|
||||
sdlAttributePtr *arrayType;
|
||||
i = zend_hash_num_elements(Z_ARRVAL_P(data));
|
||||
|
||||
if(zend_hash_find(type->attributes, SOAP_ENC_NAMESPACE":arrayType", sizeof(SOAP_ENC_NAMESPACE":arrayType"), (void **)&arrayType) == SUCCESS)
|
||||
if(style == SOAP_ENCODED)
|
||||
{
|
||||
xmlAttrPtr *wsdl;
|
||||
if(zend_hash_find((*arrayType)->extraAttributes, WSDL_NAMESPACE":arrayType", sizeof(WSDL_NAMESPACE":arrayType"), (void **)&wsdl) == SUCCESS)
|
||||
if(type->attributes &&
|
||||
zend_hash_find(type->attributes, SOAP_ENC_NAMESPACE":arrayType",
|
||||
sizeof(SOAP_ENC_NAMESPACE":arrayType"),
|
||||
(void **)&arrayType) == SUCCESS)
|
||||
{
|
||||
char *ns = NULL, *value;
|
||||
smart_str *prefix = encode_new_ns();
|
||||
smart_str smart_ns = {0};
|
||||
xmlNsPtr myNs;
|
||||
xmlAttrPtr *wsdl;
|
||||
if(zend_hash_find((*arrayType)->extraAttributes, WSDL_NAMESPACE":arrayType", sizeof(WSDL_NAMESPACE":arrayType"), (void **)&wsdl) == SUCCESS)
|
||||
{
|
||||
char *ns = NULL, *value;
|
||||
smart_str *prefix = encode_new_ns();
|
||||
smart_str smart_ns = {0};
|
||||
xmlNsPtr myNs;
|
||||
|
||||
parse_namespace((*wsdl)->children->content, &value, &ns);
|
||||
myNs = xmlSearchNs((*wsdl)->doc, (*wsdl)->parent, ns);
|
||||
parse_namespace((*wsdl)->children->content, &value, &ns);
|
||||
myNs = xmlSearchNs((*wsdl)->doc, (*wsdl)->parent, ns);
|
||||
|
||||
smart_str_appendl(&smart_ns, "xmlns:", sizeof("xmlns:") - 1);
|
||||
smart_str_appendl(&smart_ns, prefix->c, prefix->len);
|
||||
smart_str_0(&smart_ns);
|
||||
smart_str_appendl(&smart_ns, "xmlns:", sizeof("xmlns:") - 1);
|
||||
smart_str_appendl(&smart_ns, prefix->c, prefix->len);
|
||||
smart_str_0(&smart_ns);
|
||||
|
||||
xmlSetProp(xmlParam, smart_ns.c, myNs->href);
|
||||
smart_str_appends(&array_type_and_size, prefix->c);
|
||||
smart_str_appendc(&array_type_and_size, ':');
|
||||
smart_str_appends(&array_type_and_size, value);
|
||||
xmlSetProp(xmlParam, smart_ns.c, myNs->href);
|
||||
smart_str_appends(&array_type_and_size, prefix->c);
|
||||
smart_str_appendc(&array_type_and_size, ':');
|
||||
smart_str_appends(&array_type_and_size, value);
|
||||
smart_str_0(&array_type_and_size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
smart_str_appends(&array_type_and_size, type->name);
|
||||
smart_str_appendc(&array_type_and_size, '[');
|
||||
smart_str_append_long(&array_type_and_size, i);
|
||||
smart_str_appendc(&array_type_and_size, ']');
|
||||
smart_str_0(&array_type_and_size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
smart_str_appends(&array_type_and_size, type->name);
|
||||
smart_str_appendc(&array_type_and_size, '[');
|
||||
smart_str_append_long(&array_type_and_size, i);
|
||||
smart_str_appendc(&array_type_and_size, ']');
|
||||
smart_str_0(&array_type_and_size);
|
||||
}
|
||||
xmlSetProp(xmlParam, SOAP_ENC_NS_PREFIX":arrayType", array_type_and_size.c);
|
||||
|
||||
xmlSetProp(xmlParam, SOAP_ENC_NS_PREFIX":arrayType", array_type_and_size.c);
|
||||
|
||||
smart_str_free(&array_type_and_size);
|
||||
smart_str_free(&array_type);
|
||||
smart_str_free(&array_type_and_size);
|
||||
smart_str_free(&array_type);
|
||||
}
|
||||
|
||||
zend_hash_internal_pointer_reset(data->value.ht);
|
||||
for(;i > 0;i--)
|
||||
@ -216,12 +257,14 @@ xmlNodePtr sdl_to_xml_array(sdlTypePtr type, zval *data, int style)
|
||||
enc = get_conversion((*zdata)->type);
|
||||
xparam = master_to_xml(enc, (*zdata), style);
|
||||
|
||||
xmlNodeSetName(xparam, "val");
|
||||
xmlNodeSetName(xparam, type->name);
|
||||
xmlAddChild(xmlParam, xparam);
|
||||
zend_hash_move_forward(data->value.ht);
|
||||
}
|
||||
}
|
||||
set_ns_and_type_ex(xmlParam, type->namens, type->name);
|
||||
|
||||
if(style == SOAP_ENCODED)
|
||||
set_ns_and_type_ex(xmlParam, type->namens, type->name);
|
||||
return xmlParam;
|
||||
}
|
||||
|
||||
@ -250,7 +293,6 @@ zval *sdl_convert_zval_to_zval(zval *data, sdlTypePtr type)
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
sdlPtr get_sdl(char *uri)
|
||||
{
|
||||
sdlPtr tmp, *hndl;
|
||||
|
@ -155,6 +155,7 @@ sdlBindingPtr get_binding_from_type(sdlPtr sdl, int type);
|
||||
sdlBindingPtr get_binding_from_name(sdlPtr sdl, char *name, char *ns);
|
||||
|
||||
xmlNodePtr sdl_guess_convert_xml(encodeType enc, zval* data, int style);
|
||||
zval *sdl_guess_convert_zval(encodeType enc, xmlNodePtr data);
|
||||
|
||||
xmlNodePtr sdl_to_xml_array(sdlTypePtr type, zval *data, int style);
|
||||
xmlNodePtr sdl_to_xml_object(sdlTypePtr type, zval *data, int style);
|
||||
|
@ -134,12 +134,12 @@ static void php_soap_init_globals(zend_soap_globals *soap_globals)
|
||||
char *ns_type;
|
||||
ns_type = emalloc(strlen(defaultEncoding[i].details.ns) + strlen(defaultEncoding[i].details.type_str) + 2);
|
||||
sprintf(ns_type, "%s:%s", defaultEncoding[i].details.ns, defaultEncoding[i].details.type_str);
|
||||
zend_hash_add(soap_globals->defEnc, ns_type, strlen(ns_type), &enc, sizeof(encodePtr), NULL);
|
||||
zend_hash_add(soap_globals->defEnc, ns_type, strlen(ns_type) + 1, &enc, sizeof(encodePtr), NULL);
|
||||
efree(ns_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
zend_hash_add(soap_globals->defEnc, defaultEncoding[i].details.type_str, strlen(defaultEncoding[i].details.type_str), &enc, sizeof(encodePtr), NULL);
|
||||
zend_hash_add(soap_globals->defEnc, defaultEncoding[i].details.type_str, strlen(defaultEncoding[i].details.type_str) + 1, &enc, sizeof(encodePtr), NULL);
|
||||
}
|
||||
}
|
||||
//Index everything by number
|
||||
@ -1807,11 +1807,13 @@ xmlDocPtr seralize_function_call(zval *this_ptr, sdlFunctionPtr function, char *
|
||||
{
|
||||
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes;
|
||||
|
||||
ns = xmlNewNs(body, fnb->input.ns, gen_ns->c);
|
||||
style = fnb->style;
|
||||
use = fnb->input.use;
|
||||
if(style == SOAP_RPC)
|
||||
{
|
||||
ns = xmlNewNs(body, fnb->input.ns, gen_ns->c);
|
||||
method = xmlNewChild(body, ns, function->requestName , NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2263,6 +2265,4 @@ int my_call_user_function(HashTable *function_table, zval **object_pp, zval *fun
|
||||
}
|
||||
}
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user