This code works correctly in B4A (The data appears in the remote database). In B4a I get a correct result string. In B4I I get the job1.errormessage "Request completed with error". The library is iHttpUtils2. The XML File is the same for both B4A and B4i. I have access to the back end server (ASMX) and I added code to send me an email when the Sub is accessed. I get an email when I use the b4A app, none from B4I. So I surmise there is something wrong with the request. Any ideas what could be wrong?
One more thing. I have several other routines using nearly identical code, accessing different calls within the same service, and they all work.
the XML file is as follows:
One more thing. I have several other routines using nearly identical code, accessing different calls within the same service, and they all work.
B4X:
Sub AddBoat(NB As Boat)As ResumableSub
Dim Result As String
Dim req As String = File.ReadString(File.Dirassets, "addboat.xml")
req=SetParam("ID",NB.ID,req)
req=SetParam("User",NB.user,req)
req=SetParam("Password",NB.Password,req)
req=SetParam("BoatName",NB.BoatName,req)
req=SetParam("BoatClass",NB.BoatClass,req)
req=SetParam("YC",NB.YC,req)
req=SetParam("SailNum",NB.SailNum,req)
req=SetParam("PHRF",NB.PHRF,req)
req=SetParam("LOA",NB.loa,req)
req=SetParam("Skipper",NB.Skipper,req)
req=SetParam("Email",NB.Email,req)
req=SetParam("Phone",NB.Phone,req)
'Mydata.LogMD(NB.id)
Dim job1 As HttpJob
job1.Initialize("AddBoat", Me)
Dim URL As String = Connect
Try
job1.PostString(URL, req)
job1.GetRequest.SetContentType("text/xml; charset=utf-8")
Wait For (job1) JobDone(job1 As HttpJob)
If job1.Success Then
Result= job1.getstring
Else
Mydata.logmd(job1.ErrorMessage) 'logs to a file
End If
job1.Release
Dim BoatID As Int = GetIntParam("AddBoatResult",Result)
Return BoatID
Catch
hd.ToastMessageShow ("No Internet",True)
job1.Release
Return -1
End Try
End Sub
public Sub SetParam(Param As String, Value As String,XML As String ) As String
If Value = Null Then Value = ""
Dim SF As String = Param & ">?<"
Dim SF2 As String = Param & ">" & Value & "<"
Return XML.Replace(SF,SF2)
End Sub
the XML file is as follows:
B4X:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:act="https://ActiveRace.club/">
<soapenv:Header/>
<soapenv:Body>
<act:AddBoat>
<act:newboat>
<act:ID>?</act:ID>
<act:User>?</act:User>
<act:Password>?</act:Password>
<act:BoatName>?</act:BoatName>
<act:YC>?</act:YC>
<act:BoatClass>?</act:BoatClass>
<act:SailNum>?</act:SailNum>
<act:PHRF>?</act:PHRF>
<act:LOA>?</act:LOA>
<act:Skipper>?</act:Skipper>
<act:Email>?</act:Email>
<act:Phone>?</act:Phone>
</act:newboat>
</act:AddBoat>
</soapenv:Body>
</soapenv:Envelope>