Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug #45282: SoapClient has namespace issues when WSDL is distributed #15842

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
248 changes: 164 additions & 84 deletions ext/soap/php_sdl.c

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions ext/soap/php_sdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,19 @@ struct _sdl {
bool is_persistent;
};

typedef struct qname_hash_table {
HashTable inner;
} qname_hash_table;

typedef struct sdlCtx {
sdlPtr sdl;

HashTable docs; /* array of xmlDocPtr */

HashTable messages; /* array of xmlNodePtr */
HashTable bindings; /* array of xmlNodePtr */
HashTable portTypes; /* array of xmlNodePtr */
HashTable services; /* array of xmlNodePtr */
qname_hash_table messages; /* array of xmlNodePtr */
qname_hash_table bindings; /* array of xmlNodePtr */
qname_hash_table portTypes; /* array of xmlNodePtr */
qname_hash_table services; /* array of xmlNodePtr */

HashTable *attributes; /* array of sdlAttributePtr */
HashTable *attributeGroups; /* array of sdlTypesPtr */
Expand Down
3 changes: 1 addition & 2 deletions ext/soap/tests/bugs/bug29061.wsdl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ schemas.xmlsoap.org/wsdl/http/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/e
ncoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:y="http://new.webservice.namespace" targetNamespace="http
://new.webservice.namespace">
xmlns:y="http://new.webservice.namespace" targetNamespace="http://new.webservice.namespace">
<types>
<xs:schema/>
</types>
Expand Down
20 changes: 20 additions & 0 deletions ext/soap/tests/bugs/bug45282_a.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Bug #45282 (SoapClient has namespace issues when WSDL is distributed)
--EXTENSIONS--
soap
--INI--
soap.wsdl_cache_enabled=0
--FILE--
<?php
$client = new SoapClient(__DIR__ . "/bug45282_a.wsdl");
var_dump($client->__getFunctions());
?>
--EXPECT--
array(3) {
[0]=>
string(34) "date reportHealthView(int $number)"
[1]=>
string(34) "void reportHealthView(string $str)"
[2]=>
string(34) "date reportHealthView(int $number)"
}
40 changes: 40 additions & 0 deletions ext/soap/tests/bugs/bug45282_a.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://wssmcommupper/"
xmlns:tnsi="http://wssmcommupper/imported"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
name="WSSmCommUpperImplService"
targetNamespace="http://wssmcommupper/">
<types/>
<import namespace="http://wssmcommupper/imported" location="bug45282_import.wsdl" />
<message name="reportHealthView">
<part type="xs:string" name="str" />
</message>
<portType name="wssmcommupper">
<operation name="reportHealthView">
<input message="tns:reportHealthView" name="reportHealthView" />
</operation>
</portType>
<binding name="WSSmCommUpperImplServiceSoapBinding" type="tns:wssmcommupper">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="reportHealthView">
<soap:operation soapAction="" style="document" />
<input name="reportHealthView">
<soap:body use="literal" />
</input>
</operation>
</binding>
<service name="WSSmCommUpperImplService">
<port binding="tns:WSSmCommUpperImplServiceSoapBinding" name="WSSmCommUpperImplPort">
<soap:address location="http://172.20.22.9:10081/WSSmCommUpper/WSSmCommUpper" />
</port>
</service>
<!-- cross-reference imported definitions -->
<service name="WSSmCommUpperImplService2">
<port binding="tnsi:WSSmCommUpperImplServiceSoapBinding" name="WSSmCommUpperImplPort">
<soap:address location="http://172.20.22.9:10081/WSSmCommUpper/WSSmCommUpper" />
</port>
</service>
</definitions>
20 changes: 20 additions & 0 deletions ext/soap/tests/bugs/bug45282_b.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Bug #45282 (SoapClient has namespace issues when WSDL is distributed)
--EXTENSIONS--
soap
--SKIPIF--
<?php
if (getenv('SKIP_ASAN')) die('xleak libxml does not use the request allocator');
?>
--INI--
soap.wsdl_cache_enabled=0
--FILE--
<?php
try {
new SoapClient(__DIR__ . "/bug45282_b.wsdl");
} catch (SoapFault $e) {
echo $e->getMessage();
}
?>
--EXPECT--
SOAP-ERROR: Parsing WSDL: <message> 'reportHealthView' already defined
12 changes: 12 additions & 0 deletions ext/soap/tests/bugs/bug45282_b.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
name="WSSmCommUpperImplService"
targetNamespace="http://wssmcommupper/x">
<types/>
<message name="reportHealthView">
<part name="number" type="xs:int"/>
</message>
<import location="bug45282_import_nested1.wsdl"/>
</definitions>
29 changes: 29 additions & 0 deletions ext/soap/tests/bugs/bug45282_import.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://wssmcommupper/imported"
xmlns:x="http://wssmcommupper/x"
xmlns:imported2="http://wssmcommupper/imported2"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<import location="bug45282_import_nested1.wsdl"/>
<import namespace="http://wssmcommupper/imported2" location="bug45282_import_nested2.wsdl"/>
<portType name="wssmcommupper">
<operation name="reportHealthView">
<input message="x:reportHealthView" name="reportHealthView" />
<output message="imported2:reportHealthViewOut" name="reportHealthView" />
</operation>
</portType>
<!-- Intentionally missing tns declaration to test the BC fallback -->
<binding name="WSSmCommUpperImplServiceSoapBinding" type="tns:wssmcommupper">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="reportHealthView">
<soap:operation soapAction="" style="document" />
<input name="reportHealthView">
<soap:body use="literal" />
</input>
</operation>
</binding>
<service name="WSSmCommUpperImplService">
<port binding="tns:WSSmCommUpperImplServiceSoapBinding" name="WSSmCommUpperImplPort">
<soap:address location="http://172.20.22.9:10081/WSSmCommUpper/WSSmCommUpper" />
</port>
</service>
</definitions>
7 changes: 7 additions & 0 deletions ext/soap/tests/bugs/bug45282_import_nested1.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://wssmcommupper/x"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<message name="reportHealthView">
<part name="number" type="xs:int"/>
</message>
</definitions>
6 changes: 6 additions & 0 deletions ext/soap/tests/bugs/bug45282_import_nested2.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<message name="reportHealthViewOut">
<part name="date" type="xs:date"/>
</message>
</definitions>
2 changes: 1 addition & 1 deletion ext/soap/tests/server025.wsdl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:si="http://soapinterop.org/xsd"
xmlns:tns="http://linuxsrv.home/~dmitry/soap/test.wsdl"
xmlns:tns="http://testuri.org"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
Expand Down
Loading