xref: /PHP-7.0/ext/soap/tests/bug69137.phpt (revision 3b9ba619)
1--TEST--
2SOAP Bug #69137 - Peer verification fails when using a proxy with SoapClient
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6if (getenv("SKIP_ONLINE_TESTS")) { die("skip test requiring internet connection"); }
7if (!getenv('http_proxy')) { die("skip test unless an HTTP/HTTPS proxy server is specified in http_proxy environment variable"); }
8?>
9--INI--
10soap.wsdl_cache_enabled=1
11--FILE--
12<?php
13
14class IpLookup
15{
16    public $licenseKey;
17    public $ipAddress;
18}
19
20list ($proxyHost, $proxyPort) = explode(':', str_replace('http://', '', $_ENV['http_proxy']));
21
22// Prime the WSDL cache because that request sets peer_name on the HTTP context
23// and masks the SOAP bug.
24$testServiceWsdl = 'https://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl';
25$client = new SoapClient($testServiceWsdl);
26unset($client);
27
28$parameters = [
29	'proxy_host' => $proxyHost,
30	'proxy_port' => $proxyPort,
31	'trace' => 1,
32];
33$client = new SoapClient($testServiceWsdl, $parameters);
34
35$lookup = new IpLookup();
36$lookup->licenseKey = 0;
37$lookup->ipAddress = '72.52.91.14';
38
39$result = $client->ResolveIP($lookup);
40
41if ($result && is_object($result) && $result->ResolveIPResult && is_object($result->ResolveIPResult)) {
42	print "successful lookup";
43}
44?>
45--EXPECT--
46successful lookup
47