I recently update my version of b4J, this code is not working. but was working in the old release.
B4X:
Dim data As String = $"<?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 xmlns="http://tempuri.org/">
<username>${username}</username>
<password>${password}</password>
<accountId>${userid}</accountId>
</Login>
</soap:Body>
</soap:Envelope>"$
Sub connect_u(data As String)
Dim j As HttpJob
Try
Log(data)
j.Initialize("", Me)
If j.IsInitialized = True Then
Log("ok")
j.PostString("http://1.1.1.1:9191/Service.asmx",data)
j.GetRequest.SetHeader("SOAPAction","http://tempuri.org/Login")
j.GetRequest.SetContentType("text/xml; charset=utf-8")
End If
Catch
Log(LastException)
End Try
Wait For (j) jobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
End If
j.Release
End Sub
I try it on a debian server with iptraf and never try to connect to host.
May not be related, but did you clean your project after upgrading B4j? This probably should have been giving you build errors, so it's just for trying sake.
Actually, if you look at the source of HttpUtils2Service.bas (part of what makes the Http Job stuff tick), it uses your temp folder. Here's the code snippet
B4X:
#Else If B4J
TempFolder = File.DirTemp
#End If
' and later
#if B4A or B4J
Sub hc_ResponseSuccess (Response As OkHttpResponse, TaskId As Int)
Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), _
True, TaskId)
End Sub
I don't know what upgrading B4J would do to your access to your temp folder (it should not impact it at all).
I understand. You directly are not, but indirectly by using jHttpUtils2 you are (I just realized your using jHttpUtils2 not okHttpUtils2). I'm attaching a non-ui app that uses your code and the jHttpUtils2 source found at https://www.b4x.com/android/forum/threads/jhttputils2-source-code.39415/ (since it's a non-ui app, the source has to be included and the library jHttpUtils2 needs to be unchecked). The only libraries that are checked for this example are jCore (version 5.8), jHttp (version 1.11) and jStringUtils (version 1.00). For me, the app works, logging a j.ErrorMessage of
Error: org.apache.http.conn.HttpHostConnectException: Connection to http://1.1.1.1:9191 refused
Yes, is working. Maybe I make a mess with the library selection. one question I receive a cookie in that connection how can I grabbed, for sending in
another call?
What connection?
HTTP? Socket? Both could be explained by some sort of connection pooling that may be implemented by the underlying open source library used (don't have time to check right now). It may even be due to the Java garbage collector that does not instantaneously release memory. What are you expecting to happen and what is not happening. You may need to open a new thread since
1) I think we fixed the issue with post string not working (the temp file issue)
2) The release may be a different issue and therefore validate a new thread. Plus I may be out of my league on this one and hopefully other people can help.
my last issue was with the cookie. I couldn't read it. and I need that info to made se second request.
I stop for now, because I need to have a demo running on Monday. I start with php7 debian host and b4a and it's almost done using curl.
I start a new tread when I publish this soap web service.
victor