Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


HTTP POST on Device - error message


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-24-2008, 11:25 AM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default HTTP POST on Device - error message

Hello,

i'm pretty new to Basic4PPC..:-) I used the trial version to evaluate if this language is suitable for my project.Now i purchased the full version.In the very first time i tested my program on the device, but later i used only the emulator on windows desktop because it is much more comfortable.I'm using an HP IPAQ 5450 with PocketPC 2003.

Until now everything went ok so far, but now i discovered an issue related to the HTTP lib.I use an HTTP POST to send data to a webserver, which was working fine on the desktop emulator.When i tried it on the device, i'm getting an error message:

Quote:

Edit:

An error occured on sub blabla.

Line number 1017

Response.Value = Request.GetResponse

Error description:

Es kann keine Fehlermeldung angezeigt werden, da die optionale Ressource der Assembly, die die Fehlermeldung enthält, nicht gefunden wurde.

( unfortunately it's in german language, it means, there is no error message available because an optional resource that contains the error message cannot be found)

Continue ?
If i confirm the message, the programs continues to work, but after exiting the program i get another error message:

Quote:
Basic4PPC.exe
InvalidOperationException

at

System.Net.HttpWebRequest.set_ContentLength()

at

BufferConnectStream.WritingSucceeds()

at

System.Net.Http.WriteStream .Finalize()

After confirming this message Basic4PPC terminates.

Using an network sniffer i can see, that the POST request is send to the server correctly, but the following message box with the error is preventing me from receiving/getting the server's response string.

With desktop version / emulator everything works as expected, no error messages in that at all.

I installed .Net CF 2, because the serial2.dll complaint about the CF 1.

Other request, like GET or TRACE or OPTIONS are working fine, no error message.

I calculate the content.length using StrLength(my POST DATA string) and compared the Content.Length in the HTTP Header with the number of characters in the network trace.I matches the content.length number.

I need some help here to proceed with my project.Somehow i suspect the content.length to be the cause, but don't know what's wrong here.

Furthermore i updated the HTTP Lib with the latest one, but did not make a difference.

kind regards

TWELVE

Last edited by TWELVE : 04-24-2008 at 11:31 AM.
Reply With Quote
  #2 (permalink)  
Old 04-24-2008, 12:09 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 675
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

There must be an error in your code, when running on the device.

But you are missing a routine on your device to display error messages.
Look at this:
error messages on device

Hope this will bring you a step forward.

Best regards
__________________
Klaus
Switzerland
Reply With Quote
  #3 (permalink)  
Old 04-24-2008, 12:41 PM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default

Quote:
There must be an error in your code, when running on the device.
It is the same code that runs without errors on the desktop.

Nevertheless..i installed the mentioned enu-cabfile and get now this error message:

Quote:
Response.Value = Request.GetResponse

Error description:
This operation cannot be performed after the request has been submitted.
Continue ?
The same code works fine, when used with GET instead of POST Request header.I also cannot understand the error message, because the mentioned command is the one that submits the request to the server..?


kind regards

TWELVE
Reply With Quote
  #4 (permalink)  
Old 04-24-2008, 01:40 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,141
Default

Can you send me your application to erel@basic4ppc.com ?
Reply With Quote
  #5 (permalink)  
Old 04-26-2008, 02:43 AM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default

Hi Erel,

this piece of code should reveal where the problem is.It always occurs with the POST method, all other methods ( GET, TRACE...) are working fine, as long as the server is supporting them.The issue only occurs on the device, on desktop everything is fine.


Quote:
Sub Globals
'Declare the global variables here.

End Sub

Sub App_Start
Form1.Show


End Sub

Sub Button1_Click

httppost

End Sub

Sub Button2_Click

AppClose

End Sub

Sub Button3_Click

httpget

End Sub

Sub Button7_Click

TextBox1.Text = ""

End Sub


Sub httppost

Request.New1("http://www.snee.com/xml/crud/posttest.cgi")


Request.ContentLength = StrLength("fname=Doc&lname=Snider" )

Request.Method = "POST"

Request.ContentType = "application/x-www-form-urlencoded"

stream.New1(Request.GetStream,true)

stream.WriteBytes (stream.StringToBytes("fname=Doc&lname=Snider" ))

Response.New1
Response.Value = Request.GetResponse
TextBox1.Text = Response.GetString
Response.Close


End Sub

Sub httpget

Request.New1("http://www.snee.com/xml/crud/posttest.html")


'Request.ContentLength = StrLength("fname=Doc&lname=Snider" )

Request.Method = "GET"

'Request.ContentType = "application/x-www-form-urlencoded"

'stream.New1(Request.GetStream,true)

'stream.WriteBytes (stream.StringToBytes("fname=Doc&lname=Snider" ))

Response.New1
Response.Value = Request.GetResponse
TextBox1.Text = Response.GetString
Response.Close


End Sub

I also attached the source file, which also includes a small gui for easy testing.



regards

TWELVE
Attached Files
File Type: sbp Post_Test.sbp (1.9 KB, 8 views)
Reply With Quote
  #6 (permalink)  
Old 04-26-2008, 09:28 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,141
Default

Thank you for this code.
There was a bug in the HTTP library.
Please download the updated library and test it again:
http://www.basic4ppc.com/forum/showt...1833#post11833
Reply With Quote
  #7 (permalink)  
Old 04-26-2008, 10:35 AM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default

Hi Erel,

the fixed http lib did the trick.Thanks a million...!!!

I can now proceed with my project, which already contains 1000+ lines of code.

I assume nobody here used a POST within his programs yet..?

cheers

TWELVE
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP POST error message miataman Questions & Help Needed 10 07-11-2008 11:28 AM
HTTP POST error Elrick Bug Reports 3 05-24-2008 03:06 PM
HTTP GetResponse error on device only willisgt Questions & Help Needed 4 04-14-2008 06:18 PM
HTTP Post nsidney Questions & Help Needed 4 01-30-2008 10:52 AM
HTTP Post ohkovar Questions & Help Needed 3 07-07-2007 05:36 PM


All times are GMT. The time now is 09:50 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0