我正在尝试使用PHP 7.0从带有SOAP的远程服务器中获取一些数据,但是出现以下错误:
SoapFault对象[消息:受保护] => SOAP错误:解析WSDL:无法从“ https://url.com”加载。
在浏览器上以及禁用https时,它都可以正常工作。
我已经尝试通过以下方式禁用SSL验证:
'ssl' => [
// set some SSL/TLS specific options
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
并通过以下方式传递我的证书和密钥:
'ssl' => [
'local_cert' => $sslClientCert,
'local_pk' => $sslClientKey'
]
它们都不起作用。我还验证了使用phpinfo()
在服务器上启用了openssl。我该如何解决这个问题?
<?php
$url = "https://theurl.com";
$client = new SoapClient($url, [
'stream_context' => stream_context_create([
'ssl' => [
"verify_peer"=>false,
"verify_peer_name"=>false,
]
]),
'trace' => 1,
'exceptions' => true
]);
$params = ['groups' => [
[
"courseid" => 3,
"name" => "Group test",
"description" => "Group test",
"descriptionformat" => 1,
"enrolmentkey" => "",
"idnumber" => ""
]
]];
$response = $client->__soapCall('core_group_create_groups',$params);