B
Ben
I'm working on an application that I would like to get running on a
WM6 Smartphone. The application needs to be able to send HTTPS POST
requests with Content-Type text/xml
This is the code I am using to send the request:
wRequest =
(HttpWebRequest)WebRequest.Create(string.Concat(this.URLPrefix,
this.Hostname, path));
wRequest.AllowWriteStreamBuffering = true;
wRequest.Method = "POST";
wRequest.ContentType = "text/xml";
wRequest.Credentials = new NetworkCredential(this.Username,
this.Password);
using (StreamWriter writer = new
StreamWriter(wRequest.GetRequestStream()))
{
writer.WriteLine(request);
writer.Close();
}
wResponse = (HttpWebResponse)wRequest.GetResponse();
This code runs fine when compiled with the .NET Framework 2.0, and
runs fine compiled with .NET Compact Framework 2.0 and running on my
desktop system (Windows XP SP2). When running on my Smartphone or the
Windows Mobile 6 platform emulator it raises an uncatchable
ProtocolViolationException every time.
ProtocolViolationException
An error message cannot be displayed because an optional resource
assembly containing it cannot be found
at
System.Net.HttpWebRequest.startGetRequestStream()
at
System.Net.HttpWebRequest.GetRequestStream()
at
MyClass.SendRequest()
I've read through many older posts and found out that I needed to
enable AllowWriteStreamBuffering when sending a POST request and close
the StreamWriter before calling GetResponse, but those changes haven't
solved the problem.
Is there something else that I am obviously doing wrong? This is the
first time I've written an application for the Compact Framework so
I'm not at all familiar with its peculiarities.
-Ben
WM6 Smartphone. The application needs to be able to send HTTPS POST
requests with Content-Type text/xml
This is the code I am using to send the request:
wRequest =
(HttpWebRequest)WebRequest.Create(string.Concat(this.URLPrefix,
this.Hostname, path));
wRequest.AllowWriteStreamBuffering = true;
wRequest.Method = "POST";
wRequest.ContentType = "text/xml";
wRequest.Credentials = new NetworkCredential(this.Username,
this.Password);
using (StreamWriter writer = new
StreamWriter(wRequest.GetRequestStream()))
{
writer.WriteLine(request);
writer.Close();
}
wResponse = (HttpWebResponse)wRequest.GetResponse();
This code runs fine when compiled with the .NET Framework 2.0, and
runs fine compiled with .NET Compact Framework 2.0 and running on my
desktop system (Windows XP SP2). When running on my Smartphone or the
Windows Mobile 6 platform emulator it raises an uncatchable
ProtocolViolationException every time.
ProtocolViolationException
An error message cannot be displayed because an optional resource
assembly containing it cannot be found
at
System.Net.HttpWebRequest.startGetRequestStream()
at
System.Net.HttpWebRequest.GetRequestStream()
at
MyClass.SendRequest()
I've read through many older posts and found out that I needed to
enable AllowWriteStreamBuffering when sending a POST request and close
the StreamWriter before calling GetResponse, but those changes haven't
solved the problem.
Is there something else that I am obviously doing wrong? This is the
first time I've written an application for the Compact Framework so
I'm not at all familiar with its peculiarities.
-Ben