dre75230 2015-05-02 06:11
浏览 59
已采纳

卷曲响应没有得到结果数据

I am trying to send WSDL through curl. But I am getting the below response:

HTTP/1.0 200 Connection established

HTTP/1.1 100 Continue

HTTP/1.1 500 Internal Server Error
Date: Sat, 02 May 2015 05:58:05 GMT
Server: IBM_HTTP_Server
X-Powered-By: Servlet/3.0
$WSEP: 
Content-Length: 85
Content-Type: text/html;charset=ISO-8859-1
Connection: close
Content-Language: en-US

Error 500: java.lang.StringIndexOutOfBoundsException: String index out of range: -1

My code is below:

    $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_PROXY, $proxy);
        curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50);
        curl_setopt($ch, CURLOPT_TIMEOUT, 900);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HEADER, array("Content-type: text/xml;charset=\"utf-8\""));
//        curl_setopt($ch, CURLOPT_HEADER, array("Content-Type: text/xml; charset=utf-8"));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        $curl_scraped_page = curl_exec($ch);


        if ($curl_scraped_page === false) {
            return 'Curl error: ' . curl_error($ch);
            curl_close($ch);
        } else {

            return $curl_scraped_page;
            curl_close($ch);
        }
  • 写回答

1条回答 默认 最新

  • doucanshou6998 2015-05-05 11:26
    关注

    after doing some R&D i have troubleshoot the problem. there is problem in curl lines,after edit the curl code my WSDL working fine

    below is working code

    $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_PROXY, $proxy);
            curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyauth);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl, CURLOPT_TIMEOUT, 120);
            curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
    
            curl_setopt($curl, CURLOPT_HTTPHEADER, array(
                'SOAPAction:""',
                'Content-Type: text/xml; charset=utf-8',
            ));
    
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    
            $result = curl_exec($curl);
            if ($result === false) {
                return 'Curl error: ' . curl_error($curl);
                curl_close($curl);
            } else {
                //convert xml into array
                $xmlDoc = new MyDOMDocument();
                $xmlDoc->loadXML($result);
                return $xmlArray = $xmlDoc->toArray();
    
                curl_close($curl);
            }    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题