Error using HTTPS/POST in compact framework

G

Guest

Hi there

I experienced errors when using HTTPS/POST in compact framework.

Firstly, the application details
- I created a smart device application in VS.NET 200
- I used to example code as shown in HttpWebRequest with minor changes (appended below
- I created my own CertificatePolic
- The code communicates with a JSP running on BEA weblogi

The testing details
a.) communicating directly with BEA, using HTT
b.) communicating directly with BEA, using HTTP
c.) communicating with BEA over Apache with BEA connector, using HTT
d.) communicating with BEA over Apache with BEA connector, using HTTPS

The testing results, when running the application from my desktop pc
a.) works fin
b.) works fin
c.) works fin
d.) works fin

The testing results, when running the application in Pocket PC 2002 emulato
a.) works fin
b.) exception raised: blocking operatio
c.) exception raised: invalid segment lengt
d.) exception raised: blocking operatio

Running the application on a real smart device produces the same result as in emulator

IMHO, accessing a web resource should not be a matter of underlying hardware nor a matter of server-type. I expect the compact framework to behave in the same way, when running on a desktop or on a smart device. If my code is erroneous, please correct me. If its a matter of compact framework please point me out the reasons and how to avoid it

Thanky a lot for any help
Greetings
Heiner Amthaue

----------------8<-------------
Here is the significant code. Not very exiting, so far
If required, I'll post the complete application code (186 lines)

public void Go(

try

log("Creating request: "+url)
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url)
request.Method = "POST"
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = data.Length

log("Writing data")
byte [] bytes = ASCIIEncoding.ASCII.GetBytes(data)
Stream reqStream = request.GetRequestStream()
reqStream.Write(bytes, 0, data.Length)
reqStream.Close()

log("Reading response.")
HttpWebResponse response = (HttpWebResponse)request.GetResponse()
Stream resStream = response.GetResponseStream()
StreamReader reader = new StreamReader(resStream)
char [] input = new char[256]
int count = reader.Read(input, 0, 256)
while (count > 0

log(new String(input, 0, count))
count = reader.Read(input, 0, 256)
}
reader.Close()
response.Close()

log("done.")
}
catch (Exception e)

log(e.Message)
 
R

Ron Horn

I finally found the answer for this on another site. Here is the response...

"There is a bug in http client that is exposed by the code you are using.
Instead of setting req.ContentLength, you should set
AllowWriteStreamBuffering to true. This will work around the problem you
have."

http://www.error-bank.com/[email protected]_Thread.aspx

It seems to solve the problem.

Ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top