dmitry          Wed Mar 23 02:11:40 2005 EDT

  Added files:                 (Branch: PHP_5_0)
    /php-src/ext/soap/tests/bugs        bug31695.phpt bug31695.wsdl 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/soap   soap.c 
  Log:
  Fixed bug #31695 (Cannot redefine endpoint when using WSDL)
  
  
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1760.2.297&r2=1.1760.2.298&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1760.2.297 php-src/NEWS:1.1760.2.298
--- php-src/NEWS:1.1760.2.297   Tue Mar 22 10:09:18 2005
+++ php-src/NEWS        Wed Mar 23 02:11:38 2005
@@ -76,6 +76,7 @@
 - Fixed bug #31710 (Wrong return values for mysqli_autocommit/commit/rollback).
   (Georg)
 - Fixed bug #31705 (parse_url() does not recognize http://foo.com#bar). (Ilia)
+- Fixed bug #31695 (Cannot redefine endpoint when using WSDL). (Dmitry)
 - Fixed bug #31684 (dio_tcsetattr(): misconfigured termios settings).
   (elod at itfais dot com)
 - Fixed bug #31683 (changes to $name in __get($name) override future 
http://cvs.php.net/diff.php/php-src/ext/soap/soap.c?r1=1.110.2.27&r2=1.110.2.28&ty=u
Index: php-src/ext/soap/soap.c
diff -u php-src/ext/soap/soap.c:1.110.2.27 php-src/ext/soap/soap.c:1.110.2.28
--- php-src/ext/soap/soap.c:1.110.2.27  Tue Mar 22 05:18:48 2005
+++ php-src/ext/soap/soap.c     Wed Mar 23 02:11:39 2005
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <[EMAIL PROTECTED]>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: soap.c,v 1.110.2.27 2005/03/22 10:18:48 dmitry Exp $ */
+/* $Id: soap.c,v 1.110.2.28 2005/03/23 07:11:39 dmitry Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -236,6 +236,7 @@
 PHP_METHOD(SoapClient, __getTypes);
 PHP_METHOD(SoapClient, __doRequest);
 PHP_METHOD(SoapClient, __setCookie);
+PHP_METHOD(SoapClient, __setLocation);
 
 /* SoapVar Functions */
 PHP_METHOD(SoapVar, SoapVar);
@@ -323,6 +324,7 @@
        PHP_ME(SoapClient, __getTypes, NULL, 0)
        PHP_ME(SoapClient, __doRequest, NULL, 0)
        PHP_ME(SoapClient, __setCookie, NULL, 0)
+       PHP_ME(SoapClient, __setLocation, NULL, 0)
        {NULL, NULL, NULL}
 };
 
@@ -1975,14 +1977,6 @@
 
                if (wsdl == NULL) {
                        /* Fetching non-WSDL mode options */
-                       if (zend_hash_find(ht, "location", sizeof("location"), 
(void**)&tmp) == SUCCESS &&
-                           Z_TYPE_PP(tmp) == IS_STRING) {
-                               add_property_stringl(this_ptr, "location", 
Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
-                       } else {
-                               php_error_docref(NULL TSRMLS_CC, E_ERROR, 
"'location' option is requred in nonWSDL mode");
-                               return;
-                       }
-
                        if (zend_hash_find(ht, "uri", sizeof("uri"), 
(void**)&tmp) == SUCCESS &&
                            Z_TYPE_PP(tmp) == IS_STRING) {
                                add_property_stringl(this_ptr, "uri", 
Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
@@ -2004,6 +1998,14 @@
                        }
                }
 
+               if (zend_hash_find(ht, "location", sizeof("location"), 
(void**)&tmp) == SUCCESS &&
+                   Z_TYPE_PP(tmp) == IS_STRING) {
+                       add_property_stringl(this_ptr, "location", 
Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
+               } else if (wsdl == NULL) {
+                       php_error_docref(NULL TSRMLS_CC, E_ERROR, "'location' 
option is requred in nonWSDL mode");
+                       return;
+               }
+
                if (zend_hash_find(ht, "soap_version", sizeof("soap_version"), 
(void**)&tmp) == SUCCESS) {
                        if (Z_TYPE_PP(tmp) == IS_LONG ||
                            (Z_LVAL_PP(tmp) == SOAP_1_1 && Z_LVAL_PP(tmp) == 
SOAP_1_2)) {
@@ -2190,6 +2192,7 @@
                          int arg_count,
                          zval** real_args,
                          zval* return_value,
+                         char* location,
                          char* soap_action,
                          char* call_uri,
                          HashTable* soap_headers,
@@ -2222,6 +2225,13 @@
                soap_version = SOAP_1_1;
        }
 
+       if (location == NULL) {
+               if (zend_hash_find(Z_OBJPROP_P(this_ptr), "location", 
sizeof("location"),(void **) &tmp) == SUCCESS &&
+                   Z_TYPE_PP(tmp) == IS_STRING) {
+                 location = Z_STRVAL_PP(tmp);
+               }
+       }
+
        if (FIND_SDL_PROPERTY(this_ptr,tmp) != FAILURE) {
                FETCH_SDL_RES(sdl,tmp);
        }
@@ -2250,13 +2260,16 @@
                fn = get_function(sdl, function);
                if (fn != NULL) {
                        sdlBindingPtr binding = fn->binding;
+                       if (location == NULL) {
+                               location = binding->location;
+                       }
                        if (binding->bindingType == BINDING_SOAP) {
                                sdlSoapBindingFunctionPtr fnb = 
(sdlSoapBindingFunctionPtr)fn->bindingAttributes;
                                request = serialize_function_call(this_ptr, fn, 
NULL, fnb->input.ns, real_args, arg_count, soap_version, soap_headers 
TSRMLS_CC);
-                               ret = do_request(this_ptr, request, 
binding->location, fnb->soapAction, soap_version, &response TSRMLS_CC);
+                               ret = do_request(this_ptr, request, location, 
fnb->soapAction, soap_version, &response TSRMLS_CC);
                        }       else {
                                request = serialize_function_call(this_ptr, fn, 
NULL, sdl->target_ns, real_args, arg_count, soap_version, soap_headers 
TSRMLS_CC);
-                               ret = do_request(this_ptr, request, 
binding->location, NULL, soap_version, &response TSRMLS_CC);
+                               ret = do_request(this_ptr, request, location, 
NULL, soap_version, &response TSRMLS_CC);
                        }
 
                        xmlFreeDoc(request);
@@ -2277,12 +2290,12 @@
                        smart_str_free(&error);
                }
        } else {
-               zval **uri, **location;
+               zval **uri;
                smart_str action = {0};
 
                if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), 
(void *)&uri) == FAILURE) {
                        add_soap_fault(this_ptr, "Client", "Error finding 
\"uri\" property", NULL, NULL TSRMLS_CC);
-               } else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "location", 
sizeof("location"),(void **) &location) == FAILURE) {
+               } else if (location == NULL) {
                        add_soap_fault(this_ptr, "Client", "Error could not 
find \"location\" property", NULL, NULL TSRMLS_CC);
                } else {
                        if (call_uri == NULL) {
@@ -2299,7 +2312,7 @@
                        }
                        smart_str_0(&action);
 
-                       ret = do_request(this_ptr, request, 
Z_STRVAL_PP(location), action.c, soap_version, &response TSRMLS_CC);
+                       ret = do_request(this_ptr, request, location, action.c, 
soap_version, &response TSRMLS_CC);
 
                        smart_str_free(&action);
                        xmlFreeDoc(request);
@@ -2356,7 +2369,7 @@
    Calls a SOAP function */
 PHP_METHOD(SoapClient, __call)
 {
-       char *function, *soap_action = NULL, *uri = NULL;
+       char *function, *location=NULL, *soap_action = NULL, *uri = NULL;
        int function_len, i = 0;
        HashTable* soap_headers = NULL;
        zval *options = NULL;
@@ -2379,6 +2392,11 @@
                        HashTable *ht = Z_ARRVAL_P(options);
                        zval **tmp;
 
+                       if (zend_hash_find(ht, "location", sizeof("location"), 
(void**)&tmp) == SUCCESS &&
+                           Z_TYPE_PP(tmp) == IS_STRING) {
+                               location = Z_STRVAL_PP(tmp);
+                       }
+
                        if (zend_hash_find(ht, "soapaction", 
sizeof("soapaction"), (void**)&tmp) == SUCCESS &&
                            Z_TYPE_PP(tmp) == IS_STRING) {
                                soap_action = Z_STRVAL_PP(tmp);
@@ -2430,7 +2448,7 @@
        if (output_headers) {
                array_init(output_headers);
        }
-       do_soap_call(this_ptr, function, function_len, arg_count, real_args, 
return_value, soap_action, uri, soap_headers, output_headers TSRMLS_CC);
+       do_soap_call(this_ptr, function, function_len, arg_count, real_args, 
return_value, location, soap_action, uri, soap_headers, output_headers 
TSRMLS_CC);
        if (arg_count > 0) {
                efree(real_args);
        }
@@ -2590,6 +2608,7 @@
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s",
            &name, &name_len, &val, &val_len) == FAILURE) {
+               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
          RETURN_NULL();
        }
 
@@ -2616,6 +2635,37 @@
 }
 /* }}} */
 
+/* {{{ proto string SoapClient::__setLocation([string new_location])
+   Sets the location option (the endpoint URL that will be touched by the 
+   following SOAP requests).
+   If new_location is not specified or null then SoapClient will use endpoint
+   from WSDL file. 
+   The function returns old value of location options. */
+PHP_METHOD(SoapClient, __setLocation)
+{
+       char *location = NULL;
+       int  location_len;
+       zval **tmp;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s",
+           &location, &location_len) == FAILURE) {
+               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
+         RETURN_NULL();
+       }
+       if (zend_hash_find(Z_OBJPROP_P(this_ptr), "location", 
sizeof("location"),(void **) &tmp) == SUCCESS &&
+           Z_TYPE_PP(tmp) == IS_STRING) {
+         RETVAL_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
+       } else {
+         RETVAL_NULL();
+       }
+       if (location && location_len) {
+               add_property_stringl(this_ptr, "location", location, 
location_len, 1);
+       } else {
+               zend_hash_del(Z_OBJPROP_P(this_ptr), "location", 
sizeof("location"));
+       }
+}
+/* }}} */
+
 #ifndef ZEND_ENGINE_2
 static void soap_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, 
zend_property_reference *property_reference)
 {
@@ -2635,7 +2685,7 @@
                zval **arguments = (zval **) safe_emalloc(sizeof(zval *), 
arg_count, 0);
 
                zend_get_parameters_array(ht, arg_count, arguments);
-               do_soap_call(this_ptr, function, 
Z_STRLEN(function_name->element) + 1, arg_count, arguments, return_value, NULL, 
NULL, NULL, NULL TSRMLS_CC);
+               do_soap_call(this_ptr, function, 
Z_STRLEN(function_name->element) + 1, arg_count, arguments, return_value, NULL, 
NULL, NULL, NULL, NULL TSRMLS_CC);
                efree(arguments);
        }
        zval_dtor(&function_name->element);

http://cvs.php.net/co.php/php-src/ext/soap/tests/bugs/bug31695.phpt?r=1.1&p=1
Index: php-src/ext/soap/tests/bugs/bug31695.phpt
+++ php-src/ext/soap/tests/bugs/bug31695.phpt

http://cvs.php.net/co.php/php-src/ext/soap/tests/bugs/bug31695.wsdl?r=1.1&p=1
Index: php-src/ext/soap/tests/bugs/bug31695.wsdl
+++ php-src/ext/soap/tests/bugs/bug31695.wsdl

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to