Reputation: 1897
Using SoapClient
in PHP (version 5.3.10) I've come across a problem I have not been able to find a solution to.
The combination of HTTPS and Proxy for contacting the webservice is giving me some real pain. Is there a way to get this working?
Given the following setup:
$WSDL = 'https://(...).php?wsdl';
$params = array(
'proxy_host' => 'localhost',
'proxy_port' => 3128
);
This works:
$client = new SoapClient($WSDL);
var_dump($client->__getFunctions());
var_dump($client->__call('someFunc', array()));
This gives error at some point:
$client = new SoapClient($WSDL, $params);
var_dump($client->__getFunctions());
var_dump($client->__call('someFunc', array()));
I've tried a few twists and hacks trying to narrow the problems:
$WSDL
is set to an HTTP-based service, both methods works.$WSDL
is set to this, the failing method produces the functions, but fails when trying to call the function.From initializing a client with HTTPS-url to the wsdl and proxy enabled, PHP exits with the following error:
Fatal error: Uncaught SoapFault exception:
[WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://(...).php?wsdl' :
failed to load external entity https://(...).php?wsdl
When initializing the client using a locally stored WSDL-definition file, PHP exits with the following error:
Fatal error: Uncaught SoapFault exception:
[HTTP] Bad Request in test.php:19
Stack trace: #0 [internal function]: SoapClient->__doRequest
From my perspective this looks lika a PHP bug, but hopefully there is a way around it.
Do I have to go to libraries such as NuSoap?
Is this fixed in another version of PHP?
Am I missing something?
Upvotes: 0
Views: 7195
Reputation: 21
I'm behind a firewall. I had to set the proxy and port in order to make my code work.
$client = new SoapClient($wsdl, [
"trace" => 1,
"exceptions" => 1,
"proxy_host" => "PROXY_HOST_STRING",
"proxy_port" => PROXY_PORT_NUMBER
]);
Upvotes: 0
Reputation: 11991
I had this problem when using Fiddler2 proxy on localhost. Had to export Fiddler's root certificate and explicitly set cafile
option like this
$client = new SoapClient($url, [
'proxy_host' => 'localhost',
'proxy_port' => 8888,
'stream_context' => stream_context_create([
'ssl' => [ 'cafile' => 'C:\path\to\FiddlerRoot.pem' ] ])
]);
... for the https access to service to be captured.
FiddlerRoot.pem
is exported using certmgr.msc
of DO_NOT_TRUST_FiddlerRoot-CE
entry in Personal
store with Base-64 encoded X.509 (.CER)
option.
Upvotes: 1
Reputation: 282
I had to use a local copy of the wsdl file and I am using this options:
array(
'trace' => 1,
'exceptions' => true,
'cache_wsdl' => WSDL_CACHE_NONE,
'proxy_host' => self::PROXY_HOST,
'proxy_port' => self::PROXY_PORT,
'proxy_login' => self::PROXY_USER,
'proxy_password' => self::PROXY_PASS,
)
Maybe the options trace
or cache_wsdl
will help you.
Upvotes: 0