dmitry          Tue Mar 21 12:04:55 2006 UTC

  Added files:                 (Branch: PHP_5_1)
    /php-src/ext/soap/tests     server023.phpt server024.phpt 
                                server025.phpt server025.wsdl 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/soap   php_soap.h soap.c 
  Log:
  Fixed bug #36721 (The SoapServer is not able to send a header that it didn't 
receive)
  
  
http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2027.2.474&r2=1.2027.2.475&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.474 php-src/NEWS:1.2027.2.475
--- php-src/NEWS:1.2027.2.474   Tue Mar 21 08:49:42 2006
+++ php-src/NEWS        Tue Mar 21 12:04:55 2006
@@ -11,7 +11,9 @@
 - Removed the E_STRICT deprecation notice from "var". (Ilia)
 - Fixed debug_zval_dump() to support private and protected members. (Dmitry)
 - Fixed bug #36809 (__FILE__ behavior changed). (Dmitry)
-- FIxed bug #36808 (syslog ident becomes garbage between requests). (Tony)
+- Fixed bug #36808 (syslog ident becomes garbage between requests). (Tony)
+- Fixed bug #36721 (The SoapServer is not able to send a header that it didn't
+  receive). (Dmitry)
 - Fixed bug #36756 (DOMDocument::removeChild corrupts node). (Rob)
 - Fixed bug #36749 (SOAP: 'Error Fetching http body' when using HTTP Proxy).
   (Dmitry)
http://cvs.php.net/viewcvs.cgi/php-src/ext/soap/php_soap.h?r1=1.38.2.3&r2=1.38.2.4&diff_format=u
Index: php-src/ext/soap/php_soap.h
diff -u php-src/ext/soap/php_soap.h:1.38.2.3 
php-src/ext/soap/php_soap.h:1.38.2.4
--- php-src/ext/soap/php_soap.h:1.38.2.3        Tue Feb  7 12:49:09 2006
+++ php-src/ext/soap/php_soap.h Tue Mar 21 12:04:55 2006
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <[EMAIL PROTECTED]>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_soap.h,v 1.38.2.3 2006/02/07 12:49:09 dmitry Exp $ */
+/* $Id: php_soap.h,v 1.38.2.4 2006/03/21 12:04:55 dmitry Exp $ */
 
 #ifndef PHP_SOAP_H
 #define PHP_SOAP_H
@@ -97,6 +97,8 @@
        } map_class;
 };
 
+struct _soapHeader;
+
 struct _soapService {
        sdlPtr sdl;
 
@@ -120,6 +122,7 @@
        xmlCharEncodingHandlerPtr encoding;
        HashTable *class_map;
        int        features;
+       struct _soapHeader **soap_headers_ptr;
 };
 
 #define SOAP_CLASS 1
http://cvs.php.net/viewcvs.cgi/php-src/ext/soap/soap.c?r1=1.156.2.19&r2=1.156.2.20&diff_format=u
Index: php-src/ext/soap/soap.c
diff -u php-src/ext/soap/soap.c:1.156.2.19 php-src/ext/soap/soap.c:1.156.2.20
--- php-src/ext/soap/soap.c:1.156.2.19  Fri Mar 10 11:46:51 2006
+++ php-src/ext/soap/soap.c     Tue Mar 21 12:04:55 2006
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <[EMAIL PROTECTED]>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: soap.c,v 1.156.2.19 2006/03/10 11:46:51 dmitry Exp $ */
+/* $Id: soap.c,v 1.156.2.20 2006/03/21 12:04:55 dmitry Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -244,6 +244,7 @@
 PHP_METHOD(SoapServer, handle);
 PHP_METHOD(SoapServer, setPersistence);
 PHP_METHOD(SoapServer, fault);
+PHP_METHOD(SoapServer, addSoapHeader);
 #ifdef HAVE_PHP_DOMXML
 PHP_METHOD(PHP_SOAP_SERVER_CLASS, map);
 #endif
@@ -309,6 +310,7 @@
        PHP_ME(SoapServer, getFunctions, NULL, 0)
        PHP_ME(SoapServer, handle, NULL, 0)
        PHP_ME(SoapServer, fault, NULL, 0)
+       PHP_ME(SoapServer, addSoapHeader, NULL, 0)
 #ifdef HAVE_PHP_DOMXML
        PHP_ME(SoapServer, map, NULL, 0)
 #endif
@@ -1518,6 +1520,8 @@
        old_soap_version = SOAP_GLOBAL(soap_version);
        function = deserialize_function_call(service->sdl, doc_request, 
service->actor, &function_name, &num_params, &params, &soap_version, 
&soap_headers TSRMLS_CC);
        xmlFreeDoc(doc_request);
+       
+       service->soap_headers_ptr = &soap_headers;
 
        soap_obj = NULL;
        if (service->type == SOAP_CLASS) {
@@ -1802,15 +1806,18 @@
                int i;
 
                soap_headers = soap_headers->next;
-               i = h->num_params;
-               while (i > 0) {
-                       zval_ptr_dtor(&h->parameters[--i]);
+               if (h->parameters) {
+                       i = h->num_params;
+                       while (i > 0) {
+                               zval_ptr_dtor(&h->parameters[--i]);
+                       }
+                       efree(h->parameters);
                }
-               efree(h->parameters);
                zval_dtor(&h->function_name);
                zval_dtor(&h->retval);
                efree(h);
        }
+       service->soap_headers_ptr = NULL;
 
        /* Free Memory */
        if (num_params > 0) {
@@ -1847,6 +1854,37 @@
 }
 /* }}} */
 
+PHP_METHOD(SoapServer, addSoapHeader)
+{
+       soapServicePtr service;
+       zval *fault;
+       soapHeader **p;
+
+       SOAP_SERVER_BEGIN_CODE();
+
+       FETCH_THIS_SERVICE(service);
+
+       if (!service || !service->soap_headers_ptr) {
+               php_error_docref(NULL TSRMLS_CC, E_ERROR, "The 
SoapServer::addSoapHeader function may be called only during SOAP request 
processing");
+       }
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &fault, 
soap_header_class_entry) == FAILURE) {
+               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
+       }
+
+       p = service->soap_headers_ptr;
+       while (*p != NULL) {
+               p = &(*p)->next;
+       }
+       *p = emalloc(sizeof(soapHeader));
+       memset(*p, 0, sizeof(soapHeader));
+       ZVAL_NULL(&(*p)->function_name);
+       (*p)->retval = *fault;
+       zval_copy_ctor(&(*p)->retval);
+
+       SOAP_SERVER_END_CODE();
+}
+
 static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, 
soapHeader *hdr TSRMLS_DC)
 {
        int soap_version;
@@ -2523,7 +2561,7 @@
        zend_hash_internal_pointer_reset(ht);
        while (zend_hash_get_current_data(ht, (void**)&tmp) == SUCCESS) {
                if (Z_TYPE_PP(tmp) != IS_OBJECT ||
-                   Z_OBJCE_PP(tmp) != soap_header_class_entry) {
+                   !instanceof_function(Z_OBJCE_PP(tmp), 
soap_header_class_entry TSRMLS_CC)) {
                        php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid SOAP 
header");
                }
                zend_hash_move_forward(ht);
@@ -2583,7 +2621,7 @@
                verify_soap_headers_array(soap_headers TSRMLS_CC);
                free_soap_headers = 0;
        } else if (Z_TYPE_P(headers) == IS_OBJECT &&
-                  Z_OBJCE_P(headers) == soap_header_class_entry) {
+                  instanceof_function(Z_OBJCE_P(headers), 
soap_header_class_entry TSRMLS_CC)) {
            soap_headers = emalloc(sizeof(HashTable));
                zend_hash_init(soap_headers, 0, NULL, ZVAL_PTR_DTOR, 0);
                zend_hash_next_index_insert(soap_headers, &headers, 
sizeof(zval*), NULL);
@@ -2846,7 +2884,7 @@
                        add_property_zval(this_ptr, "__default_headers", 
headers);
                }
        } else if (Z_TYPE_P(headers) == IS_OBJECT &&
-                  Z_OBJCE_P(headers) == soap_header_class_entry) {
+                  instanceof_function(Z_OBJCE_P(headers), 
soap_header_class_entry TSRMLS_CC)) {
                zval *default_headers;
                ALLOC_INIT_ZVAL(default_headers);
                array_init(default_headers);
@@ -3518,7 +3556,7 @@
 
                        head = xmlNewChild(envelope, ns, "Header", NULL);
                        if (Z_TYPE_P(hdr_ret) == IS_OBJECT &&
-                           Z_OBJCE_P(hdr_ret) == soap_header_class_entry) {
+                           instanceof_function(Z_OBJCE_P(hdr_ret), 
soap_header_class_entry)) {
                                HashTable* ht = Z_OBJPROP_P(hdr_ret);
                                zval **tmp;
                                sdlSoapBindingFunctionHeaderPtr *hdr;
@@ -3745,7 +3783,7 @@
 
 
                                        if (Z_TYPE(h->retval) == IS_OBJECT &&
-                                           Z_OBJCE(h->retval) == 
soap_header_class_entry) {
+                                           
instanceof_function(Z_OBJCE(h->retval), soap_header_class_entry TSRMLS_CC)) {
                                                HashTable* ht = 
Z_OBJPROP(h->retval);
                                                zval **tmp;
                                                sdlSoapBindingFunctionHeaderPtr 
*hdr;

http://cvs.php.net/viewcvs.cgi/php-src/ext/soap/tests/server023.phpt?view=markup&rev=1.1
Index: php-src/ext/soap/tests/server023.phpt
+++ php-src/ext/soap/tests/server023.phpt

http://cvs.php.net/viewcvs.cgi/php-src/ext/soap/tests/server024.phpt?view=markup&rev=1.1
Index: php-src/ext/soap/tests/server024.phpt
+++ php-src/ext/soap/tests/server024.phpt

http://cvs.php.net/viewcvs.cgi/php-src/ext/soap/tests/server025.phpt?view=markup&rev=1.1
Index: php-src/ext/soap/tests/server025.phpt
+++ php-src/ext/soap/tests/server025.phpt

http://cvs.php.net/viewcvs.cgi/php-src/ext/soap/tests/server025.wsdl?view=markup&rev=1.1
Index: php-src/ext/soap/tests/server025.wsdl
+++ php-src/ext/soap/tests/server025.wsdl

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

Reply via email to