简体   繁体   English

卷曲响应未获取结果数据

[英]Curl response not getting result data

I am trying to send WSDL through curl. 我正在尝试通过curl发送WSDL。 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);
        }

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 卷曲线存在问题,编辑卷曲代码后,我的WSDL工作正常

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);
        }    

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

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