summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2004-02-02 17:39:10 +0000
committerDmitry Stogov <dmitry@php.net>2004-02-02 17:39:10 +0000
commita70a620a01897579ab7d28418532a55dcfb6c459 (patch)
tree48fa928dd6b00c1be678cc78f328960335bcf19d
parent862bf61de9a2f788899207a66794de65758b770f (diff)
downloadphp-git-a70a620a01897579ab7d28418532a55dcfb6c459.tar.gz
fix: proper handling of SOAP 1.1 href and unresolved attributes references
-rw-r--r--ext/soap/php_encoding.c9
-rw-r--r--ext/soap/php_schema.c7
-rw-r--r--ext/soap/php_xml.c2
-rw-r--r--ext/soap/tests/soap12/T75.phpt28
-rw-r--r--ext/soap/tests/soap12/soap12-test.inc4
-rw-r--r--ext/soap/tests/soap12/soap12-test.wsdl22
6 files changed, 68 insertions, 4 deletions
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 2e9eb23b06..12d0ca0395 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -2304,7 +2304,14 @@ xmlNodePtr sdl_guess_convert_xml(encodeTypePtr enc, zval *data, int style, xmlNo
static xmlNodePtr check_and_resolve_href(xmlNodePtr data)
{
if (data && data->properties) {
- xmlAttrPtr href = get_attribute(data->properties, "href");
+ xmlAttrPtr href;
+
+ href = data->properties;
+ while (1) {
+ href = get_attribute(href, "href");
+ if (href == NULL || href->ns == NULL) {break;}
+ href = href->next;
+ }
if (href) {
/* Internal href try and find node */
if (href->children->content[0] == '#') {
diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c
index 69372c39ce..cde1a8ef86 100644
--- a/ext/soap/php_schema.c
+++ b/ext/soap/php_schema.c
@@ -2009,6 +2009,13 @@ static void schema_attribute_fixup(sdlPtr sdl, sdlAttributePtr attr)
}
attr->encode = (*tmp)->encode;
}
+ }
+ if (attr->name == NULL && attr->ref != NULL) {
+ char *name, *ns;
+ parse_namespace(attr->ref, &name, &ns);
+ attr->name = strdup(name);
+ if (name) {efree(name);}
+ if (ns) {efree(ns);}
}
efree(attr->ref);
attr->ref = NULL;
diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c
index 65e058c2bf..0f03d19fa7 100644
--- a/ext/soap/php_xml.c
+++ b/ext/soap/php_xml.c
@@ -182,7 +182,7 @@ xmlNodePtr get_node_with_attribute_recursive_ex(xmlNodePtr node, char *name, cha
int parse_namespace(const char *inval, char **value, char **namespace)
{
- char *found = strchr(inval, ':');
+ char *found = strrchr(inval, ':');
if (found != NULL && found != inval) {
(*namespace) = estrndup(inval, found - inval);
diff --git a/ext/soap/tests/soap12/T75.phpt b/ext/soap/tests/soap12/T75.phpt
new file mode 100644
index 0000000000..3e2166d957
--- /dev/null
+++ b/ext/soap/tests/soap12/T75.phpt
@@ -0,0 +1,28 @@
+--TEST--
+SOAP 1.2: T75 echoResolvedRef
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$HTTP_RAW_POST_DATA = <<<EOF
+<?xml version='1.0' ?>
+<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
+ <env:Header>
+ <test:echoResolvedRef xmlns:test="http://example.org/ts-tests"
+ env:role="http://www.w3.org/2003/05/soap-envelope/role/next"
+ env:mustUnderstand="1">
+ <test:RelativeReference xml:base="http://example.org/today/"
+ xlink:href="new.xml"
+ xmlns:xlink="http://www.w3.org/1999/xlink" />
+ </test:echoResolvedRef>
+ </env:Header>
+ <env:Body>
+ </env:Body>
+</env:Envelope>
+EOF;
+include "soap12-test.inc";
+?>
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://example.org/ts-tests"><env:Header><ns1:responseResolvedRef>http://example.org/today/new.xml</ns1:responseResolvedRef></env:Header><env:Body/></env:Envelope>
+ok
diff --git a/ext/soap/tests/soap12/soap12-test.inc b/ext/soap/tests/soap12/soap12-test.inc
index 47f39e2b41..7d0033da56 100644
--- a/ext/soap/tests/soap12/soap12-test.inc
+++ b/ext/soap/tests/soap12/soap12-test.inc
@@ -107,6 +107,10 @@ class Soap12test {
function echoHeader() {
return $this->header;
}
+
+ function echoResolvedRef($ref) {
+ return $ref->RelativeReference->base.$ref->RelativeReference->href;
+ }
}
$server = new soapserver("http://http://example.org/ts-tests","http://example.org/ts-tests/C");
diff --git a/ext/soap/tests/soap12/soap12-test.wsdl b/ext/soap/tests/soap12/soap12-test.wsdl
index 83a6423176..8993cf5b5e 100644
--- a/ext/soap/tests/soap12/soap12-test.wsdl
+++ b/ext/soap/tests/soap12/soap12-test.wsdl
@@ -331,6 +331,13 @@
<part name="responseHeader" element="test:echoHeaderResponse"/>
</message>
+ <message name="echoResolvedRefRequest">
+ <part name="responseHeader" element="test:echoResolvedRef"/>
+ </message>
+ <message name="echoResolvedRefResponse">
+ <part name="responseHeader" element="test:responseResolvedRef"/>
+ </message>
+
<!-- "unknown" header block -->
<message name="UnknownHdrBlockLit">
<part name="Unknown" element="test:Unknown" />
@@ -355,6 +362,10 @@
<input message="tns:echoHeaderRequest" />
<output message="tns:echoHeaderResponse" />
</operation>
+ <operation name="echoResolvedRef">
+ <input message="tns:echoResolvedRefRequest" />
+ <output message="tns:echoResolvedRefResponse" />
+ </operation>
</portType>
<portType name="Soap12TestPortTypeRpc">
@@ -501,8 +512,6 @@
<soap12:operation/>
<input>
<soap12:body use="literal" />
- <soap12:header message="tns:echoOkRequest" part="echoOk" use="literal" />
- <soap12:header message="tns:UnknownHdrBlockLit" part="Unknown" use="literal" />
</input>
</operation>
<operation name="echoHeader">
@@ -517,6 +526,15 @@
<soap12:header message="tns:echoOkResponse" part="responseOk" use="literal" />
</output>
</operation>
+ <operation name="echoResolvedRef">
+ <soap12:operation/>
+ <input>
+ <soap12:body use="literal" />
+ </input>
+ <output>
+ <soap12:body use="literal" />
+ </output>
+ </operation>
</binding>
<binding name="Soap12TestRpcBinding" type="tns:Soap12TestPortTypeRpc">