smart84
08-10-2018, 23:23
Ciao a tutti,
devo realizzare un programma che chiami un web service con parametri.
Il WS non restituisce nulla in output.
Ho scritto questa parte di codice (inserita dentro il main) ma hcredo sia incompleta.
Potete aiutarmi? Grazie
var httpWebRequest = (HttpWebRequest)WebRequest.Create("url");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.Credentials = new NetworkCredential("user", "pwd", "domain");
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{p1:\'Hello\'";
string tmpjs = ",p2:\'world\'}"; json = json + tmpjs;
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
HttpWebResponse httpResponse = (HttpWebResponse) httpWebRequest.GetResponse();
devo realizzare un programma che chiami un web service con parametri.
Il WS non restituisce nulla in output.
Ho scritto questa parte di codice (inserita dentro il main) ma hcredo sia incompleta.
Potete aiutarmi? Grazie
var httpWebRequest = (HttpWebRequest)WebRequest.Create("url");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.Credentials = new NetworkCredential("user", "pwd", "domain");
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{p1:\'Hello\'";
string tmpjs = ",p2:\'world\'}"; json = json + tmpjs;
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
HttpWebResponse httpResponse = (HttpWebResponse) httpWebRequest.GetResponse();