|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2015-06-09 09:28 UTC] maciej dot lizewski at 3e dot pl
 Description:
------------
We need to connect to SSL WebService through Squid proxy.
When we connect with proxy and without wsdl cache (on disk) - it works fine
When we connect without proxy and with wsdl cache (on disk) - it works fine
when we connect with both wsdl cache on disk and proxy - only first request works (which creates cache file). All subsequent calls fail with "Could not connect to host" error. When cache file is wiped out - next request works fine, and again subsequent throw an error.
another thing is that we have to provide proxy configuration in both SoapClient options and Stream Context. When only provided in one place - same error is thrown ("Could not connect to host").
Test script:
---------------
$opts = array( 'http'=>array( 'proxy'=>'tcp://[proxy host]:3128' ) );
$context = stream_context_create( $opts );
$client = new SoapClient( 'https://webapi.allegro.pl/service.php?wsdl', array( 'proxy_host'=>'[proxy host]', 'proxy_port'=>3128, 'cache_wsdl'=>WSDL_CACHE_BOTH, 'stream_context'=>$context ) );
$request = array(
    'sysvar' => 1,
    'countryId' => 1,
    'webapiKey' => '[secret]'
);
try{
    var_dump( $client->doQuerySysStatus( $request ) );
}catch(SoapFault $e){
    echo $e->getCode() . ' ' . $e->getMessage() . "\n";
}
Expected result:
----------------
WSDL cache should work and it should use cached data when using proxy.
Actual result:
--------------
We can use only wsdl cache or proxy at once. Using both causes connection errors.
PatchesPull Requests
Pull requests: HistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 14:00:01 2025 UTC | 
Experienced the same problem, windows php 5.6.4. Found a workaround. In the stream_context, enforce 'peer_name' in ssl options: $opts['ssl']['peer_name'] = '<hostname>'; And the __soapCall can now work with a cached wsdl. Found this one by reading "ext/soap/php_http.c" source code. I'm pretty sure this section of code is not executed when context is loaded from the cache -- or something like that --. ----------- /* Set peer_name or name verification will try to use the proxy server name */ if (!context || (tmp = php_stream_context_get_option(context, "ssl", "peer_name")) == NULL) { ZVAL_STRING(&ssl_proxy_peer_name, phpurl->host); php_stream_context_set_option(PHP_STREAM_CONTEXT(stream), "ssl", "peer_name", &ssl_proxy_peer_name); zval_ptr_dtor(&ssl_proxy_peer_name); } --------------- I'm maybe wrong but at least this workaround fixed the issue for me.