Hi,
could you help me trying to use web service;
TempConvert Web Service
in b4a codes.
thank you very much
Refik Coskun
could you help me trying to use web service;
TempConvert Web Service
in b4a codes.
thank you very much
Refik Coskun
Sub runwebservice2
Dim Url1 As String
Dim requestSoapXML As String
Dim tempC As String
tempC = "25"
Url1 = "http://www.w3schools.com/webservices/tempconvert.asmx"
requestSoapXML = _
"<?xml version='1.0' encoding='utf-8'?>" & _
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" & _
"<soap:Body>" & _
"<CelsiusToFahrenheit xmlns='http://tempuri.org/'>" & _
"<Celsius>" & tempC & "</Celsius>" & _
"</CelsiusToFahrenheit>" & _
"</soap:Body>" & _
"</soap:Envelope>"
Log(requestSoapXML )
webRequest.InitializePost2(Url1, requestSoapXML.GetBytes("UTF8"))
webRequest.SetHeader("Content-Type", "text/xml; charset=utf-8")
webRequest.SetHeader("SOAPAction", "http://tempuri.org/CelsiusToFahrenheit")
webRequest.Timeout = 10000
webClient.Initialize("webClient")
If webClient.Execute(webRequest, 1) = False Then Return
End Sub
Sub webClient_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim resultSoapXML As String
resultSoapXML = Response.GetString("UTF8")
edittext1.Text = resultSoapXML
'lblLoginStatus.Text = resultSoapXML
Log("Success : " & resultSoapXML)
End Sub
Sub webClient_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Dim resultSoapXML As String
resultSoapXML = Response.GetString("UTF8")
'lblLoginStatus.Text = resultSoapXML
Log("Error : " & resultSoapXML)
Log("Reason: " & Reason)
Log("StatusCode: " & StatusCode)
End Sub
Sub Process_Globals
Dim PostUrl As String
PostUrl = "http://www.w3schools.com/webservices/tempconvert.asmx/CelsiusToFahrenheit"
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
HttpUtils.CallbackActivity = "Main"
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.PostString("POST Job1", PostUrl, "Celsius=123")
End Sub
Sub Activity_Resume
'Check whether a job has finished while the activity was paused.
If HttpUtils.Complete = True Then JobDone(HttpUtils.Job)
End Sub
Sub JobDone (Job As String)
If HttpUtils.IsSuccess(PostUrl) Then
Msgbox(HttpUtils.GetString(PostUrl), "")
Else
ToastMessageShow("Error sending request", True)
End If
HttpUtils.Complete = False 'Turn off the complete flag so we won't handle it again if the activity is resumed.
End Sub
Sub runwebservice3
Dim Url1 As String
Dim requestSoapXML As String
Dim tempC As String
' HttpUtils.PostString("POST Job1", PostUrl, "Celsius=123")
tempC = "35412003678149801"
Url1 = "http://212.58.21.132:81/BusinessService/IsTakipService.asmx"
requestSoapXML = _
"<?xml version='1.0' encoding='utf-8'?>" & _
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" & _
"<soap:Body>" & _
"<Login_ByImei xmlns='http://www.fu.com.tr/Webservices'>" & _
"<paramImeiNo>" & tempC & "</paramImeiNo>" & _
"</Login_ByImei>" & _
"</soap:Body>" & _
"</soap:Envelope>"
Log(requestSoapXML )
webRequest.InitializePost2(Url1, requestSoapXML.GetBytes("UTF8"))
webRequest.SetHeader("Content-Type", "text/xml; charset=utf-8")
webRequest.SetHeader("SOAPAction", "http://www.fu.com.tr/Webservices/Login_ByImei")
webRequest.Timeout = 10000
webClient.Initialize("webClient")
If webClient.Execute(webRequest, 1) = False Then Return
End Sub
Sub JobDone (Job As String)
Select Job
Case "POST Job1"
If HttpUtils.IsSuccess(PostUrl) Then
Msgbox(HttpUtils.GetString(PostUrl), "")
Else
ToastMessageShow("Error sending request", True)
End If
Case "POST Job2"
'your code here to handle Job2 return
End Select
HttpUtils.Complete = False 'Turn off the complete flag so we won't handle it again if the activity is resumed.
End Sub
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim webClient As HttpClient
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 btnLogin As Button
Dim pnlDM As Panel
Dim webRequest As HttpRequest
Dim lblLoginStatus As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("MainScreen")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnLogin_Click
Dim endPoint As String
Dim requestSoapXML As String
Dim resultSoapXML As String
Dim userName, password As String
userName = "Login1"
password = "password1"
endPoint = "http://servername:8080/test/Test/"
requestSoapXML = _
"<soapenv:Envelope xmlns:soapenv=" & QUOTE & "http://schemas.xmlsoap.org/soap/envelope/" & QUOTE & " xmlns:urn=" & QUOTE & "urn:System:System" & QUOTE & ">" & _
"<soapenv:Header/>" & _
"<soapenv:Body>" & _
"<urn:login>" & _
"<urn:Login>"& userName & "</urn:Login>" & _
"<urn:password>"& password & "</urn:password>" & _
" </urn:login>" & _
"</soapenv:Body>" & _
"</soapenv:Envelope>"
Log(requestSoapXML )
webRequest.InitializePost2(endPoint, requestSoapXML .GetBytes("UTF8"))
webRequest.Timeout = 10000
webRequest.SetHeader("Content-Type", "text/xml; charset=utf-8")
webRequest.SetHeader("SOAPAction", "")
webClient.Initialize("webClient")
If webClient.Execute(webRequest, 1) = False Then Return
End Sub
Sub webClient_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim resultSoapXML As String
resultSoapXML = Response.GetString("UTF8")
lblLoginStatus.Text = resultSoapXML
Log("Success : " & resultSoapXML)
End Sub
Sub webClient_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Dim resultSoapXML As String
resultSoapXML = Response.GetString("UTF8")
lblLoginStatus.Text = resultSoapXML
Log("Error : " & resultSoapXML)
Log("Reason: " & Reason)
Log("StatusCode: " & StatusCode)
End Sub