简体   繁体   English

Curl的HTTPS请求失败:0但在Curl PHP中没有响应

[英]HTTPS request with Curl Failed: 0 but no response in Curl PHP

I'm trying to make a soap request with HTTPS link. 我正在尝试使用HTTPS链接发送soap请求。 I get Curl Failed: 0 (that means no error) However, I received a empty string. 我得到卷曲失败:0(这意味着没有错误)但是,我收到一个空字符串。

$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(); 你的curl_exec();在哪里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 使用CURL将XML发布请求发送到Web服务器

EDIT: PHP also has a SOAP Client build in, maybe you could give it a try: 编辑:PHP也有一个SOAP客户端内置,也许你可以尝试:

    $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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM