]> granicus.if.org Git - php/commitdiff
Support for classes with __call() method on server side.
authorDmitry Stogov <dmitry@php.net>
Wed, 5 May 2004 10:52:33 +0000 (10:52 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 5 May 2004 10:52:33 +0000 (10:52 +0000)
ext/soap/soap.c
ext/soap/tests/server021.phpt [new file with mode: 0644]

index 158544a56aa42f284d2ad186a847d5245c7fc5a9..6c4ff14d2a34d8c3df0a48957dc4e2e633473c83 100644 (file)
@@ -1513,7 +1513,9 @@ PHP_METHOD(SoapServer, handle)
        }
 
        fn_name = estrndup(Z_STRVAL(function_name),Z_STRLEN(function_name));
-       if (zend_hash_exists(function_table, php_strtolower(fn_name, Z_STRLEN(function_name)), Z_STRLEN(function_name) + 1)) {
+       if (zend_hash_exists(function_table, php_strtolower(fn_name, Z_STRLEN(function_name)), Z_STRLEN(function_name) + 1) ||
+           (service->type == SOAP_CLASS &&
+            zend_hash_exists(function_table, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)))) {
                if (service->type == SOAP_CLASS) {
                        call_status = call_user_function(NULL, &soap_obj, &function_name, &retval, num_params, params TSRMLS_CC);
 #if HAVE_PHP_SESSION
diff --git a/ext/soap/tests/server021.phpt b/ext/soap/tests/server021.phpt
new file mode 100644 (file)
index 0000000..d557204
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+SOAP Server 21: SoapServer::setClass and __call()
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+class Foo {
+  function __call($name) {
+    if ($name == "test") {
+      return "Hello World";
+    } else {
+      return SoapFault("Server","Function $name doesn't exist");
+    }
+  }
+}
+
+$server = new soapserver(null,array('uri'=>"http://testuri.org"));
+$server->setclass("Foo");
+
+$HTTP_RAW_POST_DATA = <<<EOF
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<SOAP-ENV:Envelope
+  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
+  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:si="http://soapinterop.org/xsd">
+  <SOAP-ENV:Body>
+    <ns1:test xmlns:ns1="http://testuri.org" />
+  </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+EOF;
+
+$server->handle();
+echo "ok\n";
+?>
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:testResponse><return xsi:type="xsd:string">Hello World</return></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
+ok