PHP web服务小论坛查询
我不熟悉web服务,我有一个问题还没有解决 这就是我的wsdlPHP web服务小论坛查询,php,mysql,sql,web,wsdl,Php,Mysql,Sql,Web,Wsdl,我不熟悉web服务,我有一个问题还没有解决 这就是我的wsdl <?xml version ='1.0' encoding ='UTF-8' ?> <definitions name="Biodata" targetNamespace="urn:TestNamespace" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://sch
<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name="Biodata"
targetNamespace="urn:TestNamespace"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="TestNamespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>
<message name='insertReplyRequest'>
<part name='reply' element="Biodata"/>
</message>
<portType name='BiodataPortType'>
<operation name='insertReply'>
<input message='tns:insertReplyRequest'>
</operation>
</portType>
<binding name='BiodataBinding' type='tns:BiodataPortType'>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='insertReply'>
<soap:operation soapAction='insertReply'/>
<input>
<soap:body use='encoded' namespace='urn:examples:biodata'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
</operation>
</binding>
<service name='BiodataService'>
<port name='BiodataPort' binding='tns:BiodataBinding'>
<soap:address location='http://localhost/Kevin/FirstWebService/Asynchronous/server.php'/>
</port>
</service>
</definitions>
这是reply.php文件
<?php
$reply = $_POST["reply"];
$post_id = $_POST["post_id"];
$client = new SoapClient("http://localhost/Kevin/FirstWebService/Asynchronous/biodata.wsdl");
$return = $client->insertReply($reply, $post_id);
header("Location: http://localhost/Kevin/FirstWebService/Asynchronous/reply.html");
die();
?>
reply.html是:
<!DOCTYPE html>
<html>
<head>
<title>Reply</title>
</head>
<form action="reply.php" method=POST>
REPLY:<br>
<input type="text" name="reply">
<br>
POST ID<br>
<input type="text" name="post_id">
<br>
<input type="submit" value="Submit">
</form>
</html>
功能如下:
<?php
function insertReply($reply, $post_id){
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "structure2";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO reply (reply, post_id) VALUES ('$reply', '$post_id')";
$result = $conn->query($sql);
} ?>
和服务器:
<?php
require 'biodata_functions.php';
//require 'SoapFault.php';
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("http://localhost/Kevin/FirstWebService/Asynchronous/biodata.wsdl");
/*$server->addFunction("getName");
*/
$server->addFunction("insertPost");
$server->addFunction("insertReply");
$server->handle();
?>
我的问题是,我不能在插入$reply的同时插入$post_id,而且每次插入时,它在sql表中都是空的
我甚至尝试将函数代码中的$sql更改为:
$sql=插入到reply中,post_id值“$reply”,“8”;它在数据库中成功地输入了8个。
我的问题有问题吗?还是我的逻辑有问题?任何帮助都将不胜感激,谢谢如果$\u POST['POST\u id']{检查POST\u id值是否存在,尝试打印您的查询并检查传递给查询的值是什么,它会打印出我在POST id框HTML文件$retval=mysql\u query$sql,$conn;如果!$retval{die'无法输入数据:'.mysql\u error;}echo已成功输入数据\n;mysql\u close$conn;}