dmitry Tue Nov 16 07:07:34 2004 EDT
Added files:
/php-src/ext/soap/tests classmap.wsdl classmap001.phpt
classmap002.phpt
Modified files:
/php-src/ext/soap php_encoding.c php_soap.dsp php_soap.h soap.c
Log:
Class mapping was implemented (Bug #29385 Soapserver always uses std class).
http://cvs.php.net/diff.php/php-src/ext/soap/php_encoding.c?r1=1.81&r2=1.82&ty=u
Index: php-src/ext/soap/php_encoding.c
diff -u php-src/ext/soap/php_encoding.c:1.81
php-src/ext/soap/php_encoding.c:1.82
--- php-src/ext/soap/php_encoding.c:1.81 Fri Nov 12 15:32:43 2004
+++ php-src/ext/soap/php_encoding.c Tue Nov 16 07:07:29 2004
@@ -17,7 +17,7 @@
| Dmitry Stogov <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_encoding.c,v 1.81 2004/11/12 20:32:43 fmk Exp $ */
+/* $Id: php_encoding.c,v 1.82 2004/11/16 12:07:29 dmitry Exp $ */
#include <time.h>
@@ -360,7 +360,7 @@
}
}
}
- master_to_zval_int(encode, data);
+ return master_to_zval_int(encode, data);
}
#ifdef HAVE_PHP_DOMXML
@@ -955,8 +955,19 @@
xmlNodePtr trav;
sdlPtr sdl;
sdlTypePtr sdlType = type->sdl_type;
+ zend_class_entry *ce = ZEND_STANDARD_CLASS_DEF_PTR;
TSRMLS_FETCH();
+ if (SOAP_GLOBAL(class_map) && type->type_str) {
+ zval **classname;
+ zend_class_entry *tmp;
+
+ if (zend_hash_find(SOAP_GLOBAL(class_map), type->type_str,
strlen(type->type_str)+1, (void**)&classname) == SUCCESS &&
+ Z_TYPE_PP(classname) == IS_STRING &&
+ (tmp = zend_fetch_class(Z_STRVAL_PP(classname),
Z_STRLEN_PP(classname), ZEND_FETCH_CLASS_AUTO TSRMLS_CC)) != NULL) {
+ ce = tmp;
+ }
+ }
sdl = SOAP_GLOBAL(sdl);
if (sdlType) {
if (sdlType->kind == XSD_TYPEKIND_RESTRICTION &&
@@ -975,7 +986,7 @@
MAKE_STD_ZVAL(ret);
- object_init(ret);
+ object_init_ex(ret, ce);
base = master_to_zval_int(enc, data);
#ifdef ZEND_ENGINE_2
base->refcount--;
@@ -984,7 +995,7 @@
} else {
MAKE_STD_ZVAL(ret);
FIND_XML_NULL(data, ret);
- object_init(ret);
+ object_init_ex(ret, ce);
}
} else if (sdlType->kind == XSD_TYPEKIND_EXTENSION &&
sdlType->encode &&
@@ -1000,7 +1011,7 @@
MAKE_STD_ZVAL(ret);
- object_init(ret);
+ object_init_ex(ret, ce);
base = master_to_zval_int(sdlType->encode,
data);
#ifdef ZEND_ENGINE_2
base->refcount--;
@@ -1010,7 +1021,7 @@
} else {
MAKE_STD_ZVAL(ret);
FIND_XML_NULL(data, ret);
- object_init(ret);
+ object_init_ex(ret, ce);
}
if (sdlType->model) {
model_to_zval_object(ret, sdlType->model, data, sdl
TSRMLS_CC);
@@ -1056,7 +1067,7 @@
MAKE_STD_ZVAL(ret);
FIND_XML_NULL(data, ret);
- object_init(ret);
+ object_init_ex(ret, ce);
trav = data->children;
http://cvs.php.net/diff.php/php-src/ext/soap/php_soap.dsp?r1=1.3&r2=1.4&ty=u
Index: php-src/ext/soap/php_soap.dsp
diff -u php-src/ext/soap/php_soap.dsp:1.3 php-src/ext/soap/php_soap.dsp:1.4
--- php-src/ext/soap/php_soap.dsp:1.3 Thu Apr 1 05:47:44 2004
+++ php-src/ext/soap/php_soap.dsp Tue Nov 16 07:07:29 2004
@@ -101,6 +101,10 @@
# End Source File
# Begin Source File
+SOURCE=.\php_packet_soap.c
+# End Source File
+# Begin Source File
+
SOURCE=.\php_schema.c
# End Source File
# Begin Source File
@@ -129,6 +133,10 @@
# End Source File
# Begin Source File
+SOURCE=.\php_packet_soap.h
+# End Source File
+# Begin Source File
+
SOURCE=.\php_schema.h
# End Source File
# Begin Source File
http://cvs.php.net/diff.php/php-src/ext/soap/php_soap.h?r1=1.34&r2=1.35&ty=u
Index: php-src/ext/soap/php_soap.h
diff -u php-src/ext/soap/php_soap.h:1.34 php-src/ext/soap/php_soap.h:1.35
--- php-src/ext/soap/php_soap.h:1.34 Tue Aug 10 12:11:41 2004
+++ php-src/ext/soap/php_soap.h Tue Nov 16 07:07:29 2004
@@ -17,7 +17,7 @@
| Dmitry Stogov <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_soap.h,v 1.34 2004/08/10 16:11:41 dmitry Exp $ */
+/* $Id: php_soap.h,v 1.35 2004/11/16 12:07:29 dmitry Exp $ */
#ifndef PHP_SOAP_H
#define PHP_SOAP_H
@@ -116,6 +116,7 @@
char *actor;
char *uri;
xmlCharEncodingHandlerPtr encoding;
+ HashTable *class_map;
};
#define SOAP_CLASS 1
@@ -160,6 +161,7 @@
char* cache_dir;
long cache_ttl;
xmlCharEncodingHandlerPtr encoding;
+ HashTable *class_map;
ZEND_END_MODULE_GLOBALS(soap)
#ifdef PHP_WIN32
http://cvs.php.net/diff.php/php-src/ext/soap/soap.c?r1=1.124&r2=1.125&ty=u
Index: php-src/ext/soap/soap.c
diff -u php-src/ext/soap/soap.c:1.124 php-src/ext/soap/soap.c:1.125
--- php-src/ext/soap/soap.c:1.124 Tue Nov 9 03:13:35 2004
+++ php-src/ext/soap/soap.c Tue Nov 16 07:07:29 2004
@@ -17,7 +17,7 @@
| Dmitry Stogov <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: soap.c,v 1.124 2004/11/09 08:13:35 dmitry Exp $ */
+/* $Id: soap.c,v 1.125 2004/11/16 12:07:29 dmitry Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -441,6 +441,7 @@
SOAP_GLOBAL(sdl) = NULL;
SOAP_GLOBAL(soap_version) = SOAP_1_1;
SOAP_GLOBAL(encoding) = NULL;
+ SOAP_GLOBAL(class_map) = NULL;
return SUCCESS;
}
@@ -866,6 +867,15 @@
}
}
+ if (zend_hash_find(ht, "classmap", sizeof("classmap"),
(void**)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_ARRAY) {
+ zval *ztmp;
+
+ ALLOC_HASHTABLE(service->class_map);
+ zend_hash_init(service->class_map, 0, NULL,
ZVAL_PTR_DTOR, 0);
+ zend_hash_copy(service->class_map, (*tmp)->value.ht,
(copy_ctor_func_t) zval_add_ref, (void *) &ztmp, sizeof(zval *));
+ }
+
} else if (wsdl == NULL) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid arguments.
'uri' option is required in nonWSDL mode.");
}
@@ -1267,6 +1277,7 @@
char *arg = NULL;
int arg_len;
xmlCharEncodingHandlerPtr old_encoding;
+ HashTable *old_class_map;
SOAP_SERVER_BEGIN_CODE();
@@ -1410,6 +1421,8 @@
SOAP_GLOBAL(sdl) = service->sdl;
old_encoding = SOAP_GLOBAL(encoding);
SOAP_GLOBAL(encoding) = service->encoding;
+ old_class_map = SOAP_GLOBAL(class_map);
+ SOAP_GLOBAL(class_map) = service->class_map;
old_soap_version = SOAP_GLOBAL(soap_version);
function = deserialize_function_call(service->sdl, doc_request,
service->actor, &function_name, &num_params, ¶ms, &soap_version,
&soap_headers TSRMLS_CC);
xmlFreeDoc(doc_request);
@@ -1674,6 +1687,7 @@
SOAP_GLOBAL(soap_version) = old_soap_version;
SOAP_GLOBAL(encoding) = old_encoding;
SOAP_GLOBAL(sdl) = old_sdl;
+ SOAP_GLOBAL(class_map) = old_class_map;
/* Free soap headers */
zval_dtor(&retval);
@@ -1986,6 +2000,18 @@
add_property_stringl(this_ptr, "_encoding",
Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
}
+ if (zend_hash_find(ht, "classmap", sizeof("classmap"),
(void**)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_ARRAY) {
+ zval *class_map;
+
+ MAKE_STD_ZVAL(class_map);
+ *class_map = **tmp;
+ zval_copy_ctor(class_map);
+#ifdef ZEND_ENGINE_2
+ class_map->refcount--; /*FIXME*/
+#endif
+ add_property_zval(this_ptr, "_classmap", class_map);
+ }
} else if (wsdl == NULL) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'location' and 'uri'
options are requred in nonWSDL mode.");
return;
@@ -2097,6 +2123,7 @@
int soap_version;
zval response;
xmlCharEncodingHandlerPtr old_encoding;
+ HashTable *old_class_map;
SOAP_CLIENT_BEGIN_CODE();
@@ -2128,6 +2155,13 @@
} else {
SOAP_GLOBAL(encoding) = NULL;
}
+ old_class_map = SOAP_GLOBAL(class_map);
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_classmap",
sizeof("_classmap"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_ARRAY) {
+ SOAP_GLOBAL(class_map) = (*tmp)->value.ht;
+ } else {
+ SOAP_GLOBAL(class_map) = NULL;
+ }
if (sdl != NULL) {
fn = get_function(sdl, function);
@@ -2228,6 +2262,7 @@
if (SOAP_GLOBAL(encoding) != NULL) {
xmlCharEncCloseFunc(SOAP_GLOBAL(encoding));
}
+ SOAP_GLOBAL(class_map) = old_class_map;
SOAP_GLOBAL(encoding) = old_encoding;
SOAP_GLOBAL(sdl) = old_sdl;
SOAP_CLIENT_END_CODE();
@@ -3980,5 +4015,9 @@
if (service->encoding) {
xmlCharEncCloseFunc(service->encoding);
}
+ if (service->class_map) {
+ zend_hash_destroy(service->class_map);
+ FREE_HASHTABLE(service->class_map);
+ }
efree(service);
}
http://cvs.php.net/co.php/php-src/ext/soap/tests/classmap.wsdl?r=1.1&p=1
Index: php-src/ext/soap/tests/classmap.wsdl
+++ php-src/ext/soap/tests/classmap.wsdl
<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://schemas.nothing.com"
targetNamespace="http://schemas.nothing.com">
<wsdl:types>
<xsd:schema targetNamespace="http://schemas.nothing.com">
<xsd:complexType name="book">
<xsd:all>
<xsd:element name="a"
type="xsd:string"/>
<xsd:element name="b"
type="xsd:string"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<message name="dotestRequest">
<part name="dotestReturn" type="tns:book"/>
</message>
<message name="dotestResponse">
<part name="res" type="xsi:string"/>
</message>
<message name="dotest2Request">
<part name="dotest2" type="xsi:string"/>
</message>
<message name="dotest2Response">
<part name="res" type="tns:book"/>
</message>
<portType name="testPortType">
<operation name="dotest">
<input message="tns:dotestRequest"/>
<output message="tns:dotestResponse"/>
</operation>
<operation name="dotest2">
<input message="tns:dotest2Request"/>
<output message="tns:dotest2Response"/>
</operation>
</portType>
<binding name="testBinding" type="tns:testPortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="dotest">
<soap:operation
soapAction="http://localhost:81/test/interface.php?class=test/dotest"
style="rpc"/>
<input>
<soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://schemas.nabek.com"/>
</input>
<output>
<soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://schemas.nabek.com"/>
</output>
</operation>
<operation name="dotest2">
<soap:operation
soapAction="http://localhost:81/test/interface.php?class=test/dotest2"
style="rpc"/>
<input>
<soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://schemas.nabek.com"/>
</input>
<output>
<soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://schemas.nabek.com"/>
</output>
</operation>
</binding>
<service name="test">
<port name="testPort" binding="tns:testBinding">
<soap:address
location="http://localhost:81/test/interface.php?class=test"/>
</port>
</service>
</wsdl:definitions>
http://cvs.php.net/co.php/php-src/ext/soap/tests/classmap001.phpt?r=1.1&p=1
Index: php-src/ext/soap/tests/classmap001.phpt
+++ php-src/ext/soap/tests/classmap001.phpt
--TEST--
SOAP Classmap 1: SoapServer support for classmap
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
$GLOBALS['HTTP_RAW_POST_DATA']="
<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\"
xmlns:ns1=\"http://schemas.nothing.com\"
>
<env:Body>
<dotest>
<book xsi:type=\"ns1:book\">
<a xsi:type=\"xsd:string\">Blaat</a>
<b xsi:type=\"xsd:string\">aap</b>
</book>
</dotest>
</env:Body>
<env:Header/>
</env:Envelope>";
class test{
function dotest(book $book){
$classname=get_class($book);
return "Classname: ".$classname;
}
}
class book{
public $a="a";
public $b="c";
}
$options=Array(
'actor' =>'http://schema.nothing.com',
'classmap' => array('book'=>'book', 'wsdltype2'=>'classname2')
);
$server = new SoapServer(dirname(__FILE__)."/classmap.wsdl",$options);
$server->setClass("test");
$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://schemas.nabek.com"
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:dotestResponse><res
xsi:type="xsd:string">Classname:
book</res></ns1:dotestResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
ok
http://cvs.php.net/co.php/php-src/ext/soap/tests/classmap002.phpt?r=1.1&p=1
Index: php-src/ext/soap/tests/classmap002.phpt
+++ php-src/ext/soap/tests/classmap002.phpt
--TEST--
SOAP Classmap 2: SoapClient support for classmap
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
class TestSoapClient extends SoapClient{
function __doRequest($request, $location, $action, $version) {
return <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://schemas.nabek.com"
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:dotest2Response><res xsi:type="ns1:book">
<a xsi:type="xsd:string">Blaat</a>
<b xsi:type="xsd:string">aap</b>
</res>
</ns1:dotest2Response></SOAP-ENV:Body></SOAP-ENV:Envelope>
EOF;
}
}
class book{
public $a="a";
public $b="c";
}
$options=Array(
'actor' =>'http://schema.nothing.com',
'classmap' => array('book'=>'book', 'wsdltype2'=>'classname2')
);
$client = new TestSoapClient(dirname(__FILE__)."/classmap.wsdl",$options);
$ret = $client->dotest2("???");
var_dump($ret);
echo "ok\n";
?>
--EXPECT--
object(book)#2 (2) {
["a"]=>
string(5) "Blaat"
["b"]=>
string(3) "aap"
}
ok
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php