title: Send an XML post request to a web server with CURL
body: <p>I am trying to send a request to a web server using php and curl.
  I haven't done something like this before and although there are many nice examples online I have some difficulties understanding some of the curl commands.</p>
  
  <p>This is what I want to do: There is an established web service (for example: Web map service) and I want my php code to send a post XML request to this service. As a respond I want to get an XML file.</p>
  
  <p>This is what I have till now:</p>
  
  <pre><code>    $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, ''); 
      /*curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));*/
      /* curl_setopt($ch, CURLOPT_HEADER, 0);*/
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
      /*curl_setopt($ch, CURLOPT_REFERER, '');*/
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      $ch_result = curl_exec($ch);
      curl_close($ch);
      echo $ch_result;
  </code></pre>
  
  <p>As I said I am quite new in php and also in using curl and I think I am missing some concepts.
  My questions are:
  1) What is the string (link) that I have to put in the:</p>
  
  <pre><code>          curl_setopt($ch, CURLOPT_URL, ''); 
  </code></pre>
  
  <p>Is it the host name of the service which I want to send the request?</p>
  
  <p>2) In row 6 the variable $xml contains the xml file that I want to send as a request. Is it correct or this variable is supposed to contain something else? </p>
  
  <p>3) In which cases do I need to use a httpheader or header (row3 and row4);</p>
  
  <p>Thanks for the help.
  Dimitris</p>