Ciao a tutti
Esiste un webservice gia pronto(free) da scaricare ed eventualmente modificare scritto in php?
Grazie.
Ciao a tutti
Esiste un webservice gia pronto(free) da scaricare ed eventualmente modificare scritto in php?
Grazie.
Ciao,
webservice per fare cosa? Con quale protocollo?
E' un po' come se chiedessi "Esiste un'applicazione php/database già pronta da scaricare ed eventualmente modificare"![]()
per favore NIENTE PVT TECNICI da sconosciuti
hai ragione fabio heller scusa.
Devo trasferire delle query sql(stringhe) ad un webservice che esegue queste stringhe e mi ritorna true se tutto è andato a buon fine.Il metodo post.
In questo caso farei da solo, o al massimo utilizzerei XML-RPC (vedi ultimi articoli su freephp). SOAP è troppo complesso.
Il client inserisce la stringa SQL in un RAW POST HTTP. (Eventuale autenticazione)
Il server fa l'eventuale autenticazione, e restituisce la risposta facendo un print(0) o print(1)
Il client legge la risposta
Non c'è bisogno di XML o cose complicate per questo tipo di servizio, a meno che tu non voglia appaoggiarti a qualche protocollo standard per qualche ragione.
Trovi maggiori informazioni qui
http://freephp.html.it/articoli/view...sp?id=76&pag=7
anche sul raw post
e qui
http://freephp.html.it/articoli/view...sp?id=79&pag=6
Su XML-RPC qui
http://freephp.html.it/articoli/view...olo.asp?id=156
per favore NIENTE PVT TECNICI da sconosciuti
scusa fabio heller ma ho un altro problema:
ho letto e provato gli esempi da te indicati ,in php funzionano, ma il problema è che io devo trasferire i dati da un applicazione c#.
Ho tradotto quello che si fa in php usando le socket ma da c# non ne vuole sapere,mi vede tutto tranne le variabili php.
Devo perforza usare soap?se si mi dai qualche link?
Grazie mille ciao.
ti posto il codice php
server:
<?php
/***
SCRIPT xml_post.php
invia la request xml
***/
$host="localhost" ;
/***
Sostituisci con il tuo path assoluto
***/
$target="/phpinfo.php" ;
$port=80 ;
$timeout=60;
$protocol="HTTP/1.0" ;
$br="\r\n" ;
$xml_body=rawurlencode("user='giugio'");
$sk=fsockopen($host,$port,$errnum,$errstr,$timeout ) ;
if(!is_resource($sk)){
exit("Connessione fallita: ".$errnum." ".$errstr) ;
}
else{
$post_vars=array('user'=>'Alì Baba e i 40 ladroni','pass'=>'apriti sesamo') ;
$req_body="" ;
foreach($post_vars as $key=>$val){
$req_body.="&".$key."=".rawurlencode(htmlentities( $val)) ;
}
echo($req_body);
$headers="POST ".$target." ".$protocol.$br ;
/*.... tutti gli headers utilizzabili per GET più i seguenti, necessari per POST....*/
$headers.="Content-Type: application/x-www-form-urlencoded".$br ;
$headers.="Content-Length: ".strlen($req_body).$br.$br ;
/*
Inviamo la request aggiungendovi il "body"
*/
fputs($sk,$headers.$req_body) ;
$dati="" ;
while (!feof($sk)) {
$dati.= fgets ($sk, 2048);
}
}
fclose($sk) ;
//echo($dati) ;
?>
form:
<form action="http://localhost/info.php" method="post" enctype="application/x-www-form-urlencoded">
<input type="text" name="user" value="<?php echo($HTTP_POST_VARS["user"]); ?>" >
<input type="password" name="pass" value="apriti sesamo">
<input type="submit" name="send" value="Invia">
</form>
fin qui funziona ma da c# no.
Un POST fatto da PHP è uguale a uno fatto da un form, va letto da C# come faresti leggendo un post normale.Originariamente inviato da giuseppe500
scusa fabio heller ma ho un altro problema:
ho letto e provato gli esempi da te indicati ,in php funzionano, ma il problema è che io devo trasferire i dati da un applicazione c#.
Ho tradotto quello che si fa in php usando le socket ma da c# non ne vuole sapere,mi vede tutto tranne le variabili php.
Devo perforza usare soap?se si mi dai qualche link?
Grazie mille ciao.
Il servizio a cui invii i dati è già pronto o lo hai creato tu?
Perchè se è già pronto si aspetterà di ricevere i dati in un dato formato, se si aspetta il formato SOAP devi usare SOAP anche in php (in php4 è un po' un terno al lotto), se usa XML-RPC devi usare XML-RPC, se si aspetta un post normale devi usare l'oggetto Request di .NET, se si aspetta un raw post....non saprei
per favore NIENTE PVT TECNICI da sconosciuti
grazie per l'interessamento.
Il sevizio te l'ho postato e l'ho chiamato server.
ti posto il codice c#:
//scelgo l'host
IPHostEntry IPHost = Dns.Resolve("localhost");
Console.WriteLine(IPHost.HostName);
string []aliases = IPHost.Aliases;
IPAddress[] addr = IPHost.AddressList;
Console.WriteLine(addr[0]);
EndPoint ep = new IPEndPoint(addr[0],80);
Socket sock = new Socket(AddressFamily.InterNetwork,SocketType.Strea m,ProtocolType.Tcp);
sock.Connect(ep);
if(sock.Connected)
Console.WriteLine("OK");
Encoding ASCII = Encoding.ASCII;
string Get=@"&user=gg";
string protocol="HTTP/1.0" ;
string br="\r\n" ;
string target="/phpinfo.php" ;
string host="localhost";
string headers="POST "+target+" "+protocol+" "+br ;
headers+=" Host: "+host+br ;
headers+=" Content-Type: text/xml"+br ;
headers+=" Content-Length: "+Get.Length+" "+br+br ;
Byte[] ByteGet = ASCII.GetBytes(headers+Get);
Byte[] RecvBytes = new Byte[1256];
sock.Send(ByteGet, ByteGet.Length, 0);
Int32 bytes = sock.Receive(RecvBytes,0, RecvBytes.Length, 0);
string strRetPage="";
strRetPage = ASCII.GetString(RecvBytes, 0,RecvBytes.Length);
Console.WriteLine(strRetPage );
strRetPage = null;
strRetPage = strRetPage + ASCII.GetString(RecvBytes, 0, bytes);
while (bytes > 0)
{
bytes = sock.Receive(RecvBytes,0, RecvBytes.Length,SocketFlags.Peek);
strRetPage = strRetPage + ASCII.GetString(RecvBytes, 0, bytes);
Console.WriteLine(strRetPage );
}
sock.Shutdown(SocketShutdown.Both);
sock.Close();
}
la stringa strRetPage è:
<form action="http://localhost/info.php" method="post" enctype="application/x-www-form-urlencoded">
<input type="text" name="user" value="" >
<input type="password" name="pass" value="apriti sesamo">
<input type="submit" name="send" value="Invia">
</form>
lo stesso da php è:
<form action="http://localhost/info.php" method="post" enctype="application/x-www-form-urlencoded">
<input type="text" name="user" value="Alì Baba e i 40 ladroni" >
<input type="password" name="pass" value="apriti sesamo">
<input type="submit" name="send" value="Invia">
</form>
forse non mi sono chiarito: il client è un applicazione windows c# e deve interagire con php.
scusa se ti ho fatto perdere tempo.
A occhio hai due client e non un client/server![]()
Comunque se è un problema di C# ti consiglio di postare nel forum .NET
per favore NIENTE PVT TECNICI da sconosciuti