/* Client Functions */
PHP_METHOD(soapobject, soapobject);
PHP_METHOD(soapobject, __login);
-PHP_METHOD(soapobject, __soapversion);
-PHP_METHOD(soapobject, __use);
-PHP_METHOD(soapobject, __style);
PHP_METHOD(soapobject, __isfault);
PHP_METHOD(soapobject, __getfault);
PHP_METHOD(soapobject, __call);
-PHP_METHOD(soapobject, __trace);
PHP_METHOD(soapobject, __getfunctions);
PHP_METHOD(soapobject, __gettypes);
+PHP_METHOD(soapobject, __trace);
PHP_METHOD(soapobject, __getlastresponse);
PHP_METHOD(soapobject, __getlastrequest);
static zend_function_entry soap_client_functions[] = {
PHP_ME(soapobject, soapobject, NULL, 0)
PHP_ME(soapobject, __login, NULL, 0)
- PHP_ME(soapobject, __soapversion, NULL, 0)
PHP_ME(soapobject, __isfault, NULL, 0)
PHP_ME(soapobject, __getfault, NULL, 0)
- PHP_ME(soapobject, __use, NULL, 0)
- PHP_ME(soapobject, __style, NULL, 0)
PHP_ME(soapobject, __call, NULL, 0)
PHP_ME(soapobject, __trace, NULL, 0)
PHP_ME(soapobject, __getlastrequest, NULL, 0)
soap_globals->use_soap_error_handler = 0;
soap_globals->sdl = NULL;
+ soap_globals->soap_version = SOAP_1_1;
}
static void php_soap_del_globals(zend_soap_globals *soap_globals)
PHP_METHOD(soapserver, handle)
{
- int soap_version;
+ int soap_version, old_soap_version;
+ sdlPtr old_sdl = NULL;
soapServicePtr service;
xmlDocPtr doc_request, doc_return;
zval function_name, **params, **raw_post, *soap_obj, retval, **server_vars;
php_error(E_ERROR,"DTD are not supported by SOAP");
}
+ old_sdl = SOAP_GLOBAL(sdl);
SOAP_GLOBAL(sdl) = service->sdl;
+ old_soap_version = SOAP_GLOBAL(soap_version);
deseralize_function_call(service->sdl, doc_request, &function_name, &num_params, ¶ms, &soap_version TSRMLS_CC);
xmlFreeDoc(doc_request);
php_error(E_ERROR, "Function (%s) call failed", Z_STRVAL(function_name));
}
- SOAP_GLOBAL(sdl) = NULL;
+ SOAP_GLOBAL(soap_version) = old_soap_version;
+ SOAP_GLOBAL(sdl) = old_sdl;
/* Flush buffer */
php_end_ob_buffer(0, 0 TSRMLS_CC);
}
sprintf(cont_len, "Content-Length: %d", size);
- sapi_add_header("Content-Type: text/xml; charset=\"utf-8\"", sizeof("Content-Type: text/xml; charset=\"utf-8\""), 1);
+ if (soap_version == SOAP_1_2) {
+ sapi_add_header("Content-Type: application/soap+xml; charset=\"utf-8\"", sizeof("Content-Type: application/soap+xml; charset=\"utf-8\""), 1);
+ } else {
+ sapi_add_header("Content-Type: text/xml; charset=\"utf-8\"", sizeof("Content-Type: text/xml; charset=\"utf-8\""), 1);
+ }
sapi_add_header(cont_len, strlen(cont_len) + 1, 1);
/* Free Memory */
{
char buffer[1024];
int buffer_len;
+ int soap_version;
TSRMLS_FETCH();
if (!SOAP_GLOBAL(use_soap_error_handler)) {
old_error_handler(error_num, error_filename, error_lineno, format, args);
return;
}
+ soap_version = SOAP_GLOBAL(soap_version);
buffer_len = vsnprintf(buffer, sizeof(buffer)-1, format, args);
buffer[sizeof(buffer)-1]=0;
if (buffer_len > sizeof(buffer) - 1 || buffer_len < 0) {
php_end_ob_buffer(0, 0 TSRMLS_CC);
set_soap_fault(&ret, "SOAP-ENV:Server", buffer, NULL, &outbuf TSRMLS_CC);
- doc_return = seralize_response_call(NULL, NULL, NULL, &ret, SOAP_1_1 TSRMLS_CC);
+ doc_return = seralize_response_call(NULL, NULL, NULL, &ret, soap_version TSRMLS_CC);
/* Build and send our headers + http 500 status */
/*
xmlDocDumpMemory(doc_return, &buf, &size);
sprintf(cont_len,"Content-Length: %d", size);
sapi_add_header(cont_len, strlen(cont_len) + 1, 1);
- sapi_add_header("Content-Type: text/xml; charset=\"utf-8\"", sizeof("Content-Type: text/xml; charset=\"utf-8\""), 1);
-
+ if (soap_version == SOAP_1_2) {
+ sapi_add_header("Content-Type: application/soap+xml; charset=\"utf-8\"", sizeof("Content-Type: application/soap+xml; charset=\"utf-8\""), 1);
+ } else {
+ sapi_add_header("Content-Type: text/xml; charset=\"utf-8\"", sizeof("Content-Type: text/xml; charset=\"utf-8\""), 1);
+ }
/*
Want to return HTTP 500 but apache wants to over write
our fault code with their own handling... Figure this out later
/* SoapObject functions */
+/*
+ SoapObject($wsdl, $version=SOAP_1_1)
+ SoapObject($location, $uri, $style=SOAP_RPC, $use=SOAP_ENCODED, $version=SOAP_1_1)
+*/
PHP_METHOD(soapobject, soapobject)
{
- char *location, *uri = NULL;
- int location_len, uri_len = 0;
+ char *location;
+ int location_len;
zval *thisObj;
+ zval *arg2 = NULL;
+ long use = SOAP_RPC;
+ long style = SOAP_ENCODED;
+ long version = SOAP_1_1;
GET_THIS_OBJECT(thisObj);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &location, &location_len, &uri, &uri_len) == SUCCESS) {
- if (uri) {
- /* if two parameters assume 'proxy' and 'uri' */
- add_property_stringl(thisObj, "location", location, location_len, 1);
- add_property_stringl(thisObj, "uri", uri, uri_len, 1);
- } else {
- /* if one parameter assume 'wsdl' */
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|zlll", &location, &location_len, &arg2, &style, &use, &version) == SUCCESS) {
+ if (arg2 == NULL || Z_TYPE_P(arg2) == IS_LONG) {
+ /* SoapObject($wsdl, $version=SOAP_1_1) */
sdlPtr sdl;
int ret;
add_property_resource(thisObj, "sdl", ret);
zend_list_addref(ret);
- }
- }
-}
-PHP_METHOD(soapobject, __use)
-{
- int use;
- zval *thisObj;
-
- GET_THIS_OBJECT(thisObj);
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &use) == FAILURE) {
- php_error(E_ERROR, "Invalid arguments to SoapObject->__use");
- }
-
- if (use == SOAP_ENCODED || use == SOAP_LITERAL) {
- add_property_long(thisObj, "use", use);
- RETURN_TRUE;
- }
- RETURN_FALSE;
-}
-
-PHP_METHOD(soapobject, __style)
-{
- int style;
- zval *thisObj;
-
- GET_THIS_OBJECT(thisObj);
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &style)) {
- php_error(E_ERROR, "Invalid arguments to SoapObject->__style");
- }
-
- if (style == SOAP_RPC || style == SOAP_DOCUMENT) {
- add_property_long(thisObj, "style", style);
- RETURN_TRUE;
+ if (arg2 != NULL) {
+ version = Z_LVAL_P(arg2);
+ }
+ if (version == SOAP_1_1 || version == SOAP_1_2) {
+ add_property_long(thisObj, "_soap_version", version);
+ } else {
+ php_error(E_ERROR,"Can't create SoapObject. Wrong 'version' parameter.");
+ }
+ } else if (arg2 != NULL && Z_TYPE_P(arg2) == IS_STRING) {
+ /* SoapObject($location, $uri, $style=SOAP_RPC, $use=SOAP_ENCODED, $version=SOAP_1_1) */
+ add_property_stringl(thisObj, "location", location, location_len, 1);
+ add_property_stringl(thisObj, "uri", Z_STRVAL_P(arg2), Z_STRLEN_P(arg2), 1);
+ if (style == SOAP_RPC || style == SOAP_DOCUMENT) {
+ add_property_long(thisObj, "style", style);
+ } else {
+ php_error(E_ERROR,"Can't create SoapObject. Wrong 'style' parameter.");
+ }
+ if (use == SOAP_ENCODED || use == SOAP_LITERAL) {
+ add_property_long(thisObj, "use", use);
+ } else {
+ php_error(E_ERROR,"Can't create SoapObject. Wrong 'use' parameter.");
+ }
+ if (version == SOAP_1_1 || version == SOAP_1_2) {
+ add_property_long(thisObj, "_soap_version", version);
+ } else {
+ php_error(E_ERROR,"Can't create SoapObject. Wrong 'version' parameter.");
+ }
+ } else {
+ php_error(E_ERROR,"Can't create SoapObject. Wrong parameters.");
+ }
}
- RETURN_FALSE;
}
PHP_METHOD(soapobject, __trace)
zval **tmp;
zval **trace;
sdlPtr sdl = NULL;
+ sdlPtr old_sdl = NULL;
sdlFunctionPtr fn;
xmlDocPtr request = NULL;
char *buffer;
int len;
int ret = FALSE;
- int soap_version;
+ int soap_version, old_soap_version;
if (zend_hash_find(Z_OBJPROP_P(thisObj), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
&& Z_LVAL_PP(trace) > 0) {
clear_soap_fault(thisObj TSRMLS_CC);
zend_try {
+ old_soap_version = SOAP_GLOBAL(soap_version);
+ SOAP_GLOBAL(soap_version) = soap_version;
+ old_sdl = SOAP_GLOBAL(sdl);
SOAP_GLOBAL(sdl) = sdl;
if (sdl != NULL) {
php_strtolower(function, function_len);
if (binding->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)fn->bindingAttributes;
request = seralize_function_call(thisObj, fn, NULL, fnb->input.ns, real_args, arg_count, soap_version TSRMLS_CC);
- ret = send_http_soap_request(thisObj, request, binding->location, fnb->soapAction TSRMLS_CC);
+ ret = send_http_soap_request(thisObj, request, binding->location, fnb->soapAction, soap_version TSRMLS_CC);
} else {
request = seralize_function_call(thisObj, fn, NULL, sdl->target_ns, real_args, arg_count, soap_version TSRMLS_CC);
- ret = send_http_soap_request(thisObj, request, binding->location, NULL TSRMLS_CC);
+ ret = send_http_soap_request(thisObj, request, binding->location, NULL, soap_version TSRMLS_CC);
}
xmlFreeDoc(request);
} else {
request = seralize_function_call(thisObj, NULL, function, Z_STRVAL_PP(uri), real_args, arg_count, soap_version TSRMLS_CC);
action = build_soap_action(thisObj, function);
- ret = send_http_soap_request(thisObj, request, Z_STRVAL_PP(location), action->c TSRMLS_CC);
+ ret = send_http_soap_request(thisObj, request, Z_STRVAL_PP(location), action->c, soap_version TSRMLS_CC);
smart_str_free(action);
efree(action);
zval_copy_ctor(return_value);
}
}
- SOAP_GLOBAL(sdl) = NULL;
-}
-
-PHP_METHOD(soapobject, __soapversion)
-{
- int version;
- zval *thisObj;
-
- GET_THIS_OBJECT(thisObj);
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &version)) {
- return;
- }
-
- if (version == SOAP_1_1 || version == SOAP_1_2) {
- add_property_long(thisObj, "_soap_version", version);
- RETURN_TRUE;
- }
- RETURN_FALSE;
+ SOAP_GLOBAL(soap_version) = old_soap_version;
+ SOAP_GLOBAL(sdl) = old_sdl;
}
PHP_METHOD(soapobject, __login)
env = trav;
*version = SOAP_1_1;
envelope_ns = SOAP_1_1_ENV;
+ SOAP_GLOBAL(soap_version) = SOAP_1_1;
} else if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_2_ENV)) {
env = trav;
*version = SOAP_1_2;
envelope_ns = SOAP_1_2_ENV;
+ SOAP_GLOBAL(soap_version) = SOAP_1_2;
} else {
php_error(E_ERROR,"looks like we got bad SOAP request\n");
}
xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_1_ENC);
} else if (version == SOAP_1_2) {
xmlSetProp(envelope, "xmlns:SOAP-ENC", SOAP_1_2_ENC);
- xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_2_ENC);
+ /*xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_2_ENC);*/
}
}
xmlSetProp(envelope, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
xmlSetProp(envelope, "xmlns:" APACHE_NS_PREFIX , APACHE_NAMESPACE);
if (version == SOAP_1_1) {
- xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_1_ENC);
xmlSetProp(envelope, "xmlns:SOAP-ENC", SOAP_1_1_ENC);
+ xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_1_ENC);
} else if (version == SOAP_1_2) {
- xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_2_ENC);
xmlSetProp(envelope, "xmlns:SOAP-ENC", SOAP_1_2_ENC);
+ /*xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_2_ENC);*/
}
}
if (function->responseParameters && function->responseParameters->pListHead) {
sdlParamPtr *param;
param = function->responseParameters->pListHead->pData;
- smart_str_appendl(buf, (*param)->encode->details.type_str, strlen((*param)->encode->details.type_str));
- smart_str_appendc(buf, ' ');
+ if ((*param)->encode->details.type_str) {
+ smart_str_appendl(buf, (*param)->encode->details.type_str, strlen((*param)->encode->details.type_str));
+ smart_str_appendc(buf, ' ');
+ } else {
+ smart_str_appendl(buf, "mixed ", 6);
+ }
} else {
smart_str_appendl(buf, "void ", 5);
}
i = 0;
zend_hash_internal_pointer_reset_ex(function->requestParameters, &pos);
while (zend_hash_get_current_data_ex(function->requestParameters, (void **)¶m, &pos) != FAILURE) {
- smart_str_appendl(buf, (*param)->encode->details.type_str, strlen((*param)->encode->details.type_str));
+ if ((*param)->encode->details.type_str) {
+ smart_str_appendl(buf, (*param)->encode->details.type_str, strlen((*param)->encode->details.type_str));
+ } else {
+ smart_str_appendl(buf, "mixed ", 6);
+ }
smart_str_appendc(buf, ' ');
smart_str_appendc(buf, '$');
smart_str_appendl(buf, (*param)->paramName, strlen((*param)->paramName));