title: PHP & XML - How to generate a soap request error 415
body: <p>Why am I getting error 415, if anyone can help me
  I do not understand why the error occurs
  link to error
  <a href="http://agency.lastminute-hr.com/stranice/upisi_destinacije_unico.php" rel="nofollow">http://agency.lastminute-hr.com/stranice/upisi_destinacije_unico.php</a></p>
  
  <p>This is how the xml</p>
  
  <pre><code>POST /services/WebService.asmx HTTP/1.1
  Host: wl.filos.com.gr
  Content-Type: application/soap+xml; charset=utf-8
  Content-Length: length
  
      &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"&gt;
        &lt;soap12:Body&gt;
          &lt;PlaceSearch xmlns="http://www.cyberlogic.gr/webservices/"&gt;
            &lt;xml&gt;string&lt;/xml&gt;
          &lt;/PlaceSearch&gt;
        &lt;/soap12:Body&gt;
      &lt;/soap12:Envelope&gt;
  </code></pre>
  
  <p>my code is:</p>
  
  <pre><code>$soapUrl = "http://wl.filos.com.gr/services/WebService.asmx?op=PlaceSearch";
  
  
  
  $soap_request  = "&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n";
    $soap_request .= "&lt;soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"&gt;\n";
    $soap_request .= " &lt;soap:Body&gt;\n";
    $soap_request .= "  &lt;PlaceSearch xmlns=\"http://www.cyberlogic.gr/webservices/\"&gt;\n";
    $soap_request .= "  &lt;xml&gt;&lt;PlaceSearchRequest&gt;&lt;Username&gt;******&lt;/Username&gt;&lt;Password&gt;******&lt;/Password&gt;&lt;PlaceType&gt;Cities&lt;/PlaceType&gt;&lt;Language&gt;en&lt;/Language&gt;&lt;/PlaceSearchRequest&gt;&lt;/xml&gt;\n";
    $soap_request .= "   &lt;/PlaceSearch&gt;\n";
    $soap_request .= "  &lt;/soap:Body&gt;\n";
    $soap_request .= "&lt;/soap:Envelope&gt;";
   $xml_post_string  =  $soap_request;
  
  
  
  $headers = array(
  "POST /services/WebService.asmx HTTP/1.1",
  "Host: wl.filos.com.gr",
  "Content-Type: application/soap+xml; charset=utf-8",
  "Content-Length: ".strlen($xml_post_string)
  ); 
  
  
  
  
  $url = $soapUrl;
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS,  ($xml_post_string) );
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  
  $response = curl_exec($ch); 
  
  $info = curl_getinfo($ch);
  
       // echo results
          echo "The server responded: &lt;br /&gt;";
          echo   " " .  $info['http_code'].  "  &lt;br /&gt;";
  
  curl_close($ch);        
  $response1 = str_replace("&lt;soap12:Body&gt;","",$response);
  $response2 = str_replace("&lt;/soap12:Body&gt;","",$response1);
  
  $parser = simplexml_load_string($response2);
  </code></pre>