php:Uncaught SoapFault异常:[Client]看起来我们在[PATH]中没有XML文档

时间:2018-04-02 00:40:01

标签: php web-services soap

所以我是Php网络服务的新手,我遇到了问题。因此,每当用户想要下订单时,它应该进入下一页并且信息存储在数据库表中。但是,我收到以下错误

Uncaught SoapFault exception: [Client] looks like we got no XML document in [PATH]

这是我的代码: -

<?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);

?>

这是我在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

我做错了什么:/请帮助。

1 个答案:

答案 0 :(得分:1)

如果您使用$request,则无需直接使用XML。

此外,端点将接受单个$response = $client->proceedNewRequestBook($request); 参数,而不是您传递的多个参数。

$request

$request = array( 'MealName' => $MealName, 'Quantity' => $Quantity, 'CustName' => $CustName, 'SpecialInstructions' => $SpecialInstructions, //... ); 应该是一个对象或数组,包含您希望以WSDL指定的任何格式传递给端点的所有参数。

$response

void IntervalMapEstimator::extract_relevant_points_multithread(std::vector<Point3D>& relevant_points, std::vector<Point3D>& pointcloud, doubleIE cell_min_angle_sensor_rot, doubleIE cell_max_angle_sensor_rot) { #pragma omp parallel for shared( pointcloud, cell_min_angle_sensor_rot, cell_max_angle_sensor_rot) for(int i = 0; i < pointcloud.size(); i++) { //int numThread = omp_get_thread_num(); //std::cout << "numThread = " << numThread << std::endl; // Check whether the cell is between the 2nd and 3rd quadrant (--> e.g. -170 to 170°) if ( cell_min_angle_sensor_rot < 0 && cell_max_angle_sensor_rot >= 0 && abs(cell_min_angle_sensor_rot) > M_PI/2 && abs(cell_max_angle_sensor_rot) > M_PI/2) { // Point must be smaller than the minimum angle and bigger than the max angle (e.g. min-angle: -1.5 max-angle: 1.5 point angle bigger than 1.5 or smaller than -1.5) if ( pointcloud[i].pol_sensor_rot.phi <= cell_min_angle_sensor_rot || pointcloud[i].pol_sensor_rot.phi >= cell_max_angle_sensor_rot ) { relevant_points.push_back(pointcloud[i]); } } else { if (pointcloud[i].pol_sensor_rot.phi >= cell_min_angle_sensor_rot && pointcloud[i].pol_sensor_rot.phi <= cell_max_angle_sensor_rot ) { relevant_points.push_back(pointcloud[i]); } } } } 将是一个PHP对象,您可以开始使用它。