So I am new to Php web services and I am having a problem. So whenever the user wants to make an order, it is supposed to proceed onto next page and info is stored in the database table. However, I am getting the following error
Uncaught SoapFault exception: [Client] looks like we got no XML document in [PATH]
Here is my code:-
<?php
include ("connect.php");
$MealName = trim($_POST['mname']);
$Quantity = trim($_POST['qty']);
$CustName = trim($_POST['cname']);
$SpecialInstructions = trim($_POST['spclinstr']);
$address = trim($_POST['address']);
$phone=trim($_POST['pno']);
// SOAP Request
$wsdl_url = "http://localhost:40/rest/KFC/service.wsdl";
$client = new SoapClient($wsdl_url);
// Execute the web service function defined in service.php on the web service server
$returnedData = $client->proceedNewRequestBook($MealName, $Quantity, $CustName, $SpecialInstructions, $address, $phone); // Pass INPUT PARAMETER
echo "<br/>Response from server:$returnedData";
$res = simplexml_load_string($returnedData)or die("Error: Cannot create object");
print_r($res);
?>
and here is my code for the particular function in server.php
include ("connection.php");
function proceedNewRequestBook($MealName, $Quantity, $CustName, $SpecialInstructions, $address, $phone)
{
$conn = new mysqli("localhost", "root", "", "KFC");
if ($conn->connect_error){
die("Connection failed: ".$conn->connect_error);
}
else
{
$todayDate = date("Y-m-d H:i:s");
$sqlQuery = "INSERT INTO `KFC`.`ordertbl` (OrderID, OrderDATE, CustNAME,CustAdd, PHONE ) VALUES (NULL, '$todayDate', '$CustName', '$address',$phone);";
if ($conn->query($sqlQuery) === TRUE)
{
$xmlResult = <<<XML
<?xml version='1.0' encoding="UTF-8"?>
<BOOK_INSERT>
<BOOK>
<MSG>INSERT SUCCESS</MSG>
<CODE>0</CODE>
</BOOK>
</BOOK_INSERT>
XML;
}
else
{
$qr="Errormessage:". mysqli_error($conn);
$q=$conn->error;
$xmlResult = <<<XML
<?xml version='1.0' encoding="UTF-8"?>
<BOOK_INSERT>
<BOOK>
<MSG>$qr</MSG>
<CODE>$q</CODE>
</BOOK>
</BOOK_INSERT>
XML;
}
mysqli_close($conn);
return $xmlResult;
}
}//func close
what am I doing wrong :/ please help.