Im having a problem with SoapClient and PHP 7.0 to parse wsdl.
Im getting this error:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://ws.ocasa.com/testecommerce/service.asmx?wsdl' : failed to load external entity "https://ws.ocasa.com/testecommerce/service.asmx?wsdl"
If you put this URL in a browser you can see the SOAP, and also in SoapUI it works OK.
I'm using laravel 5.4, and my code is:
$client = new \SoapClient('https://ws.ocasa.com/testecommerce/service.asmx?wsdl',
['soap_version'=>SOAP_1_2]);
I noticed that that website is under SSL TLS 1.0. If I change PHP to 5.6, it works perfect, but with PHP 7.0 it does not work.
If I change to this other WSDL:
https://id3check.gb.co.uk/gbportalinternational/aspx/id3check_1b.asmx?WSDL
Everything works fine.
Thank you
you could choose to ignore a bad cert:
$endpoint = new SOAPClient($url,
array(
'soap_version'=>SOAP_1_2,
'stream_context' => stream_context_create(
array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false
)
)
)
)
);
This would be a solution, should you not have access to the soap server to correct the certificate, or be able to elsewise make your server accept the certificate.
This should be the last solution as indeed you ignore all warnings something is wrong
Related
I have been trying to load a particular https wsdl via php soapclient.
The error that I am getting is:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://xxxx.com?wsdl' : failed to load external entity "https://xxxx.com?wsdl"
Moreover I also try to "Curl https://xxxx.com?wsdl" as well. The error that I am getting is:
curl: (35) error:141A318A:SSL routines:tls_process_ske_dhe:dh key too
small
I am able to view the particular wsdl via browser. Curl with http instead of https returns the correct response.
The weird thing is that, my colleague has ubuntu 18.04 installed on his machine and he does not have any problems. For your information, I have debian 10 installed and we both have the same IP address.
I really don't understand where the issue can be.
You should try disable certificate validation when construct SoapClient instance
$context = stream_context_create([
'ssl' => [
// set some SSL/TLS specific options
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]);
$client = new SoapClient($url, [
... ( other params )
'stream_context' => $context
]);
If you use curl from command line you can use the --insecure/-k flag.
I'm working on payment gateway API and API is based on the SOAP request. I have tested it on my local PC (Ubuntu + php 7.2) and it's working fine locally.
my code look like:
$options = array(
'cache_wsdl' => 0,
'trace' => 1,
'stream_context' => stream_context_create(
array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
)
)
);
$soapclient = new SoapClient("domain-name", $options);
but when I moved the code on the server (Cent OS + PHP 5.6) it stop working with following error:
SOAP-ERROR: Parsing WSDL: Couldn't load from domain-name : failed to load external entity domain-name
i know there are lots of similar question have answered on the site (like this, this, this and may more) but I have tried all of them but no luck.
please help me to fix this issue.
thanks.
I had the same problem. my soap API was working on local PC but not working on the server.
then I check the port 8080 status of my server with the following command:
# netstat --listen
or
# netstat -l
then I found that the port was closed. and after opening it SOAP API start working
I hope this will helps you
I'm having the situation where I try to connect to a SSL host via SOAP in a Docker Application.
When trying to do so, I have to disable SSL on transport level in order to get it working. I'm using code like this:
$context = stream_context_create([
'ssl' => [
// set some SSL/TLS specific options
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]);
$client = new SoapClient(null, [
'location' => 'https://...',
'uri' => '...',
'stream_context' => $context
]);
Which is also the most upvoted answer on this question.
So, what I'd like to achieve is to get the connection running without this hack.
If I leave this out, I receive the following exception:
( ! ) Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://api.myhost.tld/gateway/Method?wsdl' : failed to load external entity "https://api.myhost.tld/gateway/Method?wsdl" in /var/www/html/app/code/local/Vendor/MyHost/Model/Method.php on line 31
You need trusted certificate for your domain api.myhost.tld to make it right. So you can buy "official" SSL certificate and attach that to your SOAP webserver or create self signed certificate and add that cert as trusted in your docker image like described there: How do I add a CA root certificate inside a docker image?
I am having issues connecting to a WSDL via SOAPClient on my Laravel application in a server with PHP 7.0. I have tested the following code on my local server using PHP 5.6 and it works. Both are running Linux; my local server is running Kubuntu and the other server is running CentOS 7.
var $client;
function __construct(){
ini_set('soap.wsdl_cache_enabled',WSDL_CACHE_NONE);
ini_set('soap.wsdl_cache_ttl', 0);
$this->client = new SoapClient(env('WSDL_SOLMAN02_TEST'),
['login'=>env('SOLMAN_US_TEST'),
'password'=>env('SOLMAN_PSSWD_TEST'),
'cache_wsdl' => WSDL_CACHE_NONE,
'soap_version' => SOAP_1_1,
'ssl_method' => 'SOAP_SSL_METHOD_SSLv3',
'trace' => true,
'exception' => false,
'stream_context'=> stream_context_create(array(
'ssl'=> array(
'verify_peer'=>false,
'verify_peer_name'=>false
)
))
]
);
}
public function updateTicket(Ticket $ticket){
$incident = $this->createTicketObject($ticket);
$params = get_object_vars($incident);
return $this->client->wsdlFunc($params);
}
The funny thing is that when I print dd($this->client->__getFunctions()); the WSDL responds with an array of all the functions that you can call, but when I actually call upon any function, the error is displayed.
I have tried just about everything, from changing every parameter in the connection to changing the php.ini, but nothing has worked. I have downgraded the server to PHP 5.6 and it still doesn't work.
I have also tested WSDL on SOAPUI and it works.
The only difference I find between both environments is that the server with PHP 7.0 has https.
My code was fine, I just had to add the WSDL ip address to /etc/hosts.
I faced the same problem when I upgraded from php v7.2 to v7.3 (docker):
SOAPClient Error: Could not connect to host
I tried the solution proposed by #suecamol but it did not work. Looks like php v7.3 changed something with the ssl security.
The solution, that one of my co-worker found, was to add a proper ssl ciphers encryption:
$arrContextOptions= [
'ssl' => [
'ciphers' => 'AES256-SHA',
]
];
$options = [
...
'stream_context' => stream_context_create($arrContextOptions),
];
$client = new SoapClient('some wsdl url', $options);
Hopefully this can help someone facing this issue.
I have a problem with one WSDL connection with API, after moving to a new OVH VPS machine, so it's maybe some kind of strange misconfiguration.
Other WSDL that I use with SoapClient, work fine, without problems. I'm able to use file_get_contents on the address, but when I use SoapClient I gives a exception "Could not connect to host", when trying to use a procedure from that API.
Any ideas? I've tried some stream_context with some SSL options. What's the funniest, on the other OVH VPS is working fine.
System is Debian 8 with PHP 5.6.19 onboard.
Addresss of the WSDL is here: https://api-test.paczkawruchu.pl/WebServicePwR/WebServicePwRTest.asmx?WSDL
After consultation with WSDL provider, and checking logs on both sides, we found the anwser. It looks like PHP 5.6 have some problems, and you have to change parameters to SOAP 1.2. This resolved finally the problem. Resolution could be found here, in first comment:
SOAP PHP fault parsing WSDL: failed to load external entity?
// options for ssl in php 5.6.5
$opts = array(
'ssl' => array('ciphers'=>'RC4-SHA', 'verify_peer'=>false, 'verify_peer_name'=>false)
);
// SOAP 1.2 client
$params = array ('encoding' => 'UTF-8', 'verifypeer' => false, 'verifyhost' => false, 'soap_version' => SOAP_1_2, 'trace' => 1, 'exceptions' => 1, "connection_timeout" => 180, 'stream_context' => stream_context_create($opts) );
$oSoapClient = new SoapClient ( $url . "?WSDL", $params );