}
}
}
- master_to_zval_int(encode, data);
+ return master_to_zval_int(encode, data);
}
#ifdef HAVE_PHP_DOMXML
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 &&
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--;
} 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 &&
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--;
} 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);
MAKE_STD_ZVAL(ret);
FIND_XML_NULL(data, ret);
- object_init(ret);
+ object_init_ex(ret, ce);
trav = data->children;
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\php_packet_soap.c\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\php_schema.c\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\php_packet_soap.h\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\php_schema.h\r
# End Source File\r
# Begin Source File\r
char *actor;
char *uri;
xmlCharEncodingHandlerPtr encoding;
+ HashTable *class_map;
};
#define SOAP_CLASS 1
char* cache_dir;
long cache_ttl;
xmlCharEncodingHandlerPtr encoding;
+ HashTable *class_map;
ZEND_END_MODULE_GLOBALS(soap)
#ifdef PHP_WIN32
SOAP_GLOBAL(sdl) = NULL;
SOAP_GLOBAL(soap_version) = SOAP_1_1;
SOAP_GLOBAL(encoding) = NULL;
+ SOAP_GLOBAL(class_map) = NULL;
return SUCCESS;
}
}
}
+ 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.");
}
char *arg = NULL;
int arg_len;
xmlCharEncodingHandlerPtr old_encoding;
+ HashTable *old_class_map;
SOAP_SERVER_BEGIN_CODE();
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);
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);
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;
int soap_version;
zval response;
xmlCharEncodingHandlerPtr old_encoding;
+ HashTable *old_class_map;
SOAP_CLIENT_BEGIN_CODE();
} 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);
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();
if (service->encoding) {
xmlCharEncCloseFunc(service->encoding);
}
+ if (service->class_map) {
+ zend_hash_destroy(service->class_map);
+ FREE_HASHTABLE(service->class_map);
+ }
efree(service);
}
--- /dev/null
+<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">\r
+ <wsdl:types>\r
+ <xsd:schema targetNamespace="http://schemas.nothing.com">\r
+ <xsd:complexType name="book">\r
+ <xsd:all>\r
+ <xsd:element name="a" type="xsd:string"/>\r
+ <xsd:element name="b" type="xsd:string"/>\r
+ </xsd:all>\r
+ </xsd:complexType>\r
+ </xsd:schema>\r
+ </wsdl:types>\r
+ <message name="dotestRequest">\r
+ <part name="dotestReturn" type="tns:book"/>\r
+ </message>\r
+ <message name="dotestResponse">\r
+ <part name="res" type="xsi:string"/>\r
+ </message>\r
+ <message name="dotest2Request">\r
+ <part name="dotest2" type="xsi:string"/>\r
+ </message>\r
+ <message name="dotest2Response">\r
+ <part name="res" type="tns:book"/>\r
+ </message>\r
+ <portType name="testPortType">\r
+ <operation name="dotest">\r
+ <input message="tns:dotestRequest"/>\r
+ <output message="tns:dotestResponse"/>\r
+ </operation>\r
+ <operation name="dotest2">\r
+ <input message="tns:dotest2Request"/>\r
+ <output message="tns:dotest2Response"/>\r
+ </operation>\r
+ </portType>\r
+ <binding name="testBinding" type="tns:testPortType">\r
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>\r
+ <operation name="dotest">\r
+ <soap:operation soapAction="http://localhost:81/test/interface.php?class=test/dotest" style="rpc"/>\r
+ <input>\r
+ <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://schemas.nabek.com"/>\r
+ </input>\r
+ <output>\r
+ <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://schemas.nabek.com"/>\r
+ </output>\r
+ </operation>\r
+ <operation name="dotest2">\r
+ <soap:operation soapAction="http://localhost:81/test/interface.php?class=test/dotest2" style="rpc"/>\r
+ <input>\r
+ <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://schemas.nabek.com"/>\r
+ </input>\r
+ <output>\r
+ <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://schemas.nabek.com"/>\r
+ </output>\r
+ </operation>\r
+ </binding>\r
+ <service name="test">\r
+ <port name="testPort" binding="tns:testBinding">\r
+ <soap:address location="http://localhost:81/test/interface.php?class=test"/>\r
+ </port>\r
+ </service>\r
+</wsdl:definitions>\r
--- /dev/null
+--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
--- /dev/null
+--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