HTTP POST on Device - error message

TWELVE

Active Member
Licensed User
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:

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:

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:

klaus

Expert
Licensed User
Longtime User
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:
http://www.b4x.com/forum/showthread.php?t=870

Hope this will bring you a step forward.

Best regards
 

TWELVE

Active Member
Licensed User
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:

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
 

TWELVE

Active Member
Licensed User
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.


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
 

Attachments

  • Post_Test.sbp
    1.9 KB · Views: 176

TWELVE

Active Member
Licensed User
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
 
Top