Ciao a tutti!
Sto entrando nel mondo dei Webservice e ho iniziato a provare a tirar giù qualcosa seguendo varie guide su internet; mi sono però bloccato in quanto il codice non mi da errori ma sembra che il web server non venga proprio preso in considerazione.
Se qualcuno ha qualche idea su come risolvere sarebbe mooolto apprezzata.
Grazie mille!!
Server.php
Codice PHP:
<?php
function getStockQuote($nome) {
mysql_connect('localhost','root');
mysql_select_db('mio');
$query = "SELECT * FROM nomi WHERE nome = '$nome' ";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)){
}
}
require('nusoap.php');
$server = new nusoap_server();
$server->configureWSDL('stockquote', 'urn:stockquote');
$server->register("getStockQuote",
array('symbol' => 'xsd:string'),
array('return' => 'xsd:string'),
'urn:stockquote',
'urn:stockquote#getStockQuote');
if ( !isset( $HTTP_RAW_POST_DATA ) ) $HTTP_RAW_POST_DATA =file_get_contents( 'php://input' );
$server->service($HTTP_RAW_POST_DATA);
?>
client.php
Codice PHP:
<html>
<body>
<form method="get" action="client.php">
ID: <input name="symbol" type="text" value="">
<input type="submit">
</form>
<?php
$symbol = $_GET['symbol'];
if ($symbol) {
require_once('nusoap.php');
//we create an array with the element name that has the form value of name
//now we must create a soapclient object
$c = new nusoap_client('serv.wsdl',true);
//now we call the server.
$stockprice = $c->call('getStockQuote',
array('symbol' => $symbol));
echo "Information for $symbol is $stockprice.";
}
?>