How to send data to a SOAP Web Service using Laravel & PHP
<p>I trying to send an XML vacancies to a Web Service using Laravel and I'm struggling to figure out how to connect to the web service, authorise and send the required data. </p>

<p>I have tried to use curl, but I am getting </p>

<blockquote>
  <p>Error: "" - Code: 0</p>
</blockquote>

<p>Below is my Code</p>

<pre><code>$result // IS MY XML file

$username = 'username'
$password = 'password'
$URL = 'http://xxxxxx.com;

//setting the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,"xmlRequest=" . $result);
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_exec($ch);

if(!curl_exec($ch)){
    die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
}

curl_close($ch);

}
</code></pre>

<p>Another question that would be of help would be - Is there another way of sending data to a SOAP Web Service without having to use Curl?</p>

<p>Thank you in advance</p>