I use this code
[WebMethod]
public string GetResponsePOSTData()
{
string valueReturn = string.Empty;
try
{
//Our postvars
string dataToPost = "username=username&password=password";
byte[] buffer = Encoding.ASCII.GetBytes(dataToPost);
//Initialization, we use localhost, change if applicable
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create("http://localhost:8081/testSubmit.php");
//Our method is post, otherwise the buffer (postvars) would be useless
WebReq.Method = "POST";
//We use form contentType, for the postvars.
//WebReq.ContentType = "application/x-www-form-urlencoded";
WebReq.ContentType = "text/xml";
//The length of the buffer (postvars) is used as contentlength.
WebReq.ContentLength = buffer.Length;
//We open a stream for writing the postvars
Stream PostData = WebReq.GetRequestStream();
//Now we write, and afterwards, we close. Closing is always important!
PostData.Write(buffer, 0, buffer.Length);
PostData.Close();
//Get the response handle, we have no true response yet!
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
//Now, we read the response (the string), and output it.
Stream Answer = WebResp.GetResponseStream();
StreamReader _Answer = new StreamReader(Answer);
valueReturn = _Answer.ReadToEnd().ToString();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
return valueReturn;
}
but it returns :
This XML file does not appear to have any style information associated with it. The document tree is shown below.
it must add arguments [WebMethod] or make a configuration in the Web.Config file ???