Hello, I'm asking for help.
I created a WebApi server that responds to calls and returns appropriate results (I'm using a WEBAPI server template created by Aeric). Everything works fine and without problems, except for one thing. When my WebServices should call another WebServer and I want to initialize an HTTP Job, the system no longer returns any response to me. The function is executed correctly, without errors - to the end - but the system does not return any text or string... I can't find the error...
SubRutine for simple echo...
Can somebody help me to figure out what is a problem?
Best regards, DaT
I created a WebApi server that responds to calls and returns appropriate results (I'm using a WEBAPI server template created by Aeric). Everything works fine and without problems, except for one thing. When my WebServices should call another WebServer and I want to initialize an HTTP Job, the system no longer returns any response to me. The function is executed correctly, without errors - to the end - but the system does not return any text or string... I can't find the error...
Example:
Sub Handle(req As ServletRequest, resp As ServletResponse)
Request = req
Response = resp
HRM.Initialize
' Key confirmation
If Main.API_KEY_ENABLED = True Then
Dim apiKey As String = req.GetHeader("x-api-key")
If apiKey <> Main.API_KEY Then
HRM.ResponseCode = 401
HRM.ResponseError = "Wrong api key"
HRM.ResponseString = "API key is not valid"
HRM.ResponseMessage = "API key is not valid"
HRM.ContentType = ""
Dim lstNo As List
lstNo.Initialize
HRM.ResponseData = lstNo
Utility.ReturnHttpResponse(HRM, Response)
Return
End If
End If
' checking allowed method
If req.Method <> "POST" Then
HRM.ResponseCode = 405
HRM.ResponseError = "Method Not Allowed"
Utility.ReturnHttpResponse(HRM, Response)
Return
End If
Dim ApiRequest As String = Request.RequestURI
ApiRequest = ApiRequest.SubString2(ApiRequest.LastIndexOf("/") + 1 , ApiRequest.Length)
ApiRequest = ApiRequest.ToLowerCase
Dim lstOptEcho As List
lstOptEcho.Initialize
' subhandlers
Select ApiRequest.ToLowerCase
Case "hallo"
EchoRequest
Case "test"
TestRequest
Case "sendorder"
Try
...
SubRutine for simple echo...
Sub:
Private Sub TestRequest()
' HERE IS A PROBLEM; IF I DEFINE HTTPJOB, system lose response
Dim j As HttpJob
j.Initialize("j", Me)
j.Download("https://www.google.com")
Wait For (j) JobDone (j As HttpJob)
j.Release
Response.ContentType = "text/plain"
Response.Status = 200
Response.Write("SUCCESS")
Log("Response sent successfully")
End Sub
Can somebody help me to figure out what is a problem?
Best regards, DaT