繁体   English   中英

curl成功返回但显示500错误,内部服务器错误

[英]Curl returns successfully but shows 500 error, Internal server Error

我正在使用 curl 访问 Web 服务,但有时我会收到响应,但有时它会因内部服务器错误而失败,即使我实际上收到了预期的 xml 文件。 问题可能是什么?

$header = array(
                  "Content-type: text/xml;charset=\"utf-8\"",
                  "Accept: text/xml",
                  "Cache-Control: no-cache",
                  "Pragma: no-cache",
                  "Content-length: ".strlen($send),
                );

            $URL = 'https:ip:port/xxxxx';

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
            curl_setopt($ch, CURLOPT_TIMEOUT, 120);
            curl_setopt($ch, CURLOPT_URL, $URL );
            curl_setopt($ch, CURLOPT_POST, true );
            curl_setopt($ch, CURLOPT_HTTPHEADER, $header); //array('Content-Type: text/xml'));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
            curl_setopt($ch, CURLOPT_POSTFIELDS, $send );
            //curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
try {
                $result = curl_exec($ch);        
                curl_close($ch);
                $f = fopen("./Response.xml", "w");
                fwrite($f, $result);
                fclose($f);           
            } 
            catch (Exception $e) {
                $payments = "<DIV class = 'alert alert-danger'>Failed Transaction. Please try again</DIV>";
                     $error = Date("Y-m-d h:i:s")."\nError Number:".curl_errno($soap_do)."\n";
                     $error .=  "Error String:".curl_error($ch)."\n Matrucule: ".$matricule."\n------------------------\n";
                     $f = fopen("./Payment_Error_Log.txt", "w");
                     fwrite($f, $error);
                     fclose($f);
            }

您的服务器端代码有问题.. https:ip:port/xxxxx 在向其发布时返回错误 500。

可能是 Web 服务或您发布的特定参数 ( $send ) 的问题。

暂无
暂无

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

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