]> granicus.if.org Git - php/commitdiff
Fixed bug #50762 (in WSDL mode Soap Header handler function only being called if...
authorDmitry Stogov <dmitry@php.net>
Fri, 28 May 2010 10:52:16 +0000 (10:52 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 28 May 2010 10:52:16 +0000 (10:52 +0000)
ext/soap/soap.c
ext/soap/tests/bugs/bug50762.phpt [new file with mode: 0644]
ext/soap/tests/bugs/bug50762.wsdl [new file with mode: 0644]

index 934407363fa60244925b9614e41ed548a50280ae..02e75505ccc55342ece3679e0c14ed2bb413b402 100644 (file)
@@ -1874,6 +1874,7 @@ PHP_METHOD(SoapServer, handle)
                        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 @@ PHP_METHOD(SoapServer, handle)
                                        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) &&
diff --git a/ext/soap/tests/bugs/bug50762.phpt b/ext/soap/tests/bugs/bug50762.phpt
new file mode 100644 (file)
index 0000000..f9099f1
--- /dev/null
@@ -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
diff --git a/ext/soap/tests/bugs/bug50762.wsdl b/ext/soap/tests/bugs/bug50762.wsdl
new file mode 100644 (file)
index 0000000..2980589
--- /dev/null
@@ -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>