I am making a client in php with soap for a webservice in .net. The webservice run over https with a self-signed certificate and for the tests I must trust this certificate without install it.
The problem is that I allways get this error:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://winsystemsintl.com:54904/PSAService.svc?wsdl' : failed to load external entity "https://winsystemsintl.com:54904/PSAService.svc?wsdl".
Here is my code:
$opts = [
'ssl' => [
// set some SSL/TLS specific options
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
],
'http'=>[
'user_agent' => 'PHPSoapClient'
]
];
// Initialize Soap Client
$this->client = new SoapClient($this->wsdl, array('ssl_method' => SOAP_SSL_METHOD_SSLv3,'soap_version' => SOAP_1_2, 'location' => 'https://winsystemsintl.com:54904/PSAService.svc','stream_context' => stream_context_create($opts), 'exceptions' => true, 'trace' => true));
I was able to get the wsdl with wget:
wget --secure-protocol=SSLv3 https://winsystemsintl.com:54904/PSAService.svc?wsdl --no-check-certificate
Hope someone can help me, thanks a lot.
The problem is that PHP ignores your stream context when downloading the
WSDL
file. A workaround is to download theWSDL
file, and all the schema imports to your local file system (I'm usingtidy
here to pretty print the XML):Next, you have to edit
PSAService.svc?wsdl
(the filename that wget saved to) and change the imports to point to your local system instead of the web. Use the replace-all feature in your favorite editor and replace'https://winsystemsintl.com:54904/'
with''
:Example Before:
After:
Repeat for each of the files that were downloaded.
Next, change your code to the following (I assume here that all PHP/WSDL files are in the same folder):
Now the
SoapClient
has skipped downloading theWSDL
from the web, and you're ready to start making calls using your stream context.