2
社区,我正在做一个PHP的Web服务,我需要什么在MySQL中带来数据库的信息。网络服务不能与mysql一起工作
什么我不明白,如果我通过一个文件中的所有代码(例如到client.php)这工作正常,但这里分开两个文件不起作用,在server.php不进入while函数,我创建一个包含mysql查询带来的所有信息的数组。
有人可以帮助我吗?
server.php
<?php
//call library
//require_once ('config.php');
require_once ('lib/nusoap.php');
$servidor = '?';
$user = '?';
$pass = '?';
$base = '?';
//using soap_server to create server object
$server = new soap_server;
//register a function that works on server
$server->register('get_message');
// create the function
function get_message($your_name)
{
if(!$your_name){
return new soap_fault('Client','','Put Your Name!');
}
$conexion = mysql_connect($servidor, $user,$pass);
mysql_select_db($base, $conexion);
$consulta = "SELECT * FROM ensayos_santa_laura where ENS_FECHA_MUESTREO > '2015-01-01' ";
$datos = mysql_query($consulta, $conexion);
$numDatos = @mysql_num_rows($datos);
$registro = array();
$contador = 1;
while($fetchrow = mysql_fetch_row($datos)){
$registro[$contador]['WS_NUMERO_MUESTRA'] = $fetchrow['2'];
$registro[$contador]['WS_FECHA_MUESTREO'] = $fetchrow['3'];
$registro[$contador]['WS_NUMERO_CERTIFICADO'] = $fetchrow['4'];
$registro[$contador]['WS_FECHA_ENSAYO'] = $fetchrow['5'];
$registro[$contador]['WS_NUMERO_GUIA'] = $fetchrow['6'];
$registro[$contador]['WS_EDAD'] = $fetchrow['7'];
$registro[$contador]['WS_DENSIDAD'] = $fetchrow['8'];
$registro[$contador]['WS_RESISTENCIA'] = $fetchrow['9'];
$registro[$contador]['WS_RT'] = $fetchrow['10'];
$registro[$contador]['WS_TIPO_HORMIGON'] = $fetchrow['11'];
$registro[$contador]['WS_NUMERO_CONTROL'] = $fetchrow['12'];
$registro[$contador]['WS_ASENTAMIENTO'] = $fetchrow['13'];
$registro[$contador]['WS_LINK'] = $fetchrow['14'];
$registro[$contador]['WS_ESTADO'] = $fetchrow['15'];
$registro[$contador]['WS_TIPO_PROBETA'] = $fetchrow['16'];
$registro[$contador]['WS_CODIGO_OBRA'] = $fetchrow['17'];
$registro[$contador]['WS_UBICACION_HORMIGON'] = $fetchrow['18'];
$contador++;
}
$cantidad = count($registro);
if($registro){
return $registro;
}else{
return 0;
}
}
// create HTTP listener
$server->service(file_get_contents("php://input"));
//$server->service($HTTP_RAW_POST_DATA);
exit();
?>
client.php
<?php
require_once ('config.php');
require_once ('lib/nusoap.php');
//Give it value at parameter
$param = array('your_name' => 'Monotosh Roy');
//Create object that referer a web services
$client = new nusoap_client('http://172.17.56.61/ws_santalaura/server.php');
//Call a function at server and send parameters too
$response = $client->call('get_message',$param);
//Process result
if($client->fault)
{
echo "FAULT: <p>Code: (".$client->faultcode."</p>";
echo "String: ".$client->faultstring;
}
else
{
$xml = new DOMDocument();
$dateInfoElement = $xml->createElement("dateInformation");
foreach ($response as $key => $value) {
$xmlNode = $xml->createElement($key,$value);
$dateInfoElement->appendChild($xmlNode);
}
$xml->appendChild($dateInfoElement);
$header = "Content-Type:text/xml";
header($header);
print $xml->saveXML();
//echo var_dump($response);
}
?>
对不起,我的解释不好。问题是我们有两个文件,client.php和server.php。在“client.php”是我们收到所有信息的地方,而“server.php”是存在查询和while的地方。如果我们把查询放在“client.php”中,但是如果我们有分隔的信息,这是行不通的。D: –
不,那不是。 – Shadow
你是什么意思? –