how to make IXMLHTTPRequest work over HTTPS, client being WinCE
Posted
by siddharth
on Stack Overflow
See other posts from Stack Overflow
or by siddharth
Published on 2010-04-15T09:48:10Z
Indexed on
2010/04/15
9:53 UTC
Read the original article
Hit count: 342
hi,
i am creating a client, which uploads to and dowloads from WinCE client. the code works properly for HTTP but not for HTTPS. Can any one help me about the changes that needs to be done.
Code of client on PC :
private void btnUpload_Click(object sender, EventArgs e)
{
try
{
MSXML2.DOMDocument xmlDOM = new DOMDocumentClass();
xmlDOM.load(txtUpload.Text);
MSXML2.IXMLHTTPRequest x = new XMLHTTPClass();
x.open("POST", "http://192.168.1.12/server.asp?cmd=1", false, "", "");
x.send(xmlDOM);
string result = x.responseText;
if (x.status == 200)
{
MessageBox.Show(result);
MessageBox.Show("upload file successfully");
}
else
{
MessageBox.Show("upload file unsuccessful");
MessageBox.Show(x.status.ToString() + "\n" + x.statusText);
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message + "\n" + ex.Data);
}
}
private void btnDownload_Click(object sender, EventArgs e)
{
try
{
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create("http://192.168.1.12/server.asp?cmd=2");
WebReq.Method = "GET";
HttpWebResponse WebResp = null;
WebResp = (HttpWebResponse)WebReq.GetResponse();
Stream myResponseStream = WebResp.GetResponseStream();
StreamReader myStreamReader = new StreamReader(myResponseStream);
string s = myStreamReader.ReadToEnd();
MessageBox.Show(s);
StreamWriter SW;
SW = File.CreateText(txtDownload.Text);
SW.WriteLine(s);
SW.Close();
MessageBox.Show(@"save file at" + txtDownload.Text);
myStreamReader.Close();
myResponseStream.Close();
WebResp.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\n" + ex.Data);
}
The client asp page that acts according to the command is :
On Error Resume Next
Response.Expires = 0
Dim cmd
cmd = Request.QueryString("cmd")
if cmd = "2" Then
Dim xml_dom1
set xml_dom1 = CreateObject("MSXML2.DOMDocument")
xml_dom1.load("\Windows\Config.xml") '(Server.MapPath("Config.xml"))
Response.Write(xml_dom1.xml)
set xml_dom1 = nothing
end if
if cmd = "1" Then
dim xml_dom
set xml_dom = CreateObject("MSXML2.DOMDocument")
xml_dom.load(request)
xml_dom.save("\Windows\Config.xml")
set xml_dom = Nothing
end if
If err.number <> 0 Then
Response.Write(err.Description)
Response.Write(err.number)
End If
© Stack Overflow or respective owner