dmitry                                   Fri, 28 May 2010 10:52:16 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=299901

Log:
Fixed bug #50762 (in WSDL mode Soap Header handler function only being called 
if defined in WSDL). (mephius at gmail dot com)

Bug: http://bugs.php.net/50762 (Assigned) in WSDL mode Soap Header handler 
function only being called if defined in WSDL
      
Changed paths:
    U   php/php-src/branches/PHP_5_2/NEWS
    U   php/php-src/branches/PHP_5_2/ext/soap/soap.c
    A   php/php-src/branches/PHP_5_2/ext/soap/tests/bugs/bug50762.phpt
    A   php/php-src/branches/PHP_5_2/ext/soap/tests/bugs/bug50762.wsdl
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/soap/soap.c
    A   php/php-src/branches/PHP_5_3/ext/soap/tests/bugs/bug50762.phpt
    A   php/php-src/branches/PHP_5_3/ext/soap/tests/bugs/bug50762.wsdl
    U   php/php-src/trunk/ext/soap/soap.c
    A   php/php-src/trunk/ext/soap/tests/bugs/bug50762.phpt
    A   php/php-src/trunk/ext/soap/tests/bugs/bug50762.wsdl

Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS	2010-05-28 09:27:03 UTC (rev 299900)
+++ php/php-src/branches/PHP_5_2/NEWS	2010-05-28 10:52:16 UTC (rev 299901)
@@ -65,6 +65,8 @@
 - Fixed bug #51062 (DBA DB4 uses mismatched headers and libraries). (Chris Jones)
 - Fixed bug #51023 (filter doesn't detect int overflows with GCC 4.4).
   (Raphael Geissert)
+- Fixed bug #50762 (in WSDL mode Soap Header handler function only being called
+  if defined in WSDL). (mephius at gmail dot com)
 - Fixed bug #50698 (SoapClient should handle wsdls with some incompatiable
   endpoints). (Justin Dearing)
 - Fixed bug #50383 (Exceptions thrown in __call() / __callStatic() do not

Modified: php/php-src/branches/PHP_5_2/ext/soap/soap.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/soap/soap.c	2010-05-28 09:27:03 UTC (rev 299900)
+++ php/php-src/branches/PHP_5_2/ext/soap/soap.c	2010-05-28 10:52:16 UTC (rev 299901)
@@ -1706,6 +1706,7 @@
 			soapHeader *h = header;

 			header = header->next;
+#if 0
 			if (service->sdl && !h->function && !h->hdr) {
 				if (h->mustUnderstand) {
 					soap_server_fault("MustUnderstand","Header not understood", NULL, NULL, NULL TSRMLS_CC);
@@ -1713,7 +1714,7 @@
 					continue;
 				}
 			}
-
+#endif
 			fn_name = estrndup(Z_STRVAL(h->function_name),Z_STRLEN(h->function_name));
 			if (zend_hash_exists(function_table, php_strtolower(fn_name, Z_STRLEN(h->function_name)), Z_STRLEN(h->function_name) + 1) ||
 			    ((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) &&

Added: php/php-src/branches/PHP_5_2/ext/soap/tests/bugs/bug50762.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/soap/tests/bugs/bug50762.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/soap/tests/bugs/bug50762.phpt	2010-05-28 10:52:16 UTC (rev 299901)
@@ -0,0 +1,45 @@
+--TEST--
+Bug #50762 (in WSDL mode Soap Header handler function only being called if defined in WSDL)
+--FILE--
+<?php
+class testSoap {
+	private $auth;
+	public function authToken($token){
+		$this->auth=true;
+	}
+	public function testHeader($param){
+		return 'header handler ' . ($this->auth ? 'called' : 'not called');
+	}
+}
+
+class LocalSoapClient extends SoapClient {
+
+  function __construct($wsdl, $options) {
+    parent::__construct($wsdl, $options);
+    $this->server = new SoapServer($wsdl, $options);
+	$this->server->setObject(new testSoap());
+  }
+
+  function __doRequest($request, $location, $action, $version, $one_way = 0) {
+    ob_start();
+    $this->server->handle($request);
+    $response = ob_get_contents();
+    ob_end_clean();
+    return $response;
+  }
+
+}
+
+$cl = new LocalSoapClient(dirname(__FILE__).'/bug50762.wsdl', array('cache_wsdl'=>WSDL_CACHE_NONE, 'trace'=>true));
+
+class authToken{
+	public function __construct($token){
+		$this->authToken=$token;
+	}
+}
+
+$cl->__setSoapHeaders(array(new SoapHeader('http://sova.pronto.ru/', 'authToken', new authToken('tokendata'))));
+echo $cl->testHeader('param') . PHP_EOL;
+?>
+--EXPECT--
+header handler called

Added: php/php-src/branches/PHP_5_2/ext/soap/tests/bugs/bug50762.wsdl
===================================================================
--- php/php-src/branches/PHP_5_2/ext/soap/tests/bugs/bug50762.wsdl	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/soap/tests/bugs/bug50762.wsdl	2010-05-28 10:52:16 UTC (rev 299901)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; xmlns:tns="http://sova.pronto.ru/"; xmlns:xsd1="http://sova.pronto.ru/schema"; xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; name="sova" targetNamespace="http://sova.pronto.ru/";>
+  <wsdl:message name="authToken">
+  	<wsdl:part name="authToken" type="xsd:string"/>
+  </wsdl:message>
+  <wsdl:message name="message">
+  	<wsdl:part name="param" type="xsd:string"/>
+  </wsdl:message>
+
+  <wsdl:portType name="sova">
+    <wsdl:operation name="testHeader">
+      <wsdl:input message="tns:message"/>
+      <wsdl:output message="tns:message"/>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="sovaSOAP" type="tns:sova">
+    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+    <wsdl:operation name="testHeader">
+      <soap:operation soapAction="http://sova.pronto.ru/testHeader"/>
+      <wsdl:input>
+        <soap:body namespace="http://sova.pronto.ru/"; use="literal"/>
+        <soap:header use="literal" part="authToken" message="tns:authToken" wsdl:required="true"/>
+      </wsdl:input>
+	  <wsdl:output>
+        <soap:body namespace="http://sova.pronto.ru/"; use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+
+  </wsdl:binding>
+  <wsdl:service name="sova">
+    <wsdl:port binding="tns:sovaSOAP" name="sovaSOAP">
+      <soap:address location="http://sova.mephius.prontosoft.by/sova/soaptest.php"/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS	2010-05-28 09:27:03 UTC (rev 299900)
+++ php/php-src/branches/PHP_5_3/NEWS	2010-05-28 10:52:16 UTC (rev 299901)
@@ -152,6 +152,8 @@
 - Fixed bug #50999 (unaligned memory access in dba_fetch()). (Felipe)
 - Fixed bug #50828 (DOMNotation is not subclass of DOMNode). (Rob)
 - Fixed bug #50810 (property_exists does not work for private). (Felipe)
+- Fixed bug #50762 (in WSDL mode Soap Header handler function only being called
+  if defined in WSDL). (mephius at gmail dot com)
 - Fixed bug #50731 (Inconsistent namespaces sent to functions registered with
   spl_autoload_register). (Felipe)
 - Fixed bug #50555 (DateTime::sub() allows 'relative' time modifications). (Derick)

Modified: php/php-src/branches/PHP_5_3/ext/soap/soap.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/soap/soap.c	2010-05-28 09:27:03 UTC (rev 299900)
+++ php/php-src/branches/PHP_5_3/ext/soap/soap.c	2010-05-28 10:52:16 UTC (rev 299901)
@@ -1874,6 +1874,7 @@
 			soapHeader *h = header;

 			header = header->next;
+#if 0
 			if (service->sdl && !h->function && !h->hdr) {
 				if (h->mustUnderstand) {
 					soap_server_fault("MustUnderstand","Header not understood", NULL, NULL, NULL TSRMLS_CC);
@@ -1881,7 +1882,7 @@
 					continue;
 				}
 			}
-
+#endif
 			fn_name = estrndup(Z_STRVAL(h->function_name),Z_STRLEN(h->function_name));
 			if (zend_hash_exists(function_table, php_strtolower(fn_name, Z_STRLEN(h->function_name)), Z_STRLEN(h->function_name) + 1) ||
 			    ((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) &&

Added: php/php-src/branches/PHP_5_3/ext/soap/tests/bugs/bug50762.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/soap/tests/bugs/bug50762.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/soap/tests/bugs/bug50762.phpt	2010-05-28 10:52:16 UTC (rev 299901)
@@ -0,0 +1,45 @@
+--TEST--
+Bug #50762 (in WSDL mode Soap Header handler function only being called if defined in WSDL)
+--FILE--
+<?php
+class testSoap {
+	private $auth;
+	public function authToken($token){
+		$this->auth=true;
+	}
+	public function testHeader($param){
+		return 'header handler ' . ($this->auth ? 'called' : 'not called');
+	}
+}
+
+class LocalSoapClient extends SoapClient {
+
+  function __construct($wsdl, $options) {
+    parent::__construct($wsdl, $options);
+    $this->server = new SoapServer($wsdl, $options);
+	$this->server->setObject(new testSoap());
+  }
+
+  function __doRequest($request, $location, $action, $version, $one_way = 0) {
+    ob_start();
+    $this->server->handle($request);
+    $response = ob_get_contents();
+    ob_end_clean();
+    return $response;
+  }
+
+}
+
+$cl = new LocalSoapClient(dirname(__FILE__).'/bug50762.wsdl', array('cache_wsdl'=>WSDL_CACHE_NONE, 'trace'=>true));
+
+class authToken{
+	public function __construct($token){
+		$this->authToken=$token;
+	}
+}
+
+$cl->__setSoapHeaders(array(new SoapHeader('http://sova.pronto.ru/', 'authToken', new authToken('tokendata'))));
+echo $cl->testHeader('param') . PHP_EOL;
+?>
+--EXPECT--
+header handler called

Added: php/php-src/branches/PHP_5_3/ext/soap/tests/bugs/bug50762.wsdl
===================================================================
--- php/php-src/branches/PHP_5_3/ext/soap/tests/bugs/bug50762.wsdl	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/soap/tests/bugs/bug50762.wsdl	2010-05-28 10:52:16 UTC (rev 299901)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; xmlns:tns="http://sova.pronto.ru/"; xmlns:xsd1="http://sova.pronto.ru/schema"; xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; name="sova" targetNamespace="http://sova.pronto.ru/";>
+  <wsdl:message name="authToken">
+  	<wsdl:part name="authToken" type="xsd:string"/>
+  </wsdl:message>
+  <wsdl:message name="message">
+  	<wsdl:part name="param" type="xsd:string"/>
+  </wsdl:message>
+
+  <wsdl:portType name="sova">
+    <wsdl:operation name="testHeader">
+      <wsdl:input message="tns:message"/>
+      <wsdl:output message="tns:message"/>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="sovaSOAP" type="tns:sova">
+    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+    <wsdl:operation name="testHeader">
+      <soap:operation soapAction="http://sova.pronto.ru/testHeader"/>
+      <wsdl:input>
+        <soap:body namespace="http://sova.pronto.ru/"; use="literal"/>
+        <soap:header use="literal" part="authToken" message="tns:authToken" wsdl:required="true"/>
+      </wsdl:input>
+	  <wsdl:output>
+        <soap:body namespace="http://sova.pronto.ru/"; use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+
+  </wsdl:binding>
+  <wsdl:service name="sova">
+    <wsdl:port binding="tns:sovaSOAP" name="sovaSOAP">
+      <soap:address location="http://sova.mephius.prontosoft.by/sova/soaptest.php"/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>

Modified: php/php-src/trunk/ext/soap/soap.c
===================================================================
--- php/php-src/trunk/ext/soap/soap.c	2010-05-28 09:27:03 UTC (rev 299900)
+++ php/php-src/trunk/ext/soap/soap.c	2010-05-28 10:52:16 UTC (rev 299901)
@@ -1874,6 +1874,7 @@
 			soapHeader *h = header;

 			header = header->next;
+#if 0
 			if (service->sdl && !h->function && !h->hdr) {
 				if (h->mustUnderstand) {
 					soap_server_fault("MustUnderstand","Header not understood", NULL, NULL, NULL TSRMLS_CC);
@@ -1881,7 +1882,7 @@
 					continue;
 				}
 			}
-
+#endif
 			fn_name = estrndup(Z_STRVAL(h->function_name),Z_STRLEN(h->function_name));
 			if (zend_hash_exists(function_table, php_strtolower(fn_name, Z_STRLEN(h->function_name)), Z_STRLEN(h->function_name) + 1) ||
 			    ((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) &&

Added: php/php-src/trunk/ext/soap/tests/bugs/bug50762.phpt
===================================================================
--- php/php-src/trunk/ext/soap/tests/bugs/bug50762.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/soap/tests/bugs/bug50762.phpt	2010-05-28 10:52:16 UTC (rev 299901)
@@ -0,0 +1,45 @@
+--TEST--
+Bug #50762 (in WSDL mode Soap Header handler function only being called if defined in WSDL)
+--FILE--
+<?php
+class testSoap {
+	private $auth;
+	public function authToken($token){
+		$this->auth=true;
+	}
+	public function testHeader($param){
+		return 'header handler ' . ($this->auth ? 'called' : 'not called');
+	}
+}
+
+class LocalSoapClient extends SoapClient {
+
+  function __construct($wsdl, $options) {
+    parent::__construct($wsdl, $options);
+    $this->server = new SoapServer($wsdl, $options);
+	$this->server->setObject(new testSoap());
+  }
+
+  function __doRequest($request, $location, $action, $version, $one_way = 0) {
+    ob_start();
+    $this->server->handle($request);
+    $response = ob_get_contents();
+    ob_end_clean();
+    return $response;
+  }
+
+}
+
+$cl = new LocalSoapClient(dirname(__FILE__).'/bug50762.wsdl', array('cache_wsdl'=>WSDL_CACHE_NONE, 'trace'=>true));
+
+class authToken{
+	public function __construct($token){
+		$this->authToken=$token;
+	}
+}
+
+$cl->__setSoapHeaders(array(new SoapHeader('http://sova.pronto.ru/', 'authToken', new authToken('tokendata'))));
+echo $cl->testHeader('param') . PHP_EOL;
+?>
+--EXPECT--
+header handler called

Added: php/php-src/trunk/ext/soap/tests/bugs/bug50762.wsdl
===================================================================
--- php/php-src/trunk/ext/soap/tests/bugs/bug50762.wsdl	                        (rev 0)
+++ php/php-src/trunk/ext/soap/tests/bugs/bug50762.wsdl	2010-05-28 10:52:16 UTC (rev 299901)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; xmlns:tns="http://sova.pronto.ru/"; xmlns:xsd1="http://sova.pronto.ru/schema"; xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; name="sova" targetNamespace="http://sova.pronto.ru/";>
+  <wsdl:message name="authToken">
+  	<wsdl:part name="authToken" type="xsd:string"/>
+  </wsdl:message>
+  <wsdl:message name="message">
+  	<wsdl:part name="param" type="xsd:string"/>
+  </wsdl:message>
+
+  <wsdl:portType name="sova">
+    <wsdl:operation name="testHeader">
+      <wsdl:input message="tns:message"/>
+      <wsdl:output message="tns:message"/>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="sovaSOAP" type="tns:sova">
+    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+    <wsdl:operation name="testHeader">
+      <soap:operation soapAction="http://sova.pronto.ru/testHeader"/>
+      <wsdl:input>
+        <soap:body namespace="http://sova.pronto.ru/"; use="literal"/>
+        <soap:header use="literal" part="authToken" message="tns:authToken" wsdl:required="true"/>
+      </wsdl:input>
+	  <wsdl:output>
+        <soap:body namespace="http://sova.pronto.ru/"; use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+
+  </wsdl:binding>
+  <wsdl:service name="sova">
+    <wsdl:port binding="tns:sovaSOAP" name="sovaSOAP">
+      <soap:address location="http://sova.mephius.prontosoft.by/sova/soaptest.php"/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to