Skip to content

Commit 6597e85

Browse files
committed
Fixed bug #50698 (SoapClient should handle wsdls with some incompatiable endpoints). (Justin Dearing)
1 parent 617e8a4 commit 6597e85

9 files changed

+1262
-1
lines changed

ext/soap/php_sdl.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,12 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri TSRMLS_DC)
832832
if (strncmp((char*)tmp->children->content, WSDL_HTTP_TRANSPORT, sizeof(WSDL_HTTP_TRANSPORT)) == 0) {
833833
soapBinding->transport = SOAP_TRANSPORT_HTTP;
834834
} else {
835-
soap_error1(E_ERROR, "Parsing WSDL: PHP-SOAP doesn't support transport '%s'", tmp->children->content);
835+
/* try the next binding */
836+
efree(soapBinding);
837+
efree(tmpbinding->location);
838+
efree(tmpbinding);
839+
trav = trav->next;
840+
continue;
836841
}
837842
}
838843
}
@@ -1128,6 +1133,10 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri TSRMLS_DC)
11281133
soap_error0(E_ERROR, "Parsing WSDL: Couldn't bind to service");
11291134
}
11301135

1136+
if (ctx.sdl->bindings == NULL || ctx.sdl->bindings->nNumOfElements == 0) {
1137+
soap_error0(E_ERROR, "Parsing WSDL: Could not find any usable binding services in WSDL.");
1138+
}
1139+
11311140
zend_hash_destroy(&ctx.messages);
11321141
zend_hash_destroy(&ctx.bindings);
11331142
zend_hash_destroy(&ctx.portTypes);

ext/soap/tests/bugs/bug50698_1.phpt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Request #50698_1 (SoapClient should handle wsdls with some incompatiable endpoints)
3+
--INI--
4+
soap.wsdl_cache_enabled=0
5+
--FILE--
6+
<?php
7+
new SoapClient(dirname(__FILE__) . '/bug50698_1.wsdl');
8+
echo "ok\n";
9+
?>
10+
--EXPECT--
11+
ok

ext/soap/tests/bugs/bug50698_1.wsdl

+228
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
<wsdl:definitions name="EchoService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
2+
<wsp:Policy wsu:Id="WSHttpBinding_EchoService_policy">
3+
<wsp:ExactlyOne>
4+
<wsp:All>
5+
<sp:SymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
6+
<wsp:Policy>
7+
<sp:ProtectionToken>
8+
<wsp:Policy>
9+
<sp:SecureConversationToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
10+
<wsp:Policy>
11+
<sp:RequireDerivedKeys/>
12+
<sp:BootstrapPolicy>
13+
<wsp:Policy>
14+
<sp:SignedParts>
15+
<sp:Body/>
16+
<sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing"/>
17+
<sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing"/>
18+
<sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing"/>
19+
<sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing"/>
20+
<sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing"/>
21+
<sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing"/>
22+
<sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing"/>
23+
</sp:SignedParts>
24+
<sp:EncryptedParts>
25+
<sp:Body/>
26+
</sp:EncryptedParts>
27+
<sp:SymmetricBinding>
28+
<wsp:Policy>
29+
<sp:ProtectionToken>
30+
<wsp:Policy>
31+
<sp:SpnegoContextToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
32+
<wsp:Policy>
33+
<sp:RequireDerivedKeys/>
34+
</wsp:Policy>
35+
</sp:SpnegoContextToken>
36+
</wsp:Policy>
37+
</sp:ProtectionToken>
38+
<sp:AlgorithmSuite>
39+
<wsp:Policy>
40+
<sp:Basic256/>
41+
</wsp:Policy>
42+
</sp:AlgorithmSuite>
43+
<sp:Layout>
44+
<wsp:Policy>
45+
<sp:Strict/>
46+
</wsp:Policy>
47+
</sp:Layout>
48+
<sp:IncludeTimestamp/>
49+
<sp:EncryptSignature/>
50+
<sp:OnlySignEntireHeadersAndBody/>
51+
</wsp:Policy>
52+
</sp:SymmetricBinding>
53+
<sp:Wss11>
54+
<wsp:Policy>
55+
<sp:MustSupportRefKeyIdentifier/>
56+
<sp:MustSupportRefIssuerSerial/>
57+
<sp:MustSupportRefThumbprint/>
58+
<sp:MustSupportRefEncryptedKey/>
59+
</wsp:Policy>
60+
</sp:Wss11>
61+
<sp:Trust10>
62+
<wsp:Policy>
63+
<sp:MustSupportIssuedTokens/>
64+
<sp:RequireClientEntropy/>
65+
<sp:RequireServerEntropy/>
66+
</wsp:Policy>
67+
</sp:Trust10>
68+
</wsp:Policy>
69+
</sp:BootstrapPolicy>
70+
</wsp:Policy>
71+
</sp:SecureConversationToken>
72+
</wsp:Policy>
73+
</sp:ProtectionToken>
74+
<sp:AlgorithmSuite>
75+
<wsp:Policy>
76+
<sp:Basic256/>
77+
</wsp:Policy>
78+
</sp:AlgorithmSuite>
79+
<sp:Layout>
80+
<wsp:Policy>
81+
<sp:Strict/>
82+
</wsp:Policy>
83+
</sp:Layout>
84+
<sp:IncludeTimestamp/>
85+
<sp:EncryptSignature/>
86+
<sp:OnlySignEntireHeadersAndBody/>
87+
</wsp:Policy>
88+
</sp:SymmetricBinding>
89+
<sp:Wss11 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
90+
<wsp:Policy>
91+
<sp:MustSupportRefKeyIdentifier/>
92+
<sp:MustSupportRefIssuerSerial/>
93+
<sp:MustSupportRefThumbprint/>
94+
<sp:MustSupportRefEncryptedKey/>
95+
</wsp:Policy>
96+
</sp:Wss11>
97+
<sp:Trust10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
98+
<wsp:Policy>
99+
<sp:MustSupportIssuedTokens/>
100+
<sp:RequireClientEntropy/>
101+
<sp:RequireServerEntropy/>
102+
</wsp:Policy>
103+
</sp:Trust10>
104+
<wsaw:UsingAddressing/>
105+
</wsp:All>
106+
</wsp:ExactlyOne>
107+
</wsp:Policy>
108+
<wsp:Policy wsu:Id="WSHttpBinding_EchoService_Echo_Input_policy">
109+
<wsp:ExactlyOne>
110+
<wsp:All>
111+
<sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
112+
<sp:Body/>
113+
<sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing"/>
114+
<sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing"/>
115+
<sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing"/>
116+
<sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing"/>
117+
<sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing"/>
118+
<sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing"/>
119+
<sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing"/>
120+
</sp:SignedParts>
121+
<sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
122+
<sp:Body/>
123+
</sp:EncryptedParts>
124+
</wsp:All>
125+
</wsp:ExactlyOne>
126+
</wsp:Policy>
127+
<wsp:Policy wsu:Id="WSHttpBinding_EchoService_Echo_output_policy">
128+
<wsp:ExactlyOne>
129+
<wsp:All>
130+
<sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
131+
<sp:Body/>
132+
<sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing"/>
133+
<sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing"/>
134+
<sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing"/>
135+
<sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing"/>
136+
<sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing"/>
137+
<sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing"/>
138+
<sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing"/>
139+
</sp:SignedParts>
140+
<sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
141+
<sp:Body/>
142+
</sp:EncryptedParts>
143+
</wsp:All>
144+
</wsp:ExactlyOne>
145+
</wsp:Policy>
146+
<wsp:Policy wsu:Id="NetTcpBinding_EchoService_policy">
147+
<wsp:ExactlyOne>
148+
<wsp:All>
149+
<msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1"/>
150+
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
151+
<wsp:Policy>
152+
<sp:TransportToken>
153+
<wsp:Policy>
154+
<msf:WindowsTransportSecurity xmlns:msf="http://schemas.microsoft.com/ws/2006/05/framing/policy">
155+
<msf:ProtectionLevel>EncryptAndSign</msf:ProtectionLevel>
156+
</msf:WindowsTransportSecurity>
157+
</wsp:Policy>
158+
</sp:TransportToken>
159+
<sp:AlgorithmSuite>
160+
<wsp:Policy>
161+
<sp:Basic256/>
162+
</wsp:Policy>
163+
</sp:AlgorithmSuite>
164+
<sp:Layout>
165+
<wsp:Policy>
166+
<sp:Strict/>
167+
</wsp:Policy>
168+
</sp:Layout>
169+
</wsp:Policy>
170+
</sp:TransportBinding>
171+
<wsaw:UsingAddressing/>
172+
</wsp:All>
173+
</wsp:ExactlyOne>
174+
</wsp:Policy>
175+
<wsdl:types>
176+
</wsdl:types>
177+
<wsdl:message name="EchoService_Echo_InputMessage">
178+
<wsdl:part name="parameters" element="tns:Echo"/>
179+
</wsdl:message>
180+
<wsdl:message name="EchoService_Echo_OutputMessage">
181+
<wsdl:part name="parameters" element="tns:EchoResponse"/>
182+
</wsdl:message>
183+
<wsdl:portType name="EchoService">
184+
<wsdl:operation name="Echo">
185+
<wsdl:input wsaw:Action="http://tempuri.org/EchoService/Echo" message="tns:EchoService_Echo_InputMessage"/>
186+
<wsdl:output wsaw:Action="http://tempuri.org/EchoService/EchoResponse" message="tns:EchoService_Echo_OutputMessage"/>
187+
</wsdl:operation>
188+
</wsdl:portType>
189+
<wsdl:binding name="BasicHttpBinding_EchoService" type="tns:EchoService">
190+
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
191+
<wsdl:operation name="Echo">
192+
<soap:operation soapAction="http://tempuri.org/EchoService/Echo" style="document"/>
193+
<wsdl:input>
194+
<soap:body use="literal"/>
195+
</wsdl:input>
196+
<wsdl:output>
197+
<soap:body use="literal"/>
198+
</wsdl:output>
199+
</wsdl:operation>
200+
</wsdl:binding>
201+
<wsdl:binding name="NetTcpBinding_EchoService" type="tns:EchoService">
202+
<wsp:PolicyReference URI="#NetTcpBinding_EchoService_policy"/>
203+
<soap12:binding transport="http://schemas.microsoft.com/soap/tcp"/>
204+
<wsdl:operation name="Echo">
205+
<soap12:operation soapAction="http://tempuri.org/EchoService/Echo" style="document"/>
206+
<wsdl:input>
207+
<soap12:body use="literal"/>
208+
</wsdl:input>
209+
<wsdl:output>
210+
<soap12:body use="literal"/>
211+
</wsdl:output>
212+
</wsdl:operation>
213+
</wsdl:binding>
214+
<wsdl:service name="EchoService">
215+
<wsdl:port name="BasicHttpBinding_EchoService" binding="tns:BasicHttpBinding_EchoService">
216+
<soap:address location="http://localhost:8731/EchoService/Basic"/>
217+
</wsdl:port>
218+
<wsdl:port name="NetTcpBinding_EchoService" binding="tns:NetTcpBinding_EchoService">
219+
<soap12:address location="net.tcp://localhost:8732/EchoService/"/>
220+
<wsa10:EndpointReference>
221+
<wsa10:Address>net.tcp://localhost:8732/EchoService/</wsa10:Address>
222+
<Identity xmlns="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity">
223+
<Upn>MAYA-DELL\Justin Dearing</Upn>
224+
</Identity>
225+
</wsa10:EndpointReference>
226+
</wsdl:port>
227+
</wsdl:service>
228+
</wsdl:definitions>

ext/soap/tests/bugs/bug50698_2.phpt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Request #50698_2 (SoapClient should handle wsdls with some incompatiable endpoints -- EDGECASE: Large mix of compatiable and incompatiable endpoints.)
3+
--INI--
4+
soap.wsdl_cache_enabled=0
5+
--FILE--
6+
<?php
7+
try {
8+
new SoapClient(dirname(__FILE__) . '/bug50698_2.wsdl');
9+
echo "Call: \"new SoapClient(dirname(__FILE__).'/bug50698_2.wsdl');\" should throw an exception of type 'SoapFault'";
10+
} catch (SoapFault $e) {
11+
if ($e->faultcode == 'WSDL' && $e->faultstring == 'SOAP-ERROR: Parsing WSDL: Could not find any usable binding services in WSDL.') {
12+
echo "ok\n";
13+
} else {
14+
echo "Call: \"new SoapClient(dirname(__FILE__).'/bug50698_2.wsdl');\" threw a SoapFault with an incorrect faultcode or faultmessage.";
15+
print_r($e);
16+
}
17+
}
18+
?>
19+
--EXPECT--
20+
ok

0 commit comments

Comments
 (0)