From 55c25c7275d659488479845b1f358f026c596782 Mon Sep 17 00:00:00 2001 From: George Schlossnagle Date: Sun, 3 Apr 2005 15:39:56 +0000 Subject: [PATCH] Fix qualified names for attributes according to attributeFormDefault. Add SOAP Interop tests from Dmitry. --- ext/soap/php_encoding.c | 10 ++++----- ext/soap/php_schema.c | 20 +++++++++++++++++- ext/soap/tests/bugs/bug29236.phpt | 4 ++-- ext/soap/tests/schema/schema037.phpt | 2 +- ext/soap/tests/schema/schema038.phpt | 2 +- ext/soap/tests/schema/schema039.phpt | 2 +- ext/soap/tests/schema/schema040.phpt | 2 +- ext/soap/tests/schema/schema042.phpt | 2 +- ext/soap/tests/schema/schema043.phpt | 2 +- ext/soap/tests/schema/schema044.phpt | 2 +- ext/soap/tests/schema/schema045.phpt | 2 +- ext/soap/tests/schema/schema046.phpt | 2 +- ext/soap/tests/schema/schema047.phpt | 2 +- ext/soap/tests/schema/schema048.phpt | 2 +- ext/soap/tests/schema/schema062.phpt | 2 +- ext/soap/tests/schema/schema065.phpt | 2 +- ext/soap/tests/schema/schema066.phpt | 2 +- ext/soap/tests/schema/schema067.phpt | 2 +- ext/soap/tests/schema/schema069.phpt | 2 +- ext/soap/tests/schema/schema070.phpt | 2 +- ext/soap/tests/schema/schema074.phpt | 29 +++++++++++++++++++++++++++ ext/soap/tests/schema/test_schema.inc | 11 +++++----- 22 files changed, 78 insertions(+), 30 deletions(-) create mode 100644 ext/soap/tests/schema/schema074.phpt diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index e9efb553cd..8e731679f4 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -1479,11 +1479,11 @@ static xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style, xmlNo if ((*attr)->fixed && strcmp((*attr)->fixed,dummy->children->content) != 0) { soap_error3(E_ERROR, "Encoding: Attribute '%s' has fixed value '%s' (value '%s' is not allowed)", (*attr)->name, (*attr)->fixed, dummy->children->content); } - if ((*attr)->namens) { -/* - if ((*attr)->namens && - (type->ns == NULL || strcmp((*attr)->namens, type->ns))) { -*/ + /* we need to handle xml: namespace specially, since it is + an implicit schema. Otherwise, use form. + */ + if (!strncmp((*attr)->namens, XML_NAMESPACE, sizeof(XML_NAMESPACE)) || + (*attr)->form == XSD_FORM_QUALIFIED && (*attr)->namens) { xmlNsPtr nsp = encode_add_ns(xmlParam, (*attr)->namens); xmlSetNsProp(xmlParam, nsp, (*attr)->name, dummy->children->content); diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c index 6aee0926c5..b0e537f348 100644 --- a/ext/soap/php_schema.c +++ b/ext/soap/php_schema.c @@ -1890,7 +1890,25 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr attrType, sdl } attr = attr->next; } - + if(newAttr->form == XSD_FORM_DEFAULT) { + xmlNodePtr parent = attrType->parent; + while(parent) { + if(node_is_equal_ex(parent, "schema", SCHEMA_NAMESPACE)) { + xmlAttrPtr def; + def = get_attribute(parent->properties, "attributeFormDefault"); + if(def == NULL || strncmp(def->children->content, "qualified", sizeof("qualified"))) { + newAttr->form = XSD_FORM_UNQUALIFIED; + } else { + newAttr->form = XSD_FORM_QUALIFIED; + } + break; + } + parent = parent->parent; + } + if(parent == NULL) { + newAttr->form = XSD_FORM_UNQUALIFIED; + } + } trav = attrType->children; if (trav != NULL && node_is_equal(trav, "annotation")) { /* TODO: support */ diff --git a/ext/soap/tests/bugs/bug29236.phpt b/ext/soap/tests/bugs/bug29236.phpt index 372449fbb2..4dbc302c17 100644 --- a/ext/soap/tests/bugs/bug29236.phpt +++ b/ext/soap/tests/bugs/bug29236.phpt @@ -3,7 +3,7 @@ Bug #29236 (memory error when wsdl-cache is enabled) --SKIPIF-- --FILE-- -__getFunctions()); ?> @@ -17,4 +17,4 @@ array(4) { string(41) "LogoutResponse Logout(Logout $parameters)" [3]=> string(62) "GetSystemInfoResponse GetSystemInfo(GetSystemInfo $parameters)" -} \ No newline at end of file +} diff --git a/ext/soap/tests/schema/schema037.phpt b/ext/soap/tests/schema/schema037.phpt index 75e1757554..4e59981fc9 100644 --- a/ext/soap/tests/schema/schema037.phpt +++ b/ext/soap/tests/schema/schema037.phpt @@ -18,7 +18,7 @@ echo "ok"; ?> --EXPECTF-- -str +str object(stdClass)#%d (2) { ["str"]=> string(3) "str" diff --git a/ext/soap/tests/schema/schema038.phpt b/ext/soap/tests/schema/schema038.phpt index ed7e3b4fc5..2d37e89e0b 100644 --- a/ext/soap/tests/schema/schema038.phpt +++ b/ext/soap/tests/schema/schema038.phpt @@ -19,7 +19,7 @@ echo "ok"; ?> --EXPECTF-- -str +str object(stdClass)#%d (2) { ["str"]=> string(3) "str" diff --git a/ext/soap/tests/schema/schema039.phpt b/ext/soap/tests/schema/schema039.phpt index 67b1c2544a..0b7ef5afc4 100644 --- a/ext/soap/tests/schema/schema039.phpt +++ b/ext/soap/tests/schema/schema039.phpt @@ -21,7 +21,7 @@ echo "ok"; ?> --EXPECTF-- -str +str object(stdClass)#%d (2) { ["str"]=> string(3) "str" diff --git a/ext/soap/tests/schema/schema040.phpt b/ext/soap/tests/schema/schema040.phpt index 29815fe1f5..f7ddc04546 100644 --- a/ext/soap/tests/schema/schema040.phpt +++ b/ext/soap/tests/schema/schema040.phpt @@ -22,7 +22,7 @@ echo "ok"; ?> --EXPECTF-- -str +str object(stdClass)#%d (2) { ["str"]=> string(3) "str" diff --git a/ext/soap/tests/schema/schema042.phpt b/ext/soap/tests/schema/schema042.phpt index 35a9e8ea02..a8aa8857d9 100644 --- a/ext/soap/tests/schema/schema042.phpt +++ b/ext/soap/tests/schema/schema042.phpt @@ -19,7 +19,7 @@ echo "ok"; ?> --EXPECTF-- -123 +123 object(stdClass)#%d (2) { ["_"]=> int(123) diff --git a/ext/soap/tests/schema/schema043.phpt b/ext/soap/tests/schema/schema043.phpt index db48582647..08c2996363 100644 --- a/ext/soap/tests/schema/schema043.phpt +++ b/ext/soap/tests/schema/schema043.phpt @@ -26,7 +26,7 @@ echo "ok"; ?> --EXPECTF-- -123 +123 object(stdClass)#%d (3) { ["_"]=> int(123) diff --git a/ext/soap/tests/schema/schema044.phpt b/ext/soap/tests/schema/schema044.phpt index e2b9fda77a..8fc0705518 100644 --- a/ext/soap/tests/schema/schema044.phpt +++ b/ext/soap/tests/schema/schema044.phpt @@ -19,7 +19,7 @@ echo "ok"; ?> --EXPECTF-- -123 +123 object(stdClass)#%d (2) { ["_"]=> int(123) diff --git a/ext/soap/tests/schema/schema045.phpt b/ext/soap/tests/schema/schema045.phpt index 5f7e649f5a..346a929d85 100644 --- a/ext/soap/tests/schema/schema045.phpt +++ b/ext/soap/tests/schema/schema045.phpt @@ -26,7 +26,7 @@ echo "ok"; ?> --EXPECTF-- -123 +123 object(stdClass)#%d (2) { ["_"]=> int(123) diff --git a/ext/soap/tests/schema/schema046.phpt b/ext/soap/tests/schema/schema046.phpt index 3452c20b4e..3f9d03afad 100644 --- a/ext/soap/tests/schema/schema046.phpt +++ b/ext/soap/tests/schema/schema046.phpt @@ -26,7 +26,7 @@ echo "ok"; ?> --EXPECTF-- -123 +123 object(stdClass)#%d (3) { ["_"]=> int(123) diff --git a/ext/soap/tests/schema/schema047.phpt b/ext/soap/tests/schema/schema047.phpt index f49946ff4a..1265cfd3a3 100644 --- a/ext/soap/tests/schema/schema047.phpt +++ b/ext/soap/tests/schema/schema047.phpt @@ -24,7 +24,7 @@ echo "ok"; ?> --EXPECTF-- -123 +123 object(stdClass)#%d (2) { ["int"]=> int(123) diff --git a/ext/soap/tests/schema/schema048.phpt b/ext/soap/tests/schema/schema048.phpt index 4f0cb7e20f..98d4d4be44 100644 --- a/ext/soap/tests/schema/schema048.phpt +++ b/ext/soap/tests/schema/schema048.phpt @@ -26,7 +26,7 @@ echo "ok"; ?> --EXPECTF-- -123 +123 object(stdClass)#%d (2) { ["_"]=> int(123) diff --git a/ext/soap/tests/schema/schema062.phpt b/ext/soap/tests/schema/schema062.phpt index e9e295a6a3..d4efc9a599 100644 --- a/ext/soap/tests/schema/schema062.phpt +++ b/ext/soap/tests/schema/schema062.phpt @@ -19,7 +19,7 @@ echo "ok"; ?> --EXPECTF-- - + object(stdClass)#%d (2) { ["_"]=> NULL diff --git a/ext/soap/tests/schema/schema065.phpt b/ext/soap/tests/schema/schema065.phpt index abc6cf9268..e3f0d646dc 100644 --- a/ext/soap/tests/schema/schema065.phpt +++ b/ext/soap/tests/schema/schema065.phpt @@ -16,7 +16,7 @@ echo "ok"; ?> --EXPECTF-- - + object(stdClass)#%d (2) { ["str"]=> string(3) "str" diff --git a/ext/soap/tests/schema/schema066.phpt b/ext/soap/tests/schema/schema066.phpt index 3991708ee8..b281271963 100644 --- a/ext/soap/tests/schema/schema066.phpt +++ b/ext/soap/tests/schema/schema066.phpt @@ -16,7 +16,7 @@ echo "ok"; ?> --EXPECTF-- - + object(stdClass)#%d (2) { ["str"]=> string(3) "str" diff --git a/ext/soap/tests/schema/schema067.phpt b/ext/soap/tests/schema/schema067.phpt index 34cb89c332..0e4000957a 100644 --- a/ext/soap/tests/schema/schema067.phpt +++ b/ext/soap/tests/schema/schema067.phpt @@ -16,7 +16,7 @@ echo "ok"; ?> --EXPECTF-- - + object(stdClass)#%d (2) { ["str"]=> string(3) "str" diff --git a/ext/soap/tests/schema/schema069.phpt b/ext/soap/tests/schema/schema069.phpt index 8f21e8670d..e4f733a1c0 100644 --- a/ext/soap/tests/schema/schema069.phpt +++ b/ext/soap/tests/schema/schema069.phpt @@ -17,7 +17,7 @@ echo "ok"; ?> --EXPECTF-- - + object(stdClass)#%d (2) { ["str"]=> string(3) "str" diff --git a/ext/soap/tests/schema/schema070.phpt b/ext/soap/tests/schema/schema070.phpt index e471ca88ff..af9abdc10f 100644 --- a/ext/soap/tests/schema/schema070.phpt +++ b/ext/soap/tests/schema/schema070.phpt @@ -19,7 +19,7 @@ echo "ok"; ?> --EXPECTF-- - + object(stdClass)#%d (2) { ["str"]=> string(3) "str" diff --git a/ext/soap/tests/schema/schema074.phpt b/ext/soap/tests/schema/schema074.phpt new file mode 100644 index 0000000000..3dbba0cd25 --- /dev/null +++ b/ext/soap/tests/schema/schema074.phpt @@ -0,0 +1,29 @@ +--TEST-- +SOAP XML Schema 74: Structure with attributes and qualified elements +--SKIPIF-- + +--FILE-- + + + + + + +EOF; + +test_schema($schema,'type="tns:testType"',(object)array("str"=>"str","int"=>123.5), "rpc", "encoded", 'attributeFormDefault="qualified"'); +echo "ok"; +?> +--EXPECTF-- + +str +object(stdClass)#%d (2) { + ["str"]=> + string(3) "str" + ["int"]=> + int(123) +} +ok diff --git a/ext/soap/tests/schema/test_schema.inc b/ext/soap/tests/schema/test_schema.inc index e3d83f42d7..e1d4eeb508 100644 --- a/ext/soap/tests/schema/test_schema.inc +++ b/ext/soap/tests/schema/test_schema.inc @@ -6,7 +6,7 @@ function test($input) { $val = $input; } -function test_schema($schema,$type,$param,$style="rpc",$use="encoded") { +function test_schema($schema,$type,$param,$style="rpc",$use="encoded", $attributeFormDefault='') { global $HTTP_RAW_POST_DATA, $val; $wsdl = << + targetNamespace="http://test-uri/" + > - + $schema @@ -53,7 +54,7 @@ EOF; $f = fopen($fname,"w"); fwrite($f,$wsdl); fclose($f); - ini_set("soap.wsdl_cache_enabled",0); + ini_set("soap.wsdl_cache_enabled",0); $x = new SoapClient($fname, array("trace"=>1,"exceptions"=>0)); $y = new SoapServer($fname); $y->addfunction("test"); @@ -73,4 +74,4 @@ EOF; echo $req; } } -?> \ No newline at end of file +?> -- 2.40.0