Help on Http

wgodsoe

Member
Licensed User
Longtime User
I have service running on port 6789 and the service will return a variety of responses based on the the request. The service maintains log of request and responses, and the service it would appear is being triggered and returing a response. The following program returns a ClientProtocolException, with the status code of -1, on every click. Any help would be appreciated.


'Activity module
Sub Process_Globals
Dim request As HttpRequest
Dim MainUrl As String
Dim HttpClient1 As HttpClient
Dim MainRequestId As Int
MainUrl="http://192.168.2.4:6789"
MainRequestId = 100
End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim UserTxt As EditText
Dim PasswordTxt As EditText
Dim LoginBut As Button
Dim Approved As String
Dim Password As String
Dim UserName As String
Dim EditText1 As EditText

End Sub

Sub Activity_Create(FirstTime As Boolean)
'get todays stops
' tabs
Activity.LoadLayout("APRWlogin")
UserTxt.Text=""
UserTxt.Hint = "Enter Name"
UserTxt.RequestFocus
UserTxt.ForceDoneButton=True
UserTxt.InputType = UserTxt.INPUT_TYPE_TEXT
PasswordTxt.InputType = PasswordTxt.INPUT_TYPE_TEXT
If FirstTime Then
HttpClient1.Initialize("HttpClient1")
End If


End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub LoginBut_Click
Dim request As HttpRequest
request.InitializeGet(MainUrl & "/000004DATE")
HttpClient1.Execute(request, MainRequestId)
request.Timeout = 10000 'set timeout to 10 seconds
If HttpClient1.Execute(request, 1) = False Then Return
ProgressDialogShow("Fetching data...")
End Sub
Sub HttpClient1_ResponseError (Reason As String, StatusCode As Int, TaskId As Int)
ToastMessageShow("Error. TaskId: " & TaskId & ", Reason: " & Reason & ", StatusCode: " & StatusCode, True)
ProgressDialogHide
End Sub
Sub HttpClient1_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Log("ResponseSuccess")
ProgressDialogHide
Dim result As String
result =Response.GetInputStream
' result = Response.GetString("UTF8") 'Convert the response to a string
Log(result)
ToastMessageShow(result,True)
End Sub
 

wgodsoe

Member
Licensed User
Longtime User
Erel,
The message is the same on the emulator and on my Archo70. I know for sure the service is recieving the request, and returning a simple string, as the service generates a log. I checked the manifest to assure permissions for internet was set. Not being familar with java, it reads <uses-permission android:name="android.permission.INTERNET" />

The password and user references are irrevalent at this point. Any ideas?
Thanks
Walt
 
Upvote 0
Top