我创建了这段代码来使用 nusoap 将数据插入到我的数据库中。一切正常,但数据没有插入我的数据库。
这是代码
require_once('nusoap/nusoap.php');
$server = new soap_server();
$server->configureWSDL('Insert Order', 'urn:InsertOrder');
$server->soap_defencoding = 'utf-8';
$server->register(
'InsertOrder',
array('FirstName' => 'xsd:Testing', 'LastName' => 'xsd:NuSoap'),
array('return' =>'xsd:boolean'),
'urn:InsertOrderwsdl',
'urn:InsertOrderwsdl#InsertOrder',
'rpc',
'literal'
);
function InsertOrder($FirstName, $LastName) {
$connect = mysql_pconnect("localhost","root","");
if ($connect) {
if(mysql_select_db("database", $connect)) {
mysql_query("INSERT INTO myuser SET FirstName='$FirstName', LastName='$LastName'");
return true;
}
}
return false;
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
这是wsdl文件:
<definitions targetNamespace="urn:InsertOrder">
<types>
<xsd:schema targetNamespace="urn:InsertOrder">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
</xsd:schema></types>
<message name="InsertOrderRequest">
<part name="FirstName" type="xsd:Testing"/>
<part name="LastName" type="xsd:NuSoap"/>
</message>
<message name="InsertOrderResponse">
<part name="return" type="xsd:boolean"/>
</message><portType name="Insert OrderPortType">
<operation name="InsertOrder">
<input message="tns:InsertOrderRequest"/>
<output message="tns:InsertOrderResponse"/>
</operation>
</portType>
<binding name="Insert OrderBinding" type="tns:Insert OrderPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="InsertOrder">
<soap:operation soapAction="urn:InsertOrderwsdl#InsertOrder" style="rpc"/>
<input>
<soap:body use="literal" namespace="urn:InsertOrderwsdl"/>
</input>
<output>
<soap:body use="literal" namespace="urn:InsertOrderwsdl"/>
</output>
</operation></binding>
<service name="Insert Order">
<port name="Insert OrderPort" binding="tns:Insert OrderBinding">
<soap:address location="http://localhost/nuSoap/MyService.php"/>
</port>
</service>
</definitions>
在 wsdl 文件中,参数和输出都可以。我不明白为什么不将这些数据放入我的数据库中?我必须在这里错过一些东西。任何人都知道为什么会这样?先感谢您。