I found that this code works as expected:
var url = "https://limal.info/efulfilment.php";
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
var alternativeAnswer = Encoding.UTF8.GetString(new WebClient().UploadValues(url, new NameValueCollection() { { "xml", "test" } }));
The following code however gives me a headache:
var url = "https://limal.info/efulfilment.php";
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
var request = (HttpWebRequest)WebRequest.Create(url);
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
request.Timeout = 5000; // I added this for you, so you only need to wait 5 sec...
using (var requestStream = request.GetRequestStream())
{
var writer = new StreamWriter(requestStream);
writer.Write("xml=test");
}
using (var response = request.GetResponse())
{
using (var responseStream = response.GetResponseStream())
{
var reader = new StreamReader(responseStream);
var answer = reader.ReadToEnd();
}
}
Somehow the post parameters don't get recognized and I get the response:
"limal.info bridge error: Missing 'xml' variable in post request."
(The correct answer would be that the XML data is wrongly formatted, as test is invalid XML...)
Now to the next Problem:
When I use a different url a timeout exception occurs. It hangs at UploadValues in the following code. (The other example that uses HttpWebRequest hangs at GetResponse, which I tried, too.)
var url = "https://sys.efulfilment.de/rt/";
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
var alternativeAnswer = Encoding.UTF8.GetString(new WebClient().UploadValues(url, new NameValueCollection() { { "xml", "test" } }));
I read about similar problems here and on other sites. It seems that using Http POST with SSL is a problem in .NET.
WHY?? :(