this is a sample i use - just a simple ping function to my server web service
Sub MTS_Ping()
Dim sXML As String
sXML = _
"<?xml version='1.0' encoding='utf-8'?>" & _
"<soap12:Envelope xmlns:xsi='
http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='
http://www.w3.org/2001/XMLSchema' xmlns:soap12='
http://www.w3.org/2003/05/soap-envelope'>" & _
"<soap12:Body>" & _
"<MTS_Ping xmlns='
https://mywebserviceurl.com/'>" & _
"<Element1>"&Element1&"</Element1>" & _
"<Element2>"&element2&"</Element2>" & _
"</MTS_Ping>" & _
"</soap12:Body>" & _
"</soap12:Envelope>"
webRequest.InitializePost2(URL, sXML.GetBytes("UTF8"))
webRequest.Timeout = 10000
webRequest.SetHeader("Content-Type", "text/xml; charset=utf-8")
If webClient.Execute(webRequest,1) = False Then Return
'WS function went OK
' some other operations comes here
End Sub
Sub webClient_ResponseSuccess (Response As OkHttpResponse, TaskId As Int)
Response.GetAsynchronously("Proc_StreamFinish", File.OpenOutput(File.DirDefaultExternal, "OK.txt", False), True, TaskId)
End Sub
Sub Proc_StreamFinish (Success As Boolean, TaskId As Int)
If Success = True Then
resultSoapXML= File.ReadString(File.DirDefaultExternal, "OK.txt")
Log("Success : " & resultSoapXML)
WebServiceResult = True
Else
resultSoapXML= File.ReadString(File.DirDefaultExternal, "FAIL.txt")
WebServiceResult = False
Msgbox ("Error" & CRLF & resultSoapXML, "Error")
End If
End Sub
Sub webClient_ResponseError (Response As OkHttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Response.GetAsynchronously("ProcCC_StreamFinish", File.OpenOutput(File.DirDefaultExternal, "FAIL.txt", False), True, TaskId)
End Sub
in my old application (using hhtp and httputils) it was all working just fine
now afeter changing to okhttp & okhttputil and modifying to this code as i couldnot use response.getstring anymore i get
the following error
415
Unsupported Media
what am i missing or doing wrong ?
thanks