HttpUtils PostString question

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
I am trying to use HttpUtils.PostString method, instead of Get. Previous working code is:
Dim hc as HttpClient
Dim req as HttpRequest
Dim r as string
r="http://mysite/Folder/Application.aspx?CommandString"
req.InitializeGet(r)
hc.Execute(req, 1)
(and get the aswer in StreamFinish)
To change the previous method, I started from the simple code reported in the HttpUtils first issue post, substituting the following:
1) In Sub Globals we have now b4a="http://mysite/Folder/Application.aspx"
2) Instead of HttpUtils.DownLoad of the basic code, I use:
HttpUtils.PostString("Job1",b4a,CommandString)
(CommandString is, for example : "O=1&N=xxx&P=yyy")

So , in the example modified code, we have:

Sub Globals
Dim b4a As String
b4a = "http://mysite/Folder/Application.aspx"
End Sub

Sub Activity_Create (FirstTime As Boolean)
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
'HttpUtils.Download("Job1", b4a)
HttpUtils.PostString("Job1",b4a,"O=1&N=pipp&P=www")
End Sub

Sub JobDone (Job As String)
Dim s As String
If HttpUtils.IsSuccess(b4a) Then
s = HttpUtils.GetString(b4a)
End If
End Sub
In JobDone function HttpUtils.IsSuccess(b4a) is never true.
Can anybody tell me what I am missing?
Thanks in advance..
 

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Perplexed

Thanks for answering. Actually I am a "desolatesoul" too.. Seen that you are so kind to have listened to my problem, I will submit you the general problem that I noticed in these functions. In a previous post:
async streams interactive communication
I described my problem, which is to communicate with a server. I experienced that asp/php written server programs behave differently from aspx ones, when code behind is used in the latter. Empirically, I resolved, avoiding PageLoad implicit method in aspx code, and things worked. This, unluckily, is not an aspx only issue, because, as I notice, b4a functions, in practice, don't behave same way. Unluckily I am not expert of the topic, and I can only observe the final facts. I don't know why if I write a "response write(Something)" in classic asp, or an echo(Something) in php, this is well received by b4a, either using Get or Post methods , while same ResponseWrite is not received by b4a, when issued inside PageLoad of aspx/codebehind function. But, as I said, using Get method, I resolved previous situation, empirically. Now the problem appeared again with HttpUtils.PostString: even using the aspx counterpart that works correctly with the HttpClient Get method, now the HttpUtils.GetString begins again not to get the answer: instead a generic "Internal server error" is issued. I use same code of the examples, substituting the calling strings only. If I use the HttpUtils example, I notice that a php program is called. I know that this works. What I see is that with aspx it doesn't. My opinion is that this thing should be investigated. I am available to send example code etc., though, of course I don't want you to waste time, because it could also be a problem of my code. In such situation i can only leave this b4a-aspx system and change one of the two actors.. Sorry, but I am a little exhausted.. Thanks again for listening.
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Seeing that you are a bit perplexed I would like to add a little perspective to your problem.

First, identify where the problem lies.
You have done ASP<->B4A and ASP.NET<->B4A
Now you need to write another testbench in another language so that you can confirm this behaviour. ASP<->TEST and ASP.NET<->TEST
Then by pure elimination you will know where the problem lies.

Secondly, you can look at the server logs. Since the response you are getting is 'Internal Server Error' I am sure there is something in the server logs that will identify the issue (even if it is a malformed request or otherwise).

Thirdly, you can post the address of your server here and I can try to fiddle around with the requests keeping the server as a blackbox. I only need to know what to request and what to expect as returned.

Finally, you could post the aspx code as well. I have never SEEN aspx code, but the ONLY way to debug this is to have everything in hand. Maybe someone else could help you with that.
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Great

Thanks for availability. Luckily, as sometimes happens with good will people, during preparation of test files and projects, I found my error, and so we can close this discussion. The problem was only in my aspx code. Infact, deviated from the right way by previous experience on Get, in which Browser calls were answered, while b4a program not, I was thinking strange things. Instead, this time, I forgot that I was still using a Request.QueryString.Get method, also now, in response to a Post call. This, of course, was not working.. After some tests I see that things are going, at least in test application. I don't bother you more. Thanks again.
 
Upvote 0

serkanpolat

Member
Licensed User
Longtime User
why dont you use webservices with asp.net?
i can provide you samples on how to get data from webservices and parse xml with b4a...
please pm, i can help you..
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…