I have a php file that tries to send xml data to a web servie through curl but it never goes passing the curl_exec() function.
Client Code
$url = 'http://localhost:63342/eShop/RestWs/cdService.php/';
$data = '<cds><cd><title>' . $_POST['title'] . '</title><artist>' . $_POST['artist'] .
'</artist><year>' . $_POST['year'] . '</year></cd></cds>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close'));
$start = array_sum(explode(' ', microtime()));
$result = curl_exec($ch);
$stop = array_sum(explode(' ', microtime()));
$totalTime = $stop - $start;
if(curl_errno($ch)){
echo 'Curl error: ' . curl_error($ch);
}
echo $result;
curl_close($ch);
Server Code
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo 'hi';
$input = file_get_contents('php://input');
$xml = simplexml_load_string($input);
echo($xml);
}
any ideas?