From 84bcd9ac96d7256ebce988c241e5521fb1bef193 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 8 Nov 2005 08:36:50 +0000 Subject: [PATCH] Fixed bug #35142 (SOAP Client/Server Complex Object Support) --- ext/soap/php_encoding.c | 4 + ext/soap/php_schema.c | 20 +- ext/soap/tests/bugs/bug35142.phpt | 135 ++++++++ ext/soap/tests/bugs/bug35142.wsdl | 543 ++++++++++++++++++++++++++++++ 4 files changed, 700 insertions(+), 2 deletions(-) create mode 100755 ext/soap/tests/bugs/bug35142.phpt create mode 100755 ext/soap/tests/bugs/bug35142.wsdl diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index d17dc6e262..3314ebb45c 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -1224,6 +1224,10 @@ static zval *to_zval_object(encodeTypePtr type, xmlNodePtr data) unset_zval_property(ret, "any" TSRMLS_CC); redo_any = 1; } + if (Z_TYPE_P(ret) == IS_OBJECT && ce != ZEND_STANDARD_CLASS_DEF_PTR) { + zend_object *zobj = zend_objects_get_address(ret TSRMLS_CC); + zobj->ce = ce; + } } else { zval *base; diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c index d6183ffc93..565a7fb46b 100644 --- a/ext/soap/php_schema.c +++ b/ext/soap/php_schema.c @@ -2192,9 +2192,25 @@ static void schema_content_model_fixup(sdlCtx *ctx, sdlContentModelPtr model) } break; } - case XSD_CONTENT_SEQUENCE: - case XSD_CONTENT_ALL: case XSD_CONTENT_CHOICE: { + if (model->max_occurs != 1) { + HashPosition pos; + sdlContentModelPtr *tmp; + + zend_hash_internal_pointer_reset_ex(model->u.content, &pos); + while (zend_hash_get_current_data_ex(model->u.content, (void**)&tmp, &pos) == SUCCESS) { + (*tmp)->min_occurs = 0; + (*tmp)->max_occurs = model->max_occurs; + zend_hash_move_forward_ex(model->u.content, &pos); + } + + model->kind = XSD_CONTENT_ALL; + model->min_occurs = 1; + model->max_occurs = 1; + } + } + case XSD_CONTENT_SEQUENCE: + case XSD_CONTENT_ALL: { sdlContentModelPtr *tmp; zend_hash_internal_pointer_reset(model->u.content); diff --git a/ext/soap/tests/bugs/bug35142.phpt b/ext/soap/tests/bugs/bug35142.phpt new file mode 100755 index 0000000000..b27d9bc6d9 --- /dev/null +++ b/ext/soap/tests/bugs/bug35142.phpt @@ -0,0 +1,135 @@ +--TEST-- +Bug #35142 SOAP Client/Server Complex Object Support +--SKIPIF-- + +--INI-- +soap.wsdl_cache_enabled=0 +--FILE-- +server = new SoapServer($wsdl, $options); + $this->server->addFunction('PostEvents'); + } + + function __doRequest($request, $location, $action, $version) { + echo "$request\n"; + $this->server->handle($request); + return $response; + } + +} + +$soapClient = new TestSoapClient($wsdl, + array('trace' => 1, 'exceptions' => 0, + 'classmap' => array('logOnEvent' => 'LogOnEvent', + 'logOffEvent' => 'LogOffEvent', + 'events' => 'IVREvents'))); + +$logOnEvent = new LogOnEvent(34567, $timestamp); +$logOffEvents[] = new LogOffEvent(34567, $timestamp, "Smoked"); +$logOffEvents[] = new LogOffEvent(34568, $timestamp, "SmokeFree"); +$ivrEvents = new IVREvents("1.0", 101, 12345, 'IVR', $logOnEvent, $logOffEvents); + +$result = $soapClient->PostEvents($ivrEvents); + +class LogOffEvent { + public $audienceMemberId; + public $timestamp; + public $smokeStatus; + public $callInititator; + + function __construct($audienceMemberId, $timestamp, $smokeStatus) { + $this->audienceMemberId = $audienceMemberId; + $this->timestamp = $timestamp; + $this->smokeStatus = $smokeStatus; + $this->callInitiator = "IVR"; + } +} + +class LogOnEvent { + public $audienceMemberId; + public $timestamp; + + function __construct($audienceMemberId, $timestamp) { + $this->audienceMemberId = $audienceMemberId; + $this->timestamp = $timestamp; + } +} + +class IVREvents { + public $version; + public $activityId; + public $messageId; + public $source; + public $logOnEvent; + public $logOffEvent; + + function __construct($version, $activityId, $messageId, $source, $logOnEvent=NULL, $logOffEvent=NULL) { + $this->version = $version; + $this->activityId = $activityId; + $this->messageId = $messageId; + $this->source = $source; + $this->logOnEvent = $logOnEvent; + $this->logOffEvent = $logOffEvent; + } +} +?> +--EXPECTF-- + + + +object(IVREvents)#%d (6) { + ["version"]=> + string(3) "1.0" + ["activityId"]=> + int(101) + ["messageId"]=> + int(12345) + ["logOffEvent"]=> + array(2) { + [0]=> + object(LogOffEvent)#%d (4) { + ["audienceMemberId"]=> + int(34567) + ["timestamp"]=> + string(25) "2005-11-08T11:22:07+03:00" + ["smokeStatus"]=> + string(6) "Smoked" + ["callInitiator"]=> + string(3) "IVR" + } + [1]=> + object(LogOffEvent)#%d (4) { + ["audienceMemberId"]=> + int(34568) + ["timestamp"]=> + string(25) "2005-11-08T11:22:07+03:00" + ["smokeStatus"]=> + string(9) "SmokeFree" + ["callInitiator"]=> + string(3) "IVR" + } + } + ["logOnEvent"]=> + object(LogOnEvent)#%d (2) { + ["audienceMemberId"]=> + int(34567) + ["timestamp"]=> + string(25) "2005-11-08T11:22:07+03:00" + } + ["source"]=> + string(3) "IVR" +} diff --git a/ext/soap/tests/bugs/bug35142.wsdl b/ext/soap/tests/bugs/bug35142.wsdl new file mode 100755 index 0000000000..2c712ec108 --- /dev/null +++ b/ext/soap/tests/bugs/bug35142.wsdl @@ -0,0 +1,543 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.50.1