doufu9145 2015-04-27 14:49 采纳率: 0%
浏览 2071

求助:Curl返回成功,但显示500错误,内部服务器错误

我使用 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")."
Error Number:".curl_errno($soap_do)."
";
                     $error .=  "Error String:".curl_error($ch)."
 Matrucule: ".$matricule."
------------------------
";
                     $f = fopen("./Payment_Error_Log.txt", "w");
                     fwrite($f, $error);
                     fclose($f);
            }
  • 写回答

1条回答 默认 最新

  • duanjing9339 2015-04-27 14:52
    关注

    You have a problem with the server side code.. https:ip:port/xxxxx is returning error 500 when POSTing to it.

    Could be a problem with the web service or with the specific parameters you're POSTing ($send).

    评论

报告相同问题?

悬赏问题

  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?