Ist es möglich diesen Webservice in B4a zu verwenden/einzubinden?
OpenLigaDB - rund um den Webservice
OpenLigaDB - rund um den Webservice
Sub Globals
Dim myHttpClient As HttpClient
End Sub
Sub Callwebservice()
Dim XML As StringBuilder
XML.Initialize
XML.Append("<?xml version=''1.0'' encoding=''utf-8''?>")
XML.Append("<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''>")
XML.Append(" <soap12:Body>")
XML.Append(" <GetMatchByMatchID xmlns=''http://msiggi.de/Sportsdata/Webservices''>")
XML.Append(" <MatchID>626</MatchID>")
XML.Append(" </GetMatchByMatchID>")
XML.Append(" </soap12:Body>")
XML.Append("</soap12:Envelope>")
myHttpClient.Initialize("myHttpClient")
Dim myHttpRequest As HttpRequest
Dim URL As String
URL = "http://www.openligadb.de/Webservices/Sportsdata.asmx"
myHttpRequest.InitializePost2(URL, XML.ToString.Replace("''", Chr(34)).GetBytes("UTF8"))
myHttpRequest.SetHeader("Content-Type", "application/soap+xml; charset=utf-8")
myHttpRequest.Timeout = 10000
If myHttpClient.Execute(myHttpRequest, 1) = False Then Return
End Sub
Sub myHttpClient_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Log("Success:")
Log(Response.GetString("UTF8"))
End Sub
Sub myHttpClient_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Log("Error:")
Log(Response.GetString("UTF8"))
End Sub
Du kannst aus dem Response den InputStream in einen SaxParserIst es möglich daraus wieder eine xml datei zu erstellen sodass ich diese Parsen kann?
Response.GetString(...)
mySaxParser.Parse(Response.GetInputStream, "mySaxParser")
Sub myHttpClient_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Response.GetAsynchronously("WebserviceResponse", File.OpenOutput(File.DirInternalCache, "WebserviceResponse.xml", False), True, TaskId)
End Sub
Sub WebserviceResponse_StreamFinish (Success As Boolean, TaskId As Int)
If Success = False Then
Msgbox(LastException.Message, "Error")
Return
End If
Log("Success:")
Dim myInputStream As InputStream
myInputStream = File.OpenInput(File.DirInternalCache, "WebserviceResponse.xml")
mySaxParser.Parse(myInputStream, "mySaxParser")
End Sub
puh, keine Ahnung. Kann viele Ursachen haben...@Kiffi, Weisst du woran es liegen Könnte das ich ab und zu eine Fehlermeldung bekomme [...]
japp:Ist es möglich die xml datei auch über httpUtils zu bekommen?
Sub CallWebservice2()
Dim XML As StringBuilder
XML.Initialize
XML.Append("<?xml version=''1.0'' encoding=''utf-8''?>")
XML.Append("<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''>")
XML.Append(" <soap12:Body>")
XML.Append(" <GetMatchByMatchID xmlns=''http://msiggi.de/Sportsdata/Webservices''>")
XML.Append(" <MatchID>626</MatchID>")
XML.Append(" </GetMatchByMatchID>")
XML.Append(" </soap12:Body>")
XML.Append("</soap12:Envelope>")
Dim URL As String
URL = "http://www.openligadb.de/Webservices/Sportsdata.asmx"
Dim Job As HttpJob
Job.Initialize("Job", Me)
Job.PostString(URL, XML.ToString.Replace("''", Chr(34)))
Job.GetRequest.SetHeader("Content-Type", "application/soap+xml; charset=utf-8")
End Sub
Sub JobDone(Job As HttpJob)
If Job.Success Then
Dim myTextReader As TextReader
myTextReader.Initialize(Job.GetInputStream)
Dim Xml As String = myTextReader.ReadAll
Log(Xml)
myTextReader.Close
Else
Log("!Job.Success")
End If
Job.Release
End Sub
musst Du ihn denn speichern? Wenn ja, dann -> File.WriteString()Die Frage ist vieleicht doof, aber wenn ich es über httputils mache wie speichere ich dann den string als xml datei?