title: Handling carriage return in soap request
body: <p>I am writing code in PHP to send a soap request using curl. In the soap request I have to send data of a text file which have many Carriage Returns. I have tried sending "carriage return" using \n, \r, \r\n, chr(13) etc but all of these are giving the following error from server</p>
  
  <p><strong><em>Lines in the data sent should be delimited by single CR characters only. This file appears to be using LF as a delimiter.</em></strong></p>
  
  <p>Following is my Soap request. I am developing in linux and sending request to windows server.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
      $submitFileTxt    .= "Line1 Text"."\r";
      $submitFileTxt    .= "Line2 Text"."\r";
      $submitFIleTxt    .= "Test,Test,Test"."\r";
      $submitFIleTxt    .= "Testtext,Testtext,Testtext"."\r";
  
      $wsdl   = "somewsdlurl?wsdl"; 
      $local_cert = "certificate file path";
      $password   = '';
      $xml_post_string = "&lt;s:Envelope xmlns:a='http://www.w3.org/2005/08/addressing' xmlns:s='http://www.w3.org/2003/05/soap-envelope'&gt;
      &lt;s:Header&gt;
       &lt;a:Action s:mustUnderstand='1'&gt;Data submit method&lt;/a:Action&gt;
      &lt;/s:Header&gt;
      &lt;s:Body&gt;
       &lt;Submit&gt;
       &lt;data xmlns:i='http://www.w3.org/2001/XMLSchema-instance'&gt;
        &lt;OutputFileBody&gt;{$submitFIleTxt}&lt;/OutputFileBody&gt;
           &lt;OutputFilename&gt;Some file name&lt;/OutputFilename&gt;
        &lt;/data&gt;
       &lt;/Submit&gt;
       &lt;/s:Body&gt;
    &lt;/s:Envelope&gt;";   
  
     $headers = array(
          "Content-type: application/soap+xml;charset=\"utf-8\"",
          "Accept: text/xml",
          "Cache-Control: no-cache",
          "Pragma: no-cache",
          "Content-length: ".strlen($xml_post_string),
      );  
  
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL,          $wsdl);
      curl_setopt($ch, CURLOPT_SSLCERTTYPE,   "pem");
      curl_setopt($ch, CURLOPT_SSLCERT,      $local_cert);
      curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $password);
      curl_setopt($ch, CURLOPT_SSLKEY,       $local_cert);
  
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_TIMEOUT, 50);
      curl_setopt($ch, CURLOPT_SSLVERSION, 6);
  
      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  
      $response = curl_exec($ch); 
      $err = curl_error($ch); 
      curl_close($ch);</code></pre>
  </div>
  </div>
  </p>