Reputation: 467
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.
Upvotes: 1
Views: 4944
Reputation: 115
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.
Upvotes: 4
Reputation: 467
My code was fine, I just had to add the WSDL ip address to /etc/hosts.
Upvotes: 4