I'm trying to make a soap request with HTTPS link. I get Curl Failed: 0 (that means no error) However, I received a empty string.
$url = $soapUrl;
$soap_do = curl_init();
set_time_limit(0);
curl_setopt($soap_do, CURLOPT_URL, $url);
curl_setopt($soap_do, CURLOPT_AUTOREFERER, true);
curl_setopt($soap_do, CURLOPT_MAXREDIRS, 10);
curl_setopt($soap_do, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($soap_do, CURLOPT_VERBOSE, TRUE);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($soap_do);
$error = curl_error($soap_do);
var_dump($response);
echo "Curl Failed: " . curl_errno($soap_do), "<br/>";
echo curl_error($soap_do);
Any problem with my code?
Where is your curl_exec();
?
You are setting a ton of options, but I think the most ones are just for finetuning. You could try it with this example I gave in another answer:
Send an XML post request to a web server with CURL
EDIT: PHP also has a SOAP Client build in, maybe you could give it a try:
$context = stream_context_create([
'http' => [
'user_agent' => 'PHPSoapClient'
],
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]);
$soap = new SoapClient($url, [
'stream_context' => $context,
'cache_wsdl' => WSDL_CACHE_NONE, // WSDL_CACHE_MEMORY
'trace' => 1,
'exception' => 1,
'keep_alive' => false,
'connection_timeout' => 500000
]);
// Then call the SOAP method
echo $soap->version();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.