0

I have used curl to send XML to a web service as below,when my XML is short there is no problem, but when I want to send a large XML I get Recv failure: Connection reset by peer or http://www.w3.org/2005/08/addressing/soap/faultsoapenv:Receivercom.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog at [row,col {unknown-source}]: [1,0] error. I removed Content-Length from header but nothing changed. I also added .htaccess file with php_value post_max_size 1024M code. how can I solve this problem?

$url     = "http:/xxxx?wsdl";
$header  = "POST http://xxxxx/ HTTP/1.1\r\n";
$header .= "Content-Type: text/xml;charset=UTF-8 \r\n";
$header .= "SOAPAction: '' \r\n";
$header .= "servicekey:".$servicekey."\r\n";
$header .= "Content-Length: 2171 \r\n"; 
$header .= "Host: x.x.x.x:xx \r\n";
$header .= "Connection: Keep-Alive\r\n";
$header .= "User-Agent: Apache-HttpClient/4.1.1 (java 1.5)\r\n\r\n";
$header .= $post_string;

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
curl_setopt($ch, CURLOPT_VERBOSE, true);

$data = curl_exec($ch);

if(curl_errno($ch))
  {
    $error = array();
    array_push($error, curl_error($ch));
    return $error;
  }

 else
      {
        $result = array();
        array_push($result, $data);
        return $result;
      }
Hedi
  • 322
  • 4
  • 17
  • Related: http://stackoverflow.com/questions/1434451/what-does-connection-reset-by-peer-mean – Sumurai8 Jul 03 '16 at 14:05
  • Or in other words: The other end of the connection forces the connection to be closed, or simply crashes, when you send it a lot of data. Check the logs on the remote host to see what exactly is happening. – Sumurai8 Jul 03 '16 at 14:12

0 Answers0